Example usage for org.apache.lucene.util RamUsageEstimator NUM_BYTES_ARRAY_HEADER

List of usage examples for org.apache.lucene.util RamUsageEstimator NUM_BYTES_ARRAY_HEADER

Introduction

In this page you can find the example usage for org.apache.lucene.util RamUsageEstimator NUM_BYTES_ARRAY_HEADER.

Prototype

int NUM_BYTES_ARRAY_HEADER

To view the source code for org.apache.lucene.util RamUsageEstimator NUM_BYTES_ARRAY_HEADER.

Click Source Link

Document

Number of bytes to represent an array header (no content, but with alignments).

Usage

From source file:org.apache.solr.search.DocSlice.java

License:Apache License

/** WARNING: this can over-estimate real memory use since backing arrays are shared with other DocSlice instances */
@Override/*  ww w  .  ja  v a  2s  .c o  m*/
public long ramBytesUsed() {
    return BASE_RAM_BYTES_USED + ((long) docs.length << 2)
            + (scores == null ? 0 : ((long) scores.length << 2) + RamUsageEstimator.NUM_BYTES_ARRAY_HEADER);
}

From source file:org.codelibs.elasticsearch.common.bytes.CompositeBytesReference.java

License:Apache License

public CompositeBytesReference(BytesReference... references) {
    this.references = Objects.requireNonNull(references, "references must not be null");
    this.offsets = new int[references.length];
    long ramBytesUsed = 0;
    int offset = 0;
    for (int i = 0; i < references.length; i++) {
        BytesReference reference = references[i];
        if (reference == null) {
            throw new IllegalArgumentException("references must not be null");
        }//from  w  w w. j a v a  2 s  .c om
        offsets[i] = offset; // we use the offsets to seek into the right BytesReference for random access and slicing
        offset += reference.length();
        ramBytesUsed += reference.ramBytesUsed();
    }
    this.ramBytesUsed = ramBytesUsed
            + (Integer.BYTES * offsets.length + RamUsageEstimator.NUM_BYTES_ARRAY_HEADER) // offsets
            + (references.length * RamUsageEstimator.NUM_BYTES_OBJECT_REF
                    + RamUsageEstimator.NUM_BYTES_ARRAY_HEADER) // references
            + Integer.BYTES // length
            + Long.BYTES; // ramBytesUsed
    length = offset;
}

From source file:org.elasticsearch.index.cache.id.simple.SimpleIdReaderTypeCache.java

License:Apache License

long computeSizeInBytes() {
    long sizeInBytes = 0;
    // Ignore type field
    //  sizeInBytes += ((type.length() * RamUsage.NUM_BYTES_CHAR) + (3 * RamUsage.NUM_BYTES_INT)) + RamUsage.NUM_BYTES_OBJECT_HEADER;
    sizeInBytes += RamUsageEstimator.NUM_BYTES_ARRAY_HEADER
            + (idToDoc._valuesSize() * RamUsageEstimator.NUM_BYTES_INT);
    for (Object o : idToDoc._set) {
        if (o == TObjectHash.FREE || o == TObjectHash.REMOVED) {
            sizeInBytes += RamUsageEstimator.NUM_BYTES_OBJECT_REF;
        } else {/* w  w w . j a v a2s . com*/
            HashedBytesArray bytesArray = (HashedBytesArray) o;
            sizeInBytes += RamUsageEstimator.NUM_BYTES_OBJECT_HEADER
                    + (bytesArray.length() + RamUsageEstimator.NUM_BYTES_INT);
        }
    }

    // The docIdToId array contains references to idToDoc for this segment or other segments, so we can use OBJECT_REF
    sizeInBytes += RamUsageEstimator.NUM_BYTES_ARRAY_HEADER
            + (RamUsageEstimator.NUM_BYTES_OBJECT_REF * docIdToId.length);
    for (HashedBytesArray bytesArray : parentIdsValues) {
        if (bytesArray == null) {
            sizeInBytes += RamUsageEstimator.NUM_BYTES_OBJECT_REF;
        } else {
            sizeInBytes += RamUsageEstimator.NUM_BYTES_OBJECT_HEADER
                    + (bytesArray.length() + RamUsageEstimator.NUM_BYTES_INT);
        }
    }
    sizeInBytes += RamUsageEstimator.sizeOf(parentIdsOrdinals);

    return sizeInBytes;
}