ds = (DaoDataset) repo.load(tableName);
// ensure the new entities are what we expect with get operations
for (int i = 0; i < 10; ++i) {
String iStr = Long.toString(i);
Key key = new Key.Builder(ds)
.add("part1", "part1_" + iStr)
.add("part2", "part2_" + iStr).build();
compareEntitiesWithUtf8(i, ds.get(key));
}
// ensure the new entities are what we expect with scan operations
int cnt = 0;
DatasetReader<GenericRecord> reader = ds.newReader();
assertFalse("Reader should not be open before calling open", reader.isOpen());
reader.open();
assertTrue("Reader should be open after calling open", reader.isOpen());
try {
for (GenericRecord entity : reader) {
compareEntitiesWithUtf8(cnt, entity);
cnt++;
}
assertEquals(10, cnt);
} finally {
reader.close();
assertFalse("Reader should be closed after calling close", reader.isOpen());
}
// test a partial scan
cnt = 3;
reader = new DaoView<GenericRecord>(ds)
.from(new Marker.Builder().add("part1", "part1_3").add("part2", "part2_3").build())
.to(new Marker.Builder().add("part1", "part1_7").add("part2", "part2_7").build())
.newReader();
reader.open();
try {
for (GenericRecord entity : reader) {
compareEntitiesWithUtf8(cnt, entity);
cnt++;
}
assertEquals(8, cnt);
} finally {
reader.close();
}
Key key = new Key.Builder(ds)
.add("part1", "part1_5")
.add("part2", "part2_5").build();
// test delete
ds.delete(key);