.create();
RecordScan scan = new RecordScan();
scan.setStartRecordId(idGenerator.newRecordId("PrefixScanTest"));
RecordScanner scanner = repository.getScanner(scan);
assertEquals(idGenerator.newRecordId("PrefixScanTest"), scanner.next().getId());
assertEquals(idGenerator.newRecordId("PrefixScanTest-suffix1"), scanner.next().getId());
assertEquals(idGenerator.newRecordId("PrefixScanTest-suffix2"), scanner.next().getId());
// the scanner would run till the end of the table
assertNotNull(scanner.next());
scanner.close();
scan.setRecordFilter(new RecordIdPrefixFilter(idGenerator.newRecordId("PrefixScanTest")));
scanner = repository.getScanner(scan);
assertEquals(idGenerator.newRecordId("PrefixScanTest"), scanner.next().getId());
assertEquals(idGenerator.newRecordId("PrefixScanTest-suffix1"), scanner.next().getId());
assertEquals(idGenerator.newRecordId("PrefixScanTest-suffix2"), scanner.next().getId());
// due to the prefix filter, the scanner stops once there are no records left with the same prefix
assertNull(scanner.next());
scanner.close();
//
// When using UUID record ID's, prefix scans make less sense, except for retrieving
// variants
//
RecordId uuid = idGenerator.newRecordId();
RecordId varid1 = idGenerator.newRecordId(uuid, ImmutableMap.of("lang", "en", "year", "1999"));
RecordId varid2 = idGenerator.newRecordId(uuid, ImmutableMap.of("lang", "fr"));
repository.recordBuilder()
.id(uuid)
.recordType(recordType1.getName())
.field(fieldType1.getName(), "foo")
.create();
repository.recordBuilder()
.id(varid1)
.recordType(recordType1.getName())
.field(fieldType1.getName(), "foo")
.create();
repository.recordBuilder()
.id(varid2)
.recordType(recordType1.getName())
.field(fieldType1.getName(), "foo")
.create();
scan = new RecordScan();
scan.setStartRecordId(uuid);
scan.setRecordFilter(new RecordIdPrefixFilter(uuid));
scanner = repository.getScanner(scan);
assertEquals(uuid, scanner.next().getId());
assertEquals(varid1, scanner.next().getId());
assertEquals(varid2, scanner.next().getId());
assertNull(scanner.next());
scanner.close();
}