Fix statistics

This commit is contained in:
Andrea Cavalli 2021-12-31 00:58:47 +01:00
parent d6244ab18d
commit 57bcc92512
3 changed files with 17 additions and 6 deletions

View File

@ -501,6 +501,8 @@
<overWriteReleases>false</overWriteReleases> <overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots> <overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer> <overWriteIfNewer>true</overWriteIfNewer>
<prependGroupId>true</prependGroupId>
<stripVersion>true</stripVersion>
</configuration> </configuration>
</execution> </execution>
</executions> </executions>

View File

@ -51,6 +51,7 @@ import java.util.concurrent.Phaser;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.locks.ReentrantLock; import java.util.concurrent.locks.ReentrantLock;
import org.apache.commons.lang3.time.StopWatch;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.apache.lucene.analysis.miscellaneous.PerFieldAnalyzerWrapper; import org.apache.lucene.analysis.miscellaneous.PerFieldAnalyzerWrapper;
@ -60,6 +61,7 @@ import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.index.KeepOnlyLastCommitDeletionPolicy; import org.apache.lucene.index.KeepOnlyLastCommitDeletionPolicy;
import org.apache.lucene.index.MergeScheduler; import org.apache.lucene.index.MergeScheduler;
import org.apache.lucene.index.SerialMergeScheduler; import org.apache.lucene.index.SerialMergeScheduler;
import org.apache.lucene.index.SimpleMergedSegmentWarmer;
import org.apache.lucene.index.SnapshotDeletionPolicy; import org.apache.lucene.index.SnapshotDeletionPolicy;
import org.apache.lucene.index.TieredMergePolicy; import org.apache.lucene.index.TieredMergePolicy;
import org.apache.lucene.misc.store.DirectIODirectory; import org.apache.lucene.misc.store.DirectIODirectory;
@ -222,6 +224,7 @@ public class LLLocalLuceneIndex implements LLLuceneIndex {
indexWriterConfig.setCommitOnClose(true); indexWriterConfig.setCommitOnClose(true);
var mergePolicy = new TieredMergePolicy(); var mergePolicy = new TieredMergePolicy();
indexWriterConfig.setMergePolicy(mergePolicy); indexWriterConfig.setMergePolicy(mergePolicy);
indexWriterConfig.setMergedSegmentWarmer(new SimpleMergedSegmentWarmer(null));
int writerSchedulerMaxThreadCount; int writerSchedulerMaxThreadCount;
MergeScheduler mergeScheduler; MergeScheduler mergeScheduler;
if (lowMemory) { if (lowMemory) {
@ -334,16 +337,21 @@ public class LLLocalLuceneIndex implements LLLuceneIndex {
@Override @Override
public Mono<Void> addDocuments(Flux<Entry<LLTerm, LLUpdateDocument>> documents) { public Mono<Void> addDocuments(Flux<Entry<LLTerm, LLUpdateDocument>> documents) {
return documents.collectList().flatMap(documentsList -> this.<Void>runSafe(() -> docIndexingTime.recordCallable(() -> { return documents.collectList().flatMap(documentsList -> this.<Void>runSafe(() -> {
double count = documentsList.size(); var count = documentsList.size();
StopWatch stopWatch = StopWatch.createStarted();
try {
startedDocIndexings.increment(count); startedDocIndexings.increment(count);
try { try {
indexWriter.addDocuments(LLUtils.toDocumentsFromEntries(documentsList)); indexWriter.addDocuments(LLUtils.toDocumentsFromEntries(documentsList));
} finally { } finally {
endeddDocIndexings.increment(count); endeddDocIndexings.increment(count);
} }
} finally {
docIndexingTime.record(stopWatch.getTime(TimeUnit.MILLISECONDS) / Math.max(count, 1), TimeUnit.MILLISECONDS);
}
return null; return null;
}))).transform(this::ensureOpen); })).transform(this::ensureOpen);
} }

View File

@ -96,6 +96,7 @@ public final class OptimisticRocksDBColumn extends AbstractRocksDBColumn<Optimis
Buffer prevData; Buffer prevData;
if (prevDataArray != null) { if (prevDataArray != null) {
prevData = MemoryManager.unsafeWrap(prevDataArray); prevData = MemoryManager.unsafeWrap(prevDataArray);
prevDataArray = null;
} else { } else {
prevData = null; prevData = null;
} }