@WriteOnly @Override public void delete(byte[] row, byte[][] columns) { ensureTransactionIsStarted(); if (columns == null) { delete(row); return; } // Do not delete anything when columns list is empty. Return-fast shortcut if (columns.length == 0) { return; } // same as writing null for every column // ANDREAS: shouldn't this be DELETE_MARKER? putInternal(row, columns, new byte[columns.length][]); // "0" because we don't know what gets deleted reportWrite(1, 0); }
@WriteOnly @Override public void delete(byte[] row, byte[][] columns) { ensureTransactionIsStarted(); if (columns == null) { delete(row); return; } // Do not delete anything when columns list is empty. Return-fast shortcut if (columns.length == 0) { return; } // same as writing null for every column // ANDREAS: shouldn't this be DELETE_MARKER? putInternal(row, columns, new byte[columns.length][]); // "0" because we don't know what gets deleted reportWrite(1, 0); }
/** * NOTE: if value is null corresponded column is deleted. It will not be in result set when reading. * * Also see {@link co.cask.cdap.api.dataset.table.Table#put(byte[], byte[][], byte[][])}. */ @WriteOnly @Override public void put(byte[] row, byte[][] columns, byte[][] values) { ensureTransactionIsStarted(); putInternal(row, columns, values); // report metrics _after_ write was performed reportWrite(1, getSize(row) + getSize(columns) + getSize(values)); }
/** * NOTE: if value is null corresponded column is deleted. It will not be in result set when reading. * * Also see {@link co.cask.cdap.api.dataset.table.Table#put(byte[], byte[][], byte[][])}. */ @WriteOnly @Override public void put(byte[] row, byte[][] columns, byte[][] values) { ensureTransactionIsStarted(); putInternal(row, columns, values); // report metrics _after_ write was performed reportWrite(1, getSize(row) + getSize(columns) + getSize(values)); }
@ReadWrite @Override public boolean compareAndSwap(byte[] row, byte[] column, byte[] expectedValue, byte[] newValue) { ensureTransactionIsStarted(); // TODO: add support for empty values; see https://issues.cask.co/browse/TEPHRA-45 for details. if (newValue != null && newValue.length == 0) { warnAboutEmptyValue(column); } // NOTE: there is more efficient way to do it, but for now we want more simple implementation, not over-optimizing byte[][] columns = new byte[][]{column}; try { byte[] currentValue = getRowMap(row, columns).get(column); reportRead(1); if (Arrays.equals(expectedValue, currentValue)) { putInternal(row, columns, new byte[][]{newValue}); reportWrite(1, getSize(row) + getSize(column) + getSize(newValue)); return true; } } catch (Exception e) { LOG.debug("compareAndSwap failed for table: " + getTransactionAwareName() + ", row: " + Bytes.toStringBinary(row), e); throw new DataSetException("compareAndSwap failed", e); } return false; }
@ReadWrite @Override public boolean compareAndSwap(byte[] row, byte[] column, byte[] expectedValue, byte[] newValue) { ensureTransactionIsStarted(); // TODO: add support for empty values; see https://issues.cask.co/browse/TEPHRA-45 for details. if (newValue != null && newValue.length == 0) { warnAboutEmptyValue(column); } // NOTE: there is more efficient way to do it, but for now we want more simple implementation, not over-optimizing byte[][] columns = new byte[][]{column}; try { byte[] currentValue = getRowMap(row, columns).get(column); reportRead(1); if (Arrays.equals(expectedValue, currentValue)) { putInternal(row, columns, new byte[][]{newValue}); reportWrite(1, getSize(row) + getSize(column) + getSize(newValue)); return true; } } catch (Exception e) { LOG.debug("compareAndSwap failed for table: " + getTransactionAwareName() + ", row: " + Bytes.toStringBinary(row), e); throw new DataSetException("compareAndSwap failed", e); } return false; }
putInternal(row, columns, updatedValues); reportWrite(1, getSize(row) + getSize(columns) + getSize(amounts));
putInternal(row, columns, updatedValues); reportWrite(1, getSize(row) + getSize(columns) + getSize(amounts));