2020-12-07 22:15:18 +01:00
|
|
|
package it.cavallium.dbengine.database;
|
|
|
|
|
|
|
|
import com.google.common.primitives.Ints;
|
|
|
|
import com.google.common.primitives.Longs;
|
|
|
|
import java.io.Closeable;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
|
import it.cavallium.dbengine.database.structures.LLInt;
|
|
|
|
import it.cavallium.dbengine.database.structures.LLLong;
|
|
|
|
|
|
|
|
public interface LLKeyValueDatabase extends Closeable, LLSnapshottable, LLKeyValueDatabaseStructure {
|
|
|
|
|
|
|
|
LLSingleton getSingleton(byte[] singletonListColumnName, byte[] name, byte[] defaultValue)
|
|
|
|
throws IOException;
|
|
|
|
|
|
|
|
LLDictionary getDictionary(byte[] columnName) throws IOException;
|
|
|
|
|
2021-01-30 00:24:55 +01:00
|
|
|
default LLDictionary getSet(String name) throws IOException {
|
|
|
|
return getDictionary(Column.fixedSet(name).getName().getBytes(StandardCharsets.US_ASCII));
|
2020-12-07 22:15:18 +01:00
|
|
|
}
|
|
|
|
|
2021-01-30 00:24:55 +01:00
|
|
|
default LLDictionary getMap(String name) throws IOException {
|
|
|
|
return getDictionary(Column.hashMap(name).getName().getBytes(StandardCharsets.US_ASCII));
|
2020-12-07 22:15:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
default LLInt getInteger(String singletonListName, String name, int defaultValue)
|
|
|
|
throws IOException {
|
|
|
|
LLSingleton singleton = getSingleton(
|
|
|
|
Column.special(singletonListName).getName().getBytes(StandardCharsets.US_ASCII),
|
|
|
|
name.getBytes(StandardCharsets.US_ASCII), Ints.toByteArray(defaultValue));
|
|
|
|
return new LLInt(singleton);
|
|
|
|
}
|
|
|
|
|
|
|
|
default LLLong getLong(String singletonListName, String name, long defaultValue)
|
|
|
|
throws IOException {
|
|
|
|
LLSingleton singleton = getSingleton(
|
|
|
|
Column.special(singletonListName).getName().getBytes(StandardCharsets.US_ASCII),
|
|
|
|
name.getBytes(StandardCharsets.US_ASCII), Longs.toByteArray(defaultValue));
|
|
|
|
return new LLLong(singleton);
|
|
|
|
}
|
|
|
|
|
|
|
|
long getProperty(String propertyName) throws IOException;
|
|
|
|
}
|