@Override public void abort() { try { super.abort(); } finally { if (log.isDebugEnabled()) { log.debug("CachingTransaction cache stats on abort: {}", cellCache.stats()); } } } }
@Override public void commit() throws TransactionFailedException { try { super.commit(); } finally { if (log.isDebugEnabled()) { log.debug("CachingTransaction cache stats on commit: {}", cellCache.stats()); } } }
@Override public TransactionType getTransactionType() { return delegate().getTransactionType(); } }
@Override public void delete(TableReference tableRef, Set<Cell> keys) { // Map deletes into writes of zero-length byte arrays (this is in // accordance with the semantics of our transaction API). Map<Cell, byte[]> values = Maps.newHashMap(); for (Cell c : keys) { values.put(c, new byte[0]); } validateWrites(tableRef, values); super.delete(tableRef, keys); }
@Override public void put(TableReference tableRef, Map<Cell, byte[]> values) { super.put(tableRef, values); addToCache(tableRef, values); }
@Override public Map<Cell, byte[]> get(TableReference tableRef, Set<Cell> cells) { if (cells.isEmpty()) { return ImmutableMap.of(); } Set<Cell> toLoad = Sets.newHashSet(); Map<Cell, byte[]> cacheHit = Maps.newHashMapWithExpectedSize(cells.size()); for (Cell cell : cells) { byte[] val = getCachedCellIfPresent(tableRef, cell); if (val != null) { if (val.length > 0) { cacheHit.put(cell, val); } } else { toLoad.add(cell); } } final Map<Cell, byte[]> loaded = super.get(tableRef, toLoad); cacheLoadedCells(tableRef, toLoad, loaded); cacheHit.putAll(loaded); return cacheHit; }
SortedMap<byte[], RowResult<byte[]>> loaded = super.getRows(tableRef, rows, columnSelection); cacheLoadedRows(tableRef, loaded.values()); return loaded; SortedMap<byte[], RowResult<byte[]>> results = super.getRows(tableRef, toLoad, columnSelection); cacheLoadedRows(tableRef, results.values()); inCache.putAll(results);
@Override public final void delete(TableReference tableRef, Set<Cell> cells) { super.delete(tableRef, cells); addToCache(tableRef, Cells.constantValueMap(cells, PtBytes.EMPTY_BYTE_ARRAY)); }
@Override public void put(TableReference tableRef, Map<Cell, byte[]> values) { validateWrites(tableRef, values); super.put(tableRef, values); }
@Override public Map<Cell, byte[]> get(TableReference tableRef, Set<Cell> cells) { if (cells.isEmpty()) { return ImmutableMap.of(); } Set<Cell> toLoad = Sets.newHashSet(); Map<Cell, byte[]> cacheHit = Maps.newHashMapWithExpectedSize(cells.size()); for (Cell cell : cells) { byte[] val = getCachedCellIfPresent(tableRef, cell); if (val != null) { if (val.length > 0) { cacheHit.put(cell, val); } } else { toLoad.add(cell); } } final Map<Cell, byte[]> loaded = super.get(tableRef, toLoad); cacheLoadedCells(tableRef, toLoad, loaded); cacheHit.putAll(loaded); return cacheHit; }
SortedMap<byte[], RowResult<byte[]>> loaded = super.getRows(tableRef, rows, columnSelection); cacheLoadedRows(tableRef, loaded.values()); return loaded; SortedMap<byte[], RowResult<byte[]>> results = super.getRows(tableRef, toLoad, columnSelection); cacheLoadedRows(tableRef, results.values()); inCache.putAll(results);
@Override public SortedMap<byte[], RowResult<byte[]>> getRows(TableReference tableRef, Iterable<byte[]> rows, ColumnSelection columnSelection) { return delegate().getRows(tableRef, rows, columnSelection); }
@Override public void delete(TableReference tableRef, Set<Cell> keys) { if (isTraceEnabled()) { for (Cell key : keys) { trace( "DELETE: timestamp=%d table=%s row=%s column=%s", delegate.getTimestamp(), tableRef, toHex(key.getRowName()), toHex(key.getColumnName())); } } super.delete(tableRef, keys); }
@Override public void commit(TransactionService txService) throws TransactionFailedException { try { super.commit(txService); } finally { if (log.isDebugEnabled()) { log.debug("CachingTransaction cache stats on commit(txService): {}", cellCache.stats()); } } }
@Override public void put(TableReference tableRef, Map<Cell, byte[]> values) { if (isTraceEnabled()) { for (Map.Entry<Cell, byte[]> e : values.entrySet()) { Cell key = e.getKey(); byte[] value = e.getValue(); trace( "PUT: timestamp=%d table=%s row=%s column=%s value=%s", delegate.getTimestamp(), tableRef, toHex(key.getRowName()), toHex(key.getColumnName()), toHex(value)); } } super.put(tableRef, values); }
@Override public void abort() { if (isTraceEnabled()) { trace(String.format("ABORT: timestamp=%d", delegate.getTimestamp())); } super.abort(); }
@Override public Iterator<Entry<Cell, byte[]>> getRowsColumnRange(TableReference tableRef, Iterable<byte[]> rows, ColumnRangeSelection columnRangeSelection, int batchHint) { return delegate().getRowsColumnRange(tableRef, rows, columnRangeSelection, batchHint); }
@Override public void delete(TableReference tableRef, Set<Cell> keys) { // Map deletes into writes of zero-length byte arrays (this is in // accordance with the semantics of our transaction API). Map<Cell, byte[]> values = Maps.newHashMap(); for (Cell c : keys) { values.put(c, new byte[0]); } validateWrites(tableRef, values); super.delete(tableRef, keys); }
@Override public void commit() { if (isTraceEnabled()) { trace(String.format("COMMIT: timestamp=%d", delegate.getTimestamp())); } super.commit(); }
@Override public void put(TableReference tableRef, Map<Cell, byte[]> values) { validateWrites(tableRef, values); super.put(tableRef, values); }