public void testRead3() throws IOException, ParseException {
String projection = new String("c3");
BasicTable.Reader reader = new BasicTable.Reader(path, conf);
reader.setProjection(projection);
List<RangeSplit> splits = reader.rangeSplit(1);
TableScanner scanner = reader.getScanner(splits.get(0), true);
BytesWritable key = new BytesWritable();
Tuple RowValue = TypesUtils.createTuple(scanner.getSchema());
scanner.getKey(key);
Assert.assertEquals(key, new BytesWritable("k11".getBytes()));
scanner.getValue(RowValue);
System.out.println("test record 3: row: " + RowValue.toString());
// test record 3: row: ({(1,true),(2,false),(3,true),(4,false)})
Iterator<Tuple> it = ((DataBag) RowValue.get(0)).iterator();
int list = 0;
while (it.hasNext()) {
Tuple cur = it.next();
System.out.println(cur.get(0)); // 3
list++;
if (list == 1) {
Assert.assertEquals(1, cur.get(0));
Assert.assertEquals(true, cur.get(1));
}
if (list == 2) {
Assert.assertEquals(2, cur.get(0));
Assert.assertEquals(false, cur.get(1));
}
if (list == 3) {
Assert.assertEquals(3, cur.get(0));
Assert.assertEquals(true, cur.get(1));
}
if (list == 4) {
Assert.assertEquals(4, cur.get(0));
Assert.assertEquals(false, cur.get(1));
}
}
scanner.advance();
scanner.getValue(RowValue);
System.out.println("row: " + RowValue.toString());
// row: ({(5,true),(6,false),(7,true),(8,false)})
Iterator<Tuple> it2 = ((DataBag) RowValue.get(0)).iterator();
scanner.getKey(key);
Assert.assertEquals(key, new BytesWritable("k12".getBytes()));
int list2 = 0;
while (it2.hasNext()) {
Tuple cur = it2.next();
System.out.println(cur.get(0));