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

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

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

Slice.indexOfByte介绍

暂无

代码示例

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

@Override
public void encodeValueInto(int depth, Block block, int position, SliceOutput output)
{
  Slice slice = type.getSlice(block, position);
  if (escapeByte != null && slice.indexOfByte(escapeByte) < 0) {
    throw new IllegalArgumentException("escape not implemented");
  }
  output.writeBytes(slice);
}

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

@Override
public void encodeColumn(Block block, SliceOutput output, EncodeOutput encodeOutput)
{
  for (int position = 0; position < block.getPositionCount(); position++) {
    if (block.isNull(position)) {
      output.writeBytes(nullSequence);
    }
    else {
      Slice slice = type.getSlice(block, position);
      if (escapeByte != null && slice.indexOfByte(escapeByte) < 0) {
        throw new IllegalArgumentException("escape not implemented");
      }
      output.writeBytes(slice);
    }
    encodeOutput.closeEntry();
  }
}

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

@SuppressWarnings("AssignmentToForLoopParameter")
private static ColumnData unescape(ColumnData columnData, byte escapeByte)
{
  Slice slice = columnData.getSlice();
  // does slice contain escape byte
  if (slice.indexOfByte(escapeByte) < 0) {
    return columnData;
  }
  Slice newSlice = Slices.allocate(slice.length());
  SliceOutput output = newSlice.getOutput();
  int[] newOffsets = new int[columnData.rowCount() + 1];
  for (int row = 0; row < columnData.rowCount(); row++) {
    int offset = columnData.getOffset(row);
    int length = columnData.getLength(row);
    for (int i = 0; i < length; i++) {
      byte value = slice.getByte(offset + i);
      if (value == escapeByte && i + 1 < length) {
        // read byte after escape
        i++;
        value = slice.getByte(offset + i);
      }
      output.write(value);
    }
    newOffsets[row + 1] = output.size();
  }
  return new ColumnData(newOffsets, output.slice());
}

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

@Override
public void encodeValueInto(int depth, Block block, int position, SliceOutput output)
{
  Slice slice = type.getSlice(block, position);
  if (escapeByte != null && slice.indexOfByte(escapeByte) < 0) {
    throw new IllegalArgumentException("escape not implemented");
  }
  output.writeBytes(slice);
}

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

@Override
public void encodeValueInto(int depth, Block block, int position, SliceOutput output)
{
  Slice slice = type.getSlice(block, position);
  if (escapeByte != null && slice.indexOfByte(escapeByte) < 0) {
    throw new IllegalArgumentException("escape not implemented");
  }
  output.writeBytes(slice);
}

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

@Override
public void encodeColumn(Block block, SliceOutput output, EncodeOutput encodeOutput)
{
  for (int position = 0; position < block.getPositionCount(); position++) {
    if (block.isNull(position)) {
      output.writeBytes(nullSequence);
    }
    else {
      Slice slice = type.getSlice(block, position);
      if (escapeByte != null && slice.indexOfByte(escapeByte) < 0) {
        throw new IllegalArgumentException("escape not implemented");
      }
      output.writeBytes(slice);
    }
    encodeOutput.closeEntry();
  }
}

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

@Override
public void encodeColumn(Block block, SliceOutput output, EncodeOutput encodeOutput)
{
  for (int position = 0; position < block.getPositionCount(); position++) {
    if (block.isNull(position)) {
      output.writeBytes(nullSequence);
    }
    else {
      Slice slice = type.getSlice(block, position);
      if (escapeByte != null && slice.indexOfByte(escapeByte) < 0) {
        throw new IllegalArgumentException("escape not implemented");
      }
      output.writeBytes(slice);
    }
    encodeOutput.closeEntry();
  }
}

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

@SuppressWarnings("AssignmentToForLoopParameter")
private static ColumnData unescape(ColumnData columnData, byte escapeByte)
{
  Slice slice = columnData.getSlice();
  // does slice contain escape byte
  if (slice.indexOfByte(escapeByte) < 0) {
    return columnData;
  }
  Slice newSlice = Slices.allocate(slice.length());
  SliceOutput output = newSlice.getOutput();
  int[] newOffsets = new int[columnData.rowCount() + 1];
  for (int row = 0; row < columnData.rowCount(); row++) {
    int offset = columnData.getOffset(row);
    int length = columnData.getLength(row);
    for (int i = 0; i < length; i++) {
      byte value = slice.getByte(offset + i);
      if (value == escapeByte && i + 1 < length) {
        // read byte after escape
        i++;
        value = slice.getByte(offset + i);
      }
      output.write(value);
    }
    newOffsets[row + 1] = output.size();
  }
  return new ColumnData(newOffsets, output.slice());
}

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

@SuppressWarnings("AssignmentToForLoopParameter")
private static ColumnData unescape(ColumnData columnData, byte escapeByte)
{
  Slice slice = columnData.getSlice();
  // does slice contain escape byte
  if (slice.indexOfByte(escapeByte) < 0) {
    return columnData;
  }
  Slice newSlice = Slices.allocate(slice.length());
  SliceOutput output = newSlice.getOutput();
  int[] newOffsets = new int[columnData.rowCount() + 1];
  for (int row = 0; row < columnData.rowCount(); row++) {
    int offset = columnData.getOffset(row);
    int length = columnData.getLength(row);
    for (int i = 0; i < length; i++) {
      byte value = slice.getByte(offset + i);
      if (value == escapeByte && i + 1 < length) {
        // read byte after escape
        i++;
        value = slice.getByte(offset + i);
      }
      output.write(value);
    }
    newOffsets[row + 1] = output.size();
  }
  return new ColumnData(newOffsets, output.slice());
}

相关文章