/** * Create a new <code>HBaseFijiTableReader</code> instance that sends read requests directly to * HBase. * * @param table Fiji table from which to read. * @param onDecoderCacheMiss behavior to use when a {@link ColumnReaderSpec} override * specified in a {@link FijiDataRequest} cannot be found in the prebuilt cache of cell * decoders. * @param overrides mapping from columns to overriding read behavior for those columns. * @param alternatives mapping from columns to reader spec alternatives which the * FijiTableReader will accept as overrides in data requests. * @return a new HBaseFijiTableReader. * @throws IOException in case of an error opening the reader. */ public static HBaseFijiTableReader createWithOptions( final HBaseFijiTable table, final OnDecoderCacheMiss onDecoderCacheMiss, final Map<FijiColumnName, ColumnReaderSpec> overrides, final Multimap<FijiColumnName, ColumnReaderSpec> alternatives ) throws IOException { return new HBaseFijiTableReader(table, onDecoderCacheMiss, overrides, alternatives); }
/** {@inheritDoc} */ @Override public HBaseFijiTableReader openTableReader() throws IOException { return HBaseFijiTableReader.create(mTable); }
/** {@inheritDoc} */ @Override public HBaseFijiTableReader openTableReader(Map<FijiColumnName, CellSpec> overrides) throws IOException { return HBaseFijiTableReader.createWithCellSpecOverrides(mTable, overrides); }
/** {@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); }
return Collections.singletonList(this.<T>getResult(entityIds.get(0), dataRequest)); validateRequestAgainstLayout(dataRequest, tableLayout); final HBaseDataRequestAdapter hbaseRequestAdapter = new HBaseDataRequestAdapter(dataRequest, capsule.getColumnNameTranslator()); final List<Get> hbaseGetList = makeGetList(entityIds, tableLayout, hbaseRequestAdapter); final Result[] results = doHBaseGet(hbaseGetList); Preconditions.checkState(entityIds.size() == results.length);
/** {@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()); }
/** {@inheritDoc} */ @Override public <T> HBaseFijiResultScanner<T> getFijiResultScanner( final FijiDataRequest request ) throws IOException { return getFijiResultScanner(request, new FijiScannerOptions()); }
/** {@inheritDoc} */ @Override public HBaseFijiTableReader buildAndOpen() throws IOException { if (null == mOnDecoderCacheMiss) { mOnDecoderCacheMiss = DEFAULT_CACHE_MISS; } if (null == mOverrides) { mOverrides = DEFAULT_READER_SPEC_OVERRIDES; } if (null == mAlternatives) { mAlternatives = DEFAULT_READER_SPEC_ALTERNATIVES; } return HBaseFijiTableReader.createWithOptions( mTable, mOnDecoderCacheMiss, mOverrides, mAlternatives); } }
/** {@inheritDoc} */ @Override public FijiRowScanner getScanner(FijiDataRequest dataRequest) throws IOException { return getScanner(dataRequest, new FijiScannerOptions()); }
final ReaderLayoutCapsule capsule = mReaderLayoutCapsule; final FijiTableLayout tableLayout = capsule.getLayout(); 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( entityId,
/** {@inheritDoc} */ @Override public <T> FijiResultScanner<T> getFijiResultScanner( final FijiDataRequest dataRequest, final FijiPartition partition ) throws IOException { Preconditions.checkArgument(partition instanceof HBaseFijiPartition, "Can not scan an HBase table with a non-HBase partition."); final HBaseFijiPartition hbasePartition = (HBaseFijiPartition) partition; final FijiScannerOptions options = new FijiScannerOptions(); options.setStartRow(HBaseEntityId.fromHBaseRowKey(hbasePartition.getStartKey())); options.setStopRow(HBaseEntityId.fromHBaseRowKey(hbasePartition.getEndKey())); return getFijiResultScanner(dataRequest, options); }
/** {@inheritDoc} */ @Override public FijiTableReader openTableReader() { final State state = mState.get(); Preconditions.checkState(state == State.OPEN, "Cannot open a table reader on a FijiTable in state %s.", state); try { return HBaseFijiTableReader.create(this); } catch (IOException ioe) { throw new FijiIOException(ioe); } }
/** * Creates a new <code>HbaseFijiTableReader</code> instance that sends read requests directly to * HBase. * * @param table Fiji table from which to read. * @param overrides layout overrides to modify read behavior. * @return a new HBaseFijiTableReader. * @throws IOException in case of an error opening the reader. * @deprecated use {@link #createWithOptions}. */ @Deprecated public static HBaseFijiTableReader createWithCellSpecOverrides( final HBaseFijiTable table, final Map<FijiColumnName, CellSpec> overrides ) throws IOException { return new HBaseFijiTableReader(table, overrides); }