Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

ByteBuffer is re-used even when the byte order is different, leading to wrong results #76

Closed
@jubax

Description

@jubax

In LMDB it is possible to use DbiFlags.MDB_INTEGERKEY when opening a database. When this flag is used then it is assumed that the keys are stored in native byte order.

When I have one database with MDB_INTEGERKEY then I use ByteBuffer.order(ByteOrder.nativeOrder()). Otherwise I keep the order.

When I retrieve values from the MDB_INTEGERKEY store I need to change the byte order of the returned ByteBuffer. Note that "db1" uses MDB_INTEGERKEY and "db2" not. The ByteBuffer which is returned is shared between both databases.

try (Txn<ByteBuffer> txn = env.txnRead();) {ByteBuffer result = db1.get(txn, key); // <-- This buffer is re-usedresult.order(ByteOrder.nativeOrder());assertEquals(100, result.getInt());}try (Txn<ByteBuffer> txn = env.txnRead();) {ByteBuffer result = db2.get(txn, key);assertEquals(333, result.getInt()); // FAIL because "result" has native order}

The API does not mention that I cannot change e.g. the byte order of the returned ByteBuffer object.

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


      [8]ページ先頭

      ©2009-2025 Movatter.jp