CavalliumDBEngine/src/main/java/it/cavallium/dbengine/database/disk/RocksDBColumn.java

93 lines
3.2 KiB
Java
Raw Normal View History

2021-10-20 01:51:34 +02:00
package it.cavallium.dbengine.database.disk;
import io.micrometer.core.instrument.MeterRegistry;
2023-03-06 12:19:08 +01:00
import it.cavallium.buffer.Buf;
import it.cavallium.dbengine.database.LLRange;
2021-11-12 02:05:44 +01:00
import it.cavallium.dbengine.database.LLUtils;
2023-05-22 19:12:05 +02:00
import it.cavallium.dbengine.database.disk.rocksdb.LLReadOptions;
import it.cavallium.dbengine.database.disk.rocksdb.LLWriteOptions;
2022-05-12 19:14:27 +02:00
import it.cavallium.dbengine.database.disk.rocksdb.RocksIteratorObj;
2023-03-27 22:00:32 +02:00
import it.cavallium.dbengine.database.serialization.SerializationFunction;
2021-10-20 01:51:34 +02:00
import java.io.IOException;
import java.util.List;
import java.util.stream.Stream;
2021-10-20 01:51:34 +02:00
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.rocksdb.ColumnFamilyHandle;
import org.rocksdb.CompactRangeOptions;
import org.rocksdb.FlushOptions;
import org.rocksdb.RocksDBException;
import org.rocksdb.WriteBatch;
public sealed interface RocksDBColumn permits AbstractRocksDBColumn {
/**
* This method should not modify or move the writerIndex/readerIndex of the buffers inside the range
*/
2023-05-22 19:12:05 +02:00
@NotNull RocksIteratorObj newRocksIterator(LLReadOptions readOptions,
LLRange range,
boolean reverse) throws RocksDBException;
2023-05-22 19:12:05 +02:00
default byte @Nullable [] get(@NotNull LLReadOptions readOptions,
2021-11-12 02:05:44 +01:00
byte[] key,
boolean existsAlmostCertainly)
throws RocksDBException {
var result = this.get(readOptions, Buf.wrap(key));
if (result == null) {
return null;
2021-11-12 02:05:44 +01:00
}
return LLUtils.asArray(result);
2021-11-12 02:05:44 +01:00
}
2021-10-20 01:51:34 +02:00
@Nullable
2023-05-22 19:12:05 +02:00
Buf get(@NotNull LLReadOptions readOptions, Buf key) throws RocksDBException;
2021-10-20 01:51:34 +02:00
2023-05-22 19:12:05 +02:00
boolean exists(@NotNull LLReadOptions readOptions, Buf key) throws RocksDBException;
2021-10-20 01:51:34 +02:00
2023-05-22 19:12:05 +02:00
boolean mayExists(@NotNull LLReadOptions readOptions, Buf key);
2022-04-19 23:23:12 +02:00
2023-05-22 19:12:05 +02:00
void put(@NotNull LLWriteOptions writeOptions, Buf key, Buf value) throws RocksDBException;
2021-10-20 01:51:34 +02:00
2023-05-22 19:12:05 +02:00
default void put(@NotNull LLWriteOptions writeOptions, byte[] key, byte[] value) throws RocksDBException {
this.put(writeOptions, Buf.wrap(key), Buf.wrap(value));
2021-11-12 02:05:44 +01:00
}
2023-05-22 19:12:05 +02:00
@NotNull RocksIteratorObj newIterator(@NotNull LLReadOptions readOptions, @Nullable Buf min, @Nullable Buf max);
2021-10-20 01:51:34 +02:00
Stream<RocksDBFile> getAllLiveFiles() throws RocksDBException;
2023-05-22 19:12:05 +02:00
@NotNull UpdateAtomicResult updateAtomic(@NotNull LLReadOptions readOptions,
@NotNull LLWriteOptions writeOptions,
Buf key,
2023-03-27 22:00:32 +02:00
SerializationFunction<@Nullable Buf, @Nullable Buf> updater,
2023-03-20 00:36:27 +01:00
UpdateAtomicResultMode returnMode);
2021-10-20 01:51:34 +02:00
2023-05-22 19:12:05 +02:00
void delete(LLWriteOptions writeOptions, Buf key) throws RocksDBException;
2021-10-20 01:51:34 +02:00
2023-05-22 19:12:05 +02:00
void delete(LLWriteOptions writeOptions, byte[] key) throws RocksDBException;
2021-10-20 01:51:34 +02:00
2023-05-22 19:12:05 +02:00
List<byte[]> multiGetAsList(LLReadOptions readOptions, List<byte[]> keys) throws RocksDBException;
2021-10-20 01:51:34 +02:00
2023-05-22 19:12:05 +02:00
void write(LLWriteOptions writeOptions, WriteBatch writeBatch) throws RocksDBException;
2021-10-20 01:51:34 +02:00
void suggestCompactRange() throws RocksDBException;
void compactRange(byte[] begin, byte[] end, CompactRangeOptions options) throws RocksDBException;
2021-10-20 01:51:34 +02:00
void flush(FlushOptions options) throws RocksDBException;
2021-10-20 01:51:34 +02:00
void flushWal(boolean sync) throws RocksDBException;
long getLongProperty(String property) throws RocksDBException;
2023-01-05 02:21:09 +01:00
long getNumEntries() throws RocksDBException;
ColumnFamilyHandle getColumnFamilyHandle();
2021-10-20 01:51:34 +02:00
MeterRegistry getMeterRegistry();
2021-10-20 01:51:34 +02:00
boolean supportsTransactions();
2023-03-20 00:36:27 +01:00
void forceCompaction(int volumeId);
2021-10-20 01:51:34 +02:00
}