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"); } 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; }
public void onCached(Accountable key, BytesReference value) { totalMetric.inc(key.ramBytesUsed() + value.ramBytesUsed()); }
public void onRemoval(Accountable key, BytesReference value, boolean evicted) { if (evicted) { evictionsMetric.inc(); } long dec = 0; if (key != null) { dec += key.ramBytesUsed(); } if (value != null) { dec += value.ramBytesUsed(); } totalMetric.dec(dec); } }
@Override public long ramBytesUsed() { long ramUsed = 0L; for (BytesReference document : documents) { ramUsed += document.ramBytesUsed(); } return ramUsed; }
@Override public long ramBytesUsed() { long ramUsed = 0L; for (BytesReference document : documents) { ramUsed += document.ramBytesUsed(); } return ramUsed; }
IndicesRequestCache(Settings settings) { this.size = INDICES_CACHE_QUERY_SIZE.get(settings); this.expire = INDICES_CACHE_QUERY_EXPIRE.exists(settings) ? INDICES_CACHE_QUERY_EXPIRE.get(settings) : null; long sizeInBytes = size.getBytes(); CacheBuilder<Key, BytesReference> cacheBuilder = CacheBuilder.<Key, BytesReference>builder() .setMaximumWeight(sizeInBytes).weigher((k, v) -> k.ramBytesUsed() + v.ramBytesUsed()).removalListener(this); if (expire != null) { cacheBuilder.setExpireAfterAccess(expire); } cache = cacheBuilder.build(); }
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"); } 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; }
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"); } 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; }
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"); } 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; }
IndicesRequestCache(Settings settings) { super(settings); this.size = INDICES_CACHE_QUERY_SIZE.get(settings); this.expire = INDICES_CACHE_QUERY_EXPIRE.exists(settings) ? INDICES_CACHE_QUERY_EXPIRE.get(settings) : null; long sizeInBytes = size.getBytes(); CacheBuilder<Key, BytesReference> cacheBuilder = CacheBuilder.<Key, BytesReference>builder() .setMaximumWeight(sizeInBytes).weigher((k, v) -> k.ramBytesUsed() + v.ramBytesUsed()).removalListener(this); if (expire != null) { cacheBuilder.setExpireAfterAccess(expire); } cache = cacheBuilder.build(); }
IndicesRequestCache(Settings settings) { super(settings); this.size = INDICES_CACHE_QUERY_SIZE.get(settings); this.expire = INDICES_CACHE_QUERY_EXPIRE.exists(settings) ? INDICES_CACHE_QUERY_EXPIRE.get(settings) : null; long sizeInBytes = size.getBytes(); CacheBuilder<Key, BytesReference> cacheBuilder = CacheBuilder.<Key, BytesReference>builder() .setMaximumWeight(sizeInBytes).weigher((k, v) -> k.ramBytesUsed() + v.ramBytesUsed()).removalListener(this); if (expire != null) { cacheBuilder.setExpireAfterAccess(expire); } cache = cacheBuilder.build(); }
IndicesRequestCache(Settings settings) { super(settings); this.size = INDICES_CACHE_QUERY_SIZE.get(settings); this.expire = INDICES_CACHE_QUERY_EXPIRE.exists(settings) ? INDICES_CACHE_QUERY_EXPIRE.get(settings) : null; long sizeInBytes = size.getBytes(); CacheBuilder<Key, BytesReference> cacheBuilder = CacheBuilder.<Key, BytesReference>builder() .setMaximumWeight(sizeInBytes).weigher((k, v) -> k.ramBytesUsed() + v.ramBytesUsed()).removalListener(this); if (expire != null) { cacheBuilder.setExpireAfterAccess(expire); } cache = cacheBuilder.build(); }