@Override public void increment(NavigableMap<byte[], NavigableMap<byte[], Long>> updates) { v3HBaseTable.increment(updates); }
@Override public void increment(byte[] row, Map<byte[], Long> increments) { v3HBaseTable.increment(row, increments); }
@Override public void apply() { delegate.increment(row, increments); } });
@Override public void apply() { delegate.increment(updates); } });
public void run() { while (rounds-- > 0) { try { table.increment(row, incrememts); } catch (Exception e) { System.err.println("exception for increment #" + rounds + ": " + e.getMessage()); e.printStackTrace(); } } }
v3MetricsTable.increment(rowIncrements);
@Test public void testDeleteIncrements() throws Exception { // note: this is pretty important test case for tables with counters, e.g. metrics MetricsTable table = getTable("testDeleteIncrements"); // delete increment and increment again table.increment(A, ImmutableMap.of(B, 5L)); table.increment(A, ImmutableMap.of(B, 2L)); Assert.assertEquals(7L, Bytes.toLong(table.get(A, B))); table.delete(A, new byte[][]{B}); Assert.assertNull(table.get(A, B)); table.increment(A, ImmutableMap.of(B, 3L)); Assert.assertEquals(3L, Bytes.toLong(table.get(A, B))); }
public void add(List<Fact> facts) { // Simply collecting all rows/cols/values that need to be put to the underlying table. NavigableMap<byte[], NavigableMap<byte[], byte[]>> gaugesTable = Maps.newTreeMap(Bytes.BYTES_COMPARATOR); NavigableMap<byte[], NavigableMap<byte[], byte[]>> incrementsTable = Maps.newTreeMap(Bytes.BYTES_COMPARATOR); for (Fact fact : facts) { for (Measurement measurement : fact.getMeasurements()) { byte[] rowKey = codec.createRowKey(fact.getDimensionValues(), measurement.getName(), fact.getTimestamp()); byte[] column = codec.createColumn(fact.getTimestamp()); if (MeasureType.COUNTER == measurement.getType()) { inc(incrementsTable, rowKey, column, measurement.getValue()); } else { set(gaugesTable, rowKey, column, Bytes.toBytes(measurement.getValue())); } } } NavigableMap<byte[], NavigableMap<byte[], Long>> convertedIncrementsTable = Maps.transformValues(incrementsTable, TRANSFORM_MAP_BYTE_ARRAY_TO_LONG); NavigableMap<byte[], NavigableMap<byte[], Long>> convertedGaugesTable = Maps.transformValues(gaugesTable, TRANSFORM_MAP_BYTE_ARRAY_TO_LONG); // todo: replace with single call, to be able to optimize rpcs in underlying table timeSeriesTable.put(convertedGaugesTable); timeSeriesTable.increment(convertedIncrementsTable); if (metrics != null) { metrics.increment(putCountMetric, convertedGaugesTable.size()); metrics.increment(incrementCountMetric, convertedIncrementsTable.size()); } }
timeSeriesTable.increment(incrementsTable); if (metrics != null) { metrics.increment(putCountMetric, gaugesTable.size());