@Override public Void run() throws Exception { List<Increment> processedIncrements; if (batchIncrements) { processedIncrements = coalesceIncrements(incs); } else { processedIncrements = incs; } // Only used for unit testing. if (debugIncrCallback != null) { debugIncrCallback.onAfterCoalesce(processedIncrements); } for (final Increment i : processedIncrements) { i.setWriteToWAL(enableWal); table.increment(i); } return null; } });
Increment inc = new Increment(ROW); inc.addColumn(TEST_UTIL.fam1, QUALIFIER, 1); Result result = table.increment(inc);
@Override public Result call() throws IOException { return normalHTable.increment(increment); } });
@Override public Result increment(Increment increment) throws IOException { return table.increment(increment); }
@Override public Result increment(Increment increment) throws IOException { return getTable().increment(increment); }
private void flushToHBase() throws IOException { synchronized(hTable) { if (hTable == null) { initialize(); } updateLastUsed(); for (Entry<String, CounterMap> entry: rowKeyCounterMap.entrySet()) { CounterMap pastCounterMap = entry.getValue(); rowKeyCounterMap.put(entry.getKey(), new CounterMap()); Increment increment = new Increment(Bytes.toBytes(entry.getKey())); boolean hasColumns = false; for (Entry<String, Counter> entry2 : pastCounterMap.entrySet()) { increment.addColumn(Bytes.toBytes(columnFamily), Bytes.toBytes(entry2.getKey()), entry2.getValue().value); hasColumns = true; } if (hasColumns) { updateLastUsed(); hTable.increment(increment); } } updateLastUsed(); } }
/** {@inheritDoc} */ @Override public void execute(Tuple input) { try { this.connector.getTable().increment( conf.getIncrementFromTuple(input, TupleTableConfig.DEFAULT_INCREMENT)); } catch (IOException ex) { throw new RuntimeException(ex); } if (this.autoAck) { this.collector.ack(input); } }
@Override public Void run() throws Exception { List<Increment> processedIncrements; if (batchIncrements) { processedIncrements = coalesceIncrements(incs); } else { processedIncrements = incs; } // Only used for unit testing. if (debugIncrCallback != null) { debugIncrCallback.onAfterCoalesce(processedIncrements); } for (final Increment i : processedIncrements) { i.setWriteToWAL(enableWal); table.increment(i); } return null; } });
@Override public long incrementAndGet(byte[] row, byte[] column, long delta) { byte[] distributedKey = createDistributedRowKey(row); Increment increment = new Increment(distributedKey); increment.addColumn(columnFamily, column, delta); try { Result result = hTable.increment(increment); return Bytes.toLong(result.getValue(columnFamily, column)); } catch (IOException e) { // figure out whether this is an illegal increment // currently there is not other way to extract that from the HBase exception than string match if (e.getMessage() != null && e.getMessage().contains("isn't 64 bits wide")) { throw new NumberFormatException("Attempted to increment a value that is not convertible to long," + " row: " + Bytes.toStringBinary(distributedKey) + " column: " + Bytes.toStringBinary(column)); } throw new DataSetException("IncrementAndGet failed on table " + tableId, e); } }
@Override public long incrementAndGet(byte[] row, byte[] column, long delta) { byte[] distributedKey = createDistributedRowKey(row); Increment increment = new Increment(distributedKey); increment.addColumn(columnFamily, column, delta); try { Result result = hTable.increment(increment); return Bytes.toLong(result.getValue(columnFamily, column)); } catch (IOException e) { // figure out whether this is an illegal increment // currently there is not other way to extract that from the HBase exception than string match if (e.getMessage() != null && e.getMessage().contains("isn't 64 bits wide")) { throw new NumberFormatException("Attempted to increment a value that is not convertible to long," + " row: " + Bytes.toStringBinary(distributedKey) + " column: " + Bytes.toStringBinary(column)); } throw new DataSetException("IncrementAndGet failed on table " + tableId, e); } }
@Override public void increment(TIncrement tincrement) throws IOError, TException { if (tincrement.getRow().length == 0 || tincrement.getTable().length == 0) { throw new TException("Must supply a table and a row key; can't increment"); } if (conf.getBoolean(COALESCE_INC_KEY, false)) { this.coalescer.queueIncrement(tincrement); return; } try { HTable table = getTable(tincrement.getTable()); Increment inc = ThriftUtilities.incrementFromThrift(tincrement); table.increment(inc); } catch (IOException e) { LOG.warn(e.getMessage(), e); throw new IOError(e.getMessage()); } }
Increment inc = new Increment(ROW); inc.addColumn(TEST_UTIL.fam1, QUALIFIER, 1); Result result = table.increment(inc);