final long singleValuesSize = formatAndBits.format.longCount(PackedInts.VERSION_CURRENT, reader.maxDoc(), formatAndBits.bitsPerValue) * 8L;
final PackedInts.Format format = PackedInts.Format.PACKED; final long byteCount = format.byteCount(packedIntsVersion, valueCount, bitsPerValue); // to know how much to read final int longCount = format.longCount(PackedInts.VERSION_CURRENT, valueCount, bitsPerValue); // to size the array blocks = new long[longCount];
final PackedInts.Format format = PackedInts.Format.PACKED; final long byteCount = format.byteCount(packedIntsVersion, valueCount, bitsPerValue); // to know how much to read final int longCount = format.longCount(PackedInts.VERSION_CURRENT, valueCount, bitsPerValue); // to size the array blocks = new long[longCount];
final PackedInts.Format format = PackedInts.Format.PACKED; final long byteCount = format.byteCount(packedIntsVersion, valueCount, bitsPerValue); // to know how much to read final int longCount = format.longCount(PackedInts.VERSION_CURRENT, valueCount, bitsPerValue); // to size the array blocks = new long[longCount];
private long getPageMemoryUsage(PackedLongValues values, float acceptableOverheadRatio, int pageSize, long pageMinOrdinal, long pageMaxOrdinal) { int bitsRequired; long pageMemorySize = 0; PackedInts.FormatAndBits formatAndBits; if (pageMaxOrdinal == Long.MIN_VALUE) { // empty page - will use the null reader which just stores size pageMemorySize += RamUsageEstimator.alignObjectSize(RamUsageEstimator.NUM_BYTES_OBJECT_HEADER + RamUsageEstimator.NUM_BYTES_INT); } else { long pageMinValue = values.get(pageMinOrdinal); long pageMaxValue = values.get(pageMaxOrdinal); long pageDelta = pageMaxValue - pageMinValue; if (pageDelta != 0) { bitsRequired = pageDelta < 0 ? 64 : PackedInts.bitsRequired(pageDelta); formatAndBits = PackedInts.fastestFormatAndBits(pageSize, bitsRequired, acceptableOverheadRatio); pageMemorySize += formatAndBits.format.longCount(PackedInts.VERSION_CURRENT, pageSize, formatAndBits.bitsPerValue) * RamUsageEstimator.NUM_BYTES_LONG; pageMemorySize += RamUsageEstimator.NUM_BYTES_LONG; // min value per page storage } else { // empty page pageMemorySize += RamUsageEstimator.alignObjectSize(RamUsageEstimator.NUM_BYTES_OBJECT_HEADER + RamUsageEstimator.NUM_BYTES_INT); } } return pageMemorySize; }
/** * Creates an array with the internal structures adjusted for the given * limits and initialized to 0. * @param valueCount the number of elements. * @param bitsPerValue the number of bits available for any given value. */ public Packed64(int valueCount, int bitsPerValue) { super(valueCount, bitsPerValue); final PackedInts.Format format = PackedInts.Format.PACKED; final int longCount = format.longCount(PackedInts.VERSION_CURRENT, valueCount, bitsPerValue); this.blocks = new long[longCount]; maskRight = ~0L << (BLOCK_SIZE-bitsPerValue) >>> (BLOCK_SIZE-bitsPerValue); bpvMinusBlockSize = bitsPerValue - BLOCK_SIZE; }
/** * Creates an array with the internal structures adjusted for the given * limits and initialized to 0. * @param valueCount the number of elements. * @param bitsPerValue the number of bits available for any given value. */ public Packed64(int valueCount, int bitsPerValue) { super(valueCount, bitsPerValue); final PackedInts.Format format = PackedInts.Format.PACKED; final int longCount = format.longCount(PackedInts.VERSION_CURRENT, valueCount, bitsPerValue); this.blocks = new long[longCount]; maskRight = ~0L << (BLOCK_SIZE-bitsPerValue) >>> (BLOCK_SIZE-bitsPerValue); bpvMinusBlockSize = bitsPerValue - BLOCK_SIZE; }
/** * Creates an array with the internal structures adjusted for the given * limits and initialized to 0. * @param valueCount the number of elements. * @param bitsPerValue the number of bits available for any given value. */ public Packed64(int valueCount, int bitsPerValue) { super(valueCount, bitsPerValue); final PackedInts.Format format = PackedInts.Format.PACKED; final int longCount = format.longCount(PackedInts.VERSION_CURRENT, valueCount, bitsPerValue); this.blocks = new long[longCount]; maskRight = ~0L << (BLOCK_SIZE-bitsPerValue) >>> (BLOCK_SIZE-bitsPerValue); bpvMinusBlockSize = bitsPerValue - BLOCK_SIZE; }
/** * Computes how many byte blocks are needed to store <code>values</code> * values of size <code>bitsPerValue</code>. */ public long byteCount(int packedIntsVersion, int valueCount, int bitsPerValue) { assert bitsPerValue >= 0 && bitsPerValue <= 64 : bitsPerValue; // assume long-aligned return 8L * longCount(packedIntsVersion, valueCount, bitsPerValue); }
/** * Computes how many byte blocks are needed to store <code>values</code> * values of size <code>bitsPerValue</code>. */ public long byteCount(int packedIntsVersion, int valueCount, int bitsPerValue) { assert bitsPerValue >= 0 && bitsPerValue <= 64 : bitsPerValue; // assume long-aligned return 8L * longCount(packedIntsVersion, valueCount, bitsPerValue); }
/** * Computes how many byte blocks are needed to store <code>values</code> * values of size <code>bitsPerValue</code>. */ public long byteCount(int packedIntsVersion, int valueCount, int bitsPerValue) { assert bitsPerValue >= 0 && bitsPerValue <= 64 : bitsPerValue; // assume long-aligned return 8L * longCount(packedIntsVersion, valueCount, bitsPerValue); }
final PackedInts.Format format = PackedInts.Format.PACKED; final long byteCount = format.byteCount(packedIntsVersion, valueCount, bitsPerValue); // to know how much to read final int longCount = format.longCount(PackedInts.VERSION_CURRENT, valueCount, bitsPerValue); // to size the array blocks = new long[longCount];
/** * Creates an array with the internal structures adjusted for the given * limits and initialized to 0. * @param valueCount the number of elements. * @param bitsPerValue the number of bits available for any given value. */ public Packed64(int valueCount, int bitsPerValue) { super(valueCount, bitsPerValue); final PackedInts.Format format = PackedInts.Format.PACKED; final int longCount = format.longCount(PackedInts.VERSION_CURRENT, valueCount, bitsPerValue); this.blocks = new long[longCount]; maskRight = ~0L << (BLOCK_SIZE-bitsPerValue) >>> (BLOCK_SIZE-bitsPerValue); bpvMinusBlockSize = bitsPerValue - BLOCK_SIZE; }
/** * Computes how many byte blocks are needed to store <code>values</code> * values of size <code>bitsPerValue</code>. */ public long byteCount(int packedIntsVersion, int valueCount, int bitsPerValue) { assert bitsPerValue >= 0 && bitsPerValue <= 64 : bitsPerValue; // assume long-aligned return 8L * longCount(packedIntsVersion, valueCount, bitsPerValue); }