@Override public Set<QueryableEntry> filter(QueryContext queryContext) { return ((IndexAwarePredicate) predicate).filter(queryContext); }
@Override public boolean isIndexed(QueryContext queryContext) { if (predicate instanceof IndexAwarePredicate) { return ((IndexAwarePredicate) predicate).isIndexed(queryContext); } return false; }
@Override public Set<QueryableEntry> filter(QueryContext queryContext) { List<Set<QueryableEntry>> indexedResults = new LinkedList<Set<QueryableEntry>>(); for (Predicate predicate : predicates) { if (predicate instanceof IndexAwarePredicate) { IndexAwarePredicate iap = (IndexAwarePredicate) predicate; if (iap.isIndexed(queryContext)) { Set<QueryableEntry> s = iap.filter(queryContext); if (s != null) { indexedResults.add(s); } } else { return null; } } } return indexedResults.isEmpty() ? null : new OrResultSet(indexedResults); }
@Override public Set<QueryableEntry> filter(QueryContext queryContext) { List<Set<QueryableEntry>> indexedResults = new LinkedList<Set<QueryableEntry>>(); for (Predicate predicate : predicates) { if (predicate instanceof IndexAwarePredicate) { IndexAwarePredicate iap = (IndexAwarePredicate) predicate; if (iap.isIndexed(queryContext)) { Set<QueryableEntry> s = iap.filter(queryContext); if (s != null) { indexedResults.add(s); } } else { return null; } } } return indexedResults.isEmpty() ? null : new OrResultSet(indexedResults); }
/** * Performs a query on this indexes instance using the given predicate. * * @param predicate the predicate to evaluate. * @return the produced result set or {@code null} if the query can't be * performed using the indexes known to this indexes instance. */ @SuppressWarnings("unchecked") public Set<QueryableEntry> query(Predicate predicate) { stats.incrementQueryCount(); if (!hasIndex || !(predicate instanceof IndexAwarePredicate)) { return null; } IndexAwarePredicate indexAwarePredicate = (IndexAwarePredicate) predicate; QueryContext queryContext = queryContextProvider.obtainContextFor(this); if (!indexAwarePredicate.isIndexed(queryContext)) { return null; } Set<QueryableEntry> result = indexAwarePredicate.filter(queryContext); if (result != null) { stats.incrementIndexedQueryCount(); queryContext.applyPerQueryStats(); } return result; }
@Override public boolean isIndexed(QueryContext queryContext) { for (Predicate predicate : predicates) { if (predicate instanceof IndexAwarePredicate) { IndexAwarePredicate iap = (IndexAwarePredicate) predicate; if (iap.isIndexed(queryContext)) { return true; } } } return false; }
@Override public Set<QueryableEntry> filter(QueryContext queryContext) { return ((IndexAwarePredicate) predicate).filter(queryContext); }
/** * Performs a query on this indexes instance using the given predicate. * * @param predicate the predicate to evaluate. * @return the produced result set or {@code null} if the query can't be * performed using the indexes known to this indexes instance. */ @SuppressWarnings("unchecked") public Set<QueryableEntry> query(Predicate predicate) { stats.incrementQueryCount(); if (!haveAtLeastOneIndex() || !(predicate instanceof IndexAwarePredicate)) { return null; } IndexAwarePredicate indexAwarePredicate = (IndexAwarePredicate) predicate; QueryContext queryContext = queryContextProvider.obtainContextFor(this); if (!indexAwarePredicate.isIndexed(queryContext)) { return null; } Set<QueryableEntry> result = indexAwarePredicate.filter(queryContext); if (result != null) { stats.incrementIndexedQueryCount(); queryContext.applyPerQueryStats(); } return result; }
@Override public boolean isIndexed(QueryContext queryContext) { if (predicate instanceof IndexAwarePredicate) { return ((IndexAwarePredicate) predicate).isIndexed(queryContext); } return false; }
@Override public Set<QueryableEntry> filter(QueryContext queryContext) { Predicate p = lsPredicates.get(0); if (p instanceof IndexAwarePredicate) { return ((IndexAwarePredicate) p).filter(queryContext); } return null; }
@Override public boolean isIndexed(QueryContext queryContext) { for (Predicate predicate : predicates) { if (predicate instanceof IndexAwarePredicate) { IndexAwarePredicate iap = (IndexAwarePredicate) predicate; if (iap.isIndexed(queryContext)) { return true; } } } return false; }
@Override public Set<QueryableEntry> filter(QueryContext queryContext) { Predicate p = lsPredicates.get(0); if (p instanceof IndexAwarePredicate) { return ((IndexAwarePredicate) p).filter(queryContext); } return null; }
@Override public boolean isIndexed(QueryContext context) { if (predicate instanceof IndexAwarePredicate) { return ((IndexAwarePredicate) predicate).isIndexed(context); } return false; }
@Override public Set<QueryableEntry<K, V>> filter(QueryContext context) { //logger.info("filter; context: {}", context); Set<QueryableEntry<K, V>> result = ((IndexAwarePredicate) predicate).filter(context); //logger.info("filter; result: {}", result); if (result.size() > limit) { Set<QueryableEntry<K, V>> head = new HashSet<>(limit); for (QueryableEntry<K, V> entry: result) { if (found < limit) { head.add(entry); found++; } else { break; } } result = head; } return result; }
/** * Used if inner predicate is instanceof {@link IndexAwarePredicate} for checking if indexed. * * @param queryContext * @return */ @Override public boolean isIndexed(QueryContext queryContext) { if (predicate instanceof IndexAwarePredicate) { return ((IndexAwarePredicate) predicate).isIndexed(queryContext); } return false; }
@Override public Set<QueryableEntry<K, V>> filter(QueryContext context) { //logger.info("filter; context: {}", context); Set<QueryableEntry<K, V>> result = ((IndexAwarePredicate) predicate).filter(context); //logger.info("filter; result: {}", result); if (result.size() > limit) { Set<QueryableEntry<K, V>> head = new HashSet<>(limit); for (QueryableEntry<K, V> entry: result) { if (found < limit) { head.add(entry); found++; } else { break; } } result = head; } return result; }
/** * Used if inner predicate is instanceof {@link IndexAwarePredicate} for checking if indexed. * * @param queryContext * @return */ @Override public boolean isIndexed(QueryContext queryContext) { if (predicate instanceof IndexAwarePredicate) { return ((IndexAwarePredicate) predicate).isIndexed(queryContext); } return false; }
/** * Used if inner predicate is instanceof {@link IndexAwarePredicate} for filtering. * * @param queryContext * @return */ @Override public Set<QueryableEntry<K, V>> filter(QueryContext queryContext) { if (!(predicate instanceof IndexAwarePredicate)) { return null; } Set<QueryableEntry<K, V>> set = ((IndexAwarePredicate<K, V>) predicate).filter(queryContext); if (set == null || set.isEmpty()) { return set; } List<QueryableEntry<K, V>> resultList = new ArrayList<QueryableEntry<K, V>>(); Map.Entry<Integer, Map.Entry> nearestAnchorEntry = getNearestAnchorEntry(); for (QueryableEntry<K, V> queryableEntry : set) { if (SortingUtil.compareAnchor(this, queryableEntry, nearestAnchorEntry)) { resultList.add(queryableEntry); } } List<QueryableEntry<K, V>> sortedSubList = (List) SortingUtil.getSortedSubList((List) resultList, this, nearestAnchorEntry); return new LinkedHashSet<QueryableEntry<K, V>>(sortedSubList); }
@Override public boolean isIndexed(QueryContext context) { if (predicate instanceof IndexAwarePredicate) { return ((IndexAwarePredicate) predicate).isIndexed(context); } return false; }
/** * Used if inner predicate is instanceof {@link IndexAwarePredicate} for filtering. * * @param queryContext * @return */ @Override public Set<QueryableEntry<K, V>> filter(QueryContext queryContext) { if (!(predicate instanceof IndexAwarePredicate)) { return null; } Set<QueryableEntry<K, V>> set = ((IndexAwarePredicate<K, V>) predicate).filter(queryContext); if (set == null || set.isEmpty()) { return set; } List<QueryableEntry<K, V>> resultList = new ArrayList<QueryableEntry<K, V>>(); Map.Entry<Integer, Map.Entry> nearestAnchorEntry = getNearestAnchorEntry(); for (QueryableEntry<K, V> queryableEntry : set) { if (SortingUtil.compareAnchor(this, queryableEntry, nearestAnchorEntry)) { resultList.add(queryableEntry); } } List<QueryableEntry<K, V>> sortedSubList = (List) SortingUtil.getSortedSubList((List) resultList, this, nearestAnchorEntry); return new LinkedHashSet<QueryableEntry<K, V>>(sortedSubList); }