*/
private SortedMap<Integer, byte[]> getMessageData(final long messageId, final Database oldDatabase)
{
TreeMap<Integer, byte[]> data = new TreeMap<Integer, byte[]>();
Cursor cursor = oldDatabase.openCursor(null, CursorConfig.READ_COMMITTED);
try
{
DatabaseEntry contentKeyEntry = new DatabaseEntry();
DatabaseEntry value = new DatabaseEntry();
CompoundKeyBinding binding = new CompoundKeyBinding();
binding.objectToEntry(new CompoundKey(messageId, 0), contentKeyEntry);
OperationStatus status = cursor.getSearchKeyRange(contentKeyEntry, value, LockMode.DEFAULT);
OldDataBinding dataBinding = new OldDataBinding();
while (status == OperationStatus.SUCCESS)
{
CompoundKey compoundKey = binding.entryToObject(contentKeyEntry);
long id = compoundKey.getMessageId();
if (id != messageId)
{
// we have exhausted all chunks for this message id, break
break;
}
int offsetInMessage = compoundKey.getOffset();
OldDataValue dataValue = dataBinding.entryToObject(value);
data.put(offsetInMessage, dataValue.getData());
status = cursor.getNext(contentKeyEntry, value, LockMode.DEFAULT);
}
}
finally
{
cursor.close();
}
return data;
}