Marked plutodb as deprecated until made stable

This commit is contained in:
Tefek 2020-09-03 02:53:09 +02:00
parent 744baf102a
commit 6005bad806
10 changed files with 66 additions and 17 deletions

View File

@ -4,20 +4,24 @@ import org.lwjgl.system.MemoryUtil;
import java.nio.ByteBuffer;
/**
* @deprecated Usage discouraged until tested well enough.
* */
@Deprecated
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 +29,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);

View File

@ -8,6 +8,10 @@ import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
/**
* @deprecated Usage discouraged until tested well enough.
* */
@Deprecated
public class LMDBDatabase<K extends LMDBKey, V extends ILMDBValueRecipe>
{
private LMDBTransaction transaction;
@ -42,7 +46,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 +77,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());

View File

@ -12,6 +12,10 @@ import java.io.IOException;
import javax.annotation.concurrent.ThreadSafe;
/**
* @deprecated Usage discouraged until tested well enough.
* */
@Deprecated
@ThreadSafe
public class LMDBEnvironment implements AutoCloseable
{

View File

@ -3,9 +3,13 @@ package cz.tefek.pluto.lmdb;
import org.lwjgl.system.MemoryStack;
import org.lwjgl.util.lmdb.MDBVal;
/**
* @deprecated Usage discouraged until tested well enough.
* */
@Deprecated
public class LMDBIntegerKey extends LMDBKey
{
private int key;
private final int key;
private LMDBIntegerKey(int key)
{

View File

@ -3,6 +3,10 @@ package cz.tefek.pluto.lmdb;
import org.lwjgl.system.MemoryStack;
import org.lwjgl.util.lmdb.MDBVal;
/**
* @deprecated Usage discouraged until tested well enough.
* */
@Deprecated
public abstract class LMDBKey
{
public abstract MDBVal toMDBVal(MemoryStack stack);

View File

@ -3,9 +3,13 @@ package cz.tefek.pluto.lmdb;
import org.lwjgl.system.MemoryStack;
import org.lwjgl.util.lmdb.MDBVal;
/**
* @deprecated Usage discouraged until tested well enough.
* */
@Deprecated
public class LMDBLongKey extends LMDBKey
{
private long key;
private final long key;
private LMDBLongKey(long key)
{

View File

@ -1,5 +1,9 @@
package cz.tefek.pluto.lmdb;
/**
* @deprecated Usage discouraged until tested well enough.
* */
@Deprecated
public class LMDBSchema<K extends LMDBKey, E extends ILMDBValueRecipe>
{
private String name;

View File

@ -3,9 +3,13 @@ package cz.tefek.pluto.lmdb;
import org.lwjgl.system.MemoryStack;
import org.lwjgl.util.lmdb.MDBVal;
/**
* @deprecated Usage discouraged until tested well enough.
* */
@Deprecated
public class LMDBStringKey extends LMDBKey
{
private String key;
private final String key;
private LMDBStringKey(String key)
{

View File

@ -3,6 +3,10 @@ package cz.tefek.pluto.lmdb;
import org.lwjgl.system.MemoryStack;
import org.lwjgl.util.lmdb.LMDB;
/**
* @deprecated Usage discouraged until tested well enough.
* */
@Deprecated
public class LMDBTransaction implements AutoCloseable
{
private long ptr;
@ -73,11 +77,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 +87,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;
}

View File

@ -0,0 +1 @@
package cz.tefek.pluto.lmdb;