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

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

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

Cell.getRowArray介绍

[英]Contiguous raw bytes that may start at any index in the containing array. Max length is Short.MAX_VALUE which is 32,767 bytes.
[中]可以从包含数组中的任何索引开始的连续原始字节。最大长度是短的。最大值为32767字节。

代码示例

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

/**
 * @param left
 * @param right
 * @return Result comparing rows.
 */
public int compareRows(final Cell left, final Cell right) {
 return compareRows(left.getRowArray(),left.getRowOffset(), left.getRowLength(),
 right.getRowArray(), right.getRowOffset(), right.getRowLength());
}

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

/**
 * @param left
 * @param lrowlength
 * @param right
 * @param rrowlength
 * @return True if rows match.
 */
private boolean matchingRows(final Cell left, final short lrowlength,
  final Cell right, final short rrowlength) {
 return lrowlength == rrowlength &&
   matchingRows(left.getRowArray(), left.getRowOffset(), lrowlength,
     right.getRowArray(), right.getRowOffset(), rrowlength);
}

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

public static boolean matchingRows(final Cell left, final byte[] buf, final int offset,
  final int length) {
 if (left instanceof ByteBufferExtendedCell) {
  return ByteBufferUtils.equals(((ByteBufferExtendedCell) left).getRowByteBuffer(),
    ((ByteBufferExtendedCell) left).getRowPosition(), left.getRowLength(),
    buf, offset, length);
 }
 return Bytes.equals(left.getRowArray(), left.getRowOffset(), left.getRowLength(), buf, offset,
   length);
}

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

Cell nextCell = nextRowResult.rawCells()[0];
if (currentRow == null
  || !Bytes.equals(currentRow, 0, currentRow.length, nextCell.getRowArray(),
  nextCell.getRowOffset(), nextCell.getRowLength())) {

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

/********************* common prefixes *************************/
// Having this as static is fine but if META is having DBE then we should
// change this.
public static int compareCommonRowPrefix(Cell left, Cell right, int rowCommonPrefix) {
 return Bytes.compareTo(left.getRowArray(), left.getRowOffset() + rowCommonPrefix,
   left.getRowLength() - rowCommonPrefix, right.getRowArray(), right.getRowOffset()
     + rowCommonPrefix, right.getRowLength() - rowCommonPrefix);
}

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

/********************* misc *************************************/
public static byte getRowByte(Cell cell, int index) {
 if (cell instanceof ByteBufferExtendedCell) {
  return ((ByteBufferExtendedCell) cell).getRowByteBuffer()
    .get(((ByteBufferExtendedCell) cell).getRowPosition() + index);
 }
 return cell.getRowArray()[cell.getRowOffset() + index];
}

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

Result result = results.next();
Cell cell = result.rawCells()[0];
if (Bytes.equals(currentRow, 0, currentRow.length, cell.getRowArray(),
  cell.getRowOffset(), cell.getRowLength())) {

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

private static int findCommonPrefixInRowPart(Cell left, Cell right, int rowCommonPrefix) {
 return Bytes.findCommonPrefix(left.getRowArray(), right.getRowArray(), left.getRowLength()
   - rowCommonPrefix, right.getRowLength() - rowCommonPrefix, left.getRowOffset()
   + rowCommonPrefix, right.getRowOffset() + rowCommonPrefix);
}

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

/**
 * Writes the row 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 rlength the row length
 * @throws IOException
 */
public static void writeRow(OutputStream out, Cell cell, short rlength) throws IOException {
 if (cell instanceof ByteBufferExtendedCell) {
  ByteBufferUtils.copyBufferToStream(out, ((ByteBufferExtendedCell) cell).getRowByteBuffer(),
   ((ByteBufferExtendedCell) cell).getRowPosition(), rlength);
 } else {
  out.write(cell.getRowArray(), cell.getRowOffset(), rlength);
 }
}

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

/**
 * Compares the row of two keyvalues for equality
 * @param left
 * @param right
 * @return True if rows match.
 */
public static boolean matchingRows(final Cell left, final Cell right) {
 short lrowlength = left.getRowLength();
 short rrowlength = right.getRowLength();
 if (lrowlength != rrowlength) return false;
 if (left instanceof ByteBufferExtendedCell && right instanceof ByteBufferExtendedCell) {
  return ByteBufferUtils.equals(((ByteBufferExtendedCell) left).getRowByteBuffer(),
    ((ByteBufferExtendedCell) left).getRowPosition(), lrowlength,
    ((ByteBufferExtendedCell) right).getRowByteBuffer(),
    ((ByteBufferExtendedCell) right).getRowPosition(), rrowlength);
 }
 if (left instanceof ByteBufferExtendedCell) {
  return ByteBufferUtils.equals(((ByteBufferExtendedCell) left).getRowByteBuffer(),
    ((ByteBufferExtendedCell) left).getRowPosition(), lrowlength, right.getRowArray(),
    right.getRowOffset(), rrowlength);
 }
 if (right instanceof ByteBufferExtendedCell) {
  return ByteBufferUtils.equals(((ByteBufferExtendedCell) right).getRowByteBuffer(),
    ((ByteBufferExtendedCell) right).getRowPosition(), rrowlength, left.getRowArray(),
    left.getRowOffset(), lrowlength);
 }
 return Bytes.equals(left.getRowArray(), left.getRowOffset(), lrowlength, right.getRowArray(),
   right.getRowOffset(), rrowlength);
}

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

@Override
public int compareRows(final Cell left, final Cell right) {
 return compareRows(left.getRowArray(), left.getRowOffset(), left.getRowLength(),
   right.getRowArray(), right.getRowOffset(), right.getRowLength());
}

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

/**
 * Converts the rowkey bytes of the given cell into an int value
 * @param cell
 * @return rowkey as int
 */
public static int getRowAsInt(Cell cell) {
 if (cell instanceof ByteBufferExtendedCell) {
  return ByteBufferUtils.toInt(((ByteBufferExtendedCell) cell).getRowByteBuffer(),
   ((ByteBufferExtendedCell) cell).getRowPosition());
 }
 return Bytes.toInt(cell.getRowArray(), cell.getRowOffset());
}

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

@Override
 public Entry filter(Entry entry) {
  ArrayList<Cell> cells = entry.getEdit().getCells();
  int size = cells.size();
  for (int i = size-1; i >= 0; i--) {
   Cell cell = cells.get(i);
   if (!Bytes.equals(cell.getRowArray(), cell.getRowOffset(), cell.getRowLength(),
    row, 0, row.length)) {
    cells.remove(i);
   }
  }
  return entry;
 }
});

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

/**
  * Override the row key comparison to parse and compare the meta row key parts.
  */
 @Override
 protected int compareRowKey(final Cell l, final Cell r) {
  byte[] left = l.getRowArray();
  int loffset = l.getRowOffset();
  int llength = l.getRowLength();
  byte[] right = r.getRowArray();
  int roffset = r.getRowOffset();
  int rlength = r.getRowLength();
  return compareRows(left, loffset, llength, right, roffset, rlength);
 }
}

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

@Override
 public ReturnCode filterCell(Cell c) throws IOException {
  if (Bytes.toInt(c.getRowArray(), c.getRowOffset()) == 999) {
   return ReturnCode.INCLUDE;
  } else {
   return ReturnCode.NEXT_ROW;
  }
 }
}

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

public static boolean matchingRowColumnBytes(final Cell left, final Cell right) {
 int lrowlength = left.getRowLength();
 int rrowlength = right.getRowLength();
 int lfamlength = left.getFamilyLength();
 int rfamlength = right.getFamilyLength();
 int lqlength = left.getQualifierLength();
 int rqlength = right.getQualifierLength();
 // match length
 if ((lrowlength + lfamlength + lqlength) !=
   (rrowlength + rfamlength + rqlength)) {
  return false;
 }
 // match row
 if (!Bytes.equals(left.getRowArray(), left.getRowOffset(), lrowlength, right.getRowArray(),
   right.getRowOffset(), rrowlength)) {
  return false;
 }
 //match family
 if (!Bytes.equals(left.getFamilyArray(), left.getFamilyOffset(), lfamlength,
   right.getFamilyArray(), right.getFamilyOffset(), rfamlength)) {
  return false;
 }
 //match qualifier
 return Bytes.equals(left.getQualifierArray(), left.getQualifierOffset(),
   lqlength, right.getQualifierArray(), right.getQualifierOffset(),
   rqlength);
}

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

@Override
public int compareRows(Cell left, byte[] right, int roffset, int rlength) {
 return compareRows(left.getRowArray(), left.getRowOffset(), left.getRowLength(), right,
   roffset, rlength);
}

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

@Override
public void filterRowCells(List<Cell> kvs) throws IOException {
 Cell c = kvs.get(0);
 exclude = Bytes.toInt(c.getRowArray(), c.getRowOffset()) != 999;
}

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

private static void doAssert(byte[] row) throws Exception {
 if (ReplicationEndpointForTest.lastEntries == null) {
  return; // first call
 }
 Assert.assertEquals(1, ReplicationEndpointForTest.lastEntries.size());
 List<Cell> cells = ReplicationEndpointForTest.lastEntries.get(0).getEdit().getCells();
 Assert.assertEquals(1, cells.size());
 Assert.assertTrue(Bytes.equals(cells.get(0).getRowArray(), cells.get(0).getRowOffset(),
  cells.get(0).getRowLength(), row, 0, row.length));
}

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

public AggrKey getAggrKey(List<Cell> rowCells) {
  Cell cell = rowCells.get(0);
  assert groupByMask.length == cell.getRowLength();
  aggrKey.set(cell.getRowArray(), cell.getRowOffset());
  return aggrKey;
}

相关文章