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

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

Introduction

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

Prototype

int NUM_BYTES_OBJECT_HEADER

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

Click Source Link

Document

Number of bytes to represent an object header (no fields, no alignments).

Usage

From source file:com.o19s.es.ltr.ranker.linear.LinearRanker.java

License:Apache License

/**
 * Return the memory usage of this object in bytes. Negative values are illegal.
 *//*from  w w w.jav  a 2 s . c o  m*/
@Override
public long ramBytesUsed() {
    return RamUsageEstimator.NUM_BYTES_OBJECT_HEADER + RamUsageEstimator.sizeOf(weights);
}

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 {//from w w w. j a v a2  s.c om
            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;
}

From source file:org.elasticsearch.index.engine.internal.VersionValue.java

License:Apache License

@Override
public long ramBytesUsed() {
    return RamUsageEstimator.NUM_BYTES_OBJECT_HEADER + RamUsageEstimator.NUM_BYTES_LONG
            + RamUsageEstimator.NUM_BYTES_OBJECT_REF + translogLocation.ramBytesUsed();
}

From source file:org.elasticsearch.index.percolator.stats.ShardPercolateService.java

License:Apache License

private static long computeSizeInMemory(HashedBytesRef id, Query query) {
    long size = (3 * RamUsageEstimator.NUM_BYTES_INT) + RamUsageEstimator.NUM_BYTES_OBJECT_REF
            + RamUsageEstimator.NUM_BYTES_OBJECT_HEADER + id.bytes.bytes.length;
    size += RamEstimator.sizeOf(query);/*  w  w w .  j av  a2s .  c  o  m*/
    return size;
}