CavalliumDBEngine/src/main/java/it/cavallium/dbengine/database/LLDictionary.java

46 lines
1.7 KiB
Java
Raw Normal View History

2020-12-07 22:15:18 +01:00
package it.cavallium.dbengine.database;
import java.io.IOException;
import java.util.Map.Entry;
import java.util.Optional;
import java.util.function.Consumer;
import org.jetbrains.annotations.Nullable;
import org.warp.commonutils.concurrency.atomicity.NotAtomic;
2021-01-17 18:31:25 +01:00
import org.warp.commonutils.functional.CancellableBiConsumer;
import org.warp.commonutils.functional.CancellableBiFunction;
import org.warp.commonutils.functional.ConsumerResult;
2020-12-07 22:15:18 +01:00
@NotAtomic
public interface LLDictionary extends LLKeyValueDatabaseStructure {
Optional<byte[]> get(@Nullable LLSnapshot snapshot, byte[] key) throws IOException;
boolean contains(@Nullable LLSnapshot snapshot, byte[] key) throws IOException;
Optional<byte[]> put(byte[] key, byte[] value, LLDictionaryResultType resultType)
throws IOException;
void putMulti(byte[][] key, byte[][] value, LLDictionaryResultType resultType,
Consumer<byte[]> responses) throws IOException;
Optional<byte[]> remove(byte[] key, LLDictionaryResultType resultType) throws IOException;
/**
* This method can call the consumer from different threads in parallel
*/
2021-01-17 18:31:25 +01:00
ConsumerResult forEach(@Nullable LLSnapshot snapshot, int parallelism, CancellableBiConsumer<byte[], byte[]> consumer);
2020-12-07 22:15:18 +01:00
/**
* This method can call the consumer from different threads in parallel
*/
2021-01-17 18:31:25 +01:00
ConsumerResult replaceAll(int parallelism, boolean replaceKeys, CancellableBiFunction<byte[], byte[], Entry<byte[], byte[]>> consumer) throws IOException;
2020-12-07 22:15:18 +01:00
void clear() throws IOException;
long size(@Nullable LLSnapshot snapshot, boolean fast) throws IOException;
boolean isEmpty(@Nullable LLSnapshot snapshot) throws IOException;
Optional<Entry<byte[], byte[]>> removeOne() throws IOException;
}