org.apache.lucene.search.QueryCachingPolicy Java Examples

The following examples show how to use org.apache.lucene.search.QueryCachingPolicy. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: IndexShard.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
private final EngineConfig newEngineConfig(TranslogConfig translogConfig, QueryCachingPolicy cachingPolicy) {
    final TranslogRecoveryPerformer translogRecoveryPerformer = new TranslogRecoveryPerformer(shardId, mapperService,
            queryParserService,
            indexAliasesService, indexCache, logger) {
        @Override
        protected void operationProcessed() {
            assert recoveryState != null;
            recoveryState.getTranslog().incrementRecoveredOperations();
        }

        @Override
        public int recoveryFromSnapshot(Engine engine, Translog.Snapshot snapshot) throws IOException {
            assert recoveryState != null;
            RecoveryState.Translog translogStats = recoveryState.getTranslog();
            translogStats.totalOperations(snapshot.estimatedTotalOperations());
            translogStats.totalOperationsOnStart(snapshot.estimatedTotalOperations());
            return super.recoveryFromSnapshot(engine, snapshot);
        }
    };
    return new EngineConfig(shardId,
            threadPool, indexingService, indexSettingsService.indexSettings(), warmer, store, deletionPolicy, mergePolicyConfig
            .getMergePolicy(), mergeSchedulerConfig,
            mapperService.indexAnalyzer(), similarityService.similarity(), codecService, failedEngineListener,
            translogRecoveryPerformer, indexCache.query(), cachingPolicy, wrappingService, translogConfig);
}
 
Example #2
Source File: EngineConfig.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new {@link org.elasticsearch.index.engine.EngineConfig}
 */
public EngineConfig(ShardId shardId, ThreadPool threadPool, ShardIndexingService indexingService,
                    Settings indexSettings, IndicesWarmer warmer, Store store, SnapshotDeletionPolicy deletionPolicy,
                    MergePolicy mergePolicy, MergeSchedulerConfig mergeSchedulerConfig, Analyzer analyzer,
                    Similarity similarity, CodecService codecService, Engine.FailedEngineListener failedEngineListener,
                    TranslogRecoveryPerformer translogRecoveryPerformer, QueryCache queryCache, QueryCachingPolicy queryCachingPolicy, IndexSearcherWrappingService wrappingService, TranslogConfig translogConfig) {
    this.shardId = shardId;
    this.indexSettings = indexSettings;
    this.threadPool = threadPool;
    this.indexingService = indexingService;
    this.warmer = warmer;
    this.store = store;
    this.deletionPolicy = deletionPolicy;
    this.mergePolicy = mergePolicy;
    this.mergeSchedulerConfig = mergeSchedulerConfig;
    this.analyzer = analyzer;
    this.similarity = similarity;
    this.codecService = codecService;
    this.failedEngineListener = failedEngineListener;
    this.wrappingService = wrappingService;
    this.optimizeAutoGenerateId = indexSettings.getAsBoolean(EngineConfig.INDEX_OPTIMIZE_AUTOGENERATED_ID_SETTING, false);
    this.compoundOnFlush = indexSettings.getAsBoolean(EngineConfig.INDEX_COMPOUND_ON_FLUSH, compoundOnFlush);
    codecName = indexSettings.get(EngineConfig.INDEX_CODEC_SETTING, EngineConfig.DEFAULT_CODEC_NAME);
    // We start up inactive and rely on IndexingMemoryController to give us our fair share once we start indexing:
    indexingBufferSize = IndexingMemoryController.INACTIVE_SHARD_INDEXING_BUFFER;
    gcDeletesInMillis = indexSettings.getAsTime(INDEX_GC_DELETES_SETTING, EngineConfig.DEFAULT_GC_DELETES).millis();
    versionMapSizeSetting = indexSettings.get(INDEX_VERSION_MAP_SIZE, DEFAULT_VERSION_MAP_SIZE);
    updateVersionMapSize();
    this.translogRecoveryPerformer = translogRecoveryPerformer;
    this.forceNewTranslog = indexSettings.getAsBoolean(INDEX_FORCE_NEW_TRANSLOG, false);
    this.queryCache = queryCache;
    this.queryCachingPolicy = queryCachingPolicy;
    this.translogConfig = translogConfig;
}
 
Example #3
Source File: EngineConfig.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
/**
 * Return the policy to use when caching queries.
 */
public QueryCachingPolicy getQueryCachingPolicy() {
    return queryCachingPolicy;
}
 
Example #4
Source File: IndexShard.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
public QueryCachingPolicy getQueryCachingPolicy() {
    return this.engineConfig.getQueryCachingPolicy();
}
 
Example #5
Source File: NoneQueryCache.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
public Weight doCache(Weight weight, QueryCachingPolicy policy) {
    return weight;
}
 
Example #6
Source File: IndexQueryCache.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
public Weight doCache(Weight weight, QueryCachingPolicy policy) {
    return indicesQueryCache.doCache(weight, policy);
}
 
Example #7
Source File: EngineConfig.java    From crate with Apache License 2.0 4 votes vote down vote up
/**
 * Creates a new {@link org.elasticsearch.index.engine.EngineConfig}
 */
public EngineConfig(ShardId shardId,
                    String allocationId,
                    ThreadPool threadPool,
                    IndexSettings indexSettings,
                    Store store,
                    MergePolicy mergePolicy,
                    Analyzer analyzer,
                    CodecService codecService,
                    Engine.EventListener eventListener,
                    QueryCache queryCache,
                    QueryCachingPolicy queryCachingPolicy,
                    TranslogConfig translogConfig,
                    TimeValue flushMergesAfter,
                    List<ReferenceManager.RefreshListener> externalRefreshListener,
                    List<ReferenceManager.RefreshListener> internalRefreshListener,
                    CircuitBreakerService circuitBreakerService,
                    LongSupplier globalCheckpointSupplier,
                    LongSupplier primaryTermSupplier,
                    TombstoneDocSupplier tombstoneDocSupplier) {
    this.shardId = shardId;
    this.allocationId = allocationId;
    this.indexSettings = indexSettings;
    this.threadPool = threadPool;
    this.store = store;
    this.mergePolicy = mergePolicy;
    this.analyzer = analyzer;
    this.codecService = codecService;
    this.eventListener = eventListener;
    codecName = indexSettings.getValue(INDEX_CODEC_SETTING);
    // We need to make the indexing buffer for this shard at least as large
    // as the amount of memory that is available for all engines on the
    // local node so that decisions to flush segments to disk are made by
    // IndexingMemoryController rather than Lucene.
    // Add an escape hatch in case this change proves problematic - it used
    // to be a fixed amound of RAM: 256 MB.
    // TODO: Remove this escape hatch in 8.x
    final String escapeHatchProperty = "es.index.memory.max_index_buffer_size";
    String maxBufferSize = System.getProperty(escapeHatchProperty);
    if (maxBufferSize != null) {
        indexingBufferSize = MemorySizeValue.parseBytesSizeValueOrHeapRatio(maxBufferSize, escapeHatchProperty);
    } else {
        indexingBufferSize = IndexingMemoryController.INDEX_BUFFER_SIZE_SETTING.get(indexSettings.getNodeSettings());
    }
    this.queryCache = queryCache;
    this.queryCachingPolicy = queryCachingPolicy;
    this.translogConfig = translogConfig;
    this.flushMergesAfter = flushMergesAfter;
    this.externalRefreshListener = externalRefreshListener;
    this.internalRefreshListener = internalRefreshListener;
    this.circuitBreakerService = circuitBreakerService;
    this.globalCheckpointSupplier = globalCheckpointSupplier;
    this.primaryTermSupplier = primaryTermSupplier;
    this.tombstoneDocSupplier = tombstoneDocSupplier;
}
 
Example #8
Source File: EngineConfig.java    From crate with Apache License 2.0 4 votes vote down vote up
/**
 * Return the policy to use when caching queries.
 */
public QueryCachingPolicy getQueryCachingPolicy() {
    return queryCachingPolicy;
}
 
Example #9
Source File: DisabledQueryCache.java    From crate with Apache License 2.0 4 votes vote down vote up
@Override
public Weight doCache(Weight weight, QueryCachingPolicy policy) {
    return weight;
}
 
Example #10
Source File: IndexQueryCache.java    From crate with Apache License 2.0 4 votes vote down vote up
@Override
public Weight doCache(Weight weight, QueryCachingPolicy policy) {
    return indicesQueryCache.doCache(weight, policy);
}