Skip to content

Update Transaction API getCommittedVersion To Avoid Autoboxing #12598

@belugabehr

Description

@belugabehr

The Long getCommittedVersion() has an overhead of Autoboxing the primitive long value to a Long object. It's not clear to me the use case for this return value - the JavaDoc do not comment on what a 'null' value returned would indicate.

/**
* Gets the version number at which a successful commit modified the database.
* This must be called only after the successful (non-error) completion of a call
* to {@link #commit()} on this {@code Transaction}, or the behavior is undefined.
* Read-only transactions do not modify the database when committed and will have
* a committed version of -1. Keep in mind that a transaction which reads keys and
* then sets them to their current values may be optimized to a read-only transaction.
*
* @return the database version at which the commit succeeded
*/
Long getCommittedVersion();

It looks like the source for this data is primitive already:

return Transaction_getCommittedVersion(getPtr());

Please consider adding a new method with a primitive return type to avoid this overhead.

I happened to come across this when reviewing an application that had churned 9GB of Long values in heap in ~30min - certainly not the end of the world, but something to flag. Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions