querqy.lucene.rewrite.infologging.MultiSinkInfoLogging Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of querqy-lucene Show documentation
Show all versions of querqy-lucene Show documentation
Querqy library for query rewriting for Lucene
The newest version!
package querqy.lucene.rewrite.infologging;
import querqy.rewrite.SearchEngineRequestAdapter;
import java.util.Collection;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
public class MultiSinkInfoLogging implements InfoLogging {
private final Map> mappings;
private final Set allSinks;
public MultiSinkInfoLogging(final Map> mappings) {
this.mappings = mappings;
allSinks = mappings.values().stream()
.flatMap(Collection::stream).collect(Collectors.toCollection(LinkedHashSet::new));
}
@Override
public void log(final Object message, final String rewriterId,
final SearchEngineRequestAdapter searchEngineRequestAdapter) {
final List sinks = mappings.get(rewriterId);
if (sinks != null) {
for (final Sink sink : sinks) {
sink.log(message, rewriterId, searchEngineRequestAdapter);
}
}
}
@Override
public void endOfRequest(final SearchEngineRequestAdapter searchEngineRequestAdapter) {
allSinks.forEach(sink -> sink.endOfRequest(searchEngineRequestAdapter));
}
@Override
public boolean isLoggingEnabledForRewriter(final String rewriterId) {
final List sinks = mappings.get(rewriterId);
return sinks != null && !sinks.isEmpty();
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy