/** * Selects an HTable from the pool and returns. * * @param tableName * Name of HBase table * @return the h table * @throws IOException * Signals that an I/O exception has occurred. */ public HTableInterface gethTable(final String tableName) throws IOException { return hTablePool.getTable(tableName); }
/** * Selects an HTable from the pool and returns. * * @param tableName * Name of HBase table * @return the h table * @throws IOException * Signals that an I/O exception has occurred. */ public HTableInterface gethTable(final String tableName) throws IOException { return hTablePool.getTable(tableName); }
@Override public HTableInterface get() { return tablePool.getTable(tableName); } }
@Override public HTableInterface get() { return pool.getTable(tableName); } }
/** * Selects an HTable from the pool and returns. * * @param tableName * Name of HBase table * @return the h table * @throws IOException * Signals that an I/O exception has occurred. */ public HTableInterface gethTable(final String tableName) throws IOException { return hTablePool.getTable(tableName); }
private HTableInterface getTable(byte[] tableName) { return htablePool.getTable(tableName); }
public HTableInterface getHTable(String tableName) { return pool.getTable(tableName); }
private void flushDeletes(byte[] tableName, Queue<Delete> deletes) { HTableInterface table = pool.getTable(tableName); try { table.delete(new ArrayList<Delete>(deletes)); } catch (IOException e) { throw new RuntimeException(e); } finally { pool.putTable(table); } deletes.clear(); }
private void flushPuts(byte[] tableName, Queue<Put> puts) { HTableInterface table = pool.getTable(tableName); try { table.put(new ArrayList<Put>(puts)); } catch (IOException e) { throw new RuntimeException(e); } finally { pool.putTable(table); } puts.clear(); }
private <T> T runNoIE(TableRunnable<T> runnable) throws IOException { HTableInterface table = pool.getTable(tableNameString); try { return runnable.run(table); } catch (InterruptedException e) { throw new RuntimeException(e); } finally { table.close(); } }
protected Result getResult(byte[] tableName, Get get) { HTableInterface table = pool.getTable(tableName); try { return table.get(get); } catch (IOException e) { throw new RuntimeException(e); } finally { pool.putTable(table); } }
@Override public <T extends CoprocessorProtocol, R> void coprocessorExec(Class<T> protocol, byte[] startKey, byte[] endKey, Batch.Call<T,R> callable, Batch.Callback<R> callback) throws IOException, Throwable { HTableInterface table = pool.getTable(tableNameString); try { table.coprocessorExec(protocol, startKey, endKey, callable, callback); } finally { table.close(); } }
private <T> T run(TableRunnable<T> runnable) throws IOException, InterruptedException { // passing tableNameString, since otherwise pool.getTable converts it to string anyway HTableInterface table = pool.getTable(tableNameString); try { return runnable.run(table); } finally { table.close(); } }
@Override public <T extends CoprocessorProtocol, R> Map<byte[], R> coprocessorExec(Class<T> protocol, byte[] startKey, byte[] endKey, Batch.Call<T,R> callable) throws IOException, Throwable { HTableInterface table = pool.getTable(tableNameString); try { return table.coprocessorExec(protocol, startKey, endKey, callable); } finally { table.close(); } }
private void hbaseIncrement(List<Map.Entry<BoxedByteArray, T>> entriesList, Object[] objects) throws IOException, InterruptedException { List<Row> rows = new ArrayList<>(); for (Map.Entry<BoxedByteArray, T> entry : entriesList) { long amount = Bytes.toLong(entry.getValue().serialize()); Increment increment = new Increment(entry.getKey().bytes); increment.addColumn(configuration.cf, HBaseDbHarness.QUALIFIER, amount); incrementerMetrics.incrementSize.update(amount); rows.add(increment); } try (HTableInterface table = pool.getTable(configuration.tableName)) { table.batch(rows, objects); } }
public void deleteUser(String word) throws IOException { HTableInterface words = pool.getTable(TABLE_NAME); Delete d = mkDel(word); words.delete(d); words.close(); }
public void addWordCount(WordCount w) throws IOException{ HTableInterface words = pool.getTable(TABLE_NAME); Put p = mkPut(w); words.put(p); words.close(); }
public List<WordCount> getWordCount(String word) throws IOException { HTableInterface words = pool.getTable(TABLE_NAME); Get g = mkGet(word); Result result = words.get(g); if (result.isEmpty()) { log.info(String.format("word %s not found.", word)); return null; } List<WordCount> wordCounts = WordCount.GetWordCountFromResults(result); words.close(); return wordCounts; }
private HTableDescriptor getTableSchema() throws IOException, TableNotFoundException { HTablePool pool = servlet.getTablePool(); HTableInterface table = pool.getTable(tableResource.getName()); try { return table.getTableDescriptor(); } finally { table.close(); } }
public void updateProfileCountsForSaleInHBase(Long buyerId, Long sellerId, ItemSaleEvent event) throws IOException, InterruptedException { HTableInterface profileTable = hTablePool.getTable(DataModelConsts.PROFILE_TABLE); ArrayList<Row> actions = new ArrayList<Row>(); Increment buyerValueIncrement = new Increment(generateProfileRowKey(buyerId)); buyerValueIncrement.addColumn(DataModelConsts.PROFILE_COLUMN_FAMILY, DataModelConsts.CURRENT_LOG_IN_PURCHASES_VALUE_COL, event.getItemValue()); buyerValueIncrement.addColumn(DataModelConsts.PROFILE_COLUMN_FAMILY, DataModelConsts.TOTAL_VALUE_OF_PAST_SELLS_COL, event.getItemValue()); actions.add(buyerValueIncrement); Increment sellerValueIncrement = new Increment(generateProfileRowKey(sellerId)); sellerValueIncrement.addColumn(DataModelConsts.PROFILE_COLUMN_FAMILY, DataModelConsts.CURRENT_LOG_IN_SELLS_VALUE_COL, event.getItemValue()); sellerValueIncrement.addColumn(DataModelConsts.PROFILE_COLUMN_FAMILY, DataModelConsts.TOTAL_VALUE_OF_PAST_SELLS_COL, event.getItemValue()); actions.add(sellerValueIncrement); profileTable.batch(actions); }