private Map<byte[], byte[]> getRowMap(byte[] row) throws Exception { NavigableMap<byte[], byte[]> result = Maps.newTreeMap(Bytes.BYTES_COMPARATOR); // checking if the row was deleted inside this tx NavigableMap<byte[], Update> buffCols = buff.get(row); boolean rowDeleted = buffCols == null && buff.containsKey(row); if (rowDeleted) { return Collections.emptyMap(); } Map<byte[], byte[]> persisted = getPersisted(row, null); result.putAll(persisted); if (buffCols != null) { // buffered should override those returned from persistent store mergeToPersisted(result, buffCols, null); } return unwrapDeletes(result); }
private Map<byte[], byte[]> getRowMap(byte[] row) throws Exception { NavigableMap<byte[], byte[]> result = Maps.newTreeMap(Bytes.BYTES_COMPARATOR); // checking if the row was deleted inside this tx NavigableMap<byte[], Update> buffCols = buff.get(row); boolean rowDeleted = buffCols == null && buff.containsKey(row); if (rowDeleted) { return Collections.emptyMap(); } Map<byte[], byte[]> persisted = getPersisted(row, null); result.putAll(persisted); if (buffCols != null) { // buffered should override those returned from persistent store mergeToPersisted(result, buffCols, null); } return unwrapDeletes(result); }
mergeToPersisted(result, buffCols, columns);
mergeToPersisted(result, buffCols, columns);
List<byte[]> getColumns = get.getColumns(); byte[][] columns = getColumns == null ? null : getColumns.toArray(new byte[getColumns.size()][]); mergeToPersisted(rowColumns, buffCols, columns);
List<byte[]> getColumns = get.getColumns(); byte[][] columns = getColumns == null ? null : getColumns.toArray(new byte[getColumns.size()][]); mergeToPersisted(rowColumns, buffCols, columns);
@ReadOnly @Override public Row get(byte[] row, byte[] startColumn, byte[] stopColumn, int limit) { ensureTransactionIsStarted(); reportRead(1); // checking if the row was deleted inside this tx NavigableMap<byte[], Update> buffCols = buff.get(row); // NOTE: since we cannot tell the exact column set, we always have to go to persisted store. // potential improvement: do not fetch columns available in in-mem buffer (we know them at this point) try { Map<byte[], byte[]> persistedCols = getPersisted(row, startColumn, stopColumn, limit); // adding server cols, and then overriding with buffered values NavigableMap<byte[], byte[]> result = Maps.newTreeMap(Bytes.BYTES_COMPARATOR); if (persistedCols != null) { result.putAll(persistedCols); } if (buffCols != null) { buffCols = getRange(buffCols, startColumn, stopColumn, limit); // null valued columns in in-memory buffer are deletes, so we need to delete them from the result list mergeToPersisted(result, buffCols, null); } // applying limit return new Result(row, head(result, limit)); } 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[] startColumn, byte[] stopColumn, int limit) { ensureTransactionIsStarted(); reportRead(1); // checking if the row was deleted inside this tx NavigableMap<byte[], Update> buffCols = buff.get(row); // NOTE: since we cannot tell the exact column set, we always have to go to persisted store. // potential improvement: do not fetch columns available in in-mem buffer (we know them at this point) try { Map<byte[], byte[]> persistedCols = getPersisted(row, startColumn, stopColumn, limit); // adding server cols, and then overriding with buffered values NavigableMap<byte[], byte[]> result = Maps.newTreeMap(Bytes.BYTES_COMPARATOR); if (persistedCols != null) { result.putAll(persistedCols); } if (buffCols != null) { buffCols = getRange(buffCols, startColumn, stopColumn, limit); // null valued columns in in-memory buffer are deletes, so we need to delete them from the result list mergeToPersisted(result, buffCols, null); } // applying limit return new Result(row, head(result, limit)); } catch (Exception e) { LOG.debug("get failed for table: " + getTransactionAwareName() + ", row: " + Bytes.toStringBinary(row), e); throw new DataSetException("get failed", e); } }