Java Code Examples for org.apache.lucene.util.RamUsageEstimator#sizeOf()

The following examples show how to use org.apache.lucene.util.RamUsageEstimator#sizeOf() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DirectPostingsFormat.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
@Override
public long ramBytesUsed() {
  long sizeInBytes = BASE_RAM_BYTES_USED;
  sizeInBytes += ((termBytes!=null) ? RamUsageEstimator.sizeOf(termBytes) : 0);
  sizeInBytes += ((termOffsets!=null) ? RamUsageEstimator.sizeOf(termOffsets) : 0);
  sizeInBytes += ((skips!=null) ? RamUsageEstimator.sizeOf(skips) : 0);
  sizeInBytes += ((skipOffsets!=null) ? RamUsageEstimator.sizeOf(skipOffsets) : 0);
  sizeInBytes += ((sameCounts!=null) ? RamUsageEstimator.sizeOf(sameCounts) : 0);

  if(terms!=null) {
    sizeInBytes += RamUsageEstimator.shallowSizeOf(terms);
    for(TermAndSkip termAndSkip : terms) {
      sizeInBytes += (termAndSkip!=null) ? termAndSkip.ramBytesUsed() : 0;
    }
  }

  return sizeInBytes;
}
 
Example 2
Source File: MonotonicLongValues.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@Override
public MonotonicLongValues build() {
  finish();
  pending = null;
  final PackedInts.Reader[] values = ArrayUtil.copyOfSubArray(this.values, 0, valuesOff);
  final long[] mins = ArrayUtil.copyOfSubArray(this.mins, 0, valuesOff);
  final float[] averages = ArrayUtil.copyOfSubArray(this.averages, 0, valuesOff);
  final long ramBytesUsed = MonotonicLongValues.BASE_RAM_BYTES_USED
      + RamUsageEstimator.sizeOf(values) + RamUsageEstimator.sizeOf(mins)
      + RamUsageEstimator.sizeOf(averages);
  return new MonotonicLongValues(pageShift, pageMask, values, mins, averages, size, ramBytesUsed);
}
 
Example 3
Source File: DirectPostingsFormat.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@Override
public long ramBytesUsed() {
  long sizeInBytes = BASE_RAM_BYTES_USED;
  sizeInBytes += (docIDs!=null)? RamUsageEstimator.sizeOf(docIDs) : 0;
  sizeInBytes += (freqs!=null)? RamUsageEstimator.sizeOf(freqs) : 0;

  if(positions != null) {
    sizeInBytes += RamUsageEstimator.shallowSizeOf(positions);
    for(int[] position : positions) {
      sizeInBytes += (position!=null) ? RamUsageEstimator.sizeOf(position) : 0;
    }
  }

  if (payloads != null) {
    sizeInBytes += RamUsageEstimator.shallowSizeOf(payloads);
    for(byte[][] payload : payloads) {
      if(payload != null) {
        sizeInBytes += RamUsageEstimator.shallowSizeOf(payload);
        for(byte[] pload : payload) {
          sizeInBytes += (pload!=null) ? RamUsageEstimator.sizeOf(pload) : 0;
        }
      }
    }
  }

  return sizeInBytes;
}
 
Example 4
Source File: BytesStore.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@Override
public long ramBytesUsed() {
  long size = BASE_RAM_BYTES_USED;
  for (byte[] block : blocks) {
    size += RamUsageEstimator.sizeOf(block);
  }
  return size;
}
 
Example 5
Source File: DeltaPackedLongValues.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@Override
public DeltaPackedLongValues build() {
  finish();
  pending = null;
  final PackedInts.Reader[] values = ArrayUtil.copyOfSubArray(this.values, 0, valuesOff);
  final long[] mins = ArrayUtil.copyOfSubArray(this.mins, 0, valuesOff);
  final long ramBytesUsed = DeltaPackedLongValues.BASE_RAM_BYTES_USED
      + RamUsageEstimator.sizeOf(values) + RamUsageEstimator.sizeOf(mins);
  return new DeltaPackedLongValues(pageShift, pageMask, values, mins, size, ramBytesUsed);
}
 
Example 6
Source File: DeltaPackedLongValues.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@Override
void grow(int newBlockCount) {
  super.grow(newBlockCount);
  ramBytesUsed -= RamUsageEstimator.sizeOf(mins);
  mins = ArrayUtil.growExact(mins, newBlockCount);
  ramBytesUsed += RamUsageEstimator.sizeOf(mins);
}
 
Example 7
Source File: SimpleTextBKDReader.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
@Override
public long ramBytesUsed() {
  return RamUsageEstimator.sizeOf(splitPackedValues) +
      RamUsageEstimator.sizeOf(leafBlockFPs);
}
 
Example 8
Source File: StringSizeEstimator.java    From crate with Apache License 2.0 4 votes vote down vote up
public static long estimate(@Nullable String value) {
    return RamUsageEstimator.sizeOf(value);
}
 
Example 9
Source File: OrdinalMap.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
@Override
public long ramBytesUsed() {
  return BASE_RAM_BYTES_USED + RamUsageEstimator.sizeOf(newToOld) + RamUsageEstimator.sizeOf(oldToNew);
}
 
Example 10
Source File: StringSizeEstimator.java    From crate with Apache License 2.0 4 votes vote down vote up
@Override
public long estimateSize(@Nullable String value) {
    return RamUsageEstimator.sizeOf(value);
}
 
Example 11
Source File: CharSequenceOutputs.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
@Override
public long ramBytesUsed(CharsRef output) {
  return BASE_NUM_BYTES + RamUsageEstimator.sizeOf(output.chars);
}
 
Example 12
Source File: RamUsageUtil.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
public static long ramBytesUsed(BytesRef bytesRef) {
  return BYTES_REF_BASE_RAM_USAGE + RamUsageEstimator.sizeOf(bytesRef.bytes);
}
 
Example 13
Source File: BigArrays.java    From crate with Apache License 2.0 4 votes vote down vote up
@Override
public long ramBytesUsed() {
    return SHALLOW_SIZE + RamUsageEstimator.sizeOf(array);
}
 
Example 14
Source File: SimpleTextDocValuesReader.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
@Override
public long ramBytesUsed() {
  return BASE_RAM_BYTES_USED + RamUsageEstimator.sizeOf(scratch.bytes())
      + fields.size() * (RamUsageEstimator.NUM_BYTES_OBJECT_REF * 2L + OneField.BASE_RAM_BYTES_USED);
}
 
Example 15
Source File: BigArrays.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
public long ramBytesUsed() {
    return SHALLOW_SIZE + RamUsageEstimator.sizeOf(array);
}
 
Example 16
Source File: SimpleTextStoredFieldsReader.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
@Override
public long ramBytesUsed() {
  return BASE_RAM_BYTES_USED + RamUsageEstimator.sizeOf(offsets)
      + RamUsageEstimator.sizeOf(scratch.bytes()) + RamUsageEstimator.sizeOf(scratchUTF16.chars());
}
 
Example 17
Source File: DirectPostingsFormat.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
@Override
public long ramBytesUsed() {
  return BASE_RAM_BYTES_USED +
      ((postings!=null) ? RamUsageEstimator.sizeOf(postings) : 0) +
      ((payloads!=null) ? RamUsageEstimator.sizeOf(payloads) : 0);
}
 
Example 18
Source File: BigArrays.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
public long ramBytesUsed() {
    return SHALLOW_SIZE + RamUsageEstimator.sizeOf(array);
}
 
Example 19
Source File: BigArrays.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
public long ramBytesUsed() {
    return SHALLOW_SIZE + RamUsageEstimator.sizeOf(array);
}
 
Example 20
Source File: IntSequenceOutputs.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
@Override
public long ramBytesUsed(IntsRef output) {
  return BASE_NUM_BYTES + RamUsageEstimator.sizeOf(output.ints);
}