[The following is a repost of the 12/23/05 Sleepycat blog entry.]
In JE, the various Database-based operations (e.g. Database.put(), Database.get(), etc.) all are implemented by creating a Cursor object and then running the equivalent Cursor method. The internal Cursor
method implementations all start by "cloning" the cursor and then
performing the requested operation. Upon successful completion of the
operation, the cloned cursor becomes the "real" cursor that is returned
to the user program. That way, if the operation fails somewhere in the
middle of the tree, restoring the original state of the cursor is easy
(we throw away the cloned cursor and revert back to the original cursor
that was passed to us in the first place).
But the Database
operations don't need the benefit of the clone operation because the
internal cursor is never exposed to the user. Hence, if a Database operation ends up in a strange state (i.e. the operation is not going to succeed), we don't need to revert the cursor.
The next release of JE (2.1) will remove this performance penalty from the Database operations by not cloning the internal cursor.