本文整理了Java中io.airlift.slice.Slice.getBase()
方法的一些代码示例,展示了Slice.getBase()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Slice.getBase()
方法的具体详情如下:
包路径:io.airlift.slice.Slice
类名称:Slice
方法名:getBase
[英]Returns the base object of this Slice, or null. This is appropriate for use with Unsafe if you wish to avoid all the safety belts e.g. bounds checks.
[中]返回此切片的基本对象,或null。如果您希望避免所有安全带,例如边界检查,这适用于不安全的情况。
代码示例来源:origin: prestodb/presto
private static int getRawInt(Slice decimal, int index)
{
return unsafe.getInt(decimal.getBase(), decimal.getAddress() + SIZE_OF_INT * index);
}
代码示例来源:origin: prestodb/presto
private static void setRawInt(Slice decimal, int index, int value)
{
unsafe.putInt(decimal.getBase(), decimal.getAddress() + SIZE_OF_INT * index, value);
}
代码示例来源:origin: prestodb/presto
private static void setRawLong(Slice decimal, int index, long value)
{
unsafe.putLong(decimal.getBase(), decimal.getAddress() + SIZE_OF_LONG * index, value);
}
代码示例来源:origin: prestodb/presto
private static long getRawLong(Slice decimal, int index)
{
return unsafe.getLong(decimal.getBase(), decimal.getAddress() + SIZE_OF_LONG * index);
}
代码示例来源:origin: prestodb/presto
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;
}
}
代码示例来源:origin: prestodb/presto
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;
}
}
}
}
代码示例来源:origin: prestodb/presto
@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;
}
}
代码示例来源:origin: prestodb/presto
@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;
}
代码示例来源:origin: prestodb/presto
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();
代码示例来源:origin: rakam-io/rakam
byte[] base = (byte[]) slice.getUnderlyingSlice().getBase();
RequestBody body = RequestBody.create(mediaType, base, 0, slice.size());
代码示例来源:origin: prestosql/presto
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;
}
}
代码示例来源:origin: com.teradata/re2j-td
MachineInput(Slice slice) {
this.slice = slice;
this.base = slice.getBase();
this.address = slice.getAddress();
this.length = slice.length();
}
代码示例来源:origin: io.prestosql/presto-parquet
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;
}
}
代码示例来源:origin: uk.co.nichesolutions.presto/presto-orc
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);
}
代码示例来源:origin: airlift/slice
public XxHash64 update(Slice data, int offset, int length)
{
checkPositionIndexes(0, offset + length, data.length());
updateHash(data.getBase(), data.getAddress() + offset, length);
return this;
}
代码示例来源:origin: io.airlift/slice
public XxHash64 update(Slice data, int offset, int length)
{
checkPositionIndexes(0, offset + length, data.length());
updateHash(data.getBase(), data.getAddress() + offset, length);
return this;
}
代码示例来源:origin: airlift/slice
@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);
}
};
代码示例来源:origin: io.airlift/slice
@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);
}
};
代码示例来源:origin: io.prestosql/presto-array
@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;
}
代码示例来源:origin: com.facebook.presto/presto-array
@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;
}
内容来源于网络,如有侵权,请联系作者删除!