@Override public Result preIncrement(ObserverContext<RegionCoprocessorEnvironment> c, Increment increment) throws IOException { increment.add(createCustomCell(increment)); COUNT.incrementAndGet(); return null; }
@Test public void testIncrementCopyConstructor() throws IOException { Increment origin = new Increment(Bytes.toBytes("ROW-01")); origin.setPriority(100); byte[] family = Bytes.toBytes("CF-01"); origin.add(CellBuilderFactory.create(CellBuilderType.SHALLOW_COPY) .setRow(origin.getRow()) .setFamily(family) .setQualifier(Bytes.toBytes("q")) .setType(Cell.Type.Put) .setValue(Bytes.toBytes(100)) .build()); origin.addColumn(family, Bytes.toBytes("q0"), 4); origin.setTimeRange(100, 1000); Increment clone = new Increment(origin); assertEquals(origin, clone); origin.addColumn(family, Bytes.toBytes("q1"), 3); //They should have different cell lists assertNotEquals(origin.getCellList(family), clone.getCellList(family)); }
increment.add(new KeyValue(row1, f, q, 1234L, v)); increment.setAttribute("visibility", Bytes.toBytes("tag2")); table.increment(increment); table.put(put); increment = new Increment(row2); increment.add(new KeyValue(row2, f, q, 1234L, v)); increment.setAttribute("visibility", Bytes.toBytes("tag2")); table.increment(increment);
@Test public void testIncrementWithCustomTimestamp() throws IOException { TableName TABLENAME = TableName.valueOf(name.getMethodName()); Table table = TEST_UTIL.createTable(TABLENAME, FAMILY); long timestamp = 999; Increment increment = new Increment(ROW); increment.add(CellUtil.createCell(ROW, FAMILY, QUALIFIER, timestamp, KeyValue.Type.Put.getCode(), Bytes.toBytes(100L))); Result r = table.increment(increment); assertEquals(1, r.size()); assertEquals(timestamp, r.rawCells()[0].getTimestamp()); r = table.get(new Get(ROW)); assertEquals(1, r.size()); assertEquals(timestamp, r.rawCells()[0].getTimestamp()); r = table.increment(increment); assertEquals(1, r.size()); assertNotEquals(timestamp, r.rawCells()[0].getTimestamp()); r = table.get(new Get(ROW)); assertEquals(1, r.size()); assertNotEquals(timestamp, r.rawCells()[0].getTimestamp()); }
@Test public void testIncrementCopyConstructor() throws IOException { Increment origin = new Increment(Bytes.toBytes("ROW-01")); origin.setPriority(100); byte[] family = Bytes.toBytes("CF-01"); origin.add(CellBuilderFactory.create(CellBuilderType.SHALLOW_COPY) .setRow(origin.getRow()) .setFamily(family) .setQualifier(Bytes.toBytes("q")) .setType(Cell.Type.Put) .setValue(Bytes.toBytes(100)) .build()); origin.addColumn(family, Bytes.toBytes("q0"), 4); origin.setTimeRange(100, 1000); Increment clone = new Increment(origin); assertEquals(origin, clone); origin.addColumn(family, Bytes.toBytes("q1"), 3); //They should have different cell lists assertNotEquals(origin.getCellList(family), clone.getCellList(family)); }
KeyValue.Type.Put, incValue, 0, incValue.length); inc.add(cell); } catch (IOException e) { throw new RuntimeException(e); // Impossible
increment.add(new KeyValue(row1, f, q, 1234L, v)); increment.setAttribute("visibility", Bytes.toBytes("tag2")); table.increment(increment); table.put(put); increment = new Increment(row2); increment.add(new KeyValue(row2, f, q, 1234L, v)); increment.setAttribute("visibility", Bytes.toBytes("tag2")); table.increment(increment);
@Override public Result preIncrement(ObserverContext<RegionCoprocessorEnvironment> c, Increment increment) throws IOException { increment.add(createCustomCell(increment)); COUNT.incrementAndGet(); return null; }
@Override public IncrementBuilder add(byte[] family, byte[] qualifier, long ts, long value) throws IOException { increment.add(new KeyValue(increment.getRow(), family, qualifier, ts, Bytes.toBytes(value))); return this; }
@Override public IncrementBuilder add(byte[] family, byte[] qualifier, long ts, long value) throws IOException { increment.add(new KeyValue(increment.getRow(), family, qualifier, ts, Bytes.toBytes(value))); return this; }
KeyValue.Type.Put, incValue, 0, incValue.length); inc.add(cell); } catch (IOException e) { throw new RuntimeException(e); // Impossible
KeyValue.Type.Put, incValue, 0, incValue.length); inc.add(cell); } catch (IOException e) { throw new RuntimeException(e); // Impossible
@Test public void testIncrementWithCustomTimestamp() throws IOException { TableName TABLENAME = TableName.valueOf(name.getMethodName()); Table table = TEST_UTIL.createTable(TABLENAME, FAMILY); long timestamp = 999; Increment increment = new Increment(ROW); increment.add(CellUtil.createCell(ROW, FAMILY, QUALIFIER, timestamp, KeyValue.Type.Put.getCode(), Bytes.toBytes(100L))); Result r = table.increment(increment); assertEquals(1, r.size()); assertEquals(timestamp, r.rawCells()[0].getTimestamp()); r = table.get(new Get(ROW)); assertEquals(1, r.size()); assertEquals(timestamp, r.rawCells()[0].getTimestamp()); r = table.increment(increment); assertEquals(1, r.size()); assertNotEquals(timestamp, r.rawCells()[0].getTimestamp()); r = table.get(new Get(ROW)); assertEquals(1, r.size()); assertNotEquals(timestamp, r.rawCells()[0].getTimestamp()); }