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;
|
2021-10-30 11:13:46 +02:00
|
|
|
import io.micrometer.core.instrument.MeterRegistry;
|
2022-08-15 23:07:17 +02:00
|
|
|
import it.cavallium.dbengine.client.IBackuppable;
|
2021-01-31 00:36:21 +01:00
|
|
|
import it.cavallium.dbengine.database.collections.DatabaseInt;
|
2021-02-05 20:34:58 +01:00
|
|
|
import it.cavallium.dbengine.database.collections.DatabaseLong;
|
2023-02-09 23:34:25 +01:00
|
|
|
import java.io.IOException;
|
2020-12-07 22:15:18 +01:00
|
|
|
import java.nio.charset.StandardCharsets;
|
2022-03-20 14:33:27 +01:00
|
|
|
import org.jetbrains.annotations.Nullable;
|
2023-02-09 23:34:25 +01:00
|
|
|
import org.rocksdb.RocksDBException;
|
2020-12-07 22:15:18 +01:00
|
|
|
|
2022-08-15 23:07:17 +02:00
|
|
|
public interface LLKeyValueDatabase extends LLSnapshottable, LLKeyValueDatabaseStructure, DatabaseProperties,
|
2022-11-22 17:36:31 +01:00
|
|
|
IBackuppable, DatabaseOperations {
|
2020-12-07 22:15:18 +01:00
|
|
|
|
2023-02-09 23:34:25 +01:00
|
|
|
LLSingleton getSingleton(byte[] singletonListColumnName, byte[] name, byte @Nullable [] defaultValue)
|
|
|
|
throws IOException;
|
2020-12-07 22:15:18 +01:00
|
|
|
|
2023-02-09 23:34:25 +01:00
|
|
|
LLDictionary getDictionary(byte[] columnName, UpdateMode updateMode);
|
2020-12-07 22:15:18 +01:00
|
|
|
|
2021-01-31 15:47:48 +01:00
|
|
|
@Deprecated
|
2023-02-09 23:34:25 +01:00
|
|
|
default LLDictionary getDeprecatedSet(String name, UpdateMode updateMode) {
|
2022-03-02 12:34:30 +01:00
|
|
|
return getDictionary(ColumnUtils.deprecatedSet(name).name().getBytes(StandardCharsets.US_ASCII), updateMode);
|
2020-12-07 22:15:18 +01:00
|
|
|
}
|
|
|
|
|
2023-02-09 23:34:25 +01:00
|
|
|
default LLDictionary getDictionary(String name, UpdateMode updateMode) {
|
2022-03-02 12:34:30 +01:00
|
|
|
return getDictionary(ColumnUtils.dictionary(name).name().getBytes(StandardCharsets.US_ASCII), updateMode);
|
2020-12-07 22:15:18 +01:00
|
|
|
}
|
|
|
|
|
2023-02-09 23:34:25 +01:00
|
|
|
default LLSingleton getSingleton(String singletonListName, String name) {
|
2022-03-20 14:33:27 +01:00
|
|
|
return getSingleton(ColumnUtils.special(singletonListName).name().getBytes(StandardCharsets.US_ASCII),
|
|
|
|
name.getBytes(StandardCharsets.US_ASCII),
|
|
|
|
null
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2023-02-09 23:34:25 +01:00
|
|
|
default DatabaseInt getInteger(String singletonListName, String name, int defaultValue) {
|
|
|
|
return new DatabaseInt(this.getSingleton(ColumnUtils
|
|
|
|
.special(singletonListName)
|
|
|
|
.name()
|
|
|
|
.getBytes(StandardCharsets.US_ASCII),
|
|
|
|
name.getBytes(StandardCharsets.US_ASCII),
|
|
|
|
Ints.toByteArray(defaultValue)
|
|
|
|
));
|
2020-12-07 22:15:18 +01:00
|
|
|
}
|
|
|
|
|
2023-02-09 23:34:25 +01:00
|
|
|
default DatabaseLong getLong(String singletonListName, String name, long defaultValue) {
|
|
|
|
return new DatabaseLong(this.getSingleton(ColumnUtils
|
|
|
|
.special(singletonListName)
|
|
|
|
.name()
|
|
|
|
.getBytes(StandardCharsets.US_ASCII),
|
|
|
|
name.getBytes(StandardCharsets.US_ASCII),
|
|
|
|
Longs.toByteArray(defaultValue)
|
|
|
|
));
|
2020-12-07 22:15:18 +01:00
|
|
|
}
|
|
|
|
|
2023-02-09 23:34:25 +01:00
|
|
|
void verifyChecksum();
|
2021-06-27 15:06:48 +02:00
|
|
|
|
2023-02-09 23:34:25 +01:00
|
|
|
void compact() throws RocksDBException;
|
2022-04-26 17:12:22 +02:00
|
|
|
|
2023-02-09 23:34:25 +01:00
|
|
|
void flush();
|
2021-05-03 21:41:51 +02:00
|
|
|
|
2021-10-30 11:13:46 +02:00
|
|
|
MeterRegistry getMeterRegistry();
|
|
|
|
|
2023-02-09 23:34:25 +01:00
|
|
|
void preClose();
|
|
|
|
|
|
|
|
void close();
|
2020-12-07 22:15:18 +01:00
|
|
|
}
|