io.permazen.kv.lmdb.ByteArrayLMDBKVStore Maven / Gradle / Ivy
Show all versions of permazen-kv-lmdb Show documentation
/*
* Copyright (C) 2015 Archie L. Cobbs. All rights reserved.
*/
package io.permazen.kv.lmdb;
import io.permazen.kv.KVStore;
import org.lmdbjava.Dbi;
import org.lmdbjava.Txn;
/**
* {@link KVStore} view of a LMDB transaction using {@code byte[]} array buffers.
*
*
* Instances must be {@link #close}'d when no longer needed to avoid leaking resources.
*/
public class ByteArrayLMDBKVStore extends LMDBKVStore {
// Constructors
/**
* Constructor.
*
*
* Closing this instance does not close the underlying transaction.
*
* @param db LMDB database
* @param tx LMDB transaction
* @throws IllegalArgumentException if {@code db} or {@code tx} is null
*/
public ByteArrayLMDBKVStore(Dbi db, Txn tx) {
super(db, tx);
}
@Override
protected byte[] wrap(byte[] data, boolean copy) {
return data == null ? null : copy ? data.clone() : data;
}
@Override
protected byte[] unwrap(byte[] data, boolean copy) {
return data == null ? null : copy ? data.clone() : data;
}
}