lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jpou...@apache.org
Subject [2/2] lucene-solr:branch_6x: Fix for TermsQueryTest.testRamBytesUsed failures.
Date Wed, 04 May 2016 06:17:33 GMT
Fix for TermsQueryTest.testRamBytesUsed failures.

This replaces the HashSet whose memory usage is hard to predict with a simple boolean.


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/a80984a2
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/a80984a2
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/a80984a2

Branch: refs/heads/branch_6x
Commit: a80984a24911345976e0ffc3b9a4b16117b55871
Parents: f1ed73d
Author: Adrien Grand <jpountz@gmail.com>
Authored: Wed May 4 08:15:42 2016 +0200
Committer: Adrien Grand <jpountz@gmail.com>
Committed: Wed May 4 08:17:11 2016 +0200

----------------------------------------------------------------------
 .../src/java/org/apache/lucene/queries/TermsQuery.java       | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/a80984a2/lucene/queries/src/java/org/apache/lucene/queries/TermsQuery.java
----------------------------------------------------------------------
diff --git a/lucene/queries/src/java/org/apache/lucene/queries/TermsQuery.java b/lucene/queries/src/java/org/apache/lucene/queries/TermsQuery.java
index eeee61f..c29500b 100644
--- a/lucene/queries/src/java/org/apache/lucene/queries/TermsQuery.java
+++ b/lucene/queries/src/java/org/apache/lucene/queries/TermsQuery.java
@@ -85,7 +85,7 @@ public class TermsQuery extends Query implements Accountable {
   // Same threshold as MultiTermQueryConstantScoreWrapper
   static final int BOOLEAN_REWRITE_TERM_COUNT_THRESHOLD = 16;
 
-  private final Set<String> fields;
+  private final boolean singleField; // whether all terms are from the same field
   private final PrefixCodedTerms termData;
   private final int termDataHashCode; // cached hashcode of termData
 
@@ -110,7 +110,7 @@ public class TermsQuery extends Query implements Accountable {
       }
       previous = term;
     }
-    this.fields = Collections.unmodifiableSet(fields);
+    singleField = fields.size() == 1;
     termData = builder.finish();
     termDataHashCode = termData.hashCode();
   }
@@ -137,7 +137,7 @@ public class TermsQuery extends Query implements Accountable {
       builder.add(field, term);
       previous.copyBytes(term);
     }
-    fields = Collections.singleton(field);
+    singleField = true;
     termData = builder.finish();
     termDataHashCode = termData.hashCode();
   }
@@ -307,7 +307,7 @@ public class TermsQuery extends Query implements Accountable {
               matchingTerms.add(new TermAndState(field, termsEnum));
             } else {
               assert matchingTerms.size() == threshold;
-              if (TermsQuery.this.fields.size() == 1) {
+              if (singleField) {
                 // common case: all terms are in the same field
                 // use an optimized builder that leverages terms stats to be more efficient
                 builder = new DocIdSetBuilder(reader.maxDoc(), terms);


Mime
View raw message