MCPcopy Index your code
hub / github.com/OpenTSDB/asynchbase / bufferMultiColumnAtomicIncrement

Method bufferMultiColumnAtomicIncrement

src/HBaseClient.java:1736–1772  ·  view source on GitHub ↗

Buffers a durable atomic increment for coalescing. This increment will be held in memory up to the amount of time allowed by #getFlushInterval in order to allow the client to coalesce increments. Increment coalescing can dramatically reduce the number of RPCs and write load on HBase

(final MultiColumnAtomicIncrementRequest request)

Source from the content-addressed store, hash-verified

1734 * @since 1.4 This method works with negative increment values.
1735 */
1736 public Deferred<Map<byte[], Long>> bufferMultiColumnAtomicIncrement(final MultiColumnAtomicIncrementRequest request) {
1737
1738 if (flush_interval == 0) { // Client-side buffer disabled.
1739 return atomicIncrement(request);
1740 }
1741
1742 long[] values = request.getAmounts();
1743 for(long value: values) {
1744 if (!BufferedIncrement.Amount.checkOverflow(value)) { // Value too large
1745 return atomicIncrement(request);
1746 }
1747 }
1748
1749 final BufferedMultiColumnIncrement incr = new BufferedMultiColumnIncrement(request.table(), request.key(), request.family(),
1750 request.qualifiers());
1751
1752 do {
1753 BufferedMultiColumnIncrement.Amounts amounts;
1754 // Semi-evil: the very first time we get here, `increment_buffer' will
1755 // still be null (we don't initialize it in our constructor) so we catch
1756 // the NPE that ensues to allocate the buffer and kick off a timer to
1757 // regularly flush it.
1758 try {
1759 amounts = multi_column_increment_buffer.getUnchecked(incr);
1760 } catch (NullPointerException e) {
1761 setupMultiColumnIncrementCoalescing();
1762 amounts = multi_column_increment_buffer.getUnchecked(incr);
1763 }
1764 if (amounts.update(values)) {
1765 final Deferred<Map<byte[], Long>> deferred = new Deferred<Map<byte[], Long>>();
1766 amounts.deferred.chain(deferred);
1767 return deferred;
1768 }
1769 // else: Loop again to retry.
1770 multi_column_increment_buffer.refresh(incr);
1771 } while (true);
1772 }
1773
1774 /**
1775 * Called the first time we get a buffered increment.

Callers 2

micvMethod · 0.80

Calls 9

atomicIncrementMethod · 0.95
getAmountsMethod · 0.80
tableMethod · 0.65
keyMethod · 0.65
familyMethod · 0.65
qualifiersMethod · 0.65
checkOverflowMethod · 0.45
updateMethod · 0.45

Tested by 2

micvMethod · 0.64