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

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

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

Slice.setByte介绍

[英]Sets the specified byte at the specified absolute index in this buffer. The 24 high-order bits of the specified value are ignored.
[中]在该缓冲区中指定的绝对索引处设置指定字节。指定值的24个高位将被忽略。

代码示例

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

private static void verifySlice()
{
  Slice slice = Slices.wrappedBuffer(new byte[5]);
  slice.setByte(4, 0xDE);
  slice.setByte(3, 0xAD);
  slice.setByte(2, 0xBE);
  slice.setByte(1, 0xEF);
  if (slice.getInt(1) != 0xDEADBEEF) {
    failRequirement("Slice library produced an unexpected result");
  }
}

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

public static Slice padSpaces(Slice slice, int length)
{
  int textLength = countCodePoints(slice);
  // if our string is bigger than requested then truncate
  if (textLength > length) {
    throw new IllegalArgumentException("pad length is smaller than slice length");
  }
  // if our target length is the same as our string then return our string
  if (textLength == length) {
    return slice;
  }
  // preallocate the result
  int bufferSize = slice.length() + length - textLength;
  Slice buffer = Slices.allocate(bufferSize);
  // fill in the existing string
  buffer.setBytes(0, slice);
  // fill padding spaces
  for (int i = slice.length(); i < bufferSize; ++i) {
    buffer.setByte(i, ' ');
  }
  return buffer;
}

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

@Override
public void writeByte(int value)
{
  ensureWritableBytes(SIZE_OF_BYTE);
  slice.setByte(bufferPosition, value);
  bufferPosition += SIZE_OF_BYTE;
}

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

@Override
public void writeByte(int value)
{
  ensureWritableBytes(SIZE_OF_BYTE);
  slice.setByte(bufferPosition, value);
  bufferPosition += SIZE_OF_BYTE;
}

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

@Override
public void writeByte(int value)
{
  ensureWritableBytes(SIZE_OF_BYTE);
  slice.setByte(bufferPosition, value);
  bufferPosition += SIZE_OF_BYTE;
}

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

@Override
public void writeByte(int value)
{
  ensureWritableBytes(SIZE_OF_BYTE);
  slice.setByte(bufferPosition, value);
  bufferPosition += SIZE_OF_BYTE;
}

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

@VisibleForTesting
public static Slice maxStringTruncateToValidRange(Slice value, HiveWriterVersion version)
{
  if (value == null) {
    return null;
  }
  if (version != ORIGINAL) {
    return value;
  }
  int index = findStringStatisticTruncationPositionForOriginalOrcWriter(value);
  if (index == value.length()) {
    return value;
  }
  // Append 0xFF so that it is larger than value
  Slice newValue = Slices.copyOf(value, 0, index + 1);
  newValue.setByte(index, 0xFF);
  return newValue;
}

代码示例来源:origin: embulk/embulk

private void writeBoolean(int columnIndex, boolean value) {
  bufferSlice.setByte(getOffset(columnIndex), value ? (byte) 1 : (byte) 0);
  clearNull(columnIndex);
}

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

@Setup
public void setup()
{
  Slice whitespace = createRandomUtf8Slice(ascii ? ASCII_WHITESPACE : ALL_WHITESPACE, length + 1);
  leftWhitespace = Slices.copyOf(whitespace);
  leftWhitespace.setByte(leftWhitespace.length() - 1, 'X');
  rightWhitespace = Slices.copyOf(whitespace);
  rightWhitespace.setByte(0, 'X');
  bothWhitespace = Slices.copyOf(whitespace);
  bothWhitespace.setByte(length / 2, 'X');
}

代码示例来源:origin: airlift/slice

@Override
public void writeByte(int value)
{
  slice.setByte(size, value);
  size += SIZE_OF_BYTE;
}

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

private static void verifySlice()
{
  Slice slice = Slices.wrappedBuffer(new byte[5]);
  slice.setByte(4, 0xDE);
  slice.setByte(3, 0xAD);
  slice.setByte(2, 0xBE);
  slice.setByte(1, 0xEF);
  if (slice.getInt(1) != 0xDEADBEEF) {
    failRequirement("Slice library produced an unexpected result");
  }
}

代码示例来源:origin: io.airlift/slice

@Override
public void writeByte(int value)
{
  slice = Slices.ensureSize(slice, size + SIZE_OF_BYTE);
  slice.setByte(size, value);
  size += SIZE_OF_BYTE;
}

代码示例来源:origin: com.facebook.presto/presto-orc

@Override
public void writeByte(int value)
{
  ensureWritableBytes(SIZE_OF_BYTE);
  slice.setByte(bufferPosition, value);
  bufferPosition += SIZE_OF_BYTE;
}

代码示例来源:origin: com.facebook.presto/presto-rcfile

@Override
public void writeByte(int value)
{
  ensureWritableBytes(SIZE_OF_BYTE);
  slice.setByte(bufferPosition, value);
  bufferPosition += SIZE_OF_BYTE;
}

代码示例来源:origin: io.prestosql/presto-orc

@Override
public void writeByte(int value)
{
  ensureWritableBytes(SIZE_OF_BYTE);
  slice.setByte(bufferPosition, value);
  bufferPosition += SIZE_OF_BYTE;
}

代码示例来源:origin: airlift/slice

@Setup
public void setup()
{
  Slice whitespace = createRandomUtf8Slice(ascii ? ASCII_WHITESPACE : ALL_WHITESPACE, length + 1);
  leftWhitespace = Slices.copyOf(whitespace);
  leftWhitespace.setByte(leftWhitespace.length() - 1, 'X');
  rightWhitespace = Slices.copyOf(whitespace);
  rightWhitespace.setByte(0, 'X');
  bothWhitespace = Slices.copyOf(whitespace);
  bothWhitespace.setByte(length / 2, 'X');
}

代码示例来源:origin: airlift/slice

public TestXxHash64()
{
  buffer = Slices.allocate(101);
  long value = PRIME;
  for (int i = 0; i < buffer.length(); i++) {
    buffer.setByte(i, (byte) (value >> 24));
    value *= value;
  }
}

代码示例来源:origin: io.airlift/slice

public TestXxHash64()
{
  buffer = Slices.allocate(101);
  long value = PRIME;
  for (int i = 0; i < buffer.length(); i++) {
    buffer.setByte(i, (byte) (value >> 24));
    value *= value;
  }
}

代码示例来源:origin: io.prestosql/presto-main

@Setup
public void setup()
{
  Slice whitespace = createRandomUtf8Slice(ascii ? ASCII_WHITESPACE : ALL_WHITESPACE, length + 1);
  leftWhitespace = Slices.copyOf(whitespace);
  leftWhitespace.setByte(leftWhitespace.length() - 1, 'X');
  rightWhitespace = Slices.copyOf(whitespace);
  rightWhitespace.setByte(0, 'X');
  bothWhitespace = Slices.copyOf(whitespace);
  bothWhitespace.setByte(length / 2, 'X');
}

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

@Setup
public void setup()
{
  Slice whitespace = createRandomUtf8Slice(ascii ? ASCII_WHITESPACE : ALL_WHITESPACE, length + 1);
  leftWhitespace = Slices.copyOf(whitespace);
  leftWhitespace.setByte(leftWhitespace.length() - 1, 'X');
  rightWhitespace = Slices.copyOf(whitespace);
  rightWhitespace.setByte(0, 'X');
  bothWhitespace = Slices.copyOf(whitespace);
  bothWhitespace.setByte(length / 2, 'X');
}

相关文章