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");
}
use of org.apache.hadoop.hbase.client.ResultScanner in project hbase by apache.
the class TestMobStoreScanner method testReadPt.
@Test
public void testReadPt() throws Exception {
final TableName tableName = TableName.valueOf(name.getMethodName());
setUp(0L, tableName);
long ts = System.currentTimeMillis();
byte[] value1 = Bytes.toBytes("value1");
Put put1 = new Put(row1);
put1.addColumn(family, qf1, ts, value1);
table.put(put1);
Put put2 = new Put(row2);
byte[] value2 = Bytes.toBytes("value2");
put2.addColumn(family, qf1, ts, value2);
table.put(put2);
Scan scan = new Scan();
scan.setCaching(1);
ResultScanner rs = table.getScanner(scan);
Result result = rs.next();
Put put3 = new Put(row1);
byte[] value3 = Bytes.toBytes("value3");
put3.addColumn(family, qf1, ts, value3);
table.put(put3);
Put put4 = new Put(row2);
byte[] value4 = Bytes.toBytes("value4");
put4.addColumn(family, qf1, ts, value4);
table.put(put4);
Cell cell = result.getColumnLatestCell(family, qf1);
Assert.assertArrayEquals(value1, CellUtil.cloneValue(cell));
admin.flush(tableName);
result = rs.next();
cell = result.getColumnLatestCell(family, qf1);
Assert.assertArrayEquals(value2, CellUtil.cloneValue(cell));
}
use of org.apache.hadoop.hbase.client.ResultScanner in project hbase by apache.
the class TestMobStoreScanner method testMobThreshold.
private void testMobThreshold(boolean reversed) throws Exception {
TableName tn = TableName.valueOf("testMobThreshold" + reversed);
setUp(defaultThreshold, tn);
byte[] valueLess = generateMobValue((int) defaultThreshold - 1);
byte[] valueEqual = generateMobValue((int) defaultThreshold);
byte[] valueGreater = generateMobValue((int) defaultThreshold + 1);
long ts1 = System.currentTimeMillis();
long ts2 = ts1 + 1;
long ts3 = ts1 + 2;
Put put1 = new Put(row1);
put1.addColumn(family, qf1, ts3, valueLess);
put1.addColumn(family, qf2, ts2, valueEqual);
put1.addColumn(family, qf3, ts1, valueGreater);
table.put(put1);
admin.flush(tn);
Scan scan = new Scan();
setScan(scan, reversed, true);
Cell cellLess = null;
Cell cellEqual = null;
Cell cellGreater = null;
ResultScanner results = table.getScanner(scan);
int count = 0;
for (Result res : results) {
List<Cell> cells = res.listCells();
for (Cell cell : cells) {
// Verify the value
String qf = Bytes.toString(CellUtil.cloneQualifier(cell));
if (qf.equals(Bytes.toString(qf1))) {
cellLess = cell;
}
if (qf.equals(Bytes.toString(qf2))) {
cellEqual = cell;
}
if (qf.equals(Bytes.toString(qf3))) {
cellGreater = cell;
}
count++;
}
}
Assert.assertEquals(3, count);
assertNotMobReference(cellLess, row1, family, valueLess);
assertNotMobReference(cellEqual, row1, family, valueEqual);
assertIsMobReference(cellGreater, row1, family, valueGreater, tn);
results.close();
}
use of org.apache.hadoop.hbase.client.ResultScanner in project hbase by apache.
the class TestScannerWithCorruptHFile method scan.
private void scan(Table table) throws IOException {
Scan scan = new Scan();
scan.setCaching(1);
scan.setCacheBlocks(false);
ResultScanner scanner = table.getScanner(scan);
try {
scanner.next();
} finally {
scanner.close();
}
}
Aggregations