/** * 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()); }
/** * Get a FijiResult corresponding to the same data as this KjiRowData. * * <p> * This method allows the caller to specify a type-bound on the values of the {@code FijiCell}s * of the returned {@code FijiResult}. The caller should be careful to only specify an * appropriate type. If the type is too specific (or wrong), a runtime * {@link java.lang.ClassCastException} will be thrown when the returned {@code FijiResult} is * used. See the 'Type Safety' section of {@link FijiResult}'s documentation for more details. * </p> * * @return A FijiResult corresponding to the same data as this FijiRowData. * @param <T> The type of {@code FijiCell} values in the returned {@code FijiResult}. * @throws IOException if error while decoding cells. */ public <T> FijiResult<T> asFijiResult() throws IOException { return HBaseFijiResult.create( mEntityId, mDataRequest, mResult, mTable, mTableLayout, HBaseColumnNameTranslator.from(mTableLayout), mDecoderProvider); }
/** * 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)); } }
HBaseColumnNameTranslator.from(mTableLayout);
/** * Constructs a new context that can write cells to an HFile that can be loaded into an HBase * table. * * @param hadoopContext is the Hadoop {@link TaskInputOutputContext} that will be used to perform * the writes. * @throws IOException on I/O error. */ public HFileWriterContext(TaskInputOutputContext<?, ?, ?, ?> hadoopContext) throws IOException { super(hadoopContext); final Configuration conf = new Configuration(hadoopContext.getConfiguration()); final FijiURI outputURI = FijiURI.newBuilder(conf.get(FijiConfKeys.FIJI_OUTPUT_TABLE_URI)).build(); mFiji = Fiji.Factory.open(outputURI, conf); mTable = mFiji.openTable(outputURI.getTable()); mReader = mTable.openTableReader(); mColumnNameTranslator = HBaseColumnNameTranslator.from(mTable.getLayout()); mEntityIdFactory = EntityIdFactory.getFactory(mTable.getLayout()); }
/** * Translates a Fiji table layout into an HColumnDescriptor. * * @param fijiInstanceName The name of the Fiji instance the table lives in. * @param tableLayout The Fiji table layout. * @return The HTableDescriptor to use for storing the Fiji table data. */ public HTableDescriptor toHTableDescriptor(String fijiInstanceName, FijiTableLayout tableLayout) { // Figure out the name of the table. final String tableName = tableLayout.getName(); final FijiManagedHBaseTableName hbaseTableName = FijiManagedHBaseTableName.getFijiTableName(fijiInstanceName, tableName); final HTableDescriptor tableDescriptor = new HTableDescriptor(hbaseTableName.toString()); TableLayoutDesc tableLayoutDesc = tableLayout.getDesc(); if (tableLayoutDesc.getMaxFilesize() != null) { tableDescriptor.setMaxFileSize(tableLayoutDesc.getMaxFilesize()); } if (tableLayoutDesc.getMemstoreFlushsize() != null) { tableDescriptor.setMemStoreFlushSize(tableLayoutDesc.getMemstoreFlushsize()); } HBaseColumnNameTranslator translator = HBaseColumnNameTranslator.from(tableLayout); // Add the columns. for (LocalityGroupLayout localityGroup : tableLayout.getLocalityGroupMap().values()) { tableDescriptor.addFamily(toHColumnDescriptor(localityGroup, translator)); } return tableDescriptor; }
new WriterLayoutCapsule(provider, layout, HBaseColumnNameTranslator.from(layout));
provider, layout, HBaseColumnNameTranslator.from(layout));
provider, layout, HBaseColumnNameTranslator.from(layout));
provider, layout, HBaseColumnNameTranslator.from(layout));
final HBaseColumnNameTranslator translator = HBaseColumnNameTranslator.from(layout); final HBaseDataRequestAdapter adapter = new HBaseDataRequestAdapter(nextPageDataRequest, translator);
new HBaseDataRequestAdapter(nextPageDataRequest, HBaseColumnNameTranslator.from(layout)); try { final Get hbaseGet = adapter.toGet(mEntityId, layout);
final HBaseColumnNameTranslator translator = HBaseColumnNameTranslator.from(layout); final HBaseDataRequestAdapter adapter = new HBaseDataRequestAdapter(nextPageDataRequest, translator);