private static int getRawInt(Slice decimal, int index) { return unsafe.getInt(decimal.getBase(), decimal.getAddress() + SIZE_OF_INT * index); }
private static void setRawInt(Slice decimal, int index, int value) { unsafe.putInt(decimal.getBase(), decimal.getAddress() + SIZE_OF_INT * index, value); }
private static void setRawLong(Slice decimal, int index, long value) { unsafe.putLong(decimal.getBase(), decimal.getAddress() + SIZE_OF_LONG * index, value); }
private static long getRawLong(Slice decimal, int index) { return unsafe.getLong(decimal.getBase(), decimal.getAddress() + SIZE_OF_LONG * index); }
private static int decompress(Decompressor decompressor, Slice input, int inputOffset, int inputLength, byte[] output, int outputOffset) { byte[] byteArray = (byte[]) input.getBase(); int byteArrayOffset = inputOffset + (int) (input.getAddress() - ARRAY_BYTE_BASE_OFFSET); int size = decompressor.decompress(byteArray, byteArrayOffset, inputLength, output, outputOffset, output.length - outputOffset); return size; } }
private void updateRetainedSize(long index, Slice value) { Slice currentValue = array.get(index); if (currentValue != null) { int baseReferenceCount = trackedSlices.decrementAndGet(currentValue.getBase()); int sliceReferenceCount = trackedSlices.decrementAndGet(currentValue); if (baseReferenceCount == 0) { // it is the last referenced base sizeOfSlices -= currentValue.getRetainedSize(); } else if (sliceReferenceCount == 0) { // it is the last referenced slice sizeOfSlices -= SLICE_INSTANCE_SIZE; } } if (value != null) { int baseReferenceCount = trackedSlices.incrementAndGet(value.getBase()); int sliceReferenceCount = trackedSlices.incrementAndGet(value); if (baseReferenceCount == 1) { // it is the first referenced base sizeOfSlices += value.getRetainedSize(); } else if (sliceReferenceCount == 1) { // it is the first referenced slice sizeOfSlices += SLICE_INSTANCE_SIZE; } } } }
@Override public void writeBytes(Slice source, int sourceIndex, int length) { // Write huge chunks direct to OutputStream if (length >= DIRECT_FLUSH_SIZE) { flushBufferToOutputStream(); writeDirectlyToOutputStream((byte[]) source.getBase(), sourceIndex + (int) (source.getAddress() - ARRAY_BYTE_BASE_OFFSET), length); bufferOffset += length; } else { ensureWritableBytes(length); slice.setBytes(bufferPosition, source, sourceIndex, length); bufferPosition += length; } }
@Benchmark @OperationsPerInvocation(NUMBER_OF_ENTRIES) public ReferenceCountMap benchmarkInserts(Data data) { ReferenceCountMap map = new ReferenceCountMap(); for (int i = 0; i < NUMBER_OF_ENTRIES; i++) { map.incrementAndGet(data.slices[i]); map.incrementAndGet(data.slices[i].getBase()); } return map; }
int uncompressedSize = decompressor.get().decompress((byte[]) chunk.getBase(), (int) (chunk.getAddress() - ARRAY_BYTE_BASE_OFFSET), chunk.length(), output); current = Slices.wrappedBuffer(buffer, 0, uncompressedSize).getInput();
byte[] base = (byte[]) slice.getUnderlyingSlice().getBase(); RequestBody body = RequestBody.create(mediaType, base, 0, slice.size());
private static int decompress(Decompressor decompressor, Slice input, int inputOffset, int inputLength, byte[] output, int outputOffset) { byte[] byteArray = (byte[]) input.getBase(); int byteArrayOffset = inputOffset + (int) (input.getAddress() - ARRAY_BYTE_BASE_OFFSET); int size = decompressor.decompress(byteArray, byteArrayOffset, inputLength, output, outputOffset, output.length - outputOffset); return size; } }
MachineInput(Slice slice) { this.slice = slice; this.base = slice.getBase(); this.address = slice.getAddress(); this.length = slice.length(); }
private static int decompress(Decompressor decompressor, Slice input, int inputOffset, int inputLength, byte[] output, int outputOffset) { byte[] byteArray = (byte[]) input.getBase(); int byteArrayOffset = inputOffset + (int) (input.getAddress() - ARRAY_BYTE_BASE_OFFSET); int size = decompressor.decompress(byteArray, byteArrayOffset, inputLength, output, outputOffset, output.length - outputOffset); return size; } }
private int decompressSnappy(Slice in) throws IOException { byte[] inArray = (byte[]) in.getBase(); int inOffset = (int) (in.getAddress() - ARRAY_BYTE_BASE_OFFSET); int inLength = in.length(); int uncompressedLength = Snappy.getUncompressedLength(inArray, inOffset); checkArgument(uncompressedLength <= maxBufferSize, "Snappy requires buffer (%s) larger than max size (%s)", uncompressedLength, maxBufferSize); allocateOrGrowBuffer(uncompressedLength, false); return Snappy.uncompress(inArray, inOffset, inLength, buffer, 0); }
public XxHash64 update(Slice data, int offset, int length) { checkPositionIndexes(0, offset + length, data.length()); updateHash(data.getBase(), data.getAddress() + offset, length); return this; }
public XxHash64 update(Slice data, int offset, int length) { checkPositionIndexes(0, offset + length, data.length()); updateHash(data.getBase(), data.getAddress() + offset, length); return this; }
@Override public void doCopy(Slice data, long srcOffset, long destOffset, int length) { Object base = data.getBase(); srcOffset += data.getAddress(); destOffset += data.getAddress(); int bytesToCopy = length - (length % 8); unsafe.copyMemory(base, srcOffset, base, destOffset, bytesToCopy); unsafe.copyMemory(base, srcOffset + bytesToCopy, base, destOffset + bytesToCopy, length - bytesToCopy); } };
@Override public void doCopy(Slice data, long srcOffset, long destOffset, int length) { Object base = data.getBase(); srcOffset += data.getAddress(); destOffset += data.getAddress(); int bytesToCopy = length - (length % 8); unsafe.copyMemory(base, srcOffset, base, destOffset, bytesToCopy); unsafe.copyMemory(base, srcOffset + bytesToCopy, base, destOffset + bytesToCopy, length - bytesToCopy); } };
@Benchmark @OperationsPerInvocation(NUMBER_OF_ENTRIES) public ReferenceCountMap benchmarkInserts(Data data) { ReferenceCountMap map = new ReferenceCountMap(); for (int i = 0; i < NUMBER_OF_ENTRIES; i++) { map.incrementAndGet(data.slices[i]); map.incrementAndGet(data.slices[i].getBase()); } return map; }
@Benchmark @OperationsPerInvocation(NUMBER_OF_ENTRIES) public ReferenceCountMap benchmarkInserts(Data data) { ReferenceCountMap map = new ReferenceCountMap(); for (int i = 0; i < NUMBER_OF_ENTRIES; i++) { map.incrementAndGet(data.slices[i]); map.incrementAndGet(data.slices[i].getBase()); } return map; }