.withValue(1L, "email1")
.withValue(2L, "email2")
.build();
final KijiTable table = kiji.openTable("user");
try {
final KijiTableReader reader = table.openTableReader();
try {
final EntityId eid = table.getEntityId("row");
// Make sure we have 2 versions in columns info:name and in info:email.
{
final KijiDataRequest dataRequest = KijiDataRequest.builder()
.addColumns(ColumnsDef.create()
.withMaxVersions(HConstants.ALL_VERSIONS)
.addFamily("info"))
.build();
final KijiRowData row = reader.get(eid, dataRequest);
assertEquals(2, row.getValues("info", "name").size());
assertEquals(2, row.getValues("info", "email").size());
}
// Test FirstKeyOnly filter when applied on the group-type family.
{
final KijiDataRequest dataRequest = KijiDataRequest.builder()
.addColumns(ColumnsDef.create()
.withMaxVersions(HConstants.ALL_VERSIONS)
.withFilter(new KijiFirstKeyOnlyColumnFilter())
.addFamily("info"))
.build();
final KijiRowData row = reader.get(eid, dataRequest);
assertEquals(1, row.getValues("info", "name").size());
assertEquals(1, row.getValues("info", "email").size());
}
// Test FirstKeyOnly filter when applied on a single column.
// Make sure it doesn't affect other columns.
{
final KijiDataRequest dataRequest = KijiDataRequest.builder()
.addColumns(ColumnsDef.create()
.withMaxVersions(HConstants.ALL_VERSIONS)
.withFilter(new KijiFirstKeyOnlyColumnFilter())
.add("info", "name"))
.addColumns(ColumnsDef.create()
.withMaxVersions(HConstants.ALL_VERSIONS)
.add("info", "email"))
.build();
final KijiRowData row = reader.get(eid, dataRequest);
assertEquals(1, row.getValues("info", "name").size());
assertEquals(2, row.getValues("info", "email").size());
}
// Test FirstKeyOnly filter when applied on a single column.
// Make sure it doesn't affect other columns.
{
final KijiDataRequest dataRequest = KijiDataRequest.builder()
.addColumns(ColumnsDef.create()
.withMaxVersions(HConstants.ALL_VERSIONS)
.add("info", "name"))
.addColumns(ColumnsDef.create()
.withMaxVersions(HConstants.ALL_VERSIONS)
.withFilter(new KijiFirstKeyOnlyColumnFilter())
.add("info", "email"))
.build();
final KijiRowData row = reader.get(eid, dataRequest);
assertEquals(2, row.getValues("info", "name").size());
assertEquals(1, row.getValues("info", "email").size());
}
} finally {
reader.close();
}
} finally {
table.release();
}
}