I’m trying to understand how to get rid of deprected method addToTotalCount() in my Mass Indexing Monitor but with no success.
package com.thevegcat.app.search; import java.util.concurrent.atomic.AtomicLong; import java.util.function.Consumer; import org.hibernate.search.mapper.pojo.massindexing.MassIndexingMonitor; import org.hibernate.search.mapper.pojo.massindexing.MassIndexingTypeGroupMonitor; import org.hibernate.search.mapper.pojo.massindexing.MassIndexingTypeGroupMonitorCreateContext; import org.hibernate.search.mapper.pojo.massindexing.impl.LegacyDelegatingMassIndexingTypeGroupMonitor; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.extern.slf4j.Slf4j; @Slf4j public class CustomMassIndexingMonitor implements MassIndexingMonitor { @NoArgsConstructor @Getter public class ReindexingSummary { private AtomicLong documentsAdded = new AtomicLong(0L); private AtomicLong documentsBuilt = new AtomicLong(0L); private AtomicLong entitiesLoaded = new AtomicLong(0L); private AtomicLong addToTotalCount = new AtomicLong(0L); } final Consumer<ReindexingSummary> reindexingDoneCallback; final ReindexingSummary reindexingSummary; public CustomMassIndexingMonitor(final Consumer<ReindexingSummary> reindexingDoneCallback) { this.reindexingDoneCallback = reindexingDoneCallback; this.reindexingSummary = new ReindexingSummary(); } @Override public void documentsAdded(long increment) { this.reindexingSummary.getDocumentsAdded().addAndGet(increment); log.trace("documentsAdded: {}", Long.valueOf(this.reindexingSummary.getDocumentsAdded().get())); } @Override public void documentsBuilt(long increment) { this.reindexingSummary.getDocumentsBuilt().addAndGet(increment); log.trace("documentsBuilt: {}", Long.valueOf(this.reindexingSummary.getDocumentsBuilt().get())); } @Override public void entitiesLoaded(long increment) { this.reindexingSummary.getEntitiesLoaded().addAndGet(increment); log.trace("entitiesLoaded: {}", Long.valueOf(this.reindexingSummary.getEntitiesLoaded().get())); } @Override public void addToTotalCount(long increment) { this.reindexingSummary.getAddToTotalCount().addAndGet(increment); log.trace("addToTotalCount: {}", Long.valueOf(this.reindexingSummary.getAddToTotalCount().get())); } @Override public void indexingCompleted() { this.reindexingDoneCallback.accept(this.reindexingSummary); } } JavaDoc has a hint but my understanding of it didn’t happen:
Use MassIndexingTypeGroupMonitor.indexingStarted(MassIndexingTypeGroupMonitorContext) and get the total count, if available, from the MassIndexingTypeGroupMonitorContext.totalCount(). Alternatively, use the typeGroupMonitor(MassIndexingTypeGroupMonitorCreateContext) and obtain the count from MassIndexingTypeGroupMonitorCreateContext.totalCount() if a count is needed before any indexing processes are started.
Is it possible to fix my monitor to keep the same functionalities but without deprecated methods?
Thanks!