From 27d923b03f99b6c91f40d832b87e57f26cc8ac81 Mon Sep 17 00:00:00 2001 From: Yonghui Zhao Date: Thu, 15 May 2014 23:36:19 +0800 Subject: [PATCH] Fix minIDs and maxIDs bug in other FacetDataCache --- .../facets/data/MultiValueFacetDataCache.java | 26 +++++++++++++++++++ .../MultiValueWithWeightFacetDataCache.java | 13 ++++++++++ 2 files changed, 39 insertions(+) diff --git a/bobo-browse/src/main/java/com/browseengine/bobo/facets/data/MultiValueFacetDataCache.java b/bobo-browse/src/main/java/com/browseengine/bobo/facets/data/MultiValueFacetDataCache.java index 68b9522b..0f523dc9 100644 --- a/bobo-browse/src/main/java/com/browseengine/bobo/facets/data/MultiValueFacetDataCache.java +++ b/bobo-browse/src/main/java/com/browseengine/bobo/facets/data/MultiValueFacetDataCache.java @@ -125,6 +125,19 @@ public void load(String fieldName, AtomicReader reader, TermListFactory listF } list.seal(); + // Process minIDList and maxIDList for negative number + for (int i = 1; i < negativeValueCount/2 + 1; ++i) { + int top = i; + int tail = negativeValueCount - i + 1; + int topValue = minIDList.getInt(top); + int tailValue = minIDList.getInt(tail); + minIDList.set(top, tailValue); + minIDList.set(tail, topValue); + topValue = maxIDList.getInt(top); + tailValue = maxIDList.getInt(tail); + maxIDList.set(top, tailValue); + maxIDList.set(tail, topValue); + } try { _nestedArray.load(maxdoc + 1, loader); @@ -229,6 +242,19 @@ public void load(String fieldName, AtomicReader reader, TermListFactory listF } list.seal(); + // Process minIDList and maxIDList for negative number + for (int i = 1; i < negativeValueCount/2 + 1; ++i) { + int top = i; + int tail = negativeValueCount - i + 1; + int topValue = minIDList.getInt(top); + int tailValue = minIDList.getInt(tail); + minIDList.set(top, tailValue); + minIDList.set(tail, topValue); + topValue = maxIDList.getInt(top); + tailValue = maxIDList.getInt(tail); + maxIDList.set(top, tailValue); + maxIDList.set(tail, topValue); + } this.valArray = list; this.freqs = freqList.toIntArray(); diff --git a/bobo-browse/src/main/java/com/browseengine/bobo/facets/data/MultiValueWithWeightFacetDataCache.java b/bobo-browse/src/main/java/com/browseengine/bobo/facets/data/MultiValueWithWeightFacetDataCache.java index 6b5e8436..394eb867 100644 --- a/bobo-browse/src/main/java/com/browseengine/bobo/facets/data/MultiValueWithWeightFacetDataCache.java +++ b/bobo-browse/src/main/java/com/browseengine/bobo/facets/data/MultiValueWithWeightFacetDataCache.java @@ -133,6 +133,19 @@ public void load(String fieldName, AtomicReader reader, TermListFactory listF } list.seal(); + // Process minIDList and maxIDList for negative number + for (int i = 1; i < negativeValueCount/2 + 1; ++i) { + int top = i; + int tail = negativeValueCount - i + 1; + int topValue = minIDList.getInt(top); + int tailValue = minIDList.getInt(tail); + minIDList.set(top, tailValue); + minIDList.set(tail, topValue); + topValue = maxIDList.getInt(top); + tailValue = maxIDList.getInt(tail); + maxIDList.set(top, tailValue); + maxIDList.set(tail, topValue); + } try { _nestedArray.load(maxdoc + 1, loader);