/** * Sends a batch of HBase Get requests. * * @param get HBase Get requests. * @return the HBase Results. * @throws IOException on I/O error. */ private Result[] doHBaseGet(List<Get> get) throws IOException { final HTableInterface htable = mTable.openHTableConnection(); try { LOG.debug("Sending bulk HBase Get: {}", get); return htable.get(get); } finally { htable.close(); } } }
/** * Sends an HBase Get request. * * @param get HBase Get request. * @return the HBase Result. * @throws IOException on I/O error. */ private Result doHBaseGet(Get get) throws IOException { final HTableInterface htable = mTable.openHTableConnection(); try { LOG.debug("Sending HBase Get: {}", get); return htable.get(get); } finally { htable.close(); } }
/** * Sends an HBase Get request. * * @param get HBase Get request. * @return the HBase Result. * @throws IOException on I/O error. */ private Result doHBaseGet(Get get) throws IOException { final HTableInterface htable = mTable.openHTableConnection(); try { return htable.get(get); } finally { htable.close(); } }
/** * Sends an HBase Get request. * * @param get HBase Get request. * @return the HBase Result. * @throws IOException on I/O error. */ private Result doHBaseGet(Get get) throws IOException { final HTableInterface htable = mTable.openHTableConnection(); try { return htable.get(get); } finally { htable.close(); } }
/** * Sends an HBase Get request. * * @param get HBase Get request. * @return the HBase Result. * @throws IOException on I/O error. */ private Result doHBaseGet(Get get) throws IOException { final HTableInterface htable = mTable.openHTableConnection(); try { return htable.get(get); } finally { htable.close(); } }
/** * Constructor for this AtomicFijiPutter. * * @param table The HBaseFijiTable to which this writer writes. * @throws IOException in case of an error. */ public HBaseAtomicFijiPutter(HBaseFijiTable table) throws IOException { mTable = table; mHTable = mTable.openHTableConnection(); mLayoutConsumerRegistration = mTable.registerLayoutConsumer(new InnerLayoutUpdater()); Preconditions.checkState(mWriterLayoutCapsule != null, "AtomicFijiPutter for table: %s failed to initialize.", mTable.getURI()); // Retain the table only when everything succeeds. table.retain(); final State oldState = mState.getAndSet(State.OPEN); Preconditions.checkState(oldState == State.UNINITIALIZED, "Cannot open AtomicFijiPutter instance in state %s.", oldState); }
/** * Reports the HBase table name for the specified Fiji table. * * @param table Fiji table to report the HBase table name of. * @return the HBase table name for the specified Fiji table. * @throws java.io.IOException on I/O error. */ private static byte[] getHBaseTableName(FijiTable table) throws IOException { final HBaseFijiTable htable = HBaseFijiTable.downcast(table); final HTableInterface hti = htable.openHTableConnection(); try { return hti.getTableName(); } finally { hti.close(); } }
/** * Creates a non-buffered fiji table writer that sends modifications directly to Fiji. * * @param table A fiji table. * @throws IOException on I/O error. */ public HBaseFijiTableWriter(HBaseFijiTable table) throws IOException { mTable = table; mLayoutConsumerRegistration = mTable.registerLayoutConsumer(new InnerLayoutUpdater()); Preconditions.checkState(mWriterLayoutCapsule != null, "FijiTableWriter for table: %s failed to initialize.", mTable.getURI()); mHTable = table.openHTableConnection(); SchemaPlatformBridge.get().setAutoFlush(mHTable, true); // Retain the table only when everything succeeds. mTable.retain(); final State oldState = mState.getAndSet(State.OPEN); Preconditions.checkState(oldState == State.UNINITIALIZED, "Cannot open FijiTableWriter instance in state %s.", oldState); }
/** {@inheritDoc} */ @Override public List<InputSplit> getSplits(JobContext context) throws IOException { final Configuration conf = context.getConfiguration(); final FijiURI inputTableURI = getInputTableURI(conf); final Fiji fiji = Fiji.Factory.open(inputTableURI, conf); final FijiTable table = fiji.openTable(inputTableURI.getTable()); final HTableInterface htable = HBaseFijiTable.downcast(table).openHTableConnection(); try { final List<InputSplit> splits = Lists.newArrayList(); for (FijiRegion region : table.getRegions()) { final byte[] startKey = region.getStartKey(); // TODO: a smart way to get which location is most relevant. final String location = region.getLocations().isEmpty() ? null : region.getLocations().iterator().next(); final TableSplit tableSplit = new TableSplit( htable.getTableName(), startKey, region.getEndKey(), location); splits.add(new FijiTableSplit(tableSplit, startKey)); } return splits; } finally { htable.close(); } }
mReopenScannerOnTimeout = reopenScannerOnTimeout; mEidFactory = EntityIdFactory.getFactory(mTable.getLayout()); mHTable = mTable.openHTableConnection(); try { mResultScanner = mHTable.getScanner(scan);
/** * Creates a buffered fiji table writer that stores modifications to be sent on command * or when the buffer overflows. * * @param table A fiji table. * @throws FijiTableNotFoundException in case of an invalid table parameter * @throws IOException in case of IO errors. */ public HBaseFijiBufferedWriter(HBaseFijiTable table) throws IOException { mTable = table; try { mHTable = mTable.openHTableConnection(); } catch (TableNotFoundException e) { throw new FijiTableNotFoundException(table.getURI()); } mLayoutConsumerRegistration = mTable.registerLayoutConsumer(new InnerLayoutUpdater()); Preconditions.checkState(mWriterLayoutCapsule != null, "HBaseFijiBufferedWriter for table: %s failed to initialize.", mTable.getURI()); SchemaPlatformBridge.get().setAutoFlush(mHTable, false); // Retain the table only after everything else succeeded: mTable.retain(); synchronized (mInternalLock) { Preconditions.checkState(mState == State.UNINITIALIZED, "Cannot open HBaseFijiBufferedWriter instance in state %s.", mState); mState = State.OPEN; } ResourceTracker.get().registerResource(this); }
/** * 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); }