/* DatabaseEntry represents the key and data of each record. */
DatabaseEntry key = new DatabaseEntry();
DatabaseEntry data = new DatabaseEntry();
/* Adler32 to compute the rolling checksum of key/data pair. */
Adler32 adler32 = new Adler32();
int i = 0;
int a = 0, b = 0;
md.reset();
Block block = new Block(blockId);
/* Please pay attention to the check order in while loop. */
while ((i < numKeys) &&
(cursor.getNext(key, data, LockMode.DEFAULT) ==
OperationStatus.SUCCESS)) {
/* Indicates having a new block. */
if (i == 0) {
block.setBeginKey(key.getData());
block.setBeginData(data.getData());
}
/* Calculate rollingChksum on "key|data" bytes. */
adler32.reset();
adler32.update(key.getData(), 0, key.getData().length);
adler32.update(data.getData(), 0, data.getData().length);
final int xi = (int) adler32.getValue();
a += xi;
b += a;
/* Update MessageDigest with "key|data" bytes. */
md.update(key.getData());
md.update(data.getData());