You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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-used
result.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.