use of org.apache.hadoop.hbase.client.Get in project hive by apache.
the class HBaseReadWrite method read.
private byte[] read(String table, byte[] key, byte[] colFam, byte[] colName) throws IOException {
HTableInterface htab = conn.getHBaseTable(table);
Get g = new Get(key);
g.addColumn(colFam, colName);
Result res = htab.get(g);
return res.getValue(colFam, colName);
}
use of org.apache.hadoop.hbase.client.Get in project hive by apache.
the class HBaseReadWrite method read.
private Result read(String table, byte[] key, byte[] colFam, byte[][] colNames) throws IOException {
HTableInterface htab = conn.getHBaseTable(table);
Get g = new Get(key);
for (byte[] colName : colNames) g.addColumn(colFam, colName);
return htab.get(g);
}
use of org.apache.hadoop.hbase.client.Get in project hive by apache.
the class HBaseReadWrite method multiRead.
private void multiRead(String table, byte[] colFam, byte[] colName, byte[][] keys, ByteBuffer[] resultDest) throws IOException {
assert keys.length == resultDest.length;
@SuppressWarnings("deprecation") HTableInterface htab = conn.getHBaseTable(table);
List<Get> gets = new ArrayList<>(keys.length);
for (byte[] key : keys) {
Get g = new Get(key);
g.addColumn(colFam, colName);
gets.add(g);
}
Result[] results = htab.get(gets);
for (int i = 0; i < results.length; ++i) {
Result r = results[i];
if (r.isEmpty()) {
resultDest[i] = null;
} else {
Cell cell = r.getColumnLatestCell(colFam, colName);
resultDest[i] = ByteBuffer.wrap(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength());
}
}
}
use of org.apache.hadoop.hbase.client.Get in project hbase by apache.
the class MetaTableAccessor method getReplicationPositionForAllPeer.
/**
* Get replication positions for all peers in a region.
* @param connection connection we're using
* @param encodedRegionName region's encoded name
* @return the map of positions for each peer
*/
public static Map<String, Long> getReplicationPositionForAllPeer(Connection connection, byte[] encodedRegionName) throws IOException {
Get get = new Get(encodedRegionName);
get.addFamily(HConstants.REPLICATION_POSITION_FAMILY);
Result r = get(getMetaHTable(connection), get);
Map<String, Long> map = new HashMap<>((int) (r.size() / 0.75 + 1));
for (Cell c : r.listCells()) {
map.put(Bytes.toString(c.getQualifierArray(), c.getQualifierOffset(), c.getQualifierLength()), Bytes.toLong(c.getValueArray(), c.getValueOffset(), c.getValueLength()));
}
return map;
}
use of org.apache.hadoop.hbase.client.Get in project hbase by apache.
the class MetaTableAccessor method getSerialReplicationDaughterRegion.
/**
* Get daughter region(s) for a region, only used in serial replication.
* @param connection connection we're using
* @param encodedName region's encoded name
* @throws IOException
*/
public static String getSerialReplicationDaughterRegion(Connection connection, byte[] encodedName) throws IOException {
Get get = new Get(encodedName);
get.addColumn(HConstants.REPLICATION_META_FAMILY, daughterNameCq);
Result result = get(getMetaHTable(connection), get);
if (!result.isEmpty()) {
Cell c = result.rawCells()[0];
return Bytes.toString(c.getValueArray(), c.getValueOffset(), c.getValueLength());
}
return null;
}
Aggregations