本文整理了Java中io.airlift.slice.Slice.getByte()
方法的一些代码示例,展示了Slice.getByte()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Slice.getByte()
方法的具体详情如下:
包路径:io.airlift.slice.Slice
类名称:Slice
方法名:getByte
[英]Gets a byte at the specified absolute index in this buffer.
[中]获取此缓冲区中指定绝对索引处的字节。
代码示例来源:origin: prestodb/presto
@Override
protected boolean isEntryNull(int position)
{
return valueIsNull != null && valueIsNull.getByte(position) != 0;
}
代码示例来源:origin: prestodb/presto
@ScalarOperator(CAST)
@SqlType(StandardTypes.HYPER_LOG_LOG)
public static Slice castToHyperLogLog(@SqlType(SetDigestType.NAME) Slice slice)
{
checkArgument(slice.getByte(0) == 1, "Legacy version of SetDigest cannot cast to HyperLogLog");
int hllLength = slice.getInt(SIZE_OF_BYTE);
return Slices.wrappedBuffer(slice.getBytes(SIZE_OF_BYTE + SIZE_OF_INT, hllLength));
}
}
代码示例来源:origin: prestodb/presto
private static long readVIntInternal(Slice slice, int start, int length)
{
long value = 0;
for (int i = 1; i < length; i++) {
value <<= 8;
value |= (slice.getByte(start + i) & 0xFF);
}
return isNegativeVInt(slice.getByte(start)) ? ~value : value;
}
代码示例来源:origin: prestodb/presto
public static long readVInt(Slice slice, int start, int length)
{
if (length == 1) {
return slice.getByte(start);
}
return readVIntInternal(slice, start, length);
}
代码示例来源:origin: prestodb/presto
@SuppressWarnings("PointlessArithmeticExpression")
private static boolean isFalse(Slice slice, int start, int length)
{
return (length == 5) &&
(toUpperCase(slice.getByte(start + 0)) == 'F') &&
(toUpperCase(slice.getByte(start + 1)) == 'A') &&
(toUpperCase(slice.getByte(start + 2)) == 'L') &&
(toUpperCase(slice.getByte(start + 3)) == 'S') &&
(toUpperCase(slice.getByte(start + 4)) == 'E');
}
代码示例来源:origin: prestodb/presto
@Override
protected boolean isEntryNull(int position)
{
return valueIsNull.getUnderlyingSlice().getByte(position) != 0;
}
代码示例来源:origin: prestodb/presto
@Override
public void decodeValueInto(BlockBuilder builder, Slice slice, int offset, int length)
{
type.writeLong(builder, slice.getByte(offset));
}
}
代码示例来源:origin: prestodb/presto
@SuppressWarnings("PointlessArithmeticExpression")
private static boolean isTrue(Slice slice, int start, int length)
{
return (length == 4) &&
(toUpperCase(slice.getByte(start + 0)) == 'T') &&
(toUpperCase(slice.getByte(start + 1)) == 'R') &&
(toUpperCase(slice.getByte(start + 2)) == 'U') &&
(toUpperCase(slice.getByte(start + 3)) == 'E');
}
代码示例来源:origin: prestodb/presto
private static int hashBytes(int initialValue, Slice bytes)
{
int result = initialValue;
for (int i = 0; i < bytes.length(); i++) {
result = result * 31 + bytes.getByte(i);
}
return result;
}
代码示例来源:origin: prestodb/presto
@Override
public void decodeValueInto(BlockBuilder builder, Slice slice, int offset, int length)
{
type.writeBoolean(builder, slice.getByte(offset) != 0);
}
}
代码示例来源:origin: prestodb/presto
public static boolean isNegativeVInt(Slice slice, int offset)
{
return isNegativeVInt(slice.getByte(offset));
}
代码示例来源:origin: prestodb/presto
public static int decodeVIntSize(Slice slice, int offset)
{
return decodeVIntSize(slice.getByte(offset));
}
代码示例来源:origin: prestodb/presto
private BigDecimal parseBigDecimal(Slice slice, int offset, int length)
{
checkArgument(length < buffer.length);
for (int i = 0; i < length; i++) {
buffer[i] = (char) slice.getByte(offset + i);
}
BigDecimal decimal = new BigDecimal(buffer, 0, length);
checkState(decimal.scale() <= type.getScale(), "Read decimal value scale larger than column scale");
decimal = decimal.setScale(type.getScale(), HALF_UP);
checkState(decimal.precision() <= type.getPrecision(), "Read decimal precision larger than column precision");
return decimal;
}
}
代码示例来源:origin: prestodb/presto
@Override
public void writeSlice(BlockBuilder blockBuilder, Slice value, int offset, int length)
{
if (length > 0 && value.getByte(offset + length - 1) == ' ') {
throw new IllegalArgumentException("Slice representing Char should not have trailing spaces");
}
blockBuilder.writeBytes(value, offset, length).closeEntry();
}
代码示例来源:origin: prestodb/presto
private static int compareCharsShorterToLonger(Slice shorter, Slice longer)
{
for (int i = 0; i < shorter.length(); ++i) {
int result = compareUnsignedBytes(shorter.getByte(i), longer.getByte(i));
if (result != 0) {
return result;
}
}
for (int i = shorter.length(); i < longer.length(); ++i) {
int result = compareUnsignedBytes((byte) ' ', longer.getByte(i));
if (result != 0) {
return result;
}
}
return 0;
}
代码示例来源:origin: prestodb/presto
public static long readVInt(Slice slice, int start)
{
byte firstByte = slice.getByte(start);
int length = decodeVIntSize(firstByte);
if (length == 1) {
return firstByte;
}
return readVIntInternal(slice, start, length);
}
代码示例来源:origin: prestodb/presto
@Override
public byte getByte(int position, int offset)
{
checkReadablePosition(position);
return getRawSlice().getByte(valueOffset(position) + offset);
}
代码示例来源:origin: prestodb/presto
@Override
public byte getByte(int position, int offset)
{
checkReadablePosition(position);
return getRawSlice(position).getByte(getPositionOffset(position) + offset);
}
代码示例来源:origin: prestodb/presto
@Override
public int getValueLength(Slice slice, int offset)
{
int length = 4;
if (hasNanosVInt(slice.getByte(offset))) {
int nanosVintLength = decodeVIntSize(slice, offset + 4);
length += nanosVintLength;
// is there extra data for "seconds"
if (isNegativeVInt(slice, offset + 4)) {
length += decodeVIntSize(slice, offset + 4 + nanosVintLength);
}
}
return length;
}
代码示例来源:origin: prestodb/presto
private static void writeValues(Slice[] expectedValues, BlockBuilder blockBuilder)
{
for (Slice expectedValue : expectedValues) {
if (expectedValue == null) {
blockBuilder.appendNull();
}
else {
blockBuilder.writeByte(expectedValue.getByte(0)).closeEntry();
}
}
}
内容来源于网络,如有侵权,请联系作者删除!