本文整理了Java中org.apache.lucene.search.QueryCachingPolicy
类的一些代码示例,展示了QueryCachingPolicy
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。QueryCachingPolicy
类的具体详情如下:
包路径:org.apache.lucene.search.QueryCachingPolicy
类名称:QueryCachingPolicy
[英]A policy defining which filters should be cached. Implementations of this class must be thread-safe.
[中]定义应缓存哪些筛选器的策略。此类的实现必须是线程安全的。
代码示例来源:origin: org.apache.lucene/lucene-core
@Override
public ScorerSupplier scorerSupplier(LeafReaderContext context) throws IOException {
if (used.compareAndSet(false, true)) {
policy.onUse(getQuery());
if (policy.shouldCache(in.getQuery())) {
docIdSet = cache(context);
putIfAbsent(in.getQuery(), context, docIdSet, cacheHelper);
代码示例来源:origin: com.strapdata.elasticsearch/elasticsearch
@Override
public void onUse(Query query) {
if (query.getClass() != TermQuery.class) {
// Do not waste space in the history for term queries. The assumption
// is that these queries are very fast so not worth caching
in.onUse(query);
}
}
代码示例来源:origin: com.strapdata.elasticsearch/elasticsearch
@Override
public boolean shouldCache(Query query) throws IOException {
if (query.getClass() == TermQuery.class) {
return false;
}
return in.shouldCache(query);
}
代码示例来源:origin: harbby/presto-connectors
@Override
public void onUse(Query query) {
if (query.getClass() != TermQuery.class) {
// Do not waste space in the history for term queries. The assumption
// is that these queries are very fast so not worth caching
in.onUse(query);
}
}
代码示例来源:origin: harbby/presto-connectors
@Override
public boolean shouldCache(Query query, LeafReaderContext ctx) throws IOException {
if (query.getClass() == TermQuery.class) {
return false;
}
return in.shouldCache(query, ctx);
}
代码示例来源:origin: org.apache.lucene/lucene-core
@Override
public BulkScorer bulkScorer(LeafReaderContext context) throws IOException {
if (used.compareAndSet(false, true)) {
policy.onUse(getQuery());
if (policy.shouldCache(in.getQuery())) {
docIdSet = cache(context);
putIfAbsent(in.getQuery(), context, docIdSet, cacheHelper);
代码示例来源:origin: harbby/presto-connectors
@Override
public Scorer scorer(LeafReaderContext context) throws IOException {
if (used.compareAndSet(false, true)) {
policy.onUse(getQuery());
}
DocIdSet docIdSet = get(in.getQuery(), context);
if (docIdSet == null) {
if (shouldCache(context)) {
docIdSet = cache(context);
putIfAbsent(in.getQuery(), context, docIdSet);
} else {
return in.scorer(context);
}
}
assert docIdSet != null;
if (docIdSet == DocIdSet.EMPTY) {
return null;
}
final DocIdSetIterator disi = docIdSet.iterator();
if (disi == null) {
return null;
}
return new ConstantScoreScorer(this, 0f, disi);
}
代码示例来源:origin: org.infinispan/infinispan-embedded-query
private boolean shouldCache(LeafReaderContext context) throws IOException {
return cacheEntryHasReasonableWorstCaseSize(ReaderUtil.getTopLevelContext(context).reader().maxDoc())
&& policy.shouldCache(in.getQuery(), context);
}
代码示例来源:origin: harbby/presto-connectors
@Override
public Scorer scorer(LeafReaderContext context) throws IOException {
if (used.compareAndSet(false, true)) {
policy.onUse(getQuery());
if (docIdSet != null) {
hitCount++;
} else if (policy.shouldCache(query, context)) {
missCount++;
final Scorer scorer = weight.scorer(context);
代码示例来源:origin: org.infinispan/infinispan-embedded-query
@Override
public Scorer scorer(LeafReaderContext context) throws IOException {
if (used.compareAndSet(false, true)) {
policy.onUse(getQuery());
}
DocIdSet docIdSet = get(in.getQuery(), context);
if (docIdSet == null) {
if (shouldCache(context)) {
docIdSet = cache(context);
putIfAbsent(in.getQuery(), context, docIdSet);
} else {
return in.scorer(context);
}
}
assert docIdSet != null;
if (docIdSet == DocIdSet.EMPTY) {
return null;
}
final DocIdSetIterator disi = docIdSet.iterator();
if (disi == null) {
return null;
}
return new ConstantScoreScorer(this, 0f, disi);
}
代码示例来源:origin: harbby/presto-connectors
private boolean shouldCache(LeafReaderContext context) throws IOException {
return cacheEntryHasReasonableWorstCaseSize(ReaderUtil.getTopLevelContext(context).reader().maxDoc())
&& policy.shouldCache(in.getQuery(), context);
}
代码示例来源:origin: org.infinispan/infinispan-embedded-query
@Override
public Scorer scorer(LeafReaderContext context) throws IOException {
if (used.compareAndSet(false, true)) {
policy.onUse(getQuery());
if (docIdSet != null) {
hitCount++;
} else if (policy.shouldCache(query, context)) {
missCount++;
final Scorer scorer = weight.scorer(context);
代码示例来源:origin: org.infinispan/infinispan-embedded-query
@Override
public BulkScorer bulkScorer(LeafReaderContext context) throws IOException {
if (used.compareAndSet(false, true)) {
policy.onUse(getQuery());
}
DocIdSet docIdSet = get(in.getQuery(), context);
if (docIdSet == null) {
if (shouldCache(context)) {
docIdSet = cache(context);
putIfAbsent(in.getQuery(), context, docIdSet);
} else {
return in.bulkScorer(context);
}
}
assert docIdSet != null;
if (docIdSet == DocIdSet.EMPTY) {
return null;
}
final DocIdSetIterator disi = docIdSet.iterator();
if (disi == null) {
return null;
}
return new DefaultBulkScorer(new ConstantScoreScorer(this, 0f, disi));
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.lucene
@Override
public ScorerSupplier scorerSupplier(LeafReaderContext context) throws IOException {
if (used.compareAndSet(false, true)) {
policy.onUse(getQuery());
if (policy.shouldCache(in.getQuery())) {
docIdSet = cache(context);
putIfAbsent(in.getQuery(), context, docIdSet, cacheHelper);
代码示例来源:origin: harbby/presto-connectors
@Override
public BulkScorer bulkScorer(LeafReaderContext context) throws IOException {
if (used.compareAndSet(false, true)) {
policy.onUse(getQuery());
}
DocIdSet docIdSet = get(in.getQuery(), context);
if (docIdSet == null) {
if (shouldCache(context)) {
docIdSet = cache(context);
putIfAbsent(in.getQuery(), context, docIdSet);
} else {
return in.bulkScorer(context);
}
}
assert docIdSet != null;
if (docIdSet == DocIdSet.EMPTY) {
return null;
}
final DocIdSetIterator disi = docIdSet.iterator();
if (disi == null) {
return null;
}
return new DefaultBulkScorer(new ConstantScoreScorer(this, 0f, disi));
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.lucene
@Override
public BulkScorer bulkScorer(LeafReaderContext context) throws IOException {
if (used.compareAndSet(false, true)) {
policy.onUse(getQuery());
if (policy.shouldCache(in.getQuery())) {
docIdSet = cache(context);
putIfAbsent(in.getQuery(), context, docIdSet, cacheHelper);
内容来源于网络,如有侵权,请联系作者删除!