setTable(table); final GetRequest get = new GetRequest( lastTableBytes, key.getBytes(), columnFamilyBytes); if (fields != null) {
/** * Package-private factory method to build an "exists" RPC. * @param table The non-empty name of the table to use. * @param key The row key to get in that table. * @return An {@link HBaseRpc} that will return a {@link Boolean} * indicating whether or not the given table / key exists. */ static HBaseRpc exists(final byte[] table, final byte[] key) { final GetRequest rpc = new GetRequest(0F, table, key); rpc.setProbe(true); return rpc; }
/** * Gets the entire given row from the data table. */ final Deferred<ArrayList<KeyValue>> get(final byte[] key) { return client.get(new GetRequest(table, key)); }
/** * Package-private factory method to build an "exists" RPC. * @param table The non-empty name of the table to use. * @param key The row key to get in that table. * @param family The column family to get in the table. * @return An {@link HBaseRpc} that will return a {@link Boolean} * indicating whether or not the given table / key exists. */ static HBaseRpc exists(final byte[] table, final byte[] key, final byte[] family) { final GetRequest rpc = new GetRequest(0F, table, key); rpc.family(family); rpc.setProbe(true); return rpc; }
/** * Returns the cell of the specified row key, using family:kind. */ private byte[] hbaseGet(final byte[] key, final byte[] family) throws HBaseException { final GetRequest get = new GetRequest(table, key); get.family(family).qualifier(kind); try { final ArrayList<KeyValue> row = client.get(get).joinUninterruptibly(); if (row == null || row.isEmpty()) { return null; } return row.get(0).value(); } catch (HBaseException e) { throw e; } catch (Exception e) { throw new RuntimeException("Should never be here", e); } }
/** * Gets a given row in HBase and prints it on standard output. * * @param client The HBase client to use. * @param table The name of the HBase table to use. * @param key The row key to attempt to get from HBase. * @param family The family in which we're interested. * @return 0 if at least one cell was found and printed, 1 otherwise. */ private static int findAndPrintRow(final HBaseClient client, final byte[] table, final byte[] key, final byte[] family, boolean formard) { final GetRequest get = new GetRequest(table, key); get.family(family); ArrayList<KeyValue> row; try { row = client.get(get).joinUninterruptibly(); } catch (HBaseException e) { LOG.error("Get failed: " + get, e); return 1; } catch (Exception e) { LOG.error("WTF? Unexpected exception type, get=" + get, e); return 42; } return printResult(row, family, formard) ? 0 : 1; }