You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by sh...@apache.org on 2013/07/30 16:05:48 UTC
svn commit: r1508451 - in /lucene/dev/branches/branch_4x: ./ lucene/
lucene/facet/ lucene/facet/src/java/org/apache/lucene/facet/associations/
lucene/facet/src/test/org/apache/lucene/facet/associations/
Author: shaie
Date: Tue Jul 30 14:05:48 2013
New Revision: 1508451
URL: http://svn.apache.org/r1508451
Log:
LUCENE-5151: Associations aggregators enter an infinite loop if some documents have no category associations
Modified:
lucene/dev/branches/branch_4x/ (props changed)
lucene/dev/branches/branch_4x/lucene/ (props changed)
lucene/dev/branches/branch_4x/lucene/CHANGES.txt (contents, props changed)
lucene/dev/branches/branch_4x/lucene/facet/ (props changed)
lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/associations/SumFloatAssociationFacetsAggregator.java
lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/associations/SumIntAssociationFacetsAggregator.java
lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/associations/AssociationsFacetRequestTest.java
Modified: lucene/dev/branches/branch_4x/lucene/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/CHANGES.txt?rev=1508451&r1=1508450&r2=1508451&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/CHANGES.txt (original)
+++ lucene/dev/branches/branch_4x/lucene/CHANGES.txt Tue Jul 30 14:05:48 2013
@@ -49,6 +49,9 @@ Bug Fixes
considered if the input is equal causing the malformed weight to be identical as well.
(Simon Willnauer)
+* LUCENE-5151: Associations FacetsAggregators could enter an infinite loop when
+ some result documents were missing category associations. (Shai Erera)
+
API Changes
* LUCENE-5094: Add ramBytesUsed() to MultiDocValues.OrdinalMap.
Modified: lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/associations/SumFloatAssociationFacetsAggregator.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/associations/SumFloatAssociationFacetsAggregator.java?rev=1508451&r1=1508450&r2=1508451&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/associations/SumFloatAssociationFacetsAggregator.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/associations/SumFloatAssociationFacetsAggregator.java Tue Jul 30 14:05:48 2013
@@ -54,23 +54,20 @@ public class SumFloatAssociationFacetsAg
int doc = 0;
while (doc < length && (doc = matchingDocs.bits.nextSetBit(doc)) != -1) {
dv.get(doc, bytes);
- if (bytes.length == 0) {
- continue; // no associations for this document
+ if (bytes.length > 0) {
+ // aggreate float association values for ordinals
+ int bytesUpto = bytes.offset + bytes.length;
+ int pos = bytes.offset;
+ while (pos < bytesUpto) {
+ int ordinal = ((bytes.bytes[pos++] & 0xFF) << 24) | ((bytes.bytes[pos++] & 0xFF) << 16)
+ | ((bytes.bytes[pos++] & 0xFF) << 8) | (bytes.bytes[pos++] & 0xFF);
+
+ int value = ((bytes.bytes[pos++] & 0xFF) << 24) | ((bytes.bytes[pos++] & 0xFF) << 16)
+ | ((bytes.bytes[pos++] & 0xFF) << 8) | (bytes.bytes[pos++] & 0xFF);
+
+ values[ordinal] += Float.intBitsToFloat(value);
+ }
}
-
- // aggreate float association values for ordinals
- int bytesUpto = bytes.offset + bytes.length;
- int pos = bytes.offset;
- while (pos < bytesUpto) {
- int ordinal = ((bytes.bytes[pos++] & 0xFF) << 24) | ((bytes.bytes[pos++] & 0xFF) << 16)
- | ((bytes.bytes[pos++] & 0xFF) << 8) | (bytes.bytes[pos++] & 0xFF);
-
- int value = ((bytes.bytes[pos++] & 0xFF) << 24) | ((bytes.bytes[pos++] & 0xFF) << 16)
- | ((bytes.bytes[pos++] & 0xFF) << 8) | (bytes.bytes[pos++] & 0xFF);
-
- values[ordinal] += Float.intBitsToFloat(value);
- }
-
++doc;
}
}
Modified: lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/associations/SumIntAssociationFacetsAggregator.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/associations/SumIntAssociationFacetsAggregator.java?rev=1508451&r1=1508450&r2=1508451&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/associations/SumIntAssociationFacetsAggregator.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/associations/SumIntAssociationFacetsAggregator.java Tue Jul 30 14:05:48 2013
@@ -53,23 +53,20 @@ public class SumIntAssociationFacetsAggr
int doc = 0;
while (doc < length && (doc = matchingDocs.bits.nextSetBit(doc)) != -1) {
dv.get(doc, bytes);
- if (bytes.length == 0) {
- continue; // no associations for this document
+ if (bytes.length > 0) {
+ // aggreate association values for ordinals
+ int bytesUpto = bytes.offset + bytes.length;
+ int pos = bytes.offset;
+ while (pos < bytesUpto) {
+ int ordinal = ((bytes.bytes[pos++] & 0xFF) << 24) | ((bytes.bytes[pos++] & 0xFF) << 16)
+ | ((bytes.bytes[pos++] & 0xFF) << 8) | (bytes.bytes[pos++] & 0xFF);
+
+ int value = ((bytes.bytes[pos++] & 0xFF) << 24) | ((bytes.bytes[pos++] & 0xFF) << 16)
+ | ((bytes.bytes[pos++] & 0xFF) << 8) | (bytes.bytes[pos++] & 0xFF);
+
+ values[ordinal] += value;
+ }
}
-
- // aggreate association values for ordinals
- int bytesUpto = bytes.offset + bytes.length;
- int pos = bytes.offset;
- while (pos < bytesUpto) {
- int ordinal = ((bytes.bytes[pos++] & 0xFF) << 24) | ((bytes.bytes[pos++] & 0xFF) << 16)
- | ((bytes.bytes[pos++] & 0xFF) << 8) | (bytes.bytes[pos++] & 0xFF);
-
- int value = ((bytes.bytes[pos++] & 0xFF) << 24) | ((bytes.bytes[pos++] & 0xFF) << 16)
- | ((bytes.bytes[pos++] & 0xFF) << 8) | (bytes.bytes[pos++] & 0xFF);
-
- values[ordinal] += value;
- }
-
++doc;
}
}
Modified: lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/associations/AssociationsFacetRequestTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/associations/AssociationsFacetRequestTest.java?rev=1508451&r1=1508450&r2=1508451&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/associations/AssociationsFacetRequestTest.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/associations/AssociationsFacetRequestTest.java Tue Jul 30 14:05:48 2013
@@ -67,14 +67,18 @@ public class AssociationsFacetRequestTes
AssociationsFacetFields assocFacetFields = new AssociationsFacetFields(taxoWriter);
// index documents, 50% have only 'b' and all have 'a'
- for (int i = 0; i < 100; i++) {
+ for (int i = 0; i < 110; i++) {
Document doc = new Document();
CategoryAssociationsContainer associations = new CategoryAssociationsContainer();
- associations.setAssociation(aint, new CategoryIntAssociation(2));
- associations.setAssociation(afloat, new CategoryFloatAssociation(0.5f));
- if (i % 2 == 0) { // 50
- associations.setAssociation(bint, new CategoryIntAssociation(3));
- associations.setAssociation(bfloat, new CategoryFloatAssociation(0.2f));
+ // every 11th document is added empty, this used to cause the association
+ // aggregators to go into an infinite loop
+ if (i % 11 != 0) {
+ associations.setAssociation(aint, new CategoryIntAssociation(2));
+ associations.setAssociation(afloat, new CategoryFloatAssociation(0.5f));
+ if (i % 2 == 0) { // 50
+ associations.setAssociation(bint, new CategoryIntAssociation(3));
+ associations.setAssociation(bfloat, new CategoryFloatAssociation(0.2f));
+ }
}
assocFacetFields.addFields(doc, associations);
writer.addDocument(doc);
@@ -185,6 +189,6 @@ public class AssociationsFacetRequestTes
assertEquals("Wrong count for category 'b'!",10f, (float) res.get(3).getFacetResultNode().value, 0.00001);
taxo.close();
- }
+ }
}