for (int key = 0; key <= 5; key++) {
database.command(new OCommandSQL("insert into index:equalityIdx (key,rid) values (" + key + ",#10:" + key + ")")).execute();
}
final OIndex index = database.getMetadata().getIndexManager().getIndex("equalityIdx");
final Collection<Integer> valuesMinorResults = new ArrayList<Integer>(Arrays.asList(0, 1, 2));
Collection<ODocument> indexCollection = index.getEntriesMinor(3, false);
Assert.assertEquals(indexCollection.size(), 3);
for (ODocument doc : indexCollection) {
valuesMinorResults.remove(doc.<Integer> field("key"));
Assert.assertEquals(doc.<ORecordId> rawField("rid"), new ORecordId(10, doc.<Integer> field("key").longValue()));
}
Assert.assertEquals(valuesMinorResults.size(), 0);
final Collection<Integer> valuesMinorInclusiveResults = new ArrayList<Integer>(Arrays.asList(0, 1, 2, 3));
indexCollection = index.getEntriesMinor(3, true);
Assert.assertEquals(indexCollection.size(), 4);
for (ODocument doc : indexCollection) {
valuesMinorInclusiveResults.remove(doc.<Integer> field("key"));
Assert.assertEquals(doc.<ORecordId> rawField("rid"), new ORecordId(10, doc.<Integer> field("key").longValue()));
}
Assert.assertEquals(valuesMinorInclusiveResults.size(), 0);
indexCollection = index.getEntriesMinor(0, true);
Assert.assertEquals(indexCollection.size(), 1);
Assert.assertEquals(indexCollection.iterator().next().<Integer> field("key"), Integer.valueOf(0));
Assert.assertEquals(indexCollection.iterator().next().<ORecordId> rawField("rid"), new ORecordId(10, 0));
indexCollection = index.getEntriesMinor(0, false);
Assert.assertEquals(indexCollection.size(), 0);
database.command(new OCommandSQL("drop index equalityIdx")).execute();
}