io.airlift.slice.Slice.getByte()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(5.4k)|赞(0)|评价(0)|浏览(213)

本文整理了Java中io.airlift.slice.Slice.getByte()方法的一些代码示例,展示了Slice.getByte()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Slice.getByte()方法的具体详情如下:
包路径:io.airlift.slice.Slice
类名称:Slice
方法名:getByte

Slice.getByte介绍

[英]Gets a byte at the specified absolute index in this buffer.
[中]获取此缓冲区中指定绝对索引处的字节。

代码示例

代码示例来源:origin: prestodb/presto

  1. @Override
  2. protected boolean isEntryNull(int position)
  3. {
  4. return valueIsNull != null && valueIsNull.getByte(position) != 0;
  5. }

代码示例来源:origin: prestodb/presto

  1. @ScalarOperator(CAST)
  2. @SqlType(StandardTypes.HYPER_LOG_LOG)
  3. public static Slice castToHyperLogLog(@SqlType(SetDigestType.NAME) Slice slice)
  4. {
  5. checkArgument(slice.getByte(0) == 1, "Legacy version of SetDigest cannot cast to HyperLogLog");
  6. int hllLength = slice.getInt(SIZE_OF_BYTE);
  7. return Slices.wrappedBuffer(slice.getBytes(SIZE_OF_BYTE + SIZE_OF_INT, hllLength));
  8. }
  9. }

代码示例来源:origin: prestodb/presto

  1. private static long readVIntInternal(Slice slice, int start, int length)
  2. {
  3. long value = 0;
  4. for (int i = 1; i < length; i++) {
  5. value <<= 8;
  6. value |= (slice.getByte(start + i) & 0xFF);
  7. }
  8. return isNegativeVInt(slice.getByte(start)) ? ~value : value;
  9. }

代码示例来源:origin: prestodb/presto

  1. public static long readVInt(Slice slice, int start, int length)
  2. {
  3. if (length == 1) {
  4. return slice.getByte(start);
  5. }
  6. return readVIntInternal(slice, start, length);
  7. }

代码示例来源:origin: prestodb/presto

  1. @SuppressWarnings("PointlessArithmeticExpression")
  2. private static boolean isFalse(Slice slice, int start, int length)
  3. {
  4. return (length == 5) &&
  5. (toUpperCase(slice.getByte(start + 0)) == 'F') &&
  6. (toUpperCase(slice.getByte(start + 1)) == 'A') &&
  7. (toUpperCase(slice.getByte(start + 2)) == 'L') &&
  8. (toUpperCase(slice.getByte(start + 3)) == 'S') &&
  9. (toUpperCase(slice.getByte(start + 4)) == 'E');
  10. }

代码示例来源:origin: prestodb/presto

  1. @Override
  2. protected boolean isEntryNull(int position)
  3. {
  4. return valueIsNull.getUnderlyingSlice().getByte(position) != 0;
  5. }

代码示例来源:origin: prestodb/presto

  1. @Override
  2. public void decodeValueInto(BlockBuilder builder, Slice slice, int offset, int length)
  3. {
  4. type.writeLong(builder, slice.getByte(offset));
  5. }
  6. }

代码示例来源:origin: prestodb/presto

  1. @SuppressWarnings("PointlessArithmeticExpression")
  2. private static boolean isTrue(Slice slice, int start, int length)
  3. {
  4. return (length == 4) &&
  5. (toUpperCase(slice.getByte(start + 0)) == 'T') &&
  6. (toUpperCase(slice.getByte(start + 1)) == 'R') &&
  7. (toUpperCase(slice.getByte(start + 2)) == 'U') &&
  8. (toUpperCase(slice.getByte(start + 3)) == 'E');
  9. }

代码示例来源:origin: prestodb/presto

  1. private static int hashBytes(int initialValue, Slice bytes)
  2. {
  3. int result = initialValue;
  4. for (int i = 0; i < bytes.length(); i++) {
  5. result = result * 31 + bytes.getByte(i);
  6. }
  7. return result;
  8. }

代码示例来源:origin: prestodb/presto

  1. @Override
  2. public void decodeValueInto(BlockBuilder builder, Slice slice, int offset, int length)
  3. {
  4. type.writeBoolean(builder, slice.getByte(offset) != 0);
  5. }
  6. }

代码示例来源:origin: prestodb/presto

  1. public static boolean isNegativeVInt(Slice slice, int offset)
  2. {
  3. return isNegativeVInt(slice.getByte(offset));
  4. }

代码示例来源:origin: prestodb/presto

  1. public static int decodeVIntSize(Slice slice, int offset)
  2. {
  3. return decodeVIntSize(slice.getByte(offset));
  4. }

代码示例来源:origin: prestodb/presto

  1. private BigDecimal parseBigDecimal(Slice slice, int offset, int length)
  2. {
  3. checkArgument(length < buffer.length);
  4. for (int i = 0; i < length; i++) {
  5. buffer[i] = (char) slice.getByte(offset + i);
  6. }
  7. BigDecimal decimal = new BigDecimal(buffer, 0, length);
  8. checkState(decimal.scale() <= type.getScale(), "Read decimal value scale larger than column scale");
  9. decimal = decimal.setScale(type.getScale(), HALF_UP);
  10. checkState(decimal.precision() <= type.getPrecision(), "Read decimal precision larger than column precision");
  11. return decimal;
  12. }
  13. }

代码示例来源:origin: prestodb/presto

  1. @Override
  2. public void writeSlice(BlockBuilder blockBuilder, Slice value, int offset, int length)
  3. {
  4. if (length > 0 && value.getByte(offset + length - 1) == ' ') {
  5. throw new IllegalArgumentException("Slice representing Char should not have trailing spaces");
  6. }
  7. blockBuilder.writeBytes(value, offset, length).closeEntry();
  8. }

代码示例来源:origin: prestodb/presto

  1. private static int compareCharsShorterToLonger(Slice shorter, Slice longer)
  2. {
  3. for (int i = 0; i < shorter.length(); ++i) {
  4. int result = compareUnsignedBytes(shorter.getByte(i), longer.getByte(i));
  5. if (result != 0) {
  6. return result;
  7. }
  8. }
  9. for (int i = shorter.length(); i < longer.length(); ++i) {
  10. int result = compareUnsignedBytes((byte) ' ', longer.getByte(i));
  11. if (result != 0) {
  12. return result;
  13. }
  14. }
  15. return 0;
  16. }

代码示例来源:origin: prestodb/presto

  1. public static long readVInt(Slice slice, int start)
  2. {
  3. byte firstByte = slice.getByte(start);
  4. int length = decodeVIntSize(firstByte);
  5. if (length == 1) {
  6. return firstByte;
  7. }
  8. return readVIntInternal(slice, start, length);
  9. }

代码示例来源:origin: prestodb/presto

  1. @Override
  2. public byte getByte(int position, int offset)
  3. {
  4. checkReadablePosition(position);
  5. return getRawSlice().getByte(valueOffset(position) + offset);
  6. }

代码示例来源:origin: prestodb/presto

  1. @Override
  2. public byte getByte(int position, int offset)
  3. {
  4. checkReadablePosition(position);
  5. return getRawSlice(position).getByte(getPositionOffset(position) + offset);
  6. }

代码示例来源:origin: prestodb/presto

  1. @Override
  2. public int getValueLength(Slice slice, int offset)
  3. {
  4. int length = 4;
  5. if (hasNanosVInt(slice.getByte(offset))) {
  6. int nanosVintLength = decodeVIntSize(slice, offset + 4);
  7. length += nanosVintLength;
  8. // is there extra data for "seconds"
  9. if (isNegativeVInt(slice, offset + 4)) {
  10. length += decodeVIntSize(slice, offset + 4 + nanosVintLength);
  11. }
  12. }
  13. return length;
  14. }

代码示例来源:origin: prestodb/presto

  1. private static void writeValues(Slice[] expectedValues, BlockBuilder blockBuilder)
  2. {
  3. for (Slice expectedValue : expectedValues) {
  4. if (expectedValue == null) {
  5. blockBuilder.appendNull();
  6. }
  7. else {
  8. blockBuilder.writeByte(expectedValue.getByte(0)).closeEntry();
  9. }
  10. }
  11. }

相关文章