@Override protected NavigableMap<byte[], byte[]> getPersisted(byte[] row, byte[] startColumn, byte[] stopColumn, int limit) throws Exception { return delegate.getPersisted(row, startColumn, stopColumn, limit); }
@Override protected NavigableMap<byte[], byte[]> getPersisted(byte[] row, byte[][] columns) throws Exception { return delegate.getPersisted(row, columns); }
/** * Fetches a list of rows from persistent store. Subclasses should override this if they can batch multiple * gets into a single request, as the default implementation simply loops through the gets and calls * {@link #getPersisted(byte[], byte[][])} on each get. * NOTE: persisted store can also be in-memory, it is called "persisted" to distinguish from in-memory buffer. * @param gets list of gets to perform * @return list of rows, one for each get * @throws Exception */ protected List<Map<byte[], byte[]>> getPersisted(List<Get> gets) throws Exception { List<Map<byte[], byte[]>> results = Lists.newArrayListWithCapacity(gets.size()); for (Get get : gets) { List<byte[]> getColumns = get.getColumns(); byte[][] columns = getColumns == null ? null : getColumns.toArray(new byte[getColumns.size()][]); results.add(getPersisted(get.getRow(), columns)); } return results; }
/** * Fetches a list of rows from persistent store. Subclasses should override this if they can batch multiple * gets into a single request, as the default implementation simply loops through the gets and calls * {@link #getPersisted(byte[], byte[][])} on each get. * NOTE: persisted store can also be in-memory, it is called "persisted" to distinguish from in-memory buffer. * @param gets list of gets to perform * @return list of rows, one for each get * @throws Exception */ protected List<Map<byte[], byte[]>> getPersisted(List<Get> gets) throws Exception { List<Map<byte[], byte[]>> results = Lists.newArrayListWithCapacity(gets.size()); for (Get get : gets) { List<byte[]> getColumns = get.getColumns(); byte[][] columns = getColumns == null ? null : getColumns.toArray(new byte[getColumns.size()][]); results.add(getPersisted(get.getRow(), columns)); } return results; }
return getPersisted(row, columns); getPersisted(row, colsToFetchFromPersisted.toArray(new byte[colsToFetchFromPersisted.size()][])); if (persistedCols != null) { result.putAll(persistedCols);
return getPersisted(row, columns); getPersisted(row, colsToFetchFromPersisted.toArray(new byte[colsToFetchFromPersisted.size()][])); if (persistedCols != null) { result.putAll(persistedCols);
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); }
try { List<Map<byte[], byte[]>> persistedRows = getPersisted(gets);
try { List<Map<byte[], byte[]>> persistedRows = getPersisted(gets);
@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); } }