/** * Converts cell to backup set list. * @param current current cell * @return backup set as array of table names */ private String[] cellValueToBackupSet(Cell current) { byte[] data = CellUtil.cloneValue(current); if (!ArrayUtils.isEmpty(data)) { return Bytes.toString(data).split(","); } return new String[0]; }
/** * Returns the value of the first column in the Result. * @return value of the first column */ public byte [] value() { if (isEmpty()) { return null; } return CellUtil.cloneValue(cells[0]); }
@Override public ByteBuffer getValueByteBuffer() { if (cell instanceof ByteBufferExtendedCell) { return ((ByteBufferExtendedCell) this.cell).getValueByteBuffer(); } else { return ByteBuffer.wrap(CellUtil.cloneValue(this.cell)); } }
/** * Converts cell to backup info instance. * @param current current cell * @return backup backup info instance * @throws IOException exception */ private BackupInfo cellToBackupInfo(Cell current) throws IOException { byte[] data = CellUtil.cloneValue(current); return BackupInfo.fromByteArray(data); }
@Override public BigDecimal getValue(byte[] colFamily, byte[] colQualifier, Cell kv) throws IOException { if (kv == null || CellUtil.cloneValue(kv) == null) { return null; } return PrivateCellUtil.getValueAsBigDecimal(kv).setScale(2, RoundingMode.HALF_EVEN); }
@Override public List<Values> toValues(ITuple tuple, Result result) throws Exception { List<Values> values = new ArrayList<Values>(); Cell[] cells = result.rawCells(); for (Cell cell : cells) { Values value = new Values(Bytes.toString(CellUtil.cloneQualifier(cell)), Bytes.toLong(CellUtil.cloneValue(cell))); values.add(value); } return values; }
public static FlushDescriptor getFlushDescriptor(Cell cell) throws IOException { if (CellUtil.matchingColumn(cell, METAFAMILY, FLUSH)) { return FlushDescriptor.parseFrom(CellUtil.cloneValue(cell)); } return null; }
/** * Deserialized and returns a CompactionDescriptor is the KeyValue contains one. * @param kv the key value * @return deserialized CompactionDescriptor or null. */ public static CompactionDescriptor getCompaction(Cell kv) throws IOException { if (isCompactionMarker(kv)) { return CompactionDescriptor.parseFrom(CellUtil.cloneValue(kv)); } return null; }
/** * Deserialized and returns a BulkLoadDescriptor from the passed in Cell * @param cell the key value * @return deserialized BulkLoadDescriptor or null. */ public static WALProtos.BulkLoadDescriptor getBulkLoadDescriptor(Cell cell) throws IOException { if (CellUtil.matchingColumn(cell, METAFAMILY, BULK_LOAD)) { return WALProtos.BulkLoadDescriptor.parseFrom(CellUtil.cloneValue(cell)); } return null; }
public static RegionEventDescriptor getRegionEventDescriptor(Cell cell) throws IOException { if (CellUtil.matchingColumn(cell, METAFAMILY, REGION_EVENT)) { return RegionEventDescriptor.parseFrom(CellUtil.cloneValue(cell)); } return null; }
/** * Constructor from KeyValue * @param cell */ public CellModel(org.apache.hadoop.hbase.Cell cell) { this(CellUtil.cloneFamily(cell), CellUtil.cloneQualifier(cell), cell.getTimestamp(), CellUtil .cloneValue(cell)); }
private static void assertRowAndValue(Result r, byte[] row, byte[] value) { for (Cell c : r.rawCells()) { assertTrue(Bytes.equals(CellUtil.cloneRow(c), row)); assertTrue(Bytes.equals(CellUtil.cloneValue(c), value)); } }
private void checkResult(Result r, byte[] fam, byte[] col, byte[] ... vals) { assertEquals(r.size(), vals.length); List<Cell> kvs = r.getColumnCells(fam, col); assertEquals(kvs.size(), vals.length); for (int i=0;i<vals.length;i++) { assertArrayEquals(CellUtil.cloneValue(kvs.get(i)), vals[i]); } }
static void assertGet(final HRegion r, final byte[] family, final byte[] k) throws IOException { // Now I have k, get values out and assert they are as expected. Get get = new Get(k).addFamily(family).setMaxVersions(); Cell[] results = r.get(get).rawCells(); for (int j = 0; j < results.length; j++) { byte[] tmp = CellUtil.cloneValue(results[j]); // Row should be equal to value every time. assertTrue(Bytes.equals(k, tmp)); } }
private static void assertResult(Result result, byte[] expectedValue) { assertFalse(result.isEmpty()); for (Cell c : result.rawCells()) { assertTrue(c.toString(), Bytes.equals(ROW, CellUtil.cloneRow(c))); assertTrue(c.toString(), Bytes.equals(FAMILY, CellUtil.cloneFamily(c))); assertTrue(c.toString(), Bytes.equals(expectedValue, CellUtil.cloneValue(c))); } }
/** * Assert the value is not store in mob. */ private static void assertNotMobReference(Cell cell, byte[] row, byte[] family, byte[] value) throws IOException { Assert.assertArrayEquals(row, CellUtil.cloneRow(cell)); Assert.assertArrayEquals(family, CellUtil.cloneFamily(cell)); Assert.assertArrayEquals(value, CellUtil.cloneValue(cell)); }
private static void assertGet(final HRegion region, byte [] row, byte [] familiy, byte[] qualifier, byte[] value) throws IOException { // run a get and see if the value matches Get get = new Get(row); get.addColumn(familiy, qualifier); Result result = region.get(get); assertEquals(1, result.size()); Cell kv = result.rawCells()[0]; byte[] r = CellUtil.cloneValue(kv); assertTrue(Bytes.compareTo(r, value) == 0); }
private static void assertOnlyLatest(final Table incommon, final long currentTime) throws IOException { Get get = null; get = new Get(ROW); get.addColumn(FAMILY_NAME, QUALIFIER_NAME); get.setMaxVersions(3); Result result = incommon.get(get); Assert.assertEquals(1, result.size()); long time = Bytes.toLong(CellUtil.cloneValue(result.rawCells()[0])); Assert.assertEquals(time, currentTime); }
private Cell newCellWithNotExistColumnFamily(Cell cell) { return ExtendedCellBuilderFactory.create(CellBuilderType.SHALLOW_COPY) .setRow(cell.getRowArray(), cell.getRowOffset(), cell.getRowLength()) .setFamily(CF_NOT_EXIST_BYTES, 0, CF_NOT_EXIST_BYTES.length) .setQualifier(CellUtil.cloneQualifier(cell)).setTimestamp(cell.getTimestamp()) .setType(cell.getType().getCode()).setValue(CellUtil.cloneValue(cell)).build(); }
private Cell newCellWithDifferentColumnFamily(Cell cell) { return ExtendedCellBuilderFactory.create(CellBuilderType.SHALLOW_COPY) .setRow(cell.getRowArray(), cell.getRowOffset(), cell.getRowLength()) .setFamily(CF2_BYTES, 0, CF2_BYTES.length).setQualifier(CellUtil.cloneQualifier(cell)) .setTimestamp(cell.getTimestamp()).setType(cell.getType().getCode()) .setValue(CellUtil.cloneValue(cell)).build(); }