/** {@inheritDoc} */ @Override public FijiRowData get(EntityId entityId, FijiDataRequest dataRequest) throws IOException { final State state = mState.get(); Preconditions.checkState(state == State.OPEN, "Cannot get row from FijiTableReader instance %s in state %s.", this, state); final ReaderLayoutCapsule capsule = mReaderLayoutCapsule; // Make sure the request validates against the layout of the table. final FijiTableLayout tableLayout = capsule.getLayout(); validateRequestAgainstLayout(dataRequest, tableLayout); // Construct an HBase Get to send to the HTable. HBaseDataRequestAdapter hbaseRequestAdapter = new HBaseDataRequestAdapter(dataRequest, capsule.getColumnNameTranslator()); Get hbaseGet; try { hbaseGet = hbaseRequestAdapter.toGet(entityId, tableLayout); } catch (InvalidLayoutException e) { // The table layout should never be invalid at this point, since we got it from a valid // opened table. If it is, there's something seriously wrong. throw new InternalFijiError(e); } // Send the HTable Get. final Result result = hbaseGet.hasFamilies() ? doHBaseGet(hbaseGet) : new Result(); // Parse the result. return new HBaseFijiRowData( mTable, dataRequest, entityId, result, capsule.getCellDecoderProvider()); }
/** * Constructs an HBase Scan that describes the data requested in the FijiDataRequest. * * @param tableLayout The layout of the Fiji table to read from. This is required for * determining the mapping between Fiji columns and HBase columns. * @return An HBase Scan descriptor. * @throws IOException If there is an error. */ public Scan toScan(final FijiTableLayout tableLayout) throws IOException { return toScan(tableLayout, new HBaseScanOptions()); }
new HBaseDataRequestAdapter(request, capsule.getColumnNameTranslator()); final FijiTableLayout layout = capsule.getLayout(); validateRequestAgainstLayout(request, layout); final Scan scan = adapter.toScan(layout, scannerOptions.getHBaseScanOptions()); if (null != scannerOptions.getStartRow()) { scan.setStartRow(scannerOptions.getStartRow().getHBaseRowKey());
/** * Applies the row filter to an HBase scan object. * * <p>This will tell HBase region servers to filter rows on the server-side, so filtered * rows will not even need to get sent across the network back to the client.</p> * * @param scan An HBase scan descriptor. * @throws IOException If there is an IO error. */ public void applyTo(Scan scan) throws IOException { // The filter might need to request data that isn't already requested by the scan, so add // it here if needed. try { // TODO: SCHEMA-444 Avoid constructing a new FijiColumnNameTranslator below. new HBaseDataRequestAdapter( mRowFilter.getDataRequest(), HBaseColumnNameTranslator.from(mTableLayout)) .applyToScan(scan, mTableLayout); } catch (InvalidLayoutException e) { throw new InternalFijiError(e); } // Set the filter. final FijiRowFilter.Context context = new FijiRowFilterContext(HBaseColumnNameTranslator.from(mTableLayout)); scan.setFilter(mRowFilter.toHBaseFilter(context)); } }
/** * Constructs an HBase Scan that describes the data requested in the FijiDataRequest. * * @param tableLayout The layout of the Fiji table to read from. This is required for * determining the mapping between Fiji columns and HBase columns. * @param scanOptions Custom options for this scan. * @return An HBase Scan descriptor. * @throws IOException If there is an error. */ public Scan toScan( final FijiTableLayout tableLayout, final HBaseScanOptions scanOptions ) throws IOException { // Unfortunately in HBase 95+, we can no longer create empty gets. // So create a fake one for this table and fill in the fields of a new scan. final Get tempGet = toGet(HBaseEntityId.fromHBaseRowKey(new byte[1]), tableLayout); final Scan scan = new Scan(); scan.setFilter(tempGet.getFilter()); scan.setCacheBlocks(tempGet.getCacheBlocks()); scan.setMaxVersions(tempGet.getMaxVersions()); scan.setTimeRange(tempGet.getTimeRange().getMin(), tempGet.getTimeRange().getMax()); scan.setFamilyMap(tempGet.getFamilyMap()); configureScan(scan, scanOptions); return scan; }
addColumn(get, hbaseColumnName); columnFilters.addFilter(toFilter(columnRequest, hbaseColumnName, filterContext)); final HBaseColumnName fqHBaseColumnName = mColumnNameTranslator.toHBaseColumnName(fqFijiColumnName); addColumn(get, fqHBaseColumnName); columnFilters.addFilter(toFilter(columnRequest, fqHBaseColumnName, filterContext)); columnFilters.addFilter(toFilter(columnRequest, hbaseColumnName, filterContext));
/** {@inheritDoc} */ @Override public List<FijiRowData> bulkGet(List<EntityId> entityIds, FijiDataRequest dataRequest) throws IOException { final State state = mState.get(); Preconditions.checkState(state == State.OPEN, "Cannot get rows from FijiTableReader instance %s in state %s.", this, state); // Bulk gets have some overhead associated with them, // so delegate work to get(EntityId, FijiDataRequest) if possible. if (entityIds.size() == 1) { return Collections.singletonList(this.get(entityIds.get(0), dataRequest)); } final ReaderLayoutCapsule capsule = mReaderLayoutCapsule; final FijiTableLayout tableLayout = capsule.getLayout(); validateRequestAgainstLayout(dataRequest, tableLayout); final HBaseDataRequestAdapter hbaseRequestAdapter = new HBaseDataRequestAdapter(dataRequest, capsule.getColumnNameTranslator()); // Construct a list of hbase Gets to send to the HTable. final List<Get> hbaseGetList = makeGetList(entityIds, tableLayout, hbaseRequestAdapter); // Send the HTable Gets. final Result[] results = doHBaseGet(hbaseGetList); Preconditions.checkState(entityIds.size() == results.length); // Parse the results. If a Result is null, then the corresponding FijiRowData should also // be null. This indicates that there was an error retrieving this row. return parseResults(results, entityIds, dataRequest); }
/** * Creates a list of hbase Gets for a set of entityIds. * * @param entityIds The set of entityIds to collect. * @param tableLayout The table layout specifying constraints on what data to return for a row. * @param hbaseRequestAdapter The HBaseDataRequestAdapter. * @return A list of hbase Gets-- one for each entity id. * @throws IOException If there is an error. */ private static List<Get> makeGetList(List<EntityId> entityIds, FijiTableLayout tableLayout, HBaseDataRequestAdapter hbaseRequestAdapter) throws IOException { List<Get> hbaseGetList = new ArrayList<Get>(entityIds.size()); try { for (EntityId entityId : entityIds) { hbaseGetList.add(hbaseRequestAdapter.toGet(entityId, tableLayout)); } return hbaseGetList; } catch (InvalidLayoutException ile) { // The table layout should never be invalid at this point, since we got it from a valid // opened table. If it is, there's something seriously wrong. throw new InternalFijiError(ile); } }
new HBaseDataRequestAdapter(dataRequest, capsule.getColumnNameTranslator()); final FijiTableLayout tableLayout = capsule.getLayout(); validateRequestAgainstLayout(dataRequest, tableLayout); final Scan scan = dataRequestAdapter.toScan(tableLayout, scanOptions);
validateRequestAgainstLayout(dataRequest, tableLayout); final HBaseDataRequestAdapter hbaseRequestAdapter = new HBaseDataRequestAdapter(dataRequest, capsule.getColumnNameTranslator());
validateRequestAgainstLayout(dataRequest, tableLayout); final HBaseDataRequestAdapter hbaseDataRequestAdapter = new HBaseDataRequestAdapter(dataRequest, capsule.getColumnNameTranslator()); final Get get = hbaseDataRequestAdapter.toGet(entityId, tableLayout); final Result result = get.hasFamilies() ? doHBaseGet(get) : new Result(); return HBaseFijiResult.create(
final FijiTableLayout tableLayout ) throws IOException { final Scan newScan = toScan(tableLayout);
final HBaseColumnNameTranslator translator = HBaseColumnNameTranslator.from(layout); final HBaseDataRequestAdapter adapter = new HBaseDataRequestAdapter(nextPageDataRequest, translator); try { final Get hbaseGet = adapter.toGet(mEntityId, layout); if (LOG.isDebugEnabled()) { LOG.debug("Sending HBase Get: {} with filter {}",
new HBaseDataRequestAdapter(nextPageDataRequest, HBaseColumnNameTranslator.from(layout)); try { final Get hbaseGet = adapter.toGet(mEntityId, layout); LOG.debug("Sending HBase Get: {}", hbaseGet); final Result result = doHBaseGet(hbaseGet);
final HBaseColumnNameTranslator translator = HBaseColumnNameTranslator.from(layout); final HBaseDataRequestAdapter adapter = new HBaseDataRequestAdapter(nextPageDataRequest, translator); try { final Get hbaseGet = adapter.toGet(mEntityId, layout); if (LOG.isDebugEnabled()) { LOG.debug("Sending HBase Get: {} with filter {}",