}
IndexReader reader = writer.getReader();
writer.close();
CategoryListIterator cli = new PayloadIntDecodingIterator(reader, new Term(
"f","1"), dts.encoder.createMatchingDecoder());
cli.init();
int totalCats = 0;
for (int i = 0; i < data.length; i++) {
// doc no. i
Set<Integer> values = new HashSet<Integer>();
for (int j = 0; j < data[i].length; j++) {
values.add(data[i][j]);
}
boolean hasDoc = cli.skipTo(i);
if (hasDoc) {
assertTrue("Document "+i+" must not have a payload!", i==0 || i==2 );
long cat;
while ((cat = cli.nextCategory()) < Integer.MAX_VALUE) {
assertTrue("expected category not found: " + cat, values.contains((int) cat));
++totalCats;
}
} else {
assertFalse("Document "+i+" must have a payload!", i==0 || i==2 );
}
}
assertEquals("Wrong number of total categories!", 4, totalCats);
// Ok.. went through the first 4 docs, now lets try the 6th doc (docid 5)
assertFalse("Doc #6 (docid=5) should not have a payload!",cli.skipTo(5));
reader.close();
dir.close();
}