private Slice dropStringMinMaxIfNecessary(Slice minOrMax) { if (minOrMax == null || minOrMax.length() > stringStatisticsLimitInBytes) { return null; } // Do not hold the entire slice where the actual stats could be small if (minOrMax.isCompact()) { return minOrMax; } return Slices.copyOf(minOrMax); } }
@Override public long checksum() { return XxHash64.hash(Slices.wrappedIntArray(positionLinks)); } };
@Override protected Object getGreaterValue(Object value) { return Slices.utf8Slice(((Slice) value).toStringUtf8() + "_"); } }
@Override public byte[] getSerializedData() { // Serialization format is (<key:int><min:double><max:double>)* SliceOutput output = Slices.allocate((SizeOf.SIZE_OF_INT + 2 * SizeOf.SIZE_OF_DOUBLE) * mins.size()).getOutput(); for (int key : mins.keySet()) { output.appendInt(key); output.appendDouble(mins.get(key)); output.appendDouble(maxs.get(key)); } return output.slice().getBytes(); }
private static Slice toSlice(String string) { return utf8Slice(string); } }
private static int[] toInt8Array(byte[] bytes) { Slice slice = Slices.wrappedBuffer(bytes); int[] ints = new int[8]; for (int i = 0; i < ints.length; i++) { ints[i] = slice.getInt(i * Integer.SIZE / Byte.SIZE); } return ints; }
private static Slice[] createTestValue(int positionCount) { Slice[] expectedValues = new Slice[positionCount]; for (int position = 0; position < positionCount; position++) { expectedValues[position] = Slices.wrappedBuffer((byte) position); } return expectedValues; }
public StreamDataOutput(Slice slice, Stream stream) { this( sliceOutput -> { sliceOutput.writeBytes(slice); return slice.length(); }, stream); }
protected static Slice createExpectedValue(int length) { DynamicSliceOutput dynamicSliceOutput = new DynamicSliceOutput(16); for (int index = 0; index < length; index++) { dynamicSliceOutput.writeByte(length * (index + 1)); } return dynamicSliceOutput.slice(); }
@Override protected boolean isEntryNull(int position) { return valueIsNull.getUnderlyingSlice().getByte(position) != 0; }
@Override protected Object getGreaterValue(Object value) { return Slices.utf8Slice(((Slice) value).toStringUtf8() + "_"); } }
/** * Returns a slice containing values in the specified range of the specified slice. * If the range matches the entire slice, the input slice will be returned. * Otherwise, a copy will be returned. */ static Slice compactSlice(Slice slice, int index, int length) { if (slice.isCompact() && index == 0 && length == slice.length()) { return slice; } return Slices.copyOf(slice, index, length); }
@Override public long getRetainedSizeInBytes() { return INSTANCE_SIZE + sizeOf(nullVector); } }
@Override protected Object getGreaterValue(Object value) { return Slices.utf8Slice(((Slice) value).toStringUtf8() + "_"); } }