Marked plutodb as deprecated until made stable
This commit is contained in:
parent
744baf102a
commit
8763691e77
|
@ -6,18 +6,18 @@ import java.nio.ByteBuffer;
|
|||
|
||||
public interface ILMDBValueRecipe
|
||||
{
|
||||
public int sizeOf();
|
||||
int sizeOf();
|
||||
|
||||
public void serialize(ByteBuffer output);
|
||||
void serialize(ByteBuffer output);
|
||||
|
||||
public void deserialize(ByteBuffer input);
|
||||
void deserialize(ByteBuffer input);
|
||||
|
||||
public static int sizeOfUTF8(CharSequence string)
|
||||
static int sizeOfUTF8(CharSequence string)
|
||||
{
|
||||
return Integer.BYTES + MemoryUtil.memLengthUTF8(string, false);
|
||||
}
|
||||
|
||||
public static void putUTF8(CharSequence string, ByteBuffer output)
|
||||
static void putUTF8(CharSequence string, ByteBuffer output)
|
||||
{
|
||||
int strLen = MemoryUtil.memUTF8(string, false, output, output.position() + Integer.BYTES);
|
||||
output.putInt(strLen);
|
||||
|
@ -25,7 +25,7 @@ public interface ILMDBValueRecipe
|
|||
output.position(output.position() + strLen);
|
||||
}
|
||||
|
||||
public static String getUTF8(ByteBuffer input)
|
||||
static String getUTF8(ByteBuffer input)
|
||||
{
|
||||
var strLen = input.getInt();
|
||||
var string = MemoryUtil.memUTF8(input, strLen);
|
||||
|
|
|
@ -42,7 +42,12 @@ public class LMDBDatabase<K extends LMDBKey, V extends ILMDBValueRecipe>
|
|||
|
||||
var valueStruct = MDBVal.mallocStack(stack).mv_data(data).mv_size(size);
|
||||
|
||||
assert LMDB.mdb_put(this.transaction.getAddress(), this.handle, keyStruct, valueStruct, 0) == LMDB.MDB_SUCCESS;
|
||||
int retval = LMDB.mdb_put(this.transaction.getAddress(), this.handle, keyStruct, valueStruct, 0);
|
||||
|
||||
if (retval != LMDB.MDB_SUCCESS)
|
||||
{
|
||||
throw new RuntimeException(String.format("Error: mdb_put failed with the following error code: %d", retval));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -68,7 +73,12 @@ public class LMDBDatabase<K extends LMDBKey, V extends ILMDBValueRecipe>
|
|||
|
||||
var valueStruct = MDBVal.mallocStack(stack);
|
||||
|
||||
assert LMDB.mdb_get(this.transaction.getAddress(), this.handle, keyStruct, valueStruct) == LMDB.MDB_SUCCESS;
|
||||
int retval = LMDB.mdb_get(this.transaction.getAddress(), this.handle, keyStruct, valueStruct);
|
||||
|
||||
if (retval != LMDB.MDB_SUCCESS)
|
||||
{
|
||||
throw new RuntimeException(String.format("Error: mdb_get failed with the following error code: %d", retval));
|
||||
}
|
||||
|
||||
valueToUpdate.deserialize(valueStruct.mv_data());
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ import org.lwjgl.util.lmdb.MDBVal;
|
|||
|
||||
public class LMDBIntegerKey extends LMDBKey
|
||||
{
|
||||
private int key;
|
||||
private final int key;
|
||||
|
||||
private LMDBIntegerKey(int key)
|
||||
{
|
||||
|
|
|
@ -5,7 +5,7 @@ import org.lwjgl.util.lmdb.MDBVal;
|
|||
|
||||
public class LMDBLongKey extends LMDBKey
|
||||
{
|
||||
private long key;
|
||||
private final long key;
|
||||
|
||||
private LMDBLongKey(long key)
|
||||
{
|
||||
|
|
|
@ -5,7 +5,7 @@ import org.lwjgl.util.lmdb.MDBVal;
|
|||
|
||||
public class LMDBStringKey extends LMDBKey
|
||||
{
|
||||
private String key;
|
||||
private final String key;
|
||||
|
||||
private LMDBStringKey(String key)
|
||||
{
|
||||
|
|
|
@ -73,11 +73,7 @@ public class LMDBTransaction implements AutoCloseable
|
|||
{
|
||||
return new LMDBDatabase<K, V>(this, dbHandle, recipeClazz);
|
||||
}
|
||||
catch (NoSuchMethodException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (IllegalAccessException e)
|
||||
catch (NoSuchMethodException | IllegalAccessException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -87,7 +83,13 @@ public class LMDBTransaction implements AutoCloseable
|
|||
|
||||
public void commit()
|
||||
{
|
||||
LMDB.mdb_txn_commit(this.ptr);
|
||||
int returnCode = LMDB.mdb_txn_commit(this.ptr);
|
||||
|
||||
if (returnCode != LMDB.MDB_SUCCESS)
|
||||
{
|
||||
throw new RuntimeException(String.format("Error: mdb_txn_commit failed with the following error code: %d", returnCode));
|
||||
}
|
||||
|
||||
this.uncommited = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
/**
|
||||
* @deprecated Usage discouraged until tested well enough.
|
||||
* */
|
||||
@Deprecated
|
||||
package cz.tefek.pluto.lmdb;
|
Loading…
Reference in New Issue