org.apache.hadoop.hbase.Cell.getTagsOffset()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(10.8k)|赞(0)|评价(0)|浏览(146)

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

Cell.getTagsOffset介绍

暂无

代码示例

代码示例来源:origin: apache/hbase

@Override
public int getTagsOffset() {
 return cell.getTagsOffset();
}

代码示例来源:origin: apache/hbase

@Override
public int getTagsOffset() {
 return this.cell.getTagsOffset();
}

代码示例来源:origin: apache/hbase

public static ByteRange fillTagRange(Cell cell, ByteRange range) {
 return range.set(cell.getTagsArray(), cell.getTagsOffset(), cell.getTagsLength());
}

代码示例来源:origin: apache/hbase

/**
 * Writes the tag from the given cell to the output stream
 * @param out The outputstream to which the data has to be written
 * @param cell The cell whose contents has to be written
 * @param tagsLength the tag length
 * @throws IOException
 */
public static void writeTags(OutputStream out, Cell cell, int tagsLength) throws IOException {
 if (cell instanceof ByteBufferExtendedCell) {
  ByteBufferUtils.copyBufferToStream(out, ((ByteBufferExtendedCell) cell).getTagsByteBuffer(),
   ((ByteBufferExtendedCell) cell).getTagsPosition(), tagsLength);
 } else {
  out.write(cell.getTagsArray(), cell.getTagsOffset(), tagsLength);
 }
}

代码示例来源:origin: apache/hbase

/** Returns a string representation of the cell */
public static String toString(Cell cell, boolean verbose) {
 if (cell == null) {
  return "";
 }
 StringBuilder builder = new StringBuilder();
 String keyStr = getCellKeyAsString(cell);
 String tag = null;
 String value = null;
 if (verbose) {
  // TODO: pretty print tags as well
  if (cell.getTagsLength() > 0) {
   tag = Bytes.toStringBinary(cell.getTagsArray(), cell.getTagsOffset(), cell.getTagsLength());
  }
  if (!(cell instanceof KeyValue.KeyOnlyKeyValue)) {
   value = Bytes.toStringBinary(cell.getValueArray(), cell.getValueOffset(),
    cell.getValueLength());
  }
 }
 builder.append(keyStr);
 if (tag != null && !tag.isEmpty()) {
  builder.append("/").append(tag);
 }
 if (value != null) {
  builder.append("/").append(value);
 }
 return builder.toString();
}

代码示例来源:origin: apache/hbase

/**
 * Copies the tags info into the tag portion of the cell
 * @param cell
 * @param destination
 * @param destinationOffset
 * @return position after tags
 */
public static int copyTagsTo(Cell cell, byte[] destination, int destinationOffset) {
 int tlen = cell.getTagsLength();
 if (cell instanceof ByteBufferExtendedCell) {
  ByteBufferUtils
   .copyFromBufferToArray(destination, ((ByteBufferExtendedCell) cell).getTagsByteBuffer(),
    ((ByteBufferExtendedCell) cell).getTagsPosition(), destinationOffset, tlen);
 } else {
  System
   .arraycopy(cell.getTagsArray(), cell.getTagsOffset(), destination, destinationOffset, tlen);
 }
 return destinationOffset + tlen;
}

代码示例来源:origin: apache/hbase

/**
 * Copies the tags info into the tag portion of the cell
 * @param cell
 * @param destination
 * @param destinationOffset
 * @return the position after tags
 */
public static int copyTagsTo(Cell cell, ByteBuffer destination, int destinationOffset) {
 int tlen = cell.getTagsLength();
 if (cell instanceof ByteBufferExtendedCell) {
  ByteBufferUtils.copyFromBufferToBuffer(((ByteBufferExtendedCell) cell).getTagsByteBuffer(),
   destination, ((ByteBufferExtendedCell) cell).getTagsPosition(), destinationOffset, tlen);
 } else {
  ByteBufferUtils.copyFromArrayToBuffer(destination, destinationOffset, cell.getTagsArray(),
   cell.getTagsOffset(), tlen);
 }
 return destinationOffset + tlen;
}

代码示例来源:origin: apache/hbase

int length = cell.getTagsLength();
int offset =
 bufferBacked ? ((ByteBufferExtendedCell) cell).getTagsPosition() : cell.getTagsOffset();
int pos = offset;
while (pos < offset + length) {

代码示例来源:origin: apache/hbase

/**
 * Compresses the tags to the given outputstream using the TagcompressionContext
 * @param out the outputstream to which the compression should happen
 * @param cell the cell which has tags
 * @param tagCompressionContext the TagCompressionContext
 * @throws IOException can throw IOException if the compression encounters issue
 */
public static void compressTags(OutputStream out, Cell cell,
  TagCompressionContext tagCompressionContext) throws IOException {
 if (cell instanceof ByteBufferExtendedCell) {
  tagCompressionContext.compressTags(out, ((ByteBufferExtendedCell) cell).getTagsByteBuffer(),
   ((ByteBufferExtendedCell) cell).getTagsPosition(), cell.getTagsLength());
 } else {
  tagCompressionContext.compressTags(out, cell.getTagsArray(), cell.getTagsOffset(),
   cell.getTagsLength());
 }
}

代码示例来源:origin: apache/hbase

public static byte[] concatTags(byte[] tags, Cell cell) {
 int cellTagsLen = cell.getTagsLength();
 if (cellTagsLen == 0) {
  // If no Tags, return early.
  return tags;
 }
 byte[] b = new byte[tags.length + cellTagsLen];
 int pos = Bytes.putBytes(b, 0, tags, 0, tags.length);
 if (cell instanceof ByteBufferExtendedCell) {
  ByteBufferUtils.copyFromBufferToArray(b, ((ByteBufferExtendedCell) cell).getTagsByteBuffer(),
    ((ByteBufferExtendedCell) cell).getTagsPosition(), pos, cellTagsLen);
 } else {
  Bytes.putBytes(b, pos, cell.getTagsArray(), cell.getTagsOffset(), cellTagsLen);
 }
 return b;
}

代码示例来源:origin: apache/hbase

/**
 * Util method to iterate through the tags in the given cell.
 * @param cell The Cell over which tags iterator is needed.
 * @return iterator for the tags
 */
public static Iterator<Tag> tagsIterator(final Cell cell) {
 final int tagsLength = cell.getTagsLength();
 // Save an object allocation where we can
 if (tagsLength == 0) {
  return TagUtil.EMPTY_TAGS_ITR;
 }
 if (cell instanceof ByteBufferExtendedCell) {
  return tagsIterator(((ByteBufferExtendedCell) cell).getTagsByteBuffer(),
   ((ByteBufferExtendedCell) cell).getTagsPosition(), tagsLength);
 }
 return CellUtil.tagsIterator(cell.getTagsArray(), cell.getTagsOffset(), cell.getTagsLength());
}

代码示例来源:origin: apache/hbase

out.write(cell.getTagsArray(), cell.getTagsOffset(), tlen);
size += tlen + KeyValue.TAGS_LENGTH_SIZE;

代码示例来源:origin: apache/hbase

@Override
public void write(Cell cell) throws IOException {
 checkFlushed();
 // Row
 write(cell.getRowArray(), cell.getRowOffset(), cell.getRowLength());
 // Column family
 write(cell.getFamilyArray(), cell.getFamilyOffset(), cell.getFamilyLength());
 // Qualifier
 write(cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength());
 // Version
 this.out.write(Bytes.toBytes(cell.getTimestamp()));
 // Type
 this.out.write(cell.getTypeByte());
 // Value
 write(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength());
 // Tags
 write(cell.getTagsArray(), cell.getTagsOffset(), cell.getTagsLength());
 // MvccVersion
 this.out.write(Bytes.toBytes(cell.getSequenceId()));
}

代码示例来源:origin: apache/hbase

.setType(reference.getTypeByte())
.setValue(HConstants.EMPTY_BYTE_ARRAY)
.setTags(reference.getTagsArray(), reference.getTagsOffset(),
 reference.getTagsLength())
.build();

代码示例来源:origin: apache/hbase

public KeyValue(Cell c) {
 this(c.getRowArray(), c.getRowOffset(), c.getRowLength(),
   c.getFamilyArray(), c.getFamilyOffset(), c.getFamilyLength(),
   c.getQualifierArray(), c.getQualifierOffset(), c.getQualifierLength(),
   c.getTimestamp(), Type.codeToType(c.getTypeByte()), c.getValueArray(), c.getValueOffset(),
   c.getValueLength(), c.getTagsArray(), c.getTagsOffset(), c.getTagsLength());
 this.seqId = c.getSequenceId();
}

代码示例来源:origin: apache/nifi

private ResultCell getResultCell(Cell cell) {
  final ResultCell resultCell = new ResultCell();
  resultCell.setRowArray(cell.getRowArray());
  resultCell.setRowOffset(cell.getRowOffset());
  resultCell.setRowLength(cell.getRowLength());
  resultCell.setFamilyArray(cell.getFamilyArray());
  resultCell.setFamilyOffset(cell.getFamilyOffset());
  resultCell.setFamilyLength(cell.getFamilyLength());
  resultCell.setQualifierArray(cell.getQualifierArray());
  resultCell.setQualifierOffset(cell.getQualifierOffset());
  resultCell.setQualifierLength(cell.getQualifierLength());
  resultCell.setTimestamp(cell.getTimestamp());
  resultCell.setTypeByte(cell.getTypeByte());
  resultCell.setSequenceId(cell.getSequenceId());
  resultCell.setValueArray(cell.getValueArray());
  resultCell.setValueOffset(cell.getValueOffset());
  resultCell.setValueLength(cell.getValueLength());
  resultCell.setTagsArray(cell.getTagsArray());
  resultCell.setTagsOffset(cell.getTagsOffset());
  resultCell.setTagsLength(cell.getTagsLength());
  return resultCell;
}

代码示例来源:origin: apache/nifi

private ResultCell getResultCell(Cell cell) {
  final ResultCell resultCell = new ResultCell();
  resultCell.setRowArray(cell.getRowArray());
  resultCell.setRowOffset(cell.getRowOffset());
  resultCell.setRowLength(cell.getRowLength());
  resultCell.setFamilyArray(cell.getFamilyArray());
  resultCell.setFamilyOffset(cell.getFamilyOffset());
  resultCell.setFamilyLength(cell.getFamilyLength());
  resultCell.setQualifierArray(cell.getQualifierArray());
  resultCell.setQualifierOffset(cell.getQualifierOffset());
  resultCell.setQualifierLength(cell.getQualifierLength());
  resultCell.setTimestamp(cell.getTimestamp());
  resultCell.setTypeByte(cell.getTypeByte());
  resultCell.setSequenceId(cell.getSequenceId());
  resultCell.setValueArray(cell.getValueArray());
  resultCell.setValueOffset(cell.getValueOffset());
  resultCell.setValueLength(cell.getValueLength());
  resultCell.setTagsArray(cell.getTagsArray());
  resultCell.setTagsOffset(cell.getTagsOffset());
  resultCell.setTagsLength(cell.getTagsLength());
  return resultCell;
}

代码示例来源:origin: apache/hbase

Bytes.copy(kv1.getValueArray(), kv1.getValueOffset(), kv1.getValueLength());
byte[] tagsArrayInKV =
  Bytes.copy(kv1.getTagsArray(), kv1.getTagsOffset(), kv1.getTagsLength());

代码示例来源:origin: apache/hbase

@Test
 public void testExtendedCellBuilderWithDeepCopy() {
  byte[] row = new byte[]{OLD_DATA};
  byte[] family = new byte[]{OLD_DATA};
  byte[] qualifier = new byte[]{OLD_DATA};
  byte[] value = new byte[]{OLD_DATA};
  byte[] tags = new byte[]{OLD_DATA};
  long seqId = 999;
  Cell cell = ExtendedCellBuilderFactory.create(CellBuilderType.DEEP_COPY)
      .setRow(row)
      .setFamily(family)
      .setQualifier(qualifier)
      .setType(KeyValue.Type.Put.getCode())
      .setValue(value)
      .setTags(tags)
      .setSequenceId(seqId)
      .build();
  row[0] = NEW_DATA;
  family[0] = NEW_DATA;
  qualifier[0] = NEW_DATA;
  value[0] = NEW_DATA;
  tags[0] = NEW_DATA;
  assertEquals(OLD_DATA, cell.getRowArray()[cell.getRowOffset()]);
  assertEquals(OLD_DATA, cell.getFamilyArray()[cell.getFamilyOffset()]);
  assertEquals(OLD_DATA, cell.getQualifierArray()[cell.getQualifierOffset()]);
  assertEquals(OLD_DATA, cell.getValueArray()[cell.getValueOffset()]);
  assertEquals(OLD_DATA, cell.getTagsArray()[cell.getTagsOffset()]);
  assertEquals(seqId, cell.getSequenceId());
 }
}

代码示例来源:origin: apache/hbase

@Test
public void testExtendedCellBuilderWithShallowCopy() {
 byte[] row = new byte[]{OLD_DATA};
 byte[] family = new byte[]{OLD_DATA};
 byte[] qualifier = new byte[]{OLD_DATA};
 byte[] value = new byte[]{OLD_DATA};
 byte[] tags = new byte[]{OLD_DATA};
 long seqId = 999;
 Cell cell = ExtendedCellBuilderFactory.create(CellBuilderType.SHALLOW_COPY)
     .setRow(row)
     .setFamily(family)
     .setQualifier(qualifier)
     .setType(KeyValue.Type.Put.getCode())
     .setValue(value)
     .setTags(tags)
     .setSequenceId(seqId)
     .build();
 row[0] = NEW_DATA;
 family[0] = NEW_DATA;
 qualifier[0] = NEW_DATA;
 value[0] = NEW_DATA;
 tags[0] = NEW_DATA;
 assertEquals(NEW_DATA, cell.getRowArray()[cell.getRowOffset()]);
 assertEquals(NEW_DATA, cell.getFamilyArray()[cell.getFamilyOffset()]);
 assertEquals(NEW_DATA, cell.getQualifierArray()[cell.getQualifierOffset()]);
 assertEquals(NEW_DATA, cell.getValueArray()[cell.getValueOffset()]);
 assertEquals(NEW_DATA, cell.getTagsArray()[cell.getTagsOffset()]);
 assertEquals(seqId, cell.getSequenceId());
}

相关文章