2021-07-10 20:52:01 +02:00
|
|
|
package it.cavallium.dbengine.database.memory;
|
|
|
|
|
2021-08-29 23:18:03 +02:00
|
|
|
import io.netty.buffer.api.BufferAllocator;
|
2021-07-10 20:52:01 +02:00
|
|
|
import it.cavallium.dbengine.client.DatabaseOptions;
|
|
|
|
import it.cavallium.dbengine.client.IndicizerAnalyzers;
|
|
|
|
import it.cavallium.dbengine.client.IndicizerSimilarities;
|
|
|
|
import it.cavallium.dbengine.client.LuceneOptions;
|
|
|
|
import it.cavallium.dbengine.database.Column;
|
|
|
|
import it.cavallium.dbengine.database.LLDatabaseConnection;
|
|
|
|
import it.cavallium.dbengine.database.LLKeyValueDatabase;
|
|
|
|
import it.cavallium.dbengine.database.LLLuceneIndex;
|
|
|
|
import it.cavallium.dbengine.database.disk.LLLocalKeyValueDatabase;
|
|
|
|
import it.cavallium.dbengine.database.disk.LLLocalLuceneIndex;
|
|
|
|
import it.cavallium.dbengine.database.disk.LLLocalMultiLuceneIndex;
|
|
|
|
import it.cavallium.dbengine.netty.JMXNettyMonitoringManager;
|
|
|
|
import java.nio.file.Files;
|
|
|
|
import java.nio.file.Path;
|
|
|
|
import java.util.LinkedList;
|
|
|
|
import java.util.List;
|
|
|
|
import reactor.core.publisher.Mono;
|
|
|
|
import reactor.core.scheduler.Schedulers;
|
|
|
|
|
|
|
|
public class LLMemoryDatabaseConnection implements LLDatabaseConnection {
|
|
|
|
|
|
|
|
static {
|
|
|
|
JMXNettyMonitoringManager.initialize();
|
|
|
|
}
|
|
|
|
|
2021-08-31 09:14:46 +02:00
|
|
|
private final BufferAllocator allocator;
|
2021-07-10 20:52:01 +02:00
|
|
|
|
2021-08-31 09:14:46 +02:00
|
|
|
public LLMemoryDatabaseConnection(BufferAllocator allocator) {
|
2021-07-10 20:52:01 +02:00
|
|
|
this.allocator = allocator;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2021-08-31 09:14:46 +02:00
|
|
|
public BufferAllocator getAllocator() {
|
2021-07-10 20:52:01 +02:00
|
|
|
return allocator;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Mono<LLDatabaseConnection> connect() {
|
|
|
|
return Mono.empty();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Mono<LLKeyValueDatabase> getDatabase(String name,
|
|
|
|
List<Column> columns,
|
|
|
|
DatabaseOptions databaseOptions) {
|
|
|
|
return Mono
|
|
|
|
.<LLKeyValueDatabase>fromCallable(() -> new LLMemoryKeyValueDatabase(
|
|
|
|
allocator,
|
|
|
|
name,
|
|
|
|
columns
|
|
|
|
))
|
|
|
|
.subscribeOn(Schedulers.boundedElastic());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Mono<LLLuceneIndex> getLuceneIndex(String name,
|
|
|
|
int instancesCount,
|
|
|
|
IndicizerAnalyzers indicizerAnalyzers,
|
|
|
|
IndicizerSimilarities indicizerSimilarities,
|
|
|
|
LuceneOptions luceneOptions) {
|
|
|
|
return Mono
|
|
|
|
.<LLLuceneIndex>fromCallable(() -> new LLLocalLuceneIndex(null,
|
|
|
|
name,
|
|
|
|
indicizerAnalyzers,
|
|
|
|
indicizerSimilarities,
|
|
|
|
luceneOptions
|
|
|
|
))
|
|
|
|
.subscribeOn(Schedulers.boundedElastic());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Mono<Void> disconnect() {
|
|
|
|
return Mono.empty();
|
|
|
|
}
|
|
|
|
}
|