Optimize a Filtration for querying, possibly pulling out intervals and simplifying the dimFilter in the process.

@return equivalent Filtration
436814
public Filtration optimize(final DruidQuerySignature querySignature)
  {
    return transform(
        this,
        ImmutableList.of(
            CombineAndSimplifyBounds.instance(),
            MoveTimeFiltersToIntervals.instance(),
            ConvertBoundsToSelectors.create(querySignature),
            ConvertSelectorsToIns.create(querySignature.getRowSignature()),
            MoveMarkerFiltersToIntervals.instance(),
            ValidateNoMarkerFiltersRemain.instance()
        )
    );
  }
815703
public final Set<FilterEntry<T>> getFilterExpectEntrys() {
        HashSet<FilterEntry<T>> set = new HashSet<>();
        set.addAll(expectEntrys);
        if (ors != null) ors.forEach(f -> set.addAll(f.getFilterExpectEntrys()));
        if (ands != null) ands.forEach(f -> set.addAll(f.getFilterExpectEntrys()));
        return set;
    }
1017616
public Optional<FilterList> getCurrentFilterList() {
    if (filterListStack.isEmpty()) {
      return Optional.absent();
    }
    return Optional.of(filterListStack.peek());
  }
673788
private Filter getFilter(final String columnFamily)
    {
        FilterList filter = filters.get(columnFamily);
        if (filter == null)
        {
            return this.filter;
        }
        if (this.filter != null)
        {
            filter.addFilter(this.filter);
        }
        return filter;
    }
11235
public static <T> List<T> positiveFilter(List<T> input, Predicate<T> filter) {
        argumentsAreNotNull(input, filter);
        return input.stream().filter(filter).collect(Collectors.toList());
    }
705261
public static List<Filter> toFilters(List<DimFilter> dimFilters)
  {
    return ImmutableList.copyOf(
        FunctionalIterable
            .create(dimFilters)
            .transform(
                new Function<DimFilter, Filter>()
                {
                  @Override
                  public Filter apply(DimFilter input)
                  {
                    return input.toFilter();
                  }
                }
            )
    );
  }
965187
public Filter intersect(final Filter second) {
        if (second == this || second == ALL) {
            return this;
        }
        final Filter first = this;
        return new Filter() {
            @Override
            public boolean shouldRun(Description description) {
                return first.shouldRun(description)
                        && second.shouldRun(description);
            }

            @Override
            public String describe() {
                return first.describe() + " and " + second.describe();
            }
        };
    }
824933
public static QueryFilter and(QueryFilter... queryFilters) {
        QueryFilter result = null;
        for (QueryFilter q : queryFilters) {
            result = result == null ? q : result.and(q);
        }
        return result;
    }
579314
private Filter createStateFilter() {
    byte[] processedMask = new byte[Ints.BYTES * 2 + 1];
    processedMask[processedMask.length - 1] = ConsumerEntryState.PROCESSED.getState();
    return new SingleColumnValueFilter(QueueEntryRow.COLUMN_FAMILY, stateColumnName,
                                       CompareFilter.CompareOp.NOT_EQUAL,
                                       new BitComparator(processedMask, BitComparator.BitwiseOp.AND));
  }
939060
public CmsRelationFilter filterStrong() {

        CmsRelationFilter filter = (CmsRelationFilter)clone();
        if (filter.m_types.isEmpty()) {
            filter.m_types.addAll(CmsRelationType.getAllStrong());
        } else {
            filter.m_types = new HashSet<CmsRelationType>(CmsRelationType.filterStrong(filter.m_types));
        }
        return filter;
    }
819434
public FilterBuilder<T> addWithOr(final Filter<T> filter) {
    filterInstance = ComposableFilter.or(filterInstance, filter);
    return this;
  }
124266
public MongoDeepJobConfig<T> filterQuery(Filter[] filters) {

        if (filters.length > 0) {
            List<BasicDBObject> list = new ArrayList<>();

            QueryBuilder queryBuilder = QueryBuilder.start();
            for (int i = 0; i < filters.length; i++) {
                BasicDBObject bsonObject = new BasicDBObject();

                Filter filter = filters[i];
                if (filter.getFilterType().equals(FilterType.EQ)) {
                    bsonObject.put(filter.getField(), filter.getValue());
                } else {
                    bsonObject.put(filter.getField(),
                            new BasicDBObject("$".concat(filter.getFilterType().getFilterTypeId().toLowerCase()),
                                    filter.getValue()));
                }

                list.add(bsonObject);
            }
            queryBuilder.and(list.toArray(new BasicDBObject[list.size()]));

            filterQuery(queryBuilder);
        }
        return this;

    }
1017019
public QueryBuilder intersect() {
        this.firstQuery = query();
        this.firstQuerySetOperation = Operation.INTERSECT;
        this.firstQueryAll = false;
        clear(false);
        return this;
    }
1255073
public AntiAffinityPolicyFilter where(Predicate<AntiAffinityPolicyMetadata> filter) {
        checkNotNull(filter, "Filter predicate must be not a null");

        this.predicate = this.predicate.and(filter);

        return this;
    }
83083
function() {

    if (!this._alreadyInitiallyExpandedCriteria) {
      this._wlQueryInfo.criteria = expandWhereShorthand(this._wlQueryInfo.criteria);
      this._alreadyInitiallyExpandedCriteria = true;
    }//>-

    this._wlQueryInfo.criteria.min = arguments[0];

    return this;
  }
1078117
public static <T> T[] filter(T array[], Filter<T> filter){
        List<T> filteredList = new ArrayList<T>(array.length);
        for(T element: array){
            if(filter.select(element))
                filteredList.add(element);
        }
        @SuppressWarnings("unchecked")
        T filteredArray[] = (T[])Array.newInstance(array.getClass().getComponentType(), filteredList.size());
        return filteredList.toArray(filteredArray);
    }
944264
public static <T> Iterator<T> filter(Iterator<T> it, Predicate<T> filter) {
        return new Iterator<T>() {

            private T cached = null;

            @Override
            public boolean hasNext() {
                if (this.cached != null) {
                    return true;
                }

                boolean test = false;
                while (it.hasNext() && !test) {
                    this.cached = it.next();
                    test = filter.test(this.cached);
                }
                return test;
            }

            @Override
            public T next() {
                if (!hasNext()) {
                    throw new NoSuchElementException();
                }
                final T result = this.cached;
                this.cached = null;
                return result;
            }

            @Override
            public void remove() {
                it.remove();
            }
        };
    }