/** Returns how many bits are required to hold values up * to and including maxValue * NOTE: This method returns at least 1. * @param maxValue the maximum value that should be representable. * @return the amount of bits needed to represent values from 0 to maxValue. * @lucene.internal */ public static int bitsRequired(long maxValue) { if (maxValue < 0) { throw new IllegalArgumentException("maxValue must be non-negative (got: " + maxValue + ")"); } return unsignedBitsRequired(maxValue); }
@Override public void encode(long[] values, int valuesOffset, byte[] blocks, int blocksOffset, int iterations) { int nextBlock = 0; int bitsLeft = 8; for (int i = 0; i < byteValueCount * iterations; ++i) { final long v = values[valuesOffset++]; assert PackedInts.unsignedBitsRequired(v) <= bitsPerValue; if (bitsPerValue < bitsLeft) { // just buffer nextBlock |= v << (bitsLeft - bitsPerValue); bitsLeft -= bitsPerValue; } else { // flush as many blocks as possible int bits = bitsPerValue - bitsLeft; blocks[blocksOffset++] = (byte) (nextBlock | (v >>> bits)); while (bits >= 8) { bits -= 8; blocks[blocksOffset++] = (byte) (v >>> bits); } // then buffer bitsLeft = 8 - bits; nextBlock = (int) ((v & ((1L << bits) - 1)) << bitsLeft); } } assert bitsLeft == 8; }
/** * Returns how many bits are required to hold values up * to and including maxValue, interpreted as an unsigned value. * * @param maxValue the maximum value that should be representable. * @return the amount of bits needed to represent values from 0 to maxValue. * @see PackedInts#unsignedBitsRequired(long) */ public static int unsignedBitsRequired(long maxValue) { return roundBits(PackedInts.unsignedBitsRequired(maxValue)); }
@Override public void add(long v) throws IOException { assert PackedInts.unsignedBitsRequired(v) <= bitsPerValue; assert !finished; if (valueCount != -1 && written >= valueCount) { throw new EOFException("Writing past end of stream"); } nextValues[off++] = v; if (off == nextValues.length) { flush(); } ++written; }
assert fromIndex >= 0; assert fromIndex <= toIndex; assert PackedInts.unsignedBitsRequired(val) <= bitsPerValue;
int bitsRequired = delta == 0 ? 0 : PackedInts.unsignedBitsRequired(delta); if (bitsRequired == 64) {
private void ensureCapacity(long value) { if ((value & currentMask) == value) { return; } final int bitsRequired = PackedInts.unsignedBitsRequired(value); assert bitsRequired > current.getBitsPerValue(); final int valueCount = size(); PackedInts.Mutable next = PackedInts.getMutable(valueCount, bitsRequired, acceptableOverheadRatio); PackedInts.copy(current, 0, next, 0, valueCount, PackedInts.DEFAULT_BUFFER_SIZE); current = next; currentMask = mask(current.getBitsPerValue()); }
@Override public void fill(int fromIndex, int toIndex, long val) { assert PackedInts.unsignedBitsRequired(val) <= getBitsPerValue(); assert fromIndex <= toIndex;
/** Returns how many bits are required to hold values up * to and including maxValue * NOTE: This method returns at least 1. * @param maxValue the maximum value that should be representable. * @return the amount of bits needed to represent values from 0 to maxValue. * @lucene.internal */ public static int bitsRequired(long maxValue) { if (maxValue < 0) { throw new IllegalArgumentException("maxValue must be non-negative (got: " + maxValue + ")"); } return unsignedBitsRequired(maxValue); }
/** Returns how many bits are required to hold values up * to and including maxValue * NOTE: This method returns at least 1. * @param maxValue the maximum value that should be representable. * @return the amount of bits needed to represent values from 0 to maxValue. * @lucene.internal */ public static int bitsRequired(long maxValue) { if (maxValue < 0) { throw new IllegalArgumentException("maxValue must be non-negative (got: " + maxValue + ")"); } return unsignedBitsRequired(maxValue); }
/** Returns how many bits are required to hold values up * to and including maxValue * NOTE: This method returns at least 1. * @param maxValue the maximum value that should be representable. * @return the amount of bits needed to represent values from 0 to maxValue. * @lucene.internal */ public static int bitsRequired(long maxValue) { if (maxValue < 0) { throw new IllegalArgumentException("maxValue must be non-negative (got: " + maxValue + ")"); } return unsignedBitsRequired(maxValue); }
/** * Returns how many bits are required to hold values up * to and including maxValue, interpreted as an unsigned value. * * @param maxValue the maximum value that should be representable. * @return the amount of bits needed to represent values from 0 to maxValue. * @see PackedInts#unsignedBitsRequired(long) */ public static int unsignedBitsRequired(long maxValue) { return roundBits(PackedInts.unsignedBitsRequired(maxValue)); }
/** * Returns how many bits are required to hold values up * to and including maxValue, interpreted as an unsigned value. * * @param maxValue the maximum value that should be representable. * @return the amount of bits needed to represent values from 0 to maxValue. * @see PackedInts#unsignedBitsRequired(long) */ public static int unsignedBitsRequired(long maxValue) { return roundBits(PackedInts.unsignedBitsRequired(maxValue)); }
/** * Returns how many bits are required to hold values up * to and including maxValue, interpreted as an unsigned value. * * @param maxValue the maximum value that should be representable. * @return the amount of bits needed to represent values from 0 to maxValue. * @see PackedInts#unsignedBitsRequired(long) */ public static int unsignedBitsRequired(long maxValue) { return roundBits(PackedInts.unsignedBitsRequired(maxValue)); }
@Override public void add(long v) throws IOException { assert PackedInts.unsignedBitsRequired(v) <= bitsPerValue; assert !finished; if (valueCount != -1 && written >= valueCount) { throw new EOFException("Writing past end of stream"); } nextValues[off++] = v; if (off == nextValues.length) { flush(); } ++written; }
@Override public void add(long v) throws IOException { assert PackedInts.unsignedBitsRequired(v) <= bitsPerValue; assert !finished; if (valueCount != -1 && written >= valueCount) { throw new EOFException("Writing past end of stream"); } nextValues[off++] = v; if (off == nextValues.length) { flush(); } ++written; }
@Override public void add(long v) throws IOException { assert PackedInts.unsignedBitsRequired(v) <= bitsPerValue; assert !finished; if (valueCount != -1 && written >= valueCount) { throw new EOFException("Writing past end of stream"); } nextValues[off++] = v; if (off == nextValues.length) { flush(); } ++written; }
private void ensureCapacity(long value) { if ((value & currentMask) == value) { return; } final int bitsRequired = PackedInts.unsignedBitsRequired(value); assert bitsRequired > current.getBitsPerValue(); final int valueCount = size(); PackedInts.Mutable next = PackedInts.getMutable(valueCount, bitsRequired, acceptableOverheadRatio); PackedInts.copy(current, 0, next, 0, valueCount, PackedInts.DEFAULT_BUFFER_SIZE); current = next; currentMask = mask(current.getBitsPerValue()); }
private void ensureCapacity(long value) { if ((value & currentMask) == value) { return; } final int bitsRequired = PackedInts.unsignedBitsRequired(value); assert bitsRequired > current.getBitsPerValue(); final int valueCount = size(); PackedInts.Mutable next = PackedInts.getMutable(valueCount, bitsRequired, acceptableOverheadRatio); PackedInts.copy(current, 0, next, 0, valueCount, PackedInts.DEFAULT_BUFFER_SIZE); current = next; currentMask = mask(current.getBitsPerValue()); }
private void ensureCapacity(long value) { if ((value & currentMask) == value) { return; } final int bitsRequired = PackedInts.unsignedBitsRequired(value); assert bitsRequired > current.getBitsPerValue(); final int valueCount = size(); PackedInts.Mutable next = PackedInts.getMutable(valueCount, bitsRequired, acceptableOverheadRatio); PackedInts.copy(current, 0, next, 0, valueCount, PackedInts.DEFAULT_BUFFER_SIZE); current = next; currentMask = mask(current.getBitsPerValue()); }