/** * Gets the layout of the Fiji table. * * @return The table layout. */ public FijiTableLayout getTableLayout() { return HBaseFijiTable.downcast(mFijiTable).getLayout(); }
/** * Get the column name translator for the current layout of this table. Do not cache this object. * If you need both the table layout and a column name translator within a single short lived * operation, you should use {@link #getLayout()}} and create your own * {@link HBaseColumnNameTranslator} to ensure consistent state. * @return the column name translator for the current layout of this table. */ public HBaseColumnNameTranslator getColumnNameTranslator() { final State state = mState.get(); Preconditions.checkState(state == State.OPEN, "Cannot get the column name translator of a table in state %s.", state); return HBaseColumnNameTranslator.from(getLayout()); }
/** {@inheritDoc} */ @Override public String toString() { return Objects.toStringHelper(HBaseFijiTableReader.class) .add("id", System.identityHashCode(this)) .add("table", mTable.getURI()) .add("layout-version", mReaderLayoutCapsule.getLayout().getDesc().getLayoutId()) .add("state", mState.get()) .toString(); }
/** * Creates a provider for cell decoders. * * <p> The provider creates decoders for specific Avro records. </p> * * @param table HBase FijiTable to create a CellDecoderProvider for. * @return a new CellDecoderProvider for the specified HBase FijiTable. * @throws IOException on I/O error. */ private static CellDecoderProvider createCellProvider( final HBaseFijiTable table ) throws IOException { return CellDecoderProvider.create( table.getLayout(), ImmutableMap.<FijiColumnName, BoundColumnReaderSpec>of(), ImmutableList.<BoundColumnReaderSpec>of(), FijiTableReaderBuilder.DEFAULT_CACHE_MISS); }
/** {@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); }
) throws IOException { mTable = table; mTableLayout = table.getLayout(); mDataRequest = dataRequest; mEntityId = entityId;
"Cannot get row from FijiTableReader instance %s in state %s.", this, state); final ReaderLayoutCapsule capsule = mReaderLayoutCapsule; final FijiTableLayout tableLayout = capsule.getLayout(); validateRequestAgainstLayout(dataRequest, tableLayout); final HBaseDataRequestAdapter hbaseDataRequestAdapter = result, mTable, capsule.getLayout(), capsule.getColumnNameTranslator(), capsule.getCellDecoderProvider());
mOnDecoderCacheMiss = onDecoderCacheMiss; final FijiTableLayout layout = mTable.getLayout(); final Set<FijiColumnName> layoutColumns = layout.getColumnNames(); final Map<FijiColumnName, BoundColumnReaderSpec> boundOverrides = Maps.newHashMap();
mColumnNameTranslator = columnNameTranslator; mReopenScannerOnTimeout = reopenScannerOnTimeout; mEidFactory = EntityIdFactory.getFactory(mTable.getLayout()); mHTable = mTable.openHTableConnection(); try {
/** {@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()); }
/** * Creates a new <code>FijiRowScanner</code> instance. * * @param options The options for this scanner. * @throws IOException on I/O error. */ public HBaseFijiRowScanner(Options options) throws IOException { mDataRequest = options.getDataRequest(); mTable = options.getTable(); mScan = options.getScan(); mCellDecoderProvider = options.getCellDecoderProvider(); mReopenScannerOnTimeout = options.getReopenScannerOnTimeout(); mEntityIdFactory = EntityIdFactory.getFactory(mTable.getLayout()); mHTable = mTable.openHTableConnection(); try { mResultScanner = openResultScanner(); mNextResult = getNextResult(); } catch (FijiIOException ioe) { if (mHTable != null) { mHTable.close(); } throw ioe; } final State oldState = mState.getAndSet(State.OPEN); Preconditions.checkState(oldState == State.UNINITIALIZED, "Cannot open FijiRowScanner instance in state %s.", oldState); ResourceTracker.get().registerResource(this); }
final FijiTableLayout layout = mTable.getLayout(); final HBaseColumnNameTranslator translator = HBaseColumnNameTranslator.from(layout); final HBaseDataRequestAdapter adapter =
.build(); final FijiTableLayout layout = mTable.getLayout(); final HBaseDataRequestAdapter adapter = new HBaseDataRequestAdapter(nextPageDataRequest, HBaseColumnNameTranslator.from(layout));
final HBaseDataRequestAdapter adapter = new HBaseDataRequestAdapter(request, capsule.getColumnNameTranslator()); final FijiTableLayout layout = capsule.getLayout(); validateRequestAgainstLayout(request, layout); final Scan scan = adapter.toScan(layout, scannerOptions.getHBaseScanOptions()); mTable, scan, capsule.getLayout(), capsule.getCellDecoderProvider(), capsule.getColumnNameTranslator(),
final FijiTableLayout layout = mTable.getLayout(); final HBaseColumnNameTranslator translator = HBaseColumnNameTranslator.from(layout); final HBaseDataRequestAdapter adapter =
colName, table.getURI()); Preconditions.checkArgument( table.getLayout().getFamilyMap().get(colName.getFamily()).isMapType(), "Couldn't create pager: " + "Can only generate version pagers from a column family data request for map families. "
final HBaseDataRequestAdapter dataRequestAdapter = new HBaseDataRequestAdapter(dataRequest, capsule.getColumnNameTranslator()); final FijiTableLayout tableLayout = capsule.getLayout(); validateRequestAgainstLayout(dataRequest, tableLayout); final Scan scan = dataRequestAdapter.toScan(tableLayout, scanOptions);