You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by jp...@apache.org on 2014/06/13 13:56:17 UTC

svn commit: r1602391 - in /lucene/dev/branches/branch_4x: ./ lucene/ lucene/core/ lucene/core/src/java/org/apache/lucene/search/ lucene/core/src/java/org/apache/lucene/util/ lucene/core/src/java/org/apache/lucene/util/packed/ lucene/facet/ lucene/join/...

Author: jpountz
Date: Fri Jun 13 11:56:17 2014
New Revision: 1602391

URL: http://svn.apache.org/r1602391
Log:
LUCENE-5695: DocIdSet implements Accountable.

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/core/   (props changed)
    lucene/dev/branches/branch_4x/lucene/core/build.xml
    lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/search/CachingWrapperFilter.java
    lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/search/DocIdSet.java
    lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/search/FilteredDocIdSet.java
    lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/DocIdBitSet.java
    lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/FixedBitSet.java
    lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/OpenBitSet.java
    lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/SentinelIntSet.java
    lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/packed/EliasFanoDocIdSet.java
    lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/packed/EliasFanoEncoder.java
    lucene/dev/branches/branch_4x/lucene/facet/   (props changed)
    lucene/dev/branches/branch_4x/lucene/join/   (props changed)
    lucene/dev/branches/branch_4x/lucene/join/src/java/org/apache/lucene/search/join/FixedBitSetCachingWrapperFilter.java
    lucene/dev/branches/branch_4x/lucene/queries/   (props changed)
    lucene/dev/branches/branch_4x/lucene/queries/src/test/org/apache/lucene/queries/BooleanFilterTest.java
    lucene/dev/branches/branch_4x/lucene/spatial/   (props changed)
    lucene/dev/branches/branch_4x/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/ContainsPrefixTreeFilter.java
    lucene/dev/branches/branch_4x/solr/   (props changed)
    lucene/dev/branches/branch_4x/solr/core/   (props changed)
    lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/BitDocSet.java
    lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/DocSetBase.java
    lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java
    lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/SortedIntDocSet.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=1602391&r1=1602390&r2=1602391&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/CHANGES.txt (original)
+++ lucene/dev/branches/branch_4x/lucene/CHANGES.txt Fri Jun 13 11:56:17 2014
@@ -127,6 +127,8 @@ API Changes
   copy bytes on each access, you are responsible for cloning if you want to keep
   data around. (Adrien Grand)
 
+* LUCENE-5695: DocIdSet implements Accountable. (Adrien Grand)
+
 Optimizations
 
 * LUCENE-5603: hunspell stemmer more efficiently strips prefixes

Modified: lucene/dev/branches/branch_4x/lucene/core/build.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/build.xml?rev=1602391&r1=1602390&r2=1602391&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/build.xml (original)
+++ lucene/dev/branches/branch_4x/lucene/core/build.xml Fri Jun 13 11:56:17 2014
@@ -33,7 +33,6 @@
   <property name="forbidden-rue-excludes" value="
     org/apache/lucene/search/FieldCache$CacheEntry.class
     org/apache/lucene/util/RamUsageEstimator.class
-    org/apache/lucene/search/CachingWrapperFilter.class
   "/>
 
   <import file="../common-build.xml"/>

Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/search/CachingWrapperFilter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/search/CachingWrapperFilter.java?rev=1602391&r1=1602390&r2=1602391&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/search/CachingWrapperFilter.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/search/CachingWrapperFilter.java Fri Jun 13 11:56:17 2014
@@ -17,6 +17,8 @@ package org.apache.lucene.search;
  * limitations under the License.
  */
 
+import static org.apache.lucene.search.DocIdSet.EMPTY;
+
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -28,7 +30,6 @@ import org.apache.lucene.index.AtomicRea
 import org.apache.lucene.index.AtomicReaderContext;
 import org.apache.lucene.util.Accountable;
 import org.apache.lucene.util.Bits;
-import org.apache.lucene.util.RamUsageEstimator;
 import org.apache.lucene.util.WAH8DocIdSet;
 
 /**
@@ -60,14 +61,14 @@ public class CachingWrapperFilter extend
    *  by the wrapped Filter. <p>This implementation returns the given {@link DocIdSet},
    *  if {@link DocIdSet#isCacheable} returns <code>true</code>, else it calls
    *  {@link #cacheImpl(DocIdSetIterator,AtomicReader)}
-   *  <p>Note: This method returns {@linkplain #EMPTY_DOCIDSET} if the given docIdSet
+   *  <p>Note: This method returns {@linkplain DocIdSet#EMPTY} if the given docIdSet
    *  is <code>null</code> or if {@link DocIdSet#iterator()} return <code>null</code>. The empty
    *  instance is use as a placeholder in the cache instead of the <code>null</code> value.
    */
   protected DocIdSet docIdSetToCache(DocIdSet docIdSet, AtomicReader reader) throws IOException {
     if (docIdSet == null) {
       // this is better than returning null, as the nonnull result can be cached
-      return EMPTY_DOCIDSET;
+      return EMPTY;
     } else if (docIdSet.isCacheable()) {
       return docIdSet;
     } else {
@@ -76,7 +77,7 @@ public class CachingWrapperFilter extend
       // in this case we wrap with the sentinel set,
       // which is cacheable.
       if (it == null) {
-        return EMPTY_DOCIDSET;
+        return EMPTY;
       } else {
         return cacheImpl(it, reader);
       }
@@ -110,7 +111,7 @@ public class CachingWrapperFilter extend
       cache.put(key, docIdSet);
     }
 
-    return docIdSet == EMPTY_DOCIDSET ? null : BitsFilteredDocIdSet.wrap(docIdSet, acceptDocs);
+    return docIdSet == EMPTY ? null : BitsFilteredDocIdSet.wrap(docIdSet, acceptDocs);
   }
   
   @Override
@@ -129,26 +130,6 @@ public class CachingWrapperFilter extend
   public int hashCode() {
     return (filter.hashCode() ^ getClass().hashCode());
   }
-  
-  /** An empty {@code DocIdSet} instance */
-  protected static final DocIdSet EMPTY_DOCIDSET = new DocIdSet() {
-    
-    @Override
-    public DocIdSetIterator iterator() {
-      return DocIdSetIterator.empty();
-    }
-    
-    @Override
-    public boolean isCacheable() {
-      return true;
-    }
-    
-    // we explicitly provide no random access, as this filter is 100% sparse and iterator exits faster
-    @Override
-    public Bits bits() {
-      return null;
-    }
-  };
 
   @Override
   public long ramBytesUsed() {
@@ -161,7 +142,7 @@ public class CachingWrapperFilter extend
 
     long total = 0;
     for(DocIdSet dis : docIdSets) {
-      total += RamUsageEstimator.sizeOf(dis);
+      total += dis.ramBytesUsed();
     }
 
     return total;

Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/search/DocIdSet.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/search/DocIdSet.java?rev=1602391&r1=1602390&r2=1602391&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/search/DocIdSet.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/search/DocIdSet.java Fri Jun 13 11:56:17 2014
@@ -18,13 +18,40 @@ package org.apache.lucene.search;
  */
 
 import java.io.IOException;
+
+import org.apache.lucene.util.Accountable;
 import org.apache.lucene.util.Bits;
 
 /**
  * A DocIdSet contains a set of doc ids. Implementing classes must
  * only implement {@link #iterator} to provide access to the set. 
  */
-public abstract class DocIdSet {
+public abstract class DocIdSet implements Accountable {
+
+  /** An empty {@code DocIdSet} instance */
+  public static final DocIdSet EMPTY = new DocIdSet() {
+    
+    @Override
+    public DocIdSetIterator iterator() {
+      return DocIdSetIterator.empty();
+    }
+    
+    @Override
+    public boolean isCacheable() {
+      return true;
+    }
+    
+    // we explicitly provide no random access, as this filter is 100% sparse and iterator exits faster
+    @Override
+    public Bits bits() {
+      return null;
+    }
+
+    @Override
+    public long ramBytesUsed() {
+      return 0L;
+    }
+  };
 
   /** Provides a {@link DocIdSetIterator} to access the set.
    * This implementation can return <code>null</code> if there
@@ -65,4 +92,9 @@ public abstract class DocIdSet {
   public boolean isCacheable() {
     return false;
   }
+
+  @Override
+  public long ramBytesUsed() {
+    return 0L;
+  }
 }

Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/search/FilteredDocIdSet.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/search/FilteredDocIdSet.java?rev=1602391&r1=1602390&r2=1602391&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/search/FilteredDocIdSet.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/search/FilteredDocIdSet.java Fri Jun 13 11:56:17 2014
@@ -18,7 +18,9 @@ package org.apache.lucene.search;
  */
 
 import java.io.IOException;
+
 import org.apache.lucene.util.Bits;
+import org.apache.lucene.util.RamUsageEstimator;
 
 /**
  * Abstract decorator class for a DocIdSet implementation
@@ -55,7 +57,12 @@ public abstract class FilteredDocIdSet e
   public boolean isCacheable() {
     return _innerSet.isCacheable();
   }
-  
+
+  @Override
+  public long ramBytesUsed() {
+    return RamUsageEstimator.NUM_BYTES_OBJECT_REF + _innerSet.ramBytesUsed();
+  }
+
   @Override
   public Bits bits() throws IOException {
     final Bits bits = _innerSet.bits();

Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/DocIdBitSet.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/DocIdBitSet.java?rev=1602391&r1=1602390&r2=1602391&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/DocIdBitSet.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/DocIdBitSet.java Fri Jun 13 11:56:17 2014
@@ -64,7 +64,12 @@ public class DocIdBitSet extends DocIdSe
     // the size may not be correct...
     return bitSet.size(); 
   }
-  
+
+  @Override
+  public long ramBytesUsed() {
+    return RamUsageEstimator.NUM_BYTES_OBJECT_REF + (bitSet.size() + 7) >>> 3;
+  }
+
   private static class DocIdBitSetIterator extends DocIdSetIterator {
     private int docId;
     private BitSet bitSet;

Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/FixedBitSet.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/FixedBitSet.java?rev=1602391&r1=1602390&r2=1602391&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/FixedBitSet.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/FixedBitSet.java Fri Jun 13 11:56:17 2014
@@ -218,6 +218,14 @@ public final class FixedBitSet extends D
     return true;
   }
 
+  @Override
+  public long ramBytesUsed() {
+    return RamUsageEstimator.alignObjectSize(
+          RamUsageEstimator.NUM_BYTES_OBJECT_REF // the reference to the long[]
+        + RamUsageEstimator.NUM_BYTES_INT * 2)   // numBits and numWords
+        + RamUsageEstimator.sizeOf(bits);        // the bits
+  }
+
   /** Expert. */
   public long[] getBits() {
     return bits;

Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/OpenBitSet.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/OpenBitSet.java?rev=1602391&r1=1602390&r2=1602391&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/OpenBitSet.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/OpenBitSet.java Fri Jun 13 11:56:17 2014
@@ -131,6 +131,15 @@ public class OpenBitSet extends DocIdSet
     return true;
   }
 
+  @Override
+  public long ramBytesUsed() {
+    return RamUsageEstimator.alignObjectSize(
+          RamUsageEstimator.NUM_BYTES_OBJECT_REF
+        + RamUsageEstimator.NUM_BYTES_LONG
+        + RamUsageEstimator.NUM_BYTES_INT)
+        + RamUsageEstimator.sizeOf(bits);
+  }
+
   /** Returns the current capacity in bits (1 greater than the index of the last bit) */
   public long capacity() { return bits.length << 6; }
 

Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/SentinelIntSet.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/SentinelIntSet.java?rev=1602391&r1=1602390&r2=1602391&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/SentinelIntSet.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/SentinelIntSet.java Fri Jun 13 11:56:17 2014
@@ -145,4 +145,12 @@ public class SentinelIntSet {
     }
     rehashCount = newSize - (newSize>>2);
   }
+
+  /** Return the memory footprint of this class in bytes. */
+  public long ramBytesUsed() {
+    return RamUsageEstimator.alignObjectSize(
+          RamUsageEstimator.NUM_BYTES_INT * 3
+        + RamUsageEstimator.NUM_BYTES_OBJECT_REF)
+        + RamUsageEstimator.sizeOf(keys);
+  }
 }

Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/packed/EliasFanoDocIdSet.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/packed/EliasFanoDocIdSet.java?rev=1602391&r1=1602390&r2=1602391&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/packed/EliasFanoDocIdSet.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/packed/EliasFanoDocIdSet.java Fri Jun 13 11:56:17 2014
@@ -21,8 +21,8 @@ import java.io.IOException;
 
 import org.apache.lucene.search.DocIdSet;
 import org.apache.lucene.search.DocIdSetIterator;
-
 import org.apache.lucene.util.FixedBitSet; // for javadocs
+import org.apache.lucene.util.RamUsageEstimator;
 
 
 /** A DocIdSet in Elias-Fano encoding.
@@ -126,5 +126,10 @@ public class EliasFanoDocIdSet extends D
   public int hashCode() {
     return efEncoder.hashCode() ^ getClass().hashCode();
   }
+
+  @Override
+  public long ramBytesUsed() {
+    return RamUsageEstimator.alignObjectSize(RamUsageEstimator.NUM_BYTES_OBJECT_REF) + efEncoder.ramBytesUsed();
+  }
 }
 

Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/packed/EliasFanoEncoder.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/packed/EliasFanoEncoder.java?rev=1602391&r1=1602390&r2=1602391&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/packed/EliasFanoEncoder.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/packed/EliasFanoEncoder.java Fri Jun 13 11:56:17 2014
@@ -19,8 +19,10 @@ package org.apache.lucene.util.packed;
 
 import java.util.Arrays;
 
-import org.apache.lucene.util.ToStringUtils;
+import org.apache.lucene.util.Accountable;
 import org.apache.lucene.util.FixedBitSet; // for javadocs
+import org.apache.lucene.util.RamUsageEstimator;
+import org.apache.lucene.util.ToStringUtils;
 
 
 /** Encode a non decreasing sequence of non negative whole numbers in the Elias-Fano encoding
@@ -82,7 +84,7 @@ import org.apache.lucene.util.FixedBitSe
  * @lucene.internal
  */
 
-public class EliasFanoEncoder {
+public class EliasFanoEncoder implements Accountable {
   final long numValues;
   private final long upperBound;
   final int numLowBits;
@@ -350,5 +352,15 @@ public class EliasFanoEncoder {
     return h;
   }
 
+  @Override
+  public long ramBytesUsed() {
+    return RamUsageEstimator.alignObjectSize(
+          RamUsageEstimator.NUM_BYTES_OBJECT_REF * 3
+        + RamUsageEstimator.NUM_BYTES_LONG * 8
+        + RamUsageEstimator.NUM_BYTES_INT * 2)
+        + RamUsageEstimator.sizeOf(lowerLongs)
+        + RamUsageEstimator.sizeOf(upperLongs)
+        + RamUsageEstimator.sizeOf(upperZeroBitPositionIndex);
+  }
 }
 

Modified: lucene/dev/branches/branch_4x/lucene/join/src/java/org/apache/lucene/search/join/FixedBitSetCachingWrapperFilter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/join/src/java/org/apache/lucene/search/join/FixedBitSetCachingWrapperFilter.java?rev=1602391&r1=1602390&r2=1602391&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/join/src/java/org/apache/lucene/search/join/FixedBitSetCachingWrapperFilter.java (original)
+++ lucene/dev/branches/branch_4x/lucene/join/src/java/org/apache/lucene/search/join/FixedBitSetCachingWrapperFilter.java Fri Jun 13 11:56:17 2014
@@ -17,6 +17,8 @@ package org.apache.lucene.search.join;
  * limitations under the License.
  */
 
+import static org.apache.lucene.search.DocIdSet.EMPTY;
+
 import java.io.IOException;
 
 import org.apache.lucene.index.AtomicReader;
@@ -39,7 +41,7 @@ public final class FixedBitSetCachingWra
   protected DocIdSet docIdSetToCache(DocIdSet docIdSet, AtomicReader reader)
       throws IOException {
     if (docIdSet == null) {
-      return EMPTY_DOCIDSET;
+      return EMPTY;
     } else if (docIdSet instanceof FixedBitSet) {
       // this is different from CachingWrapperFilter: even when the DocIdSet is
       // cacheable, we convert it to a FixedBitSet since we require all the
@@ -48,7 +50,7 @@ public final class FixedBitSetCachingWra
     } else {
       final DocIdSetIterator it = docIdSet.iterator();
       if (it == null) {
-        return EMPTY_DOCIDSET;
+        return EMPTY;
       } else {
         final FixedBitSet copy = new FixedBitSet(reader.maxDoc());
         copy.or(it);

Modified: lucene/dev/branches/branch_4x/lucene/queries/src/test/org/apache/lucene/queries/BooleanFilterTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/queries/src/test/org/apache/lucene/queries/BooleanFilterTest.java?rev=1602391&r1=1602390&r2=1602391&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/queries/src/test/org/apache/lucene/queries/BooleanFilterTest.java (original)
+++ lucene/dev/branches/branch_4x/lucene/queries/src/test/org/apache/lucene/queries/BooleanFilterTest.java Fri Jun 13 11:56:17 2014
@@ -111,17 +111,7 @@ public class BooleanFilterTest extends L
     return new Filter() {
       @Override
       public DocIdSet getDocIdSet(AtomicReaderContext context, Bits acceptDocs) {
-        return new DocIdSet() {
-          @Override
-          public DocIdSetIterator iterator() {
-            return null;
-          }
-          
-          @Override
-          public boolean isCacheable() {
-            return true;
-          }
-        };
+        return DocIdSet.EMPTY;
       }
     };
   }

Modified: lucene/dev/branches/branch_4x/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/ContainsPrefixTreeFilter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/ContainsPrefixTreeFilter.java?rev=1602391&r1=1602390&r2=1602391&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/ContainsPrefixTreeFilter.java (original)
+++ lucene/dev/branches/branch_4x/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/ContainsPrefixTreeFilter.java Fri Jun 13 11:56:17 2014
@@ -19,6 +19,7 @@ package org.apache.lucene.spatial.prefix
 
 import com.spatial4j.core.shape.Shape;
 import com.spatial4j.core.shape.SpatialRelation;
+
 import org.apache.lucene.index.AtomicReaderContext;
 import org.apache.lucene.index.DocsEnum;
 import org.apache.lucene.search.DocIdSet;
@@ -27,6 +28,7 @@ import org.apache.lucene.spatial.prefix.
 import org.apache.lucene.spatial.prefix.tree.SpatialPrefixTree;
 import org.apache.lucene.util.Bits;
 import org.apache.lucene.util.BytesRef;
+import org.apache.lucene.util.RamUsageEstimator;
 import org.apache.lucene.util.SentinelIntSet;
 
 import java.io.IOException;
@@ -294,6 +296,14 @@ public class ContainsPrefixTreeFilter ex
       };
     }
 
+    @Override
+    public long ramBytesUsed() {
+      return RamUsageEstimator.alignObjectSize(
+            RamUsageEstimator.NUM_BYTES_OBJECT_REF
+          + RamUsageEstimator.NUM_BYTES_INT)
+          + intSet.ramBytesUsed();
+    }
+
   }//class SmallDocSet
 
 }

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/BitDocSet.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/BitDocSet.java?rev=1602391&r1=1602390&r2=1602391&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/BitDocSet.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/BitDocSet.java Fri Jun 13 11:56:17 2014
@@ -336,6 +336,11 @@ public class BitDocSet extends DocSetBas
           }
 
           @Override
+          public long ramBytesUsed() {
+            return bs.ramBytesUsed();
+          }
+
+          @Override
           public Bits bits() {
             return new Bits() {
               @Override

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/DocSetBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/DocSetBase.java?rev=1602391&r1=1602390&r2=1602391&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/DocSetBase.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/DocSetBase.java Fri Jun 13 11:56:17 2014
@@ -216,6 +216,11 @@ abstract class DocSetBase implements Doc
           }
 
           @Override
+          public long ramBytesUsed() {
+            return bs.ramBytesUsed();
+          }
+
+          @Override
           public Bits bits() {
             // sparse filters should not use random access
             return null;

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java?rev=1602391&r1=1602390&r2=1602391&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java Fri Jun 13 11:56:17 2014
@@ -2450,6 +2450,11 @@ class FilterImpl extends Filter {
     public Bits bits() throws IOException {
       return null;  // don't use random access
     }
+
+    @Override
+    public long ramBytesUsed() {
+      return docIdSet != null ? docIdSet.ramBytesUsed() : 0L;
+    }
   }
 
   private static class FilterIterator extends DocIdSetIterator {

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/SortedIntDocSet.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/SortedIntDocSet.java?rev=1602391&r1=1602390&r2=1602391&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/SortedIntDocSet.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/SortedIntDocSet.java Fri Jun 13 11:56:17 2014
@@ -25,6 +25,7 @@ import org.apache.lucene.search.DocIdSet
 import org.apache.lucene.search.Filter;
 import org.apache.lucene.util.Bits;
 import org.apache.lucene.util.FixedBitSet;
+import org.apache.lucene.util.RamUsageEstimator;
 
 /**
  * <code>SortedIntDocSet</code> represents a sorted set of Lucene Document Ids.
@@ -766,6 +767,11 @@ public class SortedIntDocSet extends Doc
           }
 
           @Override
+          public long ramBytesUsed() {
+            return RamUsageEstimator.sizeOf(docs);
+          }
+          
+          @Override
           public Bits bits() {
             // random access is expensive for this set
             return null;