listener.onCache(shardId, value.bitset); return value; }).bitset;
@Override public void onRemoval(RemovalNotification<Object, Cache<Query, Value>> notification) { Object key = notification.getKey(); if (key == null) { return; } Cache<Query, Value> valueCache = notification.getValue(); if (valueCache == null) { return; } for (Value value : valueCache.asMap().values()) { listener.onRemoval(value.shardId, value.bitset); // if null then this means the shard has already been removed and the stats are 0 anyway for the shard this key belongs to } }
listener.onCache(shardId, value.bitset); return value; }).bitset;
listener.onCache(shardId, value.bitset); return value; }).bitset;
private BitSet getAndLoadIfNotPresent(final Query query, final LeafReaderContext context) throws IOException, ExecutionException { final Object coreCacheReader = context.reader().getCoreCacheKey(); final ShardId shardId = ShardUtils.extractShardId(context.reader()); if (indexSettings.getIndex().equals(shardId.getIndex()) == false) { // insanity throw new IllegalStateException("Trying to load bit set for index " + shardId.getIndex() + " with cache of index " + indexSettings.getIndex()); } Cache<Query, Value> filterToFbs = loadedFilters.computeIfAbsent(coreCacheReader, key -> { context.reader().addCoreClosedListener(BitsetFilterCache.this); return CacheBuilder.<Query, Value>builder().build(); }); return filterToFbs.computeIfAbsent(query, key -> { final IndexReaderContext topLevelContext = ReaderUtil.getTopLevelContext(context); final IndexSearcher searcher = new IndexSearcher(topLevelContext); searcher.setQueryCache(null); final Weight weight = searcher.createNormalizedWeight(query, false); Scorer s = weight.scorer(context); final BitSet bitSet; if (s == null) { bitSet = null; } else { bitSet = BitSet.of(s.iterator(), context.reader().maxDoc()); } Value value = new Value(bitSet, shardId); listener.onCache(shardId, value.bitset); return value; }).bitset; }
@Override public Value call() throws Exception { final IndexReaderContext topLevelContext = ReaderUtil.getTopLevelContext(context); final IndexSearcher searcher = new IndexSearcher(topLevelContext); searcher.setQueryCache(null); final Weight weight = searcher.createNormalizedWeight(query, false); final Scorer s = weight.scorer(context); final BitSet bitSet; if (s == null) { bitSet = null; } else { bitSet = BitSet.of(s.iterator(), context.reader().maxDoc()); } Value value = new Value(bitSet, shardId); listener.onCache(shardId, value.bitset); return value; } }).bitset;
@Override public void onRemoval(RemovalNotification<IndexReader.CacheKey, Cache<Query, Value>> notification) { if (notification.getKey() == null) { return; } Cache<Query, Value> valueCache = notification.getValue(); if (valueCache == null) { return; } for (Value value : valueCache.values()) { listener.onRemoval(value.shardId, value.bitset); // if null then this means the shard has already been removed and the stats are 0 anyway for the shard this key belongs to } }
@Override public void onRemoval(RemovalNotification<IndexReader.CacheKey, Cache<Query, Value>> notification) { if (notification.getKey() == null) { return; } Cache<Query, Value> valueCache = notification.getValue(); if (valueCache == null) { return; } for (Value value : valueCache.values()) { listener.onRemoval(value.shardId, value.bitset); // if null then this means the shard has already been removed and the stats are 0 anyway for the shard this key belongs to } }
@Override public void onRemoval(RemovalNotification<Object, Cache<Query, Value>> notification) { if (notification.getKey() == null) { return; } Cache<Query, Value> valueCache = notification.getValue(); if (valueCache == null) { return; } for (Value value : valueCache.values()) { listener.onRemoval(value.shardId, value.bitset); // if null then this means the shard has already been removed and the stats are 0 anyway for the shard this key belongs to } }
@Override public void onRemoval(RemovalNotification<IndexReader.CacheKey, Cache<Query, Value>> notification) { if (notification.getKey() == null) { return; } Cache<Query, Value> valueCache = notification.getValue(); if (valueCache == null) { return; } for (Value value : valueCache.values()) { listener.onRemoval(value.shardId, value.bitset); // if null then this means the shard has already been removed and the stats are 0 anyway for the shard this key belongs to } }