You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by rm...@apache.org on 2014/09/16 15:26:58 UTC

svn commit: r1625275 [2/4] - in /lucene/dev/trunk: lucene/ lucene/backward-codecs/src/java/org/apache/lucene/codecs/lucene40/ lucene/backward-codecs/src/java/org/apache/lucene/codecs/lucene42/ lucene/backward-codecs/src/java/org/apache/lucene/codecs/lu...

Modified: lucene/dev/trunk/lucene/codecs/src/java/org/apache/lucene/codecs/bloom/BloomFilteringPostingsFormat.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/codecs/src/java/org/apache/lucene/codecs/bloom/BloomFilteringPostingsFormat.java?rev=1625275&r1=1625274&r2=1625275&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/codecs/src/java/org/apache/lucene/codecs/bloom/BloomFilteringPostingsFormat.java (original)
+++ lucene/dev/trunk/lucene/codecs/src/java/org/apache/lucene/codecs/bloom/BloomFilteringPostingsFormat.java Tue Sep 16 13:26:55 2014
@@ -19,6 +19,7 @@ package org.apache.lucene.codecs.bloom;
 
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
@@ -42,6 +43,8 @@ import org.apache.lucene.index.TermsEnum
 import org.apache.lucene.store.ChecksumIndexInput;
 import org.apache.lucene.store.DataOutput;
 import org.apache.lucene.store.IndexOutput;
+import org.apache.lucene.util.Accountable;
+import org.apache.lucene.util.Accountables;
 import org.apache.lucene.util.Bits;
 import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.IOUtils;
@@ -409,9 +412,24 @@ public final class BloomFilteringPosting
     }
 
     @Override
+    public Iterable<? extends Accountable> getChildResources() {
+      List<Accountable> resources = new ArrayList<>();
+      resources.addAll(Accountables.namedAccountables("field", bloomsByFieldName));
+      if (delegateFieldsProducer != null) {
+        resources.add(Accountables.namedAccountable("delegate", delegateFieldsProducer));
+      }
+      return Collections.unmodifiableList(resources);
+    }
+
+    @Override
     public void checkIntegrity() throws IOException {
       delegateFieldsProducer.checkIntegrity();
     }
+
+    @Override
+    public String toString() {
+      return getClass().getSimpleName() + "(fields=" + bloomsByFieldName.size() + ",delegate=" + delegateFieldsProducer + ")";
+    }
   }
   
   class BloomFilteredFieldsConsumer extends FieldsConsumer {

Modified: lucene/dev/trunk/lucene/codecs/src/java/org/apache/lucene/codecs/bloom/FuzzySet.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/codecs/src/java/org/apache/lucene/codecs/bloom/FuzzySet.java?rev=1625275&r1=1625274&r2=1625275&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/codecs/src/java/org/apache/lucene/codecs/bloom/FuzzySet.java (original)
+++ lucene/dev/trunk/lucene/codecs/src/java/org/apache/lucene/codecs/bloom/FuzzySet.java Tue Sep 16 13:26:55 2014
@@ -17,6 +17,7 @@ package org.apache.lucene.codecs.bloom;
  * limitations under the License.
  */
 import java.io.IOException;
+import java.util.Collections;
 
 import org.apache.lucene.store.DataInput;
 import org.apache.lucene.store.DataOutput;
@@ -309,4 +310,14 @@ public class FuzzySet implements Account
   public long ramBytesUsed() {
     return RamUsageEstimator.sizeOf(filter.getBits());
   }
+
+  @Override
+  public Iterable<? extends Accountable> getChildResources() {
+    return Collections.emptyList();
+  }
+
+  @Override
+  public String toString() {
+    return getClass().getSimpleName() + "(hash=" + hashFunction + ")";
+  }
 }

Modified: lucene/dev/trunk/lucene/codecs/src/java/org/apache/lucene/codecs/bloom/MurmurHash2.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/codecs/src/java/org/apache/lucene/codecs/bloom/MurmurHash2.java?rev=1625275&r1=1625274&r2=1625275&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/codecs/src/java/org/apache/lucene/codecs/bloom/MurmurHash2.java (original)
+++ lucene/dev/trunk/lucene/codecs/src/java/org/apache/lucene/codecs/bloom/MurmurHash2.java Tue Sep 16 13:26:55 2014
@@ -98,5 +98,9 @@ public final class MurmurHash2 extends H
   public final int hash(BytesRef br) {
     return hash32(br.bytes, br.offset, br.length);
   }
-  
+
+  @Override
+  public String toString() {
+    return getClass().getSimpleName();
+  }  
 }

Modified: lucene/dev/trunk/lucene/codecs/src/java/org/apache/lucene/codecs/memory/DirectDocValuesProducer.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/codecs/src/java/org/apache/lucene/codecs/memory/DirectDocValuesProducer.java?rev=1625275&r1=1625274&r2=1625275&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/codecs/src/java/org/apache/lucene/codecs/memory/DirectDocValuesProducer.java (original)
+++ lucene/dev/trunk/lucene/codecs/src/java/org/apache/lucene/codecs/memory/DirectDocValuesProducer.java Tue Sep 16 13:26:55 2014
@@ -18,7 +18,10 @@ package org.apache.lucene.codecs.memory;
  */
 
 import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.concurrent.atomic.AtomicLong;
 
@@ -28,6 +31,7 @@ import org.apache.lucene.index.BinaryDoc
 import org.apache.lucene.index.CorruptIndexException;
 import org.apache.lucene.index.DocValues;
 import org.apache.lucene.index.FieldInfo;
+import org.apache.lucene.index.FieldInfos;
 import org.apache.lucene.index.IndexFileNames;
 import org.apache.lucene.index.NumericDocValues;
 import org.apache.lucene.index.RandomAccessOrds;
@@ -37,6 +41,8 @@ import org.apache.lucene.index.SortedNum
 import org.apache.lucene.index.SortedSetDocValues;
 import org.apache.lucene.store.ChecksumIndexInput;
 import org.apache.lucene.store.IndexInput;
+import org.apache.lucene.util.Accountable;
+import org.apache.lucene.util.Accountables;
 import org.apache.lucene.util.Bits;
 import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.FixedBitSet;
@@ -49,25 +55,22 @@ import org.apache.lucene.util.RamUsageEs
 
 class DirectDocValuesProducer extends DocValuesProducer {
   // metadata maps (just file pointers and minimal stuff)
-  private final Map<Integer,NumericEntry> numerics = new HashMap<>();
-  private final Map<Integer,BinaryEntry> binaries = new HashMap<>();
-  private final Map<Integer,SortedEntry> sorteds = new HashMap<>();
-  private final Map<Integer,SortedSetEntry> sortedSets = new HashMap<>();
-  private final Map<Integer,SortedNumericEntry> sortedNumerics = new HashMap<>();
+  private final Map<String,NumericEntry> numerics = new HashMap<>();
+  private final Map<String,BinaryEntry> binaries = new HashMap<>();
+  private final Map<String,SortedEntry> sorteds = new HashMap<>();
+  private final Map<String,SortedSetEntry> sortedSets = new HashMap<>();
+  private final Map<String,SortedNumericEntry> sortedNumerics = new HashMap<>();
   private final IndexInput data;
   
   // ram instances we have already loaded
-  private final Map<Integer,NumericDocValues> numericInstances = 
-      new HashMap<>();
-  private final Map<Integer,BinaryRawValues> binaryInstances =
-      new HashMap<>();
-  private final Map<Integer,SortedRawValues> sortedInstances =
-      new HashMap<>();
-  private final Map<Integer,SortedSetRawValues> sortedSetInstances =
-      new HashMap<>();
-  private final Map<Integer,SortedNumericRawValues> sortedNumericInstances =
-      new HashMap<>();
-  private final Map<Integer,Bits> docsWithFieldInstances = new HashMap<>();
+  private final Map<String,NumericRawValues> numericInstances = new HashMap<>();
+  private final Map<String,BinaryRawValues> binaryInstances = new HashMap<>();
+  private final Map<String,SortedRawValues> sortedInstances = new HashMap<>();
+  private final Map<String,SortedSetRawValues> sortedSetInstances = new HashMap<>();
+  private final Map<String,SortedNumericRawValues> sortedNumericInstances = new HashMap<>();
+  private final Map<String,FixedBitSet> docsWithFieldInstances = new HashMap<>();
+  
+  private final int numEntries;
   
   private final int maxDoc;
   private final AtomicLong ramBytesUsed;
@@ -95,7 +98,7 @@ class DirectDocValuesProducer extends Do
       version = CodecUtil.checkHeader(in, metaCodec, 
                                       VERSION_START,
                                       VERSION_CURRENT);
-      readFields(in);
+      numEntries = readFields(in, state.fieldInfos);
 
       CodecUtil.checkFooter(in);
       success = true;
@@ -188,37 +191,41 @@ class DirectDocValuesProducer extends Do
     return entry;
   }
 
-  private void readFields(IndexInput meta) throws IOException {
+  private int readFields(IndexInput meta, FieldInfos infos) throws IOException {
+    int numEntries = 0;
     int fieldNumber = meta.readVInt();
     while (fieldNumber != -1) {
+      numEntries++;
+      FieldInfo info = infos.fieldInfo(fieldNumber);
       int fieldType = meta.readByte();
       if (fieldType == NUMBER) {
-        numerics.put(fieldNumber, readNumericEntry(meta));
+        numerics.put(info.name, readNumericEntry(meta));
       } else if (fieldType == BYTES) {
-        binaries.put(fieldNumber, readBinaryEntry(meta));
+        binaries.put(info.name, readBinaryEntry(meta));
       } else if (fieldType == SORTED) {
         SortedEntry entry = readSortedEntry(meta);
-        sorteds.put(fieldNumber, entry);
-        binaries.put(fieldNumber, entry.values);
+        sorteds.put(info.name, entry);
+        binaries.put(info.name, entry.values);
       } else if (fieldType == SORTED_SET) {
         SortedSetEntry entry = readSortedSetEntry(meta, false);
-        sortedSets.put(fieldNumber, entry);
-        binaries.put(fieldNumber, entry.values);
+        sortedSets.put(info.name, entry);
+        binaries.put(info.name, entry.values);
       } else if (fieldType == SORTED_SET_SINGLETON) {
         SortedSetEntry entry = readSortedSetEntry(meta, true);
-        sortedSets.put(fieldNumber, entry);
-        binaries.put(fieldNumber, entry.values);
+        sortedSets.put(info.name, entry);
+        binaries.put(info.name, entry.values);
       } else if (fieldType == SORTED_NUMERIC) {
         SortedNumericEntry entry = readSortedNumericEntry(meta, false);
-        sortedNumerics.put(fieldNumber, entry);
+        sortedNumerics.put(info.name, entry);
       } else if (fieldType == SORTED_NUMERIC_SINGLETON) {
         SortedNumericEntry entry = readSortedNumericEntry(meta, true);
-        sortedNumerics.put(fieldNumber, entry);
+        sortedNumerics.put(info.name, entry);
       } else {
-        throw new CorruptIndexException("invalid entry type: " + fieldType + ", input=" + meta);
+        throw new CorruptIndexException("invalid entry type: " + fieldType + ", field= " + info.name + ", input=" + meta);
       }
       fieldNumber = meta.readVInt();
     }
+    return numEntries;
   }
 
   @Override
@@ -227,35 +234,55 @@ class DirectDocValuesProducer extends Do
   }
   
   @Override
+  public synchronized Iterable<? extends Accountable> getChildResources() {
+    List<Accountable> resources = new ArrayList<>();
+    resources.addAll(Accountables.namedAccountables("numeric field", numericInstances));
+    resources.addAll(Accountables.namedAccountables("binary field", binaryInstances));
+    resources.addAll(Accountables.namedAccountables("sorted field", sortedInstances));
+    resources.addAll(Accountables.namedAccountables("sorted set field", sortedSetInstances));
+    resources.addAll(Accountables.namedAccountables("sorted numeric field", sortedNumericInstances));
+    resources.addAll(Accountables.namedAccountables("missing bitset field", docsWithFieldInstances));
+    return Collections.unmodifiableList(resources);
+  }
+  
+  @Override
+  public String toString() {
+    return getClass().getSimpleName() + "(entries=" + numEntries + ")";
+  }
+
+  @Override
   public void checkIntegrity() throws IOException {
     CodecUtil.checksumEntireFile(data);
   }
 
   @Override
   public synchronized NumericDocValues getNumeric(FieldInfo field) throws IOException {
-    NumericDocValues instance = numericInstances.get(field.number);
+    NumericRawValues instance = numericInstances.get(field.name);
     if (instance == null) {
       // Lazy load
-      instance = loadNumeric(numerics.get(field.number));
-      numericInstances.put(field.number, instance);
+      instance = loadNumeric(numerics.get(field.name));
+      numericInstances.put(field.name, instance);
     }
-    return instance;
+    return instance.numerics;
   }
   
-  private NumericDocValues loadNumeric(NumericEntry entry) throws IOException {
+  private NumericRawValues loadNumeric(NumericEntry entry) throws IOException {
+    NumericRawValues ret = new NumericRawValues();
     data.seek(entry.offset + entry.missingBytes);
     switch (entry.byteWidth) {
     case 1:
       {
         final byte[] values = new byte[entry.count];
         data.readBytes(values, 0, entry.count);
-        ramBytesUsed.addAndGet(RamUsageEstimator.sizeOf(values));
-        return new NumericDocValues() {
+        ret.bytesUsed = RamUsageEstimator.sizeOf(values);
+        ramBytesUsed.addAndGet(ret.bytesUsed);
+        ret.numerics = new NumericDocValues() {
           @Override
           public long get(int idx) {
             return values[idx];
           }
         };
+        return ret;
       }
 
     case 2:
@@ -264,13 +291,15 @@ class DirectDocValuesProducer extends Do
         for(int i=0;i<entry.count;i++) {
           values[i] = data.readShort();
         }
-        ramBytesUsed.addAndGet(RamUsageEstimator.sizeOf(values));
-        return new NumericDocValues() {
+        ret.bytesUsed = RamUsageEstimator.sizeOf(values);
+        ramBytesUsed.addAndGet(ret.bytesUsed);
+        ret.numerics = new NumericDocValues() {
           @Override
           public long get(int idx) {
             return values[idx];
           }
         };
+        return ret;
       }
 
     case 4:
@@ -279,13 +308,15 @@ class DirectDocValuesProducer extends Do
         for(int i=0;i<entry.count;i++) {
           values[i] = data.readInt();
         }
-        ramBytesUsed.addAndGet(RamUsageEstimator.sizeOf(values));
-        return new NumericDocValues() {
+        ret.bytesUsed = RamUsageEstimator.sizeOf(values);
+        ramBytesUsed.addAndGet(ret.bytesUsed);
+        ret.numerics = new NumericDocValues() {
           @Override
           public long get(int idx) {
             return values[idx];
           }
         };
+        return ret;
       }
 
     case 8:
@@ -294,13 +325,15 @@ class DirectDocValuesProducer extends Do
         for(int i=0;i<entry.count;i++) {
           values[i] = data.readLong();
         }
-        ramBytesUsed.addAndGet(RamUsageEstimator.sizeOf(values));
-        return new NumericDocValues() {
+        ret.bytesUsed = RamUsageEstimator.sizeOf(values);
+        ramBytesUsed.addAndGet(ret.bytesUsed);
+        ret.numerics = new NumericDocValues() {
           @Override
           public long get(int idx) {
             return values[idx];
           }
         };
+        return ret;
       }
     
     default:
@@ -310,11 +343,11 @@ class DirectDocValuesProducer extends Do
 
   @Override
   public synchronized BinaryDocValues getBinary(FieldInfo field) throws IOException {
-    BinaryRawValues instance = binaryInstances.get(field.number);
+    BinaryRawValues instance = binaryInstances.get(field.name);
     if (instance == null) {
       // Lazy load
-      instance = loadBinary(binaries.get(field.number));
-      binaryInstances.put(field.number, instance);
+      instance = loadBinary(binaries.get(field.name));
+      binaryInstances.put(field.name, instance);
     }
     final byte[] bytes = instance.bytes;
     final int[] address = instance.address;
@@ -354,17 +387,17 @@ class DirectDocValuesProducer extends Do
   
   @Override
   public SortedDocValues getSorted(FieldInfo field) throws IOException {
-    final SortedEntry entry = sorteds.get(field.number);
+    final SortedEntry entry = sorteds.get(field.name);
     SortedRawValues instance;
     synchronized (this) {
-      instance = sortedInstances.get(field.number);
+      instance = sortedInstances.get(field.name);
       if (instance == null) {
         // Lazy load
         instance = loadSorted(field);
-        sortedInstances.put(field.number, instance);
+        sortedInstances.put(field.name, instance);
       }
     }
-    return newSortedInstance(instance.docToOrd, getBinary(field), entry.values.count);
+    return newSortedInstance(instance.docToOrd.numerics, getBinary(field), entry.values.count);
   }
   
   private SortedDocValues newSortedInstance(final NumericDocValues docToOrd, final BinaryDocValues values, final int count) {
@@ -392,8 +425,8 @@ class DirectDocValuesProducer extends Do
   }
 
   private SortedRawValues loadSorted(FieldInfo field) throws IOException {
-    final SortedEntry entry = sorteds.get(field.number);
-    final NumericDocValues docToOrd = loadNumeric(entry.docToOrd);
+    final SortedEntry entry = sorteds.get(field.name);
+    final NumericRawValues docToOrd = loadNumeric(entry.docToOrd);
     final SortedRawValues values = new SortedRawValues();
     values.docToOrd = docToOrd;
     return values;
@@ -401,21 +434,21 @@ class DirectDocValuesProducer extends Do
 
   @Override
   public synchronized SortedNumericDocValues getSortedNumeric(FieldInfo field) throws IOException {
-    SortedNumericRawValues instance = sortedNumericInstances.get(field.number);
-    final SortedNumericEntry entry = sortedNumerics.get(field.number);
+    SortedNumericRawValues instance = sortedNumericInstances.get(field.name);
+    final SortedNumericEntry entry = sortedNumerics.get(field.name);
     if (instance == null) {
       // Lazy load
       instance = loadSortedNumeric(entry);
-      sortedNumericInstances.put(field.number, instance);
+      sortedNumericInstances.put(field.name, instance);
     }
     
     if (entry.docToAddress == null) {
-      final NumericDocValues single = instance.values;
-      final Bits docsWithField = getMissingBits(field.number, entry.values.missingOffset, entry.values.missingBytes);
+      final NumericDocValues single = instance.values.numerics;
+      final Bits docsWithField = getMissingBits(field, entry.values.missingOffset, entry.values.missingBytes);
       return DocValues.singleton(single, docsWithField);
     } else {
-      final NumericDocValues docToAddress = instance.docToAddress;
-      final NumericDocValues values = instance.values;
+      final NumericDocValues docToAddress = instance.docToAddress.numerics;
+      final NumericDocValues values = instance.values.numerics;
       
       return new SortedNumericDocValues() {
         int valueStart;
@@ -451,20 +484,20 @@ class DirectDocValuesProducer extends Do
 
   @Override
   public synchronized SortedSetDocValues getSortedSet(FieldInfo field) throws IOException {
-    SortedSetRawValues instance = sortedSetInstances.get(field.number);
-    final SortedSetEntry entry = sortedSets.get(field.number);
+    SortedSetRawValues instance = sortedSetInstances.get(field.name);
+    final SortedSetEntry entry = sortedSets.get(field.name);
     if (instance == null) {
       // Lazy load
       instance = loadSortedSet(entry);
-      sortedSetInstances.put(field.number, instance);
+      sortedSetInstances.put(field.name, instance);
     }
 
     if (instance.docToOrdAddress == null) {
-      SortedDocValues sorted = newSortedInstance(instance.ords, getBinary(field), entry.values.count);
+      SortedDocValues sorted = newSortedInstance(instance.ords.numerics, getBinary(field), entry.values.count);
       return DocValues.singleton(sorted);
     } else {
-      final NumericDocValues docToOrdAddress = instance.docToOrdAddress;
-      final NumericDocValues ords = instance.ords;
+      final NumericDocValues docToOrdAddress = instance.docToOrdAddress.numerics;
+      final NumericDocValues ords = instance.ords.numerics;
       final BinaryDocValues values = getBinary(field);
       
       // Must make a new instance since the iterator has state:
@@ -524,13 +557,13 @@ class DirectDocValuesProducer extends Do
     return instance;
   }
 
-  private Bits getMissingBits(int fieldNumber, final long offset, final long length) throws IOException {
+  private Bits getMissingBits(FieldInfo field, final long offset, final long length) throws IOException {
     if (offset == -1) {
       return new Bits.MatchAllBits(maxDoc);
     } else {
-      Bits instance;
+      FixedBitSet instance;
       synchronized(this) {
-        instance = docsWithFieldInstances.get(fieldNumber);
+        instance = docsWithFieldInstances.get(field.name);
         if (instance == null) {
           IndexInput data = this.data.clone();
           data.seek(offset);
@@ -540,7 +573,7 @@ class DirectDocValuesProducer extends Do
             bits[i] = data.readLong();
           }
           instance = new FixedBitSet(bits, maxDoc);
-          docsWithFieldInstances.put(fieldNumber, instance);
+          docsWithFieldInstances.put(field.name, instance);
         }
       }
       return instance;
@@ -557,11 +590,11 @@ class DirectDocValuesProducer extends Do
       case SORTED:
         return DocValues.docsWithValue(getSorted(field), maxDoc);
       case BINARY:
-        BinaryEntry be = binaries.get(field.number);
-        return getMissingBits(field.number, be.missingOffset, be.missingBytes);
+        BinaryEntry be = binaries.get(field.name);
+        return getMissingBits(field, be.missingOffset, be.missingBytes);
       case NUMERIC:
-        NumericEntry ne = numerics.get(field.number);
-        return getMissingBits(field.number, ne.missingOffset, ne.missingBytes);
+        NumericEntry ne = numerics.get(field.name);
+        return getMissingBits(field, ne.missingOffset, ne.missingBytes);
       default: 
         throw new AssertionError();
     }
@@ -572,23 +605,130 @@ class DirectDocValuesProducer extends Do
     data.close();
   }
 
-  static class BinaryRawValues {
+  static class BinaryRawValues implements Accountable {
     byte[] bytes;
     int[] address;
+    
+    @Override
+    public long ramBytesUsed() {
+      long bytesUsed = RamUsageEstimator.sizeOf(bytes);
+      if (address != null) {
+        bytesUsed += RamUsageEstimator.sizeOf(address);
+      }
+      return bytesUsed;
+    }
+    
+    @Override
+    public Iterable<? extends Accountable> getChildResources() {
+      List<Accountable> resources = new ArrayList<>();
+      if (address != null) {
+        resources.add(Accountables.namedAccountable("addresses", RamUsageEstimator.sizeOf(address)));
+      }
+      resources.add(Accountables.namedAccountable("bytes", RamUsageEstimator.sizeOf(bytes)));
+      return Collections.unmodifiableList(resources);
+    }
+
+    @Override
+    public String toString() {
+      return getClass().getSimpleName();
+    }
+  }
+  
+  static class NumericRawValues implements Accountable {
+    NumericDocValues numerics;
+    long bytesUsed;
+    
+    @Override
+    public long ramBytesUsed() {
+      return bytesUsed;
+    }
+    
+    @Override
+    public Iterable<? extends Accountable> getChildResources() {
+      return Collections.emptyList();
+    }
+    
+    @Override
+    public String toString() {
+      return getClass().getSimpleName();
+    }
   }
 
-  static class SortedRawValues {
-    NumericDocValues docToOrd;
+  static class SortedRawValues implements Accountable {
+    NumericRawValues docToOrd;
+
+    @Override
+    public long ramBytesUsed() {
+      return docToOrd.ramBytesUsed();
+    }
+
+    @Override
+    public Iterable<? extends Accountable> getChildResources() {
+      return docToOrd.getChildResources();
+    }
+    
+    @Override
+    public String toString() {
+      return getClass().getSimpleName();
+    }
   }
   
-  static class SortedNumericRawValues {
-    NumericDocValues docToAddress;
-    NumericDocValues values;
+  static class SortedNumericRawValues implements Accountable {
+    NumericRawValues docToAddress;
+    NumericRawValues values;
+    
+    @Override
+    public long ramBytesUsed() {
+      long bytesUsed = values.ramBytesUsed();
+      if (docToAddress != null) {
+        bytesUsed += docToAddress.ramBytesUsed();
+      }
+      return bytesUsed;
+    }
+    
+    @Override
+    public Iterable<? extends Accountable> getChildResources() {
+      List<Accountable> resources = new ArrayList<>();
+      if (docToAddress != null) {
+        resources.add(Accountables.namedAccountable("addresses", docToAddress));
+      }
+      resources.add(Accountables.namedAccountable("values", values));
+      return Collections.unmodifiableList(resources);
+    }
+    
+    @Override
+    public String toString() {
+      return getClass().getSimpleName();
+    }
   }
 
-  static class SortedSetRawValues {
-    NumericDocValues docToOrdAddress;
-    NumericDocValues ords;
+  static class SortedSetRawValues implements Accountable {
+    NumericRawValues docToOrdAddress;
+    NumericRawValues ords;
+
+    @Override
+    public long ramBytesUsed() {
+      long bytesUsed = ords.ramBytesUsed();
+      if (docToOrdAddress != null) {
+        bytesUsed += docToOrdAddress.ramBytesUsed();
+      }
+      return bytesUsed;
+    }
+
+    @Override
+    public Iterable<? extends Accountable> getChildResources() {
+      List<Accountable> resources = new ArrayList<>();
+      if (docToOrdAddress != null) {
+        resources.add(Accountables.namedAccountable("addresses", docToOrdAddress));
+      }
+      resources.add(Accountables.namedAccountable("ordinals", ords));
+      return Collections.unmodifiableList(resources);
+    }
+    
+    @Override
+    public String toString() {
+      return getClass().getSimpleName();
+    }
   }
 
   static class NumericEntry {

Modified: lucene/dev/trunk/lucene/codecs/src/java/org/apache/lucene/codecs/memory/DirectPostingsFormat.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/codecs/src/java/org/apache/lucene/codecs/memory/DirectPostingsFormat.java?rev=1625275&r1=1625274&r2=1625275&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/codecs/src/java/org/apache/lucene/codecs/memory/DirectPostingsFormat.java (original)
+++ lucene/dev/trunk/lucene/codecs/src/java/org/apache/lucene/codecs/memory/DirectPostingsFormat.java Tue Sep 16 13:26:55 2014
@@ -41,6 +41,7 @@ import org.apache.lucene.index.TermsEnum
 import org.apache.lucene.store.IOContext;
 import org.apache.lucene.store.RAMOutputStream;
 import org.apache.lucene.util.Accountable;
+import org.apache.lucene.util.Accountables;
 import org.apache.lucene.util.ArrayUtil;
 import org.apache.lucene.util.Bits;
 import org.apache.lucene.util.BytesRef;
@@ -159,12 +160,22 @@ public final class DirectPostingsFormat 
       }
       return sizeInBytes;
     }
+    
+    @Override
+    public Iterable<? extends Accountable> getChildResources() {
+      return Accountables.namedAccountables("field", fields);
+    }
 
     @Override
     public void checkIntegrity() throws IOException {
       // if we read entirely into ram, we already validated.
       // otherwise returned the raw postings reader
     }
+
+    @Override
+    public String toString() {
+      return getClass().getSimpleName() + "(fields=" + fields.size() + ")";
+    }
   }
 
   private final static class DirectField extends Terms implements Accountable {
@@ -197,6 +208,11 @@ public final class DirectPostingsFormat 
             ((postings!=null) ? RamUsageEstimator.sizeOf(postings) : 0) + 
             ((payloads!=null) ? RamUsageEstimator.sizeOf(payloads) : 0);
       }
+
+      @Override
+      public Iterable<? extends Accountable> getChildResources() {
+        return Collections.emptyList();
+      }
     }
 
     // TODO: maybe specialize into prx/no-prx/no-frq cases?
@@ -245,6 +261,11 @@ public final class DirectPostingsFormat 
          
          return sizeInBytes;
       }
+      
+      @Override
+      public Iterable<? extends Accountable> getChildResources() {
+        return Collections.emptyList();
+      }
     }
 
     private final byte[] termBytes;
@@ -522,6 +543,16 @@ public final class DirectPostingsFormat 
       
       return sizeInBytes;
     }
+    
+    @Override
+    public Iterable<? extends Accountable> getChildResources() {
+      return Collections.emptyList();
+    }
+
+    @Override
+    public String toString() {
+      return "DirectTerms(terms=" + terms.length + ",postings=" + sumDocFreq + ",positions=" + sumTotalTermFreq + ",docs=" + docCount + ")";
+    }
 
     // Compares in unicode (UTF8) order:
     int compare(int ord, BytesRef other) {

Modified: lucene/dev/trunk/lucene/codecs/src/java/org/apache/lucene/codecs/memory/FSTOrdTermsReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/codecs/src/java/org/apache/lucene/codecs/memory/FSTOrdTermsReader.java?rev=1625275&r1=1625274&r2=1625275&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/codecs/src/java/org/apache/lucene/codecs/memory/FSTOrdTermsReader.java (original)
+++ lucene/dev/trunk/lucene/codecs/src/java/org/apache/lucene/codecs/memory/FSTOrdTermsReader.java Tue Sep 16 13:26:55 2014
@@ -23,6 +23,7 @@ import java.util.ArrayList;
 import java.util.BitSet;
 import java.util.Collections;
 import java.util.Iterator;
+import java.util.List;
 import java.util.TreeMap;
 
 import org.apache.lucene.index.CorruptIndexException;
@@ -43,6 +44,8 @@ import org.apache.lucene.store.IndexInpu
 import org.apache.lucene.util.ArrayUtil;
 import org.apache.lucene.util.automaton.ByteRunAutomaton;
 import org.apache.lucene.util.automaton.CompiledAutomaton;
+import org.apache.lucene.util.Accountable;
+import org.apache.lucene.util.Accountables;
 import org.apache.lucene.util.Bits;
 import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.BytesRefBuilder;
@@ -182,7 +185,7 @@ public class FSTOrdTermsReader extends F
     }
   }
 
-  final class TermsReader extends Terms {
+  final class TermsReader extends Terms implements Accountable {
     final FieldInfo fieldInfo;
     final long numTerms;
     final long sumTotalTermFreq;
@@ -276,6 +279,33 @@ public class FSTOrdTermsReader extends F
       return new IntersectTermsEnum(compiled, startTerm);
     }
 
+    @Override
+    public long ramBytesUsed() {
+      long ramBytesUsed = 0;
+      if (index != null) {
+        ramBytesUsed += index.ramBytesUsed();
+        ramBytesUsed += RamUsageEstimator.sizeOf(metaBytesBlock);
+        ramBytesUsed += RamUsageEstimator.sizeOf(metaLongsBlock);
+        ramBytesUsed += RamUsageEstimator.sizeOf(skipInfo);
+        ramBytesUsed += RamUsageEstimator.sizeOf(statsBlock);
+      }
+      return ramBytesUsed;
+    }
+
+    @Override
+    public Iterable<? extends Accountable> getChildResources() {
+      if (index == null) {
+        return Collections.emptyList();
+      } else {
+        return Collections.singletonList(Accountables.namedAccountable("terms", index));
+      }
+    }
+    
+    @Override
+    public String toString() {
+      return "FSTOrdTerms(terms=" + numTerms + ",postings=" + sumDocFreq + ",positions=" + sumTotalTermFreq + ",docs=" + docCount + ")";
+    }
+
     // Only wraps common operations for PBF interact
     abstract class BaseTermsEnum extends TermsEnum {
 
@@ -834,18 +864,25 @@ public class FSTOrdTermsReader extends F
   public long ramBytesUsed() {
     long ramBytesUsed = postingsReader.ramBytesUsed();
     for (TermsReader r : fields.values()) {
-      if (r.index != null) {
-        ramBytesUsed += r.index.ramBytesUsed();
-        ramBytesUsed += RamUsageEstimator.sizeOf(r.metaBytesBlock);
-        ramBytesUsed += RamUsageEstimator.sizeOf(r.metaLongsBlock);
-        ramBytesUsed += RamUsageEstimator.sizeOf(r.skipInfo);
-        ramBytesUsed += RamUsageEstimator.sizeOf(r.statsBlock);
-      }
+      ramBytesUsed += r.ramBytesUsed();
     }
     return ramBytesUsed;
   }
   
   @Override
+  public Iterable<? extends Accountable> getChildResources() {
+    List<Accountable> resources = new ArrayList<>();
+    resources.addAll(Accountables.namedAccountables("field", fields));
+    resources.add(Accountables.namedAccountable("delegate", postingsReader));
+    return Collections.unmodifiableList(resources);
+  }
+  
+  @Override
+  public String toString() {
+    return getClass().getSimpleName() + "(fields=" + fields.size() + ",delegate=" + postingsReader + ")";
+  }
+
+  @Override
   public void checkIntegrity() throws IOException {
     postingsReader.checkIntegrity();
   }

Modified: lucene/dev/trunk/lucene/codecs/src/java/org/apache/lucene/codecs/memory/FSTTermOutputs.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/codecs/src/java/org/apache/lucene/codecs/memory/FSTTermOutputs.java?rev=1625275&r1=1625274&r2=1625275&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/codecs/src/java/org/apache/lucene/codecs/memory/FSTTermOutputs.java (original)
+++ lucene/dev/trunk/lucene/codecs/src/java/org/apache/lucene/codecs/memory/FSTTermOutputs.java Tue Sep 16 13:26:55 2014
@@ -19,6 +19,7 @@ package org.apache.lucene.codecs.memory;
 
 import java.io.IOException;
 import java.util.Arrays;
+import java.util.Collections;
 
 import org.apache.lucene.index.FieldInfo;
 import org.apache.lucene.index.FieldInfo.IndexOptions;
@@ -79,6 +80,11 @@ class FSTTermOutputs extends Outputs<FST
       return ramBytesUsed;
     }
 
+    @Override
+    public Iterable<? extends Accountable> getChildResources() {
+      return Collections.emptyList();
+    }
+    
     // NOTE: actually, FST nodes are seldom 
     // identical when outputs on their arcs 
     // aren't NO_OUTPUTs.

Modified: lucene/dev/trunk/lucene/codecs/src/java/org/apache/lucene/codecs/memory/FSTTermsReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/codecs/src/java/org/apache/lucene/codecs/memory/FSTTermsReader.java?rev=1625275&r1=1625274&r2=1625275&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/codecs/src/java/org/apache/lucene/codecs/memory/FSTTermsReader.java (original)
+++ lucene/dev/trunk/lucene/codecs/src/java/org/apache/lucene/codecs/memory/FSTTermsReader.java Tue Sep 16 13:26:55 2014
@@ -22,6 +22,7 @@ import java.util.ArrayList;
 import java.util.BitSet;
 import java.util.Collections;
 import java.util.Iterator;
+import java.util.List;
 import java.util.TreeMap;
 
 import org.apache.lucene.index.CorruptIndexException;
@@ -42,6 +43,7 @@ import org.apache.lucene.util.ArrayUtil;
 import org.apache.lucene.util.automaton.ByteRunAutomaton;
 import org.apache.lucene.util.automaton.CompiledAutomaton;
 import org.apache.lucene.util.Accountable;
+import org.apache.lucene.util.Accountables;
 import org.apache.lucene.util.Bits;
 import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.BytesRefBuilder;
@@ -190,7 +192,25 @@ public class FSTTermsReader extends Fiel
 
     @Override
     public long ramBytesUsed() {
-      return BASE_RAM_BYTES_USED + dict.ramBytesUsed();
+      long bytesUsed = BASE_RAM_BYTES_USED;
+      if (dict != null) {
+        bytesUsed += dict.ramBytesUsed();
+      }
+      return bytesUsed;
+    }
+
+    @Override
+    public Iterable<? extends Accountable> getChildResources() {
+      if (dict == null) {
+        return Collections.emptyList();
+      } else {
+        return Collections.singletonList(Accountables.namedAccountable("terms", dict));
+      }
+    }
+    
+    @Override
+    public String toString() {
+      return "FSTTerms(terms=" + numTerms + ",postings=" + sumDocFreq + ",positions=" + sumTotalTermFreq + ",docs=" + docCount + ")";
     }
 
     @Override
@@ -752,6 +772,19 @@ public class FSTTermsReader extends Fiel
   }
   
   @Override
+  public Iterable<? extends Accountable> getChildResources() {
+    List<Accountable> resources = new ArrayList<>();
+    resources.addAll(Accountables.namedAccountables("field", fields));
+    resources.add(Accountables.namedAccountable("delegate", postingsReader));
+    return Collections.unmodifiableCollection(resources);
+  }
+
+  @Override
+  public String toString() {
+    return getClass().getSimpleName() + "(fields=" + fields.size() + ",delegate=" + postingsReader + ")";
+  }
+
+  @Override
   public void checkIntegrity() throws IOException {
     postingsReader.checkIntegrity();
   }

Modified: lucene/dev/trunk/lucene/codecs/src/java/org/apache/lucene/codecs/memory/MemoryDocValuesProducer.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/codecs/src/java/org/apache/lucene/codecs/memory/MemoryDocValuesProducer.java?rev=1625275&r1=1625274&r2=1625275&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/codecs/src/java/org/apache/lucene/codecs/memory/MemoryDocValuesProducer.java (original)
+++ lucene/dev/trunk/lucene/codecs/src/java/org/apache/lucene/codecs/memory/MemoryDocValuesProducer.java Tue Sep 16 13:26:55 2014
@@ -18,7 +18,10 @@ package org.apache.lucene.codecs.memory;
  */
 
 import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.concurrent.atomic.AtomicLong;
 
@@ -41,6 +44,8 @@ import org.apache.lucene.index.TermsEnum
 import org.apache.lucene.store.ByteArrayDataInput;
 import org.apache.lucene.store.ChecksumIndexInput;
 import org.apache.lucene.store.IndexInput;
+import org.apache.lucene.util.Accountable;
+import org.apache.lucene.util.Accountables;
 import org.apache.lucene.util.Bits;
 import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.BytesRefBuilder;
@@ -67,23 +72,23 @@ import org.apache.lucene.util.packed.Pac
  */
 class MemoryDocValuesProducer extends DocValuesProducer {
   // metadata maps (just file pointers and minimal stuff)
-  private final Map<Integer,NumericEntry> numerics = new HashMap<>();
-  private final Map<Integer,BinaryEntry> binaries = new HashMap<>();
-  private final Map<Integer,FSTEntry> fsts = new HashMap<>();
-  private final Map<Integer,SortedSetEntry> sortedSets = new HashMap<>();
-  private final Map<Integer,SortedNumericEntry> sortedNumerics = new HashMap<>();
+  private final Map<String,NumericEntry> numerics = new HashMap<>();
+  private final Map<String,BinaryEntry> binaries = new HashMap<>();
+  private final Map<String,FSTEntry> fsts = new HashMap<>();
+  private final Map<String,SortedSetEntry> sortedSets = new HashMap<>();
+  private final Map<String,SortedNumericEntry> sortedNumerics = new HashMap<>();
   private final IndexInput data;
   
   // ram instances we have already loaded
-  private final Map<Integer,NumericDocValues> numericInstances = 
-      new HashMap<>();
-  private final Map<Integer,BytesAndAddresses> pagedBytesInstances =
-      new HashMap<>();
-  private final Map<Integer,FST<Long>> fstInstances =
-      new HashMap<>();
-  private final Map<Integer,Bits> docsWithFieldInstances = new HashMap<>();
-  private final Map<Integer,MonotonicBlockPackedReader> addresses = new HashMap<>();
+  private final Map<String,NumericDocValues> numericInstances = new HashMap<>();
+  private final Map<String,BytesAndAddresses> pagedBytesInstances = new HashMap<>();
+  private final Map<String,FST<Long>> fstInstances = new HashMap<>();
+  private final Map<String,FixedBitSet> docsWithFieldInstances = new HashMap<>();
+  private final Map<String,MonotonicBlockPackedReader> addresses = new HashMap<>();
   
+  private final Map<String,Accountable> numericInfo = new HashMap<>();
+
+  private final int numEntries;
   private final int maxDoc;
   private final AtomicLong ramBytesUsed;
   private final int version;
@@ -116,7 +121,7 @@ class MemoryDocValuesProducer extends Do
       version = CodecUtil.checkHeader(in, metaCodec, 
                                       VERSION_START,
                                       VERSION_CURRENT);
-      readFields(in, state.fieldInfos);
+      numEntries = readFields(in, state.fieldInfos);
       CodecUtil.checkFooter(in);
       ramBytesUsed = new AtomicLong(RamUsageEstimator.shallowSizeOfInstance(getClass()));
       success = true;
@@ -203,24 +208,30 @@ class MemoryDocValuesProducer extends Do
     return entry;
   }
   
-  private void readFields(IndexInput meta, FieldInfos infos) throws IOException {
+  private int readFields(IndexInput meta, FieldInfos infos) throws IOException {
+    int numEntries = 0;
     int fieldNumber = meta.readVInt();
     while (fieldNumber != -1) {
+      numEntries++;
+      FieldInfo info = infos.fieldInfo(fieldNumber);
+      if (info == null) {
+        throw new CorruptIndexException("invalid field number: " + fieldNumber + " (resource=" + meta + ")");
+      }
       int fieldType = meta.readByte();
       if (fieldType == NUMBER) {
-        numerics.put(fieldNumber, readNumericEntry(meta));
+        numerics.put(info.name, readNumericEntry(meta));
       } else if (fieldType == BYTES) {
-        binaries.put(fieldNumber, readBinaryEntry(meta));
+        binaries.put(info.name, readBinaryEntry(meta));
       } else if (fieldType == FST) {
-        fsts.put(fieldNumber,readFSTEntry(meta));
+        fsts.put(info.name,readFSTEntry(meta));
       } else if (fieldType == SORTED_SET) {
         SortedSetEntry entry = new SortedSetEntry();
         entry.singleton = false;
-        sortedSets.put(fieldNumber, entry);
+        sortedSets.put(info.name, entry);
       } else if (fieldType == SORTED_SET_SINGLETON) {
         SortedSetEntry entry = new SortedSetEntry();
         entry.singleton = true;
-        sortedSets.put(fieldNumber, entry);
+        sortedSets.put(info.name, entry);
       } else if (fieldType == SORTED_NUMERIC) {
         SortedNumericEntry entry = new SortedNumericEntry();
         entry.singleton = false;
@@ -228,24 +239,25 @@ class MemoryDocValuesProducer extends Do
         entry.blockSize = meta.readVInt();
         entry.addressOffset = meta.readLong();
         entry.valueCount = meta.readLong();
-        sortedNumerics.put(fieldNumber, entry);
+        sortedNumerics.put(info.name, entry);
       } else if (fieldType == SORTED_NUMERIC_SINGLETON) {
         SortedNumericEntry entry = new SortedNumericEntry();
         entry.singleton = true;
-        sortedNumerics.put(fieldNumber, entry);
+        sortedNumerics.put(info.name, entry);
       } else {
-        throw new CorruptIndexException("invalid entry type: " + fieldType + ", input=" + meta);
+        throw new CorruptIndexException("invalid entry type: " + fieldType + ", fieldName=" + info.name + ", input=" + meta);
       }
       fieldNumber = meta.readVInt();
     }
+    return numEntries;
   }
 
   @Override
   public synchronized NumericDocValues getNumeric(FieldInfo field) throws IOException {
-    NumericDocValues instance = numericInstances.get(field.number);
+    NumericDocValues instance = numericInstances.get(field.name);
     if (instance == null) {
       instance = loadNumeric(field);
-      numericInstances.put(field.number, instance);
+      numericInstances.put(field.name, instance);
     }
     return instance;
   }
@@ -256,12 +268,28 @@ class MemoryDocValuesProducer extends Do
   }
   
   @Override
+  public synchronized Iterable<? extends Accountable> getChildResources() {
+    List<Accountable> resources = new ArrayList<>();
+    resources.addAll(Accountables.namedAccountables("numeric field", numericInfo));
+    resources.addAll(Accountables.namedAccountables("pagedbytes field", pagedBytesInstances));
+    resources.addAll(Accountables.namedAccountables("term dict field", fstInstances));
+    resources.addAll(Accountables.namedAccountables("missing bitset field", docsWithFieldInstances));
+    resources.addAll(Accountables.namedAccountables("addresses field", addresses));
+    return Collections.unmodifiableList(resources);
+  }
+
+  @Override
   public void checkIntegrity() throws IOException {
     CodecUtil.checksumEntireFile(data);
   }
   
+  @Override
+  public String toString() {
+    return getClass().getSimpleName() + "(entries=" + numEntries + ")";
+  }
+
   private NumericDocValues loadNumeric(FieldInfo field) throws IOException {
-    NumericEntry entry = numerics.get(field.number);
+    NumericEntry entry = numerics.get(field.name);
     data.seek(entry.offset + entry.missingBytes);
     switch (entry.format) {
       case TABLE_COMPRESSED:
@@ -277,6 +305,7 @@ class MemoryDocValuesProducer extends Do
         final int bitsPerValue = data.readVInt();
         final PackedInts.Reader ordsReader = PackedInts.getReaderNoHeader(data, PackedInts.Format.byId(formatID), entry.packedIntsVersion, (int)entry.count, bitsPerValue);
         ramBytesUsed.addAndGet(RamUsageEstimator.sizeOf(decode) + ordsReader.ramBytesUsed());
+        numericInfo.put(field.name, Accountables.namedAccountable("table compressed", ordsReader));
         return new NumericDocValues() {
           @Override
           public long get(int docID) {
@@ -289,6 +318,7 @@ class MemoryDocValuesProducer extends Do
         final int bitsPerValueDelta = data.readVInt();
         final PackedInts.Reader deltaReader = PackedInts.getReaderNoHeader(data, PackedInts.Format.byId(formatIDDelta), entry.packedIntsVersion, (int)entry.count, bitsPerValueDelta);
         ramBytesUsed.addAndGet(deltaReader.ramBytesUsed());
+        numericInfo.put(field.name, Accountables.namedAccountable("delta compressed", deltaReader));
         return new NumericDocValues() {
           @Override
           public long get(int docID) {
@@ -299,6 +329,7 @@ class MemoryDocValuesProducer extends Do
         final int blockSize = data.readVInt();
         final BlockPackedReader reader = new BlockPackedReader(data, entry.packedIntsVersion, blockSize, entry.count, false);
         ramBytesUsed.addAndGet(reader.ramBytesUsed());
+        numericInfo.put(field.name, Accountables.namedAccountable("block compressed", reader));
         return reader;
       case GCD_COMPRESSED:
         final long min = data.readLong();
@@ -307,6 +338,7 @@ class MemoryDocValuesProducer extends Do
         final int bitsPerValueGCD = data.readVInt();
         final PackedInts.Reader quotientReader = PackedInts.getReaderNoHeader(data, PackedInts.Format.byId(formatIDGCD), entry.packedIntsVersion, (int)entry.count, bitsPerValueGCD);
         ramBytesUsed.addAndGet(quotientReader.ramBytesUsed());
+        numericInfo.put(field.name, Accountables.namedAccountable("gcd compressed", quotientReader));
         return new NumericDocValues() {
           @Override
           public long get(int docID) {
@@ -320,14 +352,14 @@ class MemoryDocValuesProducer extends Do
 
   @Override
   public BinaryDocValues getBinary(FieldInfo field) throws IOException {
-    BinaryEntry entry = binaries.get(field.number);
+    BinaryEntry entry = binaries.get(field.name);
 
     BytesAndAddresses instance;
     synchronized (this) {
-      instance = pagedBytesInstances.get(field.number);
+      instance = pagedBytesInstances.get(field.name);
       if (instance == null) {
         instance = loadBinary(field);
-        pagedBytesInstances.put(field.number, instance);
+        pagedBytesInstances.put(field.name, instance);
       }
     }
     final PagedBytes.Reader bytesReader = instance.reader;
@@ -362,7 +394,7 @@ class MemoryDocValuesProducer extends Do
   
   private BytesAndAddresses loadBinary(FieldInfo field) throws IOException {
     BytesAndAddresses bytesAndAddresses = new BytesAndAddresses();
-    BinaryEntry entry = binaries.get(field.number);
+    BinaryEntry entry = binaries.get(field.name);
     data.seek(entry.offset);
     PagedBytes bytes = new PagedBytes(16);
     bytes.copy(data, entry.numBytes);
@@ -378,18 +410,18 @@ class MemoryDocValuesProducer extends Do
   
   @Override
   public SortedDocValues getSorted(FieldInfo field) throws IOException {
-    final FSTEntry entry = fsts.get(field.number);
+    final FSTEntry entry = fsts.get(field.name);
     if (entry.numOrds == 0) {
       return DocValues.emptySorted();
     }
     FST<Long> instance;
     synchronized(this) {
-      instance = fstInstances.get(field.number);
+      instance = fstInstances.get(field.name);
       if (instance == null) {
         data.seek(entry.offset);
         instance = new FST<>(data, PositiveIntOutputs.getSingleton());
         ramBytesUsed.addAndGet(instance.ramBytesUsed());
-        fstInstances.put(field.number, instance);
+        fstInstances.put(field.name, instance);
       }
     }
     final NumericDocValues docToOrd = getNumeric(field);
@@ -452,21 +484,21 @@ class MemoryDocValuesProducer extends Do
   
   @Override
   public SortedNumericDocValues getSortedNumeric(FieldInfo field) throws IOException {
-    SortedNumericEntry entry = sortedNumerics.get(field.number);
+    SortedNumericEntry entry = sortedNumerics.get(field.name);
     if (entry.singleton) {
       NumericDocValues values = getNumeric(field);
-      NumericEntry ne = numerics.get(field.number);
-      Bits docsWithField = getMissingBits(field.number, ne.missingOffset, ne.missingBytes);
+      NumericEntry ne = numerics.get(field.name);
+      Bits docsWithField = getMissingBits(field, ne.missingOffset, ne.missingBytes);
       return DocValues.singleton(values, docsWithField);
     } else {
       final NumericDocValues values = getNumeric(field);
       final MonotonicBlockPackedReader addr;
       synchronized (this) {
-        MonotonicBlockPackedReader res = addresses.get(field.number);
+        MonotonicBlockPackedReader res = addresses.get(field.name);
         if (res == null) {
           data.seek(entry.addressOffset);
           res = MonotonicBlockPackedReader.of(data, entry.packedIntsVersion, entry.blockSize, entry.valueCount, false);
-          addresses.put(field.number, res);
+          addresses.put(field.name, res);
         }
         addr = res;
       }
@@ -520,23 +552,23 @@ class MemoryDocValuesProducer extends Do
   
   @Override
   public SortedSetDocValues getSortedSet(FieldInfo field) throws IOException {
-    SortedSetEntry sortedSetEntry = sortedSets.get(field.number);
+    SortedSetEntry sortedSetEntry = sortedSets.get(field.name);
     if (sortedSetEntry.singleton) {
       return DocValues.singleton(getSorted(field));
     }
     
-    final FSTEntry entry = fsts.get(field.number);
+    final FSTEntry entry = fsts.get(field.name);
     if (entry.numOrds == 0) {
       return DocValues.emptySortedSet(); // empty FST!
     }
     FST<Long> instance;
     synchronized(this) {
-      instance = fstInstances.get(field.number);
+      instance = fstInstances.get(field.name);
       if (instance == null) {
         data.seek(entry.offset);
         instance = new FST<>(data, PositiveIntOutputs.getSingleton());
         ramBytesUsed.addAndGet(instance.ramBytesUsed());
-        fstInstances.put(field.number, instance);
+        fstInstances.put(field.name, instance);
       }
     }
     final BinaryDocValues docToOrds = getBinary(field);
@@ -611,13 +643,13 @@ class MemoryDocValuesProducer extends Do
     };
   }
   
-  private Bits getMissingBits(int fieldNumber, final long offset, final long length) throws IOException {
+  private Bits getMissingBits(FieldInfo field, final long offset, final long length) throws IOException {
     if (offset == -1) {
       return new Bits.MatchAllBits(maxDoc);
     } else {
-      Bits instance;
+      FixedBitSet instance;
       synchronized(this) {
-        instance = docsWithFieldInstances.get(fieldNumber);
+        instance = docsWithFieldInstances.get(field.name);
         if (instance == null) {
           IndexInput data = this.data.clone();
           data.seek(offset);
@@ -627,7 +659,7 @@ class MemoryDocValuesProducer extends Do
             bits[i] = data.readLong();
           }
           instance = new FixedBitSet(bits, maxDoc);
-          docsWithFieldInstances.put(fieldNumber, instance);
+          docsWithFieldInstances.put(field.name, instance);
         }
       }
       return instance;
@@ -644,11 +676,11 @@ class MemoryDocValuesProducer extends Do
       case SORTED:
         return DocValues.docsWithValue(getSorted(field), maxDoc);
       case BINARY:
-        BinaryEntry be = binaries.get(field.number);
-        return getMissingBits(field.number, be.missingOffset, be.missingBytes);
+        BinaryEntry be = binaries.get(field.name);
+        return getMissingBits(field, be.missingOffset, be.missingBytes);
       case NUMERIC:
-        NumericEntry ne = numerics.get(field.number);
-        return getMissingBits(field.number, ne.missingOffset, ne.missingBytes);
+        NumericEntry ne = numerics.get(field.name);
+        return getMissingBits(field, ne.missingOffset, ne.missingBytes);
       default: 
         throw new AssertionError();
     }
@@ -696,9 +728,28 @@ class MemoryDocValuesProducer extends Do
     long valueCount;
   }
 
-  static class BytesAndAddresses {
+  static class BytesAndAddresses implements Accountable {
     PagedBytes.Reader reader;
     MonotonicBlockPackedReader addresses;
+    
+    @Override
+    public long ramBytesUsed() {
+      long bytesUsed = reader.ramBytesUsed();
+      if (addresses != null) {
+        bytesUsed += addresses.ramBytesUsed();
+      }
+      return bytesUsed;
+    }
+    
+    @Override
+    public Iterable<? extends Accountable> getChildResources() {
+      List<Accountable> resources = new ArrayList<>();
+      if (addresses != null) {
+        resources.add(Accountables.namedAccountable("addresses", addresses));
+      }
+      resources.add(Accountables.namedAccountable("term bytes", reader));
+      return Collections.unmodifiableList(resources);
+    }
   }
 
   // exposes FSTEnum directly as a TermsEnum: avoids binary-search next()

Modified: lucene/dev/trunk/lucene/codecs/src/java/org/apache/lucene/codecs/memory/MemoryPostingsFormat.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/codecs/src/java/org/apache/lucene/codecs/memory/MemoryPostingsFormat.java?rev=1625275&r1=1625274&r2=1625275&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/codecs/src/java/org/apache/lucene/codecs/memory/MemoryPostingsFormat.java (original)
+++ lucene/dev/trunk/lucene/codecs/src/java/org/apache/lucene/codecs/memory/MemoryPostingsFormat.java Tue Sep 16 13:26:55 2014
@@ -47,6 +47,7 @@ import org.apache.lucene.store.IndexInpu
 import org.apache.lucene.store.IndexOutput;
 import org.apache.lucene.store.RAMOutputStream;
 import org.apache.lucene.util.Accountable;
+import org.apache.lucene.util.Accountables;
 import org.apache.lucene.util.ArrayUtil;
 import org.apache.lucene.util.Bits;
 import org.apache.lucene.util.BytesRef;
@@ -953,6 +954,20 @@ public final class MemoryPostingsFormat 
     public long ramBytesUsed() {
       return ((fst!=null) ? fst.ramBytesUsed() : 0);
     }
+    
+    @Override
+    public Iterable<? extends Accountable> getChildResources() {
+      if (fst == null) {
+        return Collections.emptyList();
+      } else {
+        return Collections.singletonList(Accountables.namedAccountable("terms", fst));
+      }
+    }
+    
+    @Override
+    public String toString() {
+      return "MemoryTerms(terms=" + termCount + ",postings=" + sumDocFreq + ",positions=" + sumTotalTermFreq + ",docs=" + docCount + ")";
+    }
   }
 
   @Override
@@ -1013,6 +1028,16 @@ public final class MemoryPostingsFormat 
       }
 
       @Override
+      public Iterable<? extends Accountable> getChildResources() {
+        return Accountables.namedAccountables("field", fields);
+      }
+
+      @Override
+      public String toString() {
+        return "MemoryPostings(fields=" + fields.size() + ")";
+      }
+
+      @Override
       public void checkIntegrity() throws IOException {}
     };
   }

Modified: lucene/dev/trunk/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextDocValuesReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextDocValuesReader.java?rev=1625275&r1=1625274&r2=1625275&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextDocValuesReader.java (original)
+++ lucene/dev/trunk/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextDocValuesReader.java Tue Sep 16 13:26:55 2014
@@ -34,6 +34,7 @@ import java.nio.charset.StandardCharsets
 import java.text.DecimalFormat;
 import java.text.DecimalFormatSymbols;
 import java.text.ParseException;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.Locale;
 import java.util.Map;
@@ -53,6 +54,7 @@ import org.apache.lucene.index.SortedSet
 import org.apache.lucene.store.BufferedChecksumIndexInput;
 import org.apache.lucene.store.ChecksumIndexInput;
 import org.apache.lucene.store.IndexInput;
+import org.apache.lucene.util.Accountable;
 import org.apache.lucene.util.Bits;
 import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.BytesRefBuilder;
@@ -509,6 +511,16 @@ class SimpleTextDocValuesReader extends 
   }
 
   @Override
+  public Iterable<? extends Accountable> getChildResources() {
+    return Collections.emptyList();
+  }
+
+  @Override
+  public String toString() {
+    return getClass().getSimpleName() + "(fields=" + fields.size() + ")";
+  }
+
+  @Override
   public void checkIntegrity() throws IOException {
     BytesRefBuilder scratch = new BytesRefBuilder();
     IndexInput clone = data.clone();

Modified: lucene/dev/trunk/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextFieldsReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextFieldsReader.java?rev=1625275&r1=1625274&r2=1625275&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextFieldsReader.java (original)
+++ lucene/dev/trunk/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextFieldsReader.java Tue Sep 16 13:26:55 2014
@@ -48,6 +48,7 @@ import org.apache.lucene.store.BufferedC
 import org.apache.lucene.store.ChecksumIndexInput;
 import org.apache.lucene.store.IndexInput;
 import org.apache.lucene.util.Accountable;
+import org.apache.lucene.util.Accountables;
 import org.apache.lucene.util.ArrayUtil;
 import org.apache.lucene.util.Bits;
 import org.apache.lucene.util.BytesRef;
@@ -596,6 +597,20 @@ class SimpleTextFieldsReader extends Fie
     }
 
     @Override
+    public Iterable<? extends Accountable> getChildResources() {
+      if (fst == null) {
+        return Collections.emptyList();
+      } else {
+        return Collections.singletonList(Accountables.namedAccountable("term cache", fst));
+      }
+    }
+
+    @Override
+    public String toString() {
+      return getClass().getSimpleName() + "(terms=" + termCount + ",postings=" + sumDocFreq + ",positions=" + sumTotalTermFreq + ",docs=" + docCount + ")";
+    }
+
+    @Override
     public TermsEnum iterator(TermsEnum reuse) throws IOException {
       if (fst != null) {
         return new SimpleTextTermsEnum(fst, fieldInfo.getIndexOptions());
@@ -687,5 +702,15 @@ class SimpleTextFieldsReader extends Fie
   }
 
   @Override
+  public synchronized Iterable<? extends Accountable> getChildResources() {
+    return Accountables.namedAccountables("field", termsCache);
+  }
+
+  @Override
+  public String toString() {
+    return getClass().getSimpleName() + "(fields=" + fields.size() + ")";
+  }
+
+  @Override
   public void checkIntegrity() throws IOException {}
 }

Modified: lucene/dev/trunk/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextNormsFormat.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextNormsFormat.java?rev=1625275&r1=1625274&r2=1625275&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextNormsFormat.java (original)
+++ lucene/dev/trunk/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextNormsFormat.java Tue Sep 16 13:26:55 2014
@@ -28,6 +28,7 @@ import org.apache.lucene.index.FieldInfo
 import org.apache.lucene.index.NumericDocValues;
 import org.apache.lucene.index.SegmentReadState;
 import org.apache.lucene.index.SegmentWriteState;
+import org.apache.lucene.util.Accountable;
 
 /**
  * plain-text norms format.
@@ -81,9 +82,19 @@ public class SimpleTextNormsFormat exten
     }
     
     @Override
+    public Iterable<? extends Accountable> getChildResources() {
+      return impl.getChildResources();
+    }
+
+    @Override
     public void checkIntegrity() throws IOException {
       impl.checkIntegrity();
     }
+
+    @Override
+    public String toString() {
+      return getClass().getSimpleName() + "(" + impl + ")";
+    }
   }
   
   /**

Modified: lucene/dev/trunk/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextStoredFieldsReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextStoredFieldsReader.java?rev=1625275&r1=1625274&r2=1625275&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextStoredFieldsReader.java (original)
+++ lucene/dev/trunk/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextStoredFieldsReader.java Tue Sep 16 13:26:55 2014
@@ -19,6 +19,7 @@ package org.apache.lucene.codecs.simplet
 
 import java.io.IOException;
 import java.nio.charset.StandardCharsets;
+import java.util.Collections;
 
 import org.apache.lucene.codecs.StoredFieldsReader;
 import org.apache.lucene.index.FieldInfo;
@@ -32,6 +33,7 @@ import org.apache.lucene.store.ChecksumI
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.IOContext;
 import org.apache.lucene.store.IndexInput;
+import org.apache.lucene.util.Accountable;
 import org.apache.lucene.util.ArrayUtil;
 import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.BytesRefBuilder;
@@ -213,5 +215,15 @@ public class SimpleTextStoredFieldsReade
   }
 
   @Override
+  public Iterable<? extends Accountable> getChildResources() {
+    return Collections.emptyList();
+  }
+
+  @Override
+  public String toString() {
+    return getClass().getSimpleName();
+  }
+
+  @Override
   public void checkIntegrity() throws IOException {}
 }

Modified: lucene/dev/trunk/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextTermVectorsReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextTermVectorsReader.java?rev=1625275&r1=1625274&r2=1625275&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextTermVectorsReader.java (original)
+++ lucene/dev/trunk/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextTermVectorsReader.java Tue Sep 16 13:26:55 2014
@@ -38,6 +38,7 @@ import org.apache.lucene.store.ChecksumI
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.IOContext;
 import org.apache.lucene.store.IndexInput;
+import org.apache.lucene.util.Accountable;
 import org.apache.lucene.util.ArrayUtil;
 import org.apache.lucene.util.Bits;
 import org.apache.lucene.util.BytesRef;
@@ -552,5 +553,15 @@ public class SimpleTextTermVectorsReader
   }
 
   @Override
+  public Iterable<? extends Accountable> getChildResources() {
+    return Collections.emptyList();
+  }
+  
+  @Override
+  public String toString() {
+    return getClass().getSimpleName();
+  }
+
+  @Override
   public void checkIntegrity() throws IOException {}
 }

Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/blocktree/BlockTreeTermsReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/blocktree/BlockTreeTermsReader.java?rev=1625275&r1=1625274&r2=1625275&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/blocktree/BlockTreeTermsReader.java (original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/blocktree/BlockTreeTermsReader.java Tue Sep 16 13:26:55 2014
@@ -18,8 +18,10 @@ package org.apache.lucene.codecs.blocktr
  */
 
 import java.io.IOException;
+import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Iterator;
+import java.util.List;
 import java.util.TreeMap;
 
 import org.apache.lucene.codecs.CodecUtil;
@@ -35,6 +37,8 @@ import org.apache.lucene.index.Terms;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.IOContext;
 import org.apache.lucene.store.IndexInput;
+import org.apache.lucene.util.Accountable;
+import org.apache.lucene.util.Accountables;
 import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.IOUtils;
 
@@ -293,11 +297,19 @@ public final class BlockTreeTermsReader 
 
   @Override
   public long ramBytesUsed() {
-    long sizeInByes = ((postingsReader!=null) ? postingsReader.ramBytesUsed() : 0);
+    long sizeInBytes = postingsReader.ramBytesUsed();
     for(FieldReader reader : fields.values()) {
-      sizeInByes += reader.ramBytesUsed();
+      sizeInBytes += reader.ramBytesUsed();
     }
-    return sizeInByes;
+    return sizeInBytes;
+  }
+
+  @Override
+  public Iterable<? extends Accountable> getChildResources() {
+    List<Accountable> resources = new ArrayList<>();
+    resources.addAll(Accountables.namedAccountables("field", fields));
+    resources.add(Accountables.namedAccountable("delegate", postingsReader));
+    return Collections.unmodifiableList(resources);
   }
 
   @Override
@@ -310,4 +322,9 @@ public final class BlockTreeTermsReader 
       postingsReader.checkIntegrity();
     }
   }
+
+  @Override
+  public String toString() {
+    return getClass().getSimpleName() + "(fields=" + fields.size() + ",delegate=" + postingsReader + ")";
+  }
 }

Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/blocktree/FieldReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/blocktree/FieldReader.java?rev=1625275&r1=1625274&r2=1625275&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/blocktree/FieldReader.java (original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/blocktree/FieldReader.java Tue Sep 16 13:26:55 2014
@@ -18,6 +18,7 @@ package org.apache.lucene.codecs.blocktr
  */
 
 import java.io.IOException;
+import java.util.Collections;
 
 import org.apache.lucene.index.FieldInfo;
 import org.apache.lucene.index.FieldInfo.IndexOptions;
@@ -26,6 +27,7 @@ import org.apache.lucene.index.TermsEnum
 import org.apache.lucene.store.ByteArrayDataInput;
 import org.apache.lucene.store.IndexInput;
 import org.apache.lucene.util.Accountable;
+import org.apache.lucene.util.Accountables;
 import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.RamUsageEstimator;
 import org.apache.lucene.util.automaton.CompiledAutomaton;
@@ -180,4 +182,18 @@ public final class FieldReader extends T
   public long ramBytesUsed() {
     return BASE_RAM_BYTES_USED + ((index!=null)? index.ramBytesUsed() : 0);
   }
+
+  @Override
+  public Iterable<? extends Accountable> getChildResources() {
+    if (index == null) {
+      return Collections.emptyList();
+    } else {
+      return Collections.singleton(Accountables.namedAccountable("term index", index));
+    }
+  }
+
+  @Override
+  public String toString() {
+    return "BlockTreeTerms(terms=" + numTerms + ",postings=" + sumDocFreq + ",positions=" + sumTotalTermFreq + ",docs=" + docCount + ")";
+  }
 }

Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/compressing/CompressingStoredFieldsIndexReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/compressing/CompressingStoredFieldsIndexReader.java?rev=1625275&r1=1625274&r2=1625275&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/compressing/CompressingStoredFieldsIndexReader.java (original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/compressing/CompressingStoredFieldsIndexReader.java Tue Sep 16 13:26:55 2014
@@ -20,12 +20,16 @@ package org.apache.lucene.codecs.compres
 import static org.apache.lucene.util.BitUtil.zigZagDecode;
 
 import java.io.IOException;
+import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
 
 import org.apache.lucene.index.CorruptIndexException;
 import org.apache.lucene.index.SegmentInfo;
 import org.apache.lucene.store.IndexInput;
 import org.apache.lucene.util.Accountable;
+import org.apache.lucene.util.Accountables;
 import org.apache.lucene.util.ArrayUtil;
 import org.apache.lucene.util.RamUsageEstimator;
 import org.apache.lucene.util.packed.PackedInts;
@@ -184,4 +188,27 @@ public final class CompressingStoredFiel
     return res;
   }
 
+  @Override
+  public Iterable<? extends Accountable> getChildResources() {
+    List<Accountable> resources = new ArrayList<>();
+    
+    long docBaseDeltaBytes = RamUsageEstimator.shallowSizeOf(docBasesDeltas);
+    for (PackedInts.Reader r : docBasesDeltas) {
+      docBaseDeltaBytes += r.ramBytesUsed();
+    }
+    resources.add(Accountables.namedAccountable("doc base deltas", docBaseDeltaBytes));
+    
+    long startPointerDeltaBytes = RamUsageEstimator.shallowSizeOf(startPointersDeltas);
+    for (PackedInts.Reader r : startPointersDeltas) {
+      startPointerDeltaBytes += r.ramBytesUsed();
+    }
+    resources.add(Accountables.namedAccountable("start pointer deltas", startPointerDeltaBytes));
+    
+    return resources;
+  }
+
+  @Override
+  public String toString() {
+    return getClass().getSimpleName() + "(blocks=" + docBases.length + ")";
+  }
 }

Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/compressing/CompressingStoredFieldsReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/compressing/CompressingStoredFieldsReader.java?rev=1625275&r1=1625274&r2=1625275&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/compressing/CompressingStoredFieldsReader.java (original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/compressing/CompressingStoredFieldsReader.java Tue Sep 16 13:26:55 2014
@@ -38,6 +38,7 @@ import java.io.EOFException;
 import java.io.IOException;
 import java.nio.charset.StandardCharsets;
 import java.util.Arrays;
+import java.util.Collections;
 
 import org.apache.lucene.codecs.CodecUtil;
 import org.apache.lucene.codecs.StoredFieldsReader;
@@ -55,6 +56,8 @@ import org.apache.lucene.store.DataInput
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.IOContext;
 import org.apache.lucene.store.IndexInput;
+import org.apache.lucene.util.Accountable;
+import org.apache.lucene.util.Accountables;
 import org.apache.lucene.util.ArrayUtil;
 import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.IOUtils;
@@ -528,6 +531,11 @@ public final class CompressingStoredFiel
   public long ramBytesUsed() {
     return indexReader.ramBytesUsed();
   }
+  
+  @Override
+  public Iterable<? extends Accountable> getChildResources() {
+    return Collections.singleton(Accountables.namedAccountable("stored field index", indexReader));
+  }
 
   @Override
   public void checkIntegrity() throws IOException {
@@ -536,4 +544,8 @@ public final class CompressingStoredFiel
     }
   }
 
+  @Override
+  public String toString() {
+    return getClass().getSimpleName() + "(mode=" + compressionMode + ",chunksize=" + chunkSize + ")";
+  }
 }

Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/compressing/CompressingTermVectorsReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/compressing/CompressingTermVectorsReader.java?rev=1625275&r1=1625274&r2=1625275&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/compressing/CompressingTermVectorsReader.java (original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/compressing/CompressingTermVectorsReader.java Tue Sep 16 13:26:55 2014
@@ -32,6 +32,7 @@ import static org.apache.lucene.codecs.c
 
 import java.io.Closeable;
 import java.io.IOException;
+import java.util.Collections;
 import java.util.Iterator;
 import java.util.NoSuchElementException;
 
@@ -53,6 +54,8 @@ import org.apache.lucene.store.ChecksumI
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.IOContext;
 import org.apache.lucene.store.IndexInput;
+import org.apache.lucene.util.Accountable;
+import org.apache.lucene.util.Accountables;
 import org.apache.lucene.util.ArrayUtil;
 import org.apache.lucene.util.Bits;
 import org.apache.lucene.util.BytesRef;
@@ -1069,10 +1072,19 @@ public final class CompressingTermVector
   }
   
   @Override
+  public Iterable<? extends Accountable> getChildResources() {
+    return Collections.singleton(Accountables.namedAccountable("term vector index", indexReader));
+  }
+  
+  @Override
   public void checkIntegrity() throws IOException {
     if (version >= VERSION_CHECKSUM) {
       CodecUtil.checksumEntireFile(vectorsStream);
     }
   }
 
+  @Override
+  public String toString() {
+    return getClass().getSimpleName() + "(mode=" + compressionMode + ",chunksize=" + chunkSize + ")";
+  }
 }

Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/lucene41/Lucene41PostingsReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/lucene41/Lucene41PostingsReader.java?rev=1625275&r1=1625274&r2=1625275&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/lucene41/Lucene41PostingsReader.java (original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/lucene41/Lucene41PostingsReader.java Tue Sep 16 13:26:55 2014
@@ -24,6 +24,7 @@ import static org.apache.lucene.codecs.l
 
 import java.io.IOException;
 import java.util.Arrays;
+import java.util.Collections;
 
 import org.apache.lucene.codecs.BlockTermState;
 import org.apache.lucene.codecs.CodecUtil;
@@ -39,6 +40,7 @@ import org.apache.lucene.store.DataInput
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.IOContext;
 import org.apache.lucene.store.IndexInput;
+import org.apache.lucene.util.Accountable;
 import org.apache.lucene.util.ArrayUtil;
 import org.apache.lucene.util.Bits;
 import org.apache.lucene.util.BytesRef;
@@ -1580,6 +1582,11 @@ public final class Lucene41PostingsReade
   public long ramBytesUsed() {
     return BASE_RAM_BYTES_USED;
   }
+  
+  @Override
+  public Iterable<? extends Accountable> getChildResources() {
+    return Collections.emptyList();
+  }
 
   @Override
   public void checkIntegrity() throws IOException {
@@ -1595,4 +1602,9 @@ public final class Lucene41PostingsReade
       }
     }
   }
+
+  @Override
+  public String toString() {
+    return getClass().getSimpleName() + "(positions=" + (posIn != null) + ",payloads=" + (payIn != null) +")";
+  }
 }