Refine search
/** * @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()); }
/** * @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); }
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); }
Cell nextCell = nextRowResult.rawCells()[0]; if (currentRow == null || !Bytes.equals(currentRow, 0, currentRow.length, nextCell.getRowArray(), nextCell.getRowOffset(), nextCell.getRowLength())) {
/********************* 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); }
/********************* 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]; }
Result result = results.next(); Cell cell = result.rawCells()[0]; if (Bytes.equals(currentRow, 0, currentRow.length, cell.getRowArray(), cell.getRowOffset(), cell.getRowLength())) {
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); }
/** * 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); } }
/** * 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); }
@Override public int compareRows(final Cell left, final Cell right) { return compareRows(left.getRowArray(), left.getRowOffset(), left.getRowLength(), right.getRowArray(), right.getRowOffset(), right.getRowLength()); }
/** * 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()); }
@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; } });
/** * 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); } }
@Override public ReturnCode filterCell(Cell c) throws IOException { if (Bytes.toInt(c.getRowArray(), c.getRowOffset()) == 999) { return ReturnCode.INCLUDE; } else { return ReturnCode.NEXT_ROW; } } }
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); }
@Override public int compareRows(Cell left, byte[] right, int roffset, int rlength) { return compareRows(left.getRowArray(), left.getRowOffset(), left.getRowLength(), right, roffset, rlength); }
@Override public void filterRowCells(List<Cell> kvs) throws IOException { Cell c = kvs.get(0); exclude = Bytes.toInt(c.getRowArray(), c.getRowOffset()) != 999; }
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)); }
public AggrKey getAggrKey(List<Cell> rowCells) { Cell cell = rowCells.get(0); assert groupByMask.length == cell.getRowLength(); aggrKey.set(cell.getRowArray(), cell.getRowOffset()); return aggrKey; }