/** * NOTE: Depending on the use-case, calling this method may be much less efficient than calling same method * with columns as parameters because it will require a round trip to persistent store. */ @WriteOnly @Override public void delete(byte[] row) { ensureTransactionIsStarted(); // this is going to be expensive, but the only we can do as delete implementation act on per-column level try { Map<byte[], byte[]> rowMap = getRowMap(row); delete(row, rowMap.keySet().toArray(new byte[rowMap.keySet().size()][])); // "0" because we don't know what gets deleted reportWrite(1, 0); } catch (Exception e) { LOG.debug("delete failed for table: " + getTransactionAwareName() + ", row: " + Bytes.toStringBinary(row), e); throw new DataSetException("delete failed", e); } }
/** * NOTE: Depending on the use-case, calling this method may be much less efficient than calling same method * with columns as parameters because it will require a round trip to persistent store. */ @WriteOnly @Override public void delete(byte[] row) { ensureTransactionIsStarted(); // this is going to be expensive, but the only we can do as delete implementation act on per-column level try { Map<byte[], byte[]> rowMap = getRowMap(row); delete(row, rowMap.keySet().toArray(new byte[rowMap.keySet().size()][])); // "0" because we don't know what gets deleted reportWrite(1, 0); } catch (Exception e) { LOG.debug("delete failed for table: " + getTransactionAwareName() + ", row: " + Bytes.toStringBinary(row), e); throw new DataSetException("delete failed", e); } }
@ReadOnly @Override public Row get(byte[] row, byte[][] columns) { ensureTransactionIsStarted(); reportRead(1); try { return new Result(row, getRowMap(row, columns)); } catch (Exception e) { LOG.debug("get failed for table: " + getTransactionAwareName() + ", row: " + Bytes.toStringBinary(row), e); throw new DataSetException("get failed", e); } }
@ReadOnly @Override public Row get(byte[] row, byte[][] columns) { ensureTransactionIsStarted(); reportRead(1); try { return new Result(row, getRowMap(row, columns)); } catch (Exception e) { LOG.debug("get failed for table: " + getTransactionAwareName() + ", row: " + Bytes.toStringBinary(row), e); throw new DataSetException("get failed", e); } }
/** * NOTE: Depending on the use-case, calling this method may be much less * efficient than calling same method with columns as parameters because it may always require round trip to * persistent store */ @ReadOnly @Override public Row get(byte[] row) { ensureTransactionIsStarted(); reportRead(1); try { return new Result(row, getRowMap(row)); } catch (Exception e) { LOG.debug("get failed for table: " + getTransactionAwareName() + ", row: " + Bytes.toStringBinary(row), e); throw new DataSetException("get failed", e); } }
/** * NOTE: Depending on the use-case, calling this method may be much less * efficient than calling same method with columns as parameters because it may always require round trip to * persistent store */ @ReadOnly @Override public Row get(byte[] row) { ensureTransactionIsStarted(); reportRead(1); try { return new Result(row, getRowMap(row)); } catch (Exception e) { LOG.debug("get failed for table: " + getTransactionAwareName() + ", row: " + Bytes.toStringBinary(row), e); throw new DataSetException("get failed", e); } }
@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; }
rowMap = getRowMap(row, columns); reportRead(1); } catch (Exception e) {
rowMap = getRowMap(row, columns); reportRead(1); } catch (Exception e) {