Bulk operations in the driver APIs are quite different from the
Java base APIs. In Java base APIs, multiple entries are encoded into a
single byte array. In the driver APIs, they are simply maintained as
a list of entries. As a consequence, the
MultipleEntry class has no counterpart in
the driver APIs, and SMultipleDataEntry ,
SMultipleKeyDataEntry and
SMultipleRecnoDataEntry are no longer
subclasses of SDatabaseEntry. To support
functions that accept any type of data entries,
SDatabaseEntryBase is added as the base
interface of all data entry classes, and
SMultiplePairs is added as the base class
of SMultipleKeyDataEntry and
SMultipleRecnoDataEntry.
In driver APIs, the amount of data to be returned in a single
bulk retrieval is not limited by a buffer size, because
SMultipleDataEntry ,
SMultipleKeyDataEntry or
SMultipleRecnoDataEntry does not use a
byte array buffer. Instead, the number of entries to be returned is
specified with the setBatchSize method:
SEnvironment env = ...
// Open the database with the default configuration.
SDatabase db = env.openDatabase(null, "db", null, null);
// Create a SMultipleDataEntry for bulk retrieval.
SMultipleDataEntry dataEntries = new SMultipleDataEntry();
// Return at maximum of 10 data items from a single retrieval.
dataEntries.setBatchSize(10);
// Perform a bulk retrieval to return multiple data items
// for the same duplicated key.
db.get(null, new SDatabaseEntry("key".getBytes()), dataEntries, null);
// Iterate over the retrieved items.
SDatabaseEntry item = new SDatabaseEntry();
while (dataEntries.next(item)) {
// Do something for each item.
}