Code cleanup
This commit is contained in:
parent
1a64d98697
commit
297c249243
@ -899,23 +899,6 @@ public class LLUtils {
|
||||
discardStage(o);
|
||||
}
|
||||
});
|
||||
// todo: check if the single object discard hook is more performant
|
||||
/*
|
||||
.doOnDiscard(SafeCloseable.class, LLUtils::discardRefCounted)
|
||||
.doOnDiscard(Map.Entry.class, LLUtils::discardEntry)
|
||||
.doOnDiscard(Collection.class, LLUtils::discardCollection)
|
||||
.doOnDiscard(Tuple2.class, LLUtils::discardTuple2)
|
||||
.doOnDiscard(Tuple3.class, LLUtils::discardTuple3)
|
||||
.doOnDiscard(LLEntry.class, LLUtils::discardLLEntry)
|
||||
.doOnDiscard(LLRange.class, LLUtils::discardLLRange)
|
||||
.doOnDiscard(Delta.class, LLUtils::discardDelta)
|
||||
.doOnDiscard(LLDelta.class, LLUtils::discardLLDelta)
|
||||
.doOnDiscard(Send.class, LLUtils::discardSend)
|
||||
.doOnDiscard(Resource.class, LLUtils::discardResource)
|
||||
.doOnDiscard(Map.class, LLUtils::discardMap)
|
||||
.doOnDiscard(DatabaseStage.class, LLUtils::discardStage);
|
||||
|
||||
*/
|
||||
}
|
||||
|
||||
public static <T> Flux<T> handleDiscard(Flux<T> mono) {
|
||||
@ -948,22 +931,6 @@ public class LLUtils {
|
||||
discardStage(o);
|
||||
}
|
||||
});
|
||||
// todo: check if the single object discard hook is more performant
|
||||
/*
|
||||
.doOnDiscard(SafeCloseable.class, LLUtils::discardRefCounted)
|
||||
.doOnDiscard(Map.Entry.class, LLUtils::discardEntry)
|
||||
.doOnDiscard(Collection.class, LLUtils::discardCollection)
|
||||
.doOnDiscard(Tuple2.class, LLUtils::discardTuple2)
|
||||
.doOnDiscard(Tuple3.class, LLUtils::discardTuple3)
|
||||
.doOnDiscard(LLEntry.class, LLUtils::discardLLEntry)
|
||||
.doOnDiscard(LLRange.class, LLUtils::discardLLRange)
|
||||
.doOnDiscard(Delta.class, LLUtils::discardDelta)
|
||||
.doOnDiscard(LLDelta.class, LLUtils::discardLLDelta)
|
||||
.doOnDiscard(Send.class, LLUtils::discardSend)
|
||||
.doOnDiscard(Map.class, LLUtils::discardMap)
|
||||
.doOnDiscard(DatabaseStage.class, LLUtils::discardStage);
|
||||
|
||||
*/
|
||||
}
|
||||
|
||||
private static void discardLLEntry(LLEntry entry) {
|
||||
|
@ -388,7 +388,6 @@ public class DatabaseMapDictionaryDeep<T, U, US extends DatabaseStage<U>> extend
|
||||
});
|
||||
}
|
||||
|
||||
//todo: temporary wrapper. convert the whole class to buffers
|
||||
protected T deserializeSuffix(@NotNull Buffer keySuffix) throws SerializationException {
|
||||
assert suffixKeyLengthConsistency(keySuffix.readableBytes());
|
||||
var result = keySuffixSerializer.deserialize(keySuffix);
|
||||
@ -396,7 +395,6 @@ public class DatabaseMapDictionaryDeep<T, U, US extends DatabaseStage<U>> extend
|
||||
return result;
|
||||
}
|
||||
|
||||
//todo: temporary wrapper. convert the whole class to buffers
|
||||
protected void serializeSuffix(T keySuffix, Buffer output) throws SerializationException {
|
||||
output.ensureWritable(keySuffixLength);
|
||||
var beforeWriterOffset = output.writerOffset();
|
||||
|
@ -173,12 +173,10 @@ public class DatabaseSingleMapped<A, B> extends ResourceSupport<DatabaseStage<A>
|
||||
return this.serializedSingle.badBlocks();
|
||||
}
|
||||
|
||||
//todo: temporary wrapper. convert the whole class to buffers
|
||||
private A unMap(B bytes) throws SerializationException {
|
||||
return mapper.unmap(bytes);
|
||||
}
|
||||
|
||||
//todo: temporary wrapper. convert the whole class to buffers
|
||||
private B map(A bytes) throws SerializationException {
|
||||
return mapper.map(bytes);
|
||||
}
|
||||
|
@ -132,29 +132,26 @@ public class CachedIndexSearcherManager implements IndexSearcherManager {
|
||||
}
|
||||
|
||||
private Mono<Send<LLIndexSearcher>> generateCachedSearcher(@Nullable LLSnapshot snapshot) {
|
||||
// todo: check if defer is really needed
|
||||
return Mono.defer(() -> {
|
||||
if (closeRequested.get()) {
|
||||
return Mono.empty();
|
||||
}
|
||||
return Mono.fromCallable(() -> {
|
||||
activeSearchers.register();
|
||||
IndexSearcher indexSearcher;
|
||||
boolean decRef;
|
||||
if (snapshot == null) {
|
||||
indexSearcher = searcherManager.acquire();
|
||||
decRef = true;
|
||||
} else {
|
||||
indexSearcher = snapshotsManager.resolveSnapshot(snapshot).getIndexSearcher(SEARCH_EXECUTOR);
|
||||
decRef = false;
|
||||
}
|
||||
indexSearcher.setSimilarity(similarity);
|
||||
assert indexSearcher.getIndexReader().getRefCount() > 0;
|
||||
return new LLIndexSearcher(indexSearcher, decRef, this::dropCachedIndexSearcher).send();
|
||||
})
|
||||
.doOnDiscard(Send.class, Send::close)
|
||||
.doOnDiscard(Resource.class, Resource::close);
|
||||
});
|
||||
return Mono.fromCallable(() -> {
|
||||
if (closeRequested.get()) {
|
||||
return null;
|
||||
}
|
||||
activeSearchers.register();
|
||||
IndexSearcher indexSearcher;
|
||||
boolean decRef;
|
||||
if (snapshot == null) {
|
||||
indexSearcher = searcherManager.acquire();
|
||||
decRef = true;
|
||||
} else {
|
||||
indexSearcher = snapshotsManager.resolveSnapshot(snapshot).getIndexSearcher(SEARCH_EXECUTOR);
|
||||
decRef = false;
|
||||
}
|
||||
indexSearcher.setSimilarity(similarity);
|
||||
assert indexSearcher.getIndexReader().getRefCount() > 0;
|
||||
return new LLIndexSearcher(indexSearcher, decRef, this::dropCachedIndexSearcher).send();
|
||||
})
|
||||
.doOnDiscard(Send.class, Send::close)
|
||||
.doOnDiscard(Resource.class, Resource::close);
|
||||
}
|
||||
|
||||
private void dropCachedIndexSearcher() {
|
||||
|
@ -211,6 +211,7 @@ public class LLLocalLuceneIndex implements LLLuceneIndex {
|
||||
writerSchedulerMaxThreadCount = 1;
|
||||
} else {
|
||||
var concurrentMergeScheduler = new ConcurrentMergeScheduler();
|
||||
// false means SSD, true means HDD
|
||||
concurrentMergeScheduler.setDefaultMaxMergesAndThreads(false);
|
||||
if (luceneOptions.inMemory()) {
|
||||
concurrentMergeScheduler.disableAutoIOThrottle();
|
||||
@ -230,7 +231,7 @@ public class LLLocalLuceneIndex implements LLLuceneIndex {
|
||||
} else {
|
||||
indexWriterConfig.setRAMBufferSizeMB(luceneOptions.indexWriterBufferSize() / 1024D / 1024D);
|
||||
}
|
||||
indexWriterConfig.setReaderPooling(false);
|
||||
//indexWriterConfig.setReaderPooling(false);
|
||||
indexWriterConfig.setSimilarity(getLuceneSimilarity());
|
||||
this.indexWriter = new IndexWriter(directory, indexWriterConfig);
|
||||
this.snapshotsManager = new SnapshotsManager(indexWriter, snapshotter);
|
||||
|
Loading…
Reference in New Issue
Block a user