use of org.apache.hadoop.hbase.client.ResultScanner in project hbase by apache.
the class ThriftHBaseServiceHandler method getScannerResults.
@Override
public List<TResult> getScannerResults(ByteBuffer table, TScan scan, int numRows) throws TIOError, TException {
Table htable = getTable(table);
List<TResult> results = null;
ResultScanner scanner = null;
try {
scanner = htable.getScanner(scanFromThrift(scan));
results = resultsFromHBase(scanner.next(numRows));
} catch (IOException e) {
throw getTIOError(e);
} finally {
if (scanner != null) {
scanner.close();
}
closeTable(htable);
}
return results;
}
use of org.apache.hadoop.hbase.client.ResultScanner in project hbase by apache.
the class ThriftHBaseServiceHandler method getScannerRows.
@Override
public List<TResult> getScannerRows(int scannerId, int numRows) throws TIOError, TIllegalArgument, TException {
ResultScanner scanner = getScanner(scannerId);
if (scanner == null) {
TIllegalArgument ex = new TIllegalArgument();
ex.setMessage("Invalid scanner Id");
throw ex;
}
try {
connectionCache.updateConnectionAccessTime();
return resultsFromHBase(scanner.next(numRows));
} catch (IOException e) {
throw getTIOError(e);
}
}
use of org.apache.hadoop.hbase.client.ResultScanner in project hbase by apache.
the class TestHRegionOnCluster method putDataAndVerify.
private void putDataAndVerify(Table table, String row, byte[] family, String value, int verifyNum) throws IOException {
System.out.println("=========Putting data :" + row);
Put put = new Put(Bytes.toBytes(row));
put.addColumn(family, Bytes.toBytes("q1"), Bytes.toBytes(value));
table.put(put);
ResultScanner resultScanner = table.getScanner(new Scan());
List<Result> results = new ArrayList<>();
while (true) {
Result r = resultScanner.next();
if (r == null)
break;
results.add(r);
}
resultScanner.close();
if (results.size() != verifyNum) {
System.out.println(results);
}
assertEquals(verifyNum, results.size());
}
use of org.apache.hadoop.hbase.client.ResultScanner in project hbase by apache.
the class TestMobStoreScanner method testGetReferences.
private void testGetReferences(boolean reversed) throws Exception {
TableName tn = TableName.valueOf("testGetReferences" + reversed);
setUp(defaultThreshold, tn);
long ts1 = System.currentTimeMillis();
long ts2 = ts1 + 1;
long ts3 = ts1 + 2;
byte[] value = generateMobValue((int) defaultThreshold + 1);
;
Put put1 = new Put(row1);
put1.addColumn(family, qf1, ts3, value);
put1.addColumn(family, qf2, ts2, value);
put1.addColumn(family, qf3, ts1, value);
table.put(put1);
admin.flush(tn);
Scan scan = new Scan();
setScan(scan, reversed, true);
ResultScanner results = table.getScanner(scan);
int count = 0;
for (Result res : results) {
List<Cell> cells = res.listCells();
for (Cell cell : cells) {
// Verify the value
assertIsMobReference(cell, row1, family, value, tn);
count++;
}
}
results.close();
Assert.assertEquals(3, count);
}
use of org.apache.hadoop.hbase.client.ResultScanner in project hbase by apache.
the class TestJoinedScanners method runScanner.
private void runScanner(Table table, boolean slow) throws Exception {
long time = System.nanoTime();
Scan scan = new Scan();
scan.addColumn(cf_essential, col_name);
scan.addColumn(cf_joined, col_name);
SingleColumnValueFilter filter = new SingleColumnValueFilter(cf_essential, col_name, CompareFilter.CompareOp.EQUAL, flag_yes);
filter.setFilterIfMissing(true);
scan.setFilter(filter);
scan.setLoadColumnFamiliesOnDemand(!slow);
ResultScanner result_scanner = table.getScanner(scan);
Result res;
long rows_count = 0;
while ((res = result_scanner.next()) != null) {
rows_count++;
}
double timeSec = (System.nanoTime() - time) / 1000000000.0;
result_scanner.close();
LOG.info((slow ? "Slow" : "Joined") + " scanner finished in " + Double.toString(timeSec) + " seconds, got " + Long.toString(rows_count / 2) + " rows");
}
Aggregations