Returns a new or cached query for the given query specification.

@param filter optional filter object, defaults to open filter if null
@param values optional values object, defaults to filter initial values
@param ordering optional order-by properties
322142
public Query<S> query(Filter<S> filter, FilterValues<S> values, OrderingList<S> ordering)
        throws FetchException
    {
        return query(filter, values, ordering, null);
    }
373136
@Override
	public Collection<T> find(final SearchTerm[] terms, JiteratorFilter<T> filter,
			Boolean orderDesc, String... orderFields)
			throws PersistenceException {

		PopulatorThread<T> populator;

		populator = new PopulatorThread<T>(new JiteratorPopulator<T>() {
			public void populate(Jiterator<T> iterator) throws PersistenceException {
				ResultSet rs = null;
				try {             
					String index = null;
					String[] values = new String[terms.length];
					FindOperator operator = null;

					for (int i = 0; i < terms.length; i++) {
						// since no other way to get index, just assume column
						index = terms[i].getColumn(); 
						values[i] = terms[i].getValue().toString();		
						
						switch (terms[i].getOperator()) {
							case EQUALS: operator = FindOperator.EQ; break;
							case GREATER_THAN: operator = FindOperator.GT; break;
							case GREATER_THAN_OR_EQUAL_TO: operator = FindOperator.GE; break;
							case LESS_THAN: operator = FindOperator.LT; break;
							case LESS_THAN_OR_EQUAL_TO: operator = FindOperator.LE; break;
							default: throw new PersistenceException("Operator " + operator + " not supported!");							
						}						
					}

					// open a session to retrieve the primary key of the table by the values of the specified index
					rs = getSession(index, getPrimaryKeyField()).find(values, operator, 1, 0);

					// for each row, get the object from cache
					while (rs.next()) {
						T object = get(getValue(getPrimaryKeyField(), 1, rs));
						if (object != null) {
							iterator.push(object);
						}
					}
				} catch (Exception e) {
					throw new PersistenceException(e.getMessage());
				} finally {
					try {
						rs.close();
					} catch (SQLException e) {
						throw new PersistenceException(e.getMessage());
					}
				}
			}
		});
		populator.populate();
		return populator.getResult();
	}
1062332
@Override
	public List<V> load(final int first, final int pageSize,
			final List<SortMeta> multiSortMeta,
			final Map<String, Object> filters) {

		final boolean filtersChanged = handleFilters(filters);
		final boolean sortOrderChanged = handleSortOrder(multiSortMeta);
		boolean notify = false;

		// clear cache
		if (filtersChanged || sortOrderChanged) {
			adaptee.clearCache();
			notify = filtersChanged || notifyOnSortOrderChanges;
		}

		adaptee.setPageSize(pageSize);
		final int size = adaptee.getSize();
		adaptee.setFirst(first >= size ? Math.max(0, size - 1) : first);
		setRowCount(size);

		// notify observers
		if (filtersChanged && clearSelectionOnFilterChanges) {
			adaptee.clearSelection();
		}
		if (notify) {
			adaptee.notify(ChangeEventType.DATA);
		}

		return adaptee.getData();
	}
1128204
public ServerFilter where(Predicate<ServerMetadata> filter) {
        checkNotNull(filter, "Filter must be not a null");

        predicate = predicate.and(filter);

        return this;
    }
1178579
public function findByWhereFilter($name, $filter, $orderColumn = null, $orderType = NULL) {
        $this->load();
        $mapper = MapperBuilder::buildFromName($this->mapping, $name);

        $query = "SELECT * FROM `" . $mapper->getTable() . "` ";
        $query .= "WHERE 1 ";
        if (!is_null($filter)) {
            $query .= "AND " . $filter;
        }

        if (!is_null($orderColumn)) {
            $query .= "ORDER BY `$orderColumn` ";
            if (!is_null($orderType)) {
                $query .= "$orderType";
            } else {
                $query .= "ASC ";
            }
        }

        $result = $this->getDataSource()->query($query);

        if ($result) {
            $collection = new Collection($mapper->getClass(), $result, $mapper);
        } else {
            $collection = new Collection($mapper->getClass(), array(), $mapper);
        }

        return $collection;
    }
188714
function sortQueryresults(matches, order) {
  const orderArray = order.split(',').map(k => {
    let dir = 'asc';
    let key = k;

    if (k.charAt(0) === '-') {
      key = k.substring(1);
      dir = 'desc';
    }

    return [item => deserializeQueryParam(item[key]), dir];
  });

  const keys = orderArray.map(_.first);
  const orders = orderArray.map(_.last);

  return _.orderBy(matches, keys, orders);
}
274680
private void orderResults(ResultSet cqlRows) throws InvalidRequestException
    {
        if (cqlRows.size() == 0 || !needsPostQueryOrdering())
            return;

        assert orderingIndexes != null;

        List<Integer> idToSort = new ArrayList<Integer>();
        List<Comparator<ByteBuffer>> sorters = new ArrayList<Comparator<ByteBuffer>>();

        for (ColumnIdentifier.Raw identifier : parameters.orderings.keySet())
        {
            ColumnDefinition orderingColumn = cfm.getColumnDefinition(identifier.prepare(cfm));
            idToSort.add(orderingIndexes.get(orderingColumn.name));
            sorters.add(orderingColumn.type);
        }

        Comparator<List<ByteBuffer>> comparator = idToSort.size() == 1
                                                ? new SingleColumnComparator(idToSort.get(0), sorters.get(0))
                                                : new CompositeComparator(sorters, idToSort);
        Collections.sort(cqlRows.rows, comparator);
    }
1196551
@SuppressWarnings("unchecked")
  private OpenOrders filterOrders(OpenOrders rawOpenOrders, OpenOrdersParams params) {
    if (params == null) {
      return rawOpenOrders;
    }

    List<LimitOrder> openOrdersList = rawOpenOrders.getOpenOrders();
    openOrdersList.removeIf(openOrder -> !params.accept(openOrder));

    return new OpenOrders(openOrdersList, (List<Order>) rawOpenOrders.getHiddenOrders());
  }
500214
@Override
    public List values(CacheKeyFilter filter) throws IOException {
	if (CacheUtil.allowAll(filter)) return values();

	List<String> keys = keys();

	List<Object> list = new ArrayList<Object>();
	Iterator<String> it = keys.iterator();
	String key;
	while (it.hasNext()) {
	    key = it.next();
	    if (filter.accept(key)) {
		CacheEntry ce = getQuiet(key, null);
		if (ce != null) // possible that the entry is gone since keys(); call above
		    list.add(ce.getValue());
	    }
	}
	return list;
    }
968201
public @NotNull List<Page> getPages(@NotNull Predicate<Page> filter) {
    return getPages(filter, (Page)null);
  }
1079437
public static Result list(int page, String sortBy, String order, String filter) {
        return ok(
            list.render(
                Computer.page(page, 10, sortBy, order, filter),
                sortBy, order, filter
            )
        );
    }
949818
public GroupFilter where(Predicate<GroupMetadata> filter) {
        checkNotNull(filter, "Filter predicate must be not a null");

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

        return this;
    }
716008
public static cachepolicy[] get_filtered(nitro_service service, String filter) throws Exception{
		cachepolicy obj = new cachepolicy();
		options option = new options();
		option.set_filter(filter);
		cachepolicy[] response = (cachepolicy[]) obj.getfiltered(service, option);
		return response;
	}
1227410
private void addRequestCachingFilter() {
        FilterMapping filterMapping = new FilterMapping();
        filterMapping.setFilterName("request-caching-filter");
        filterMapping.setPathSpec("/*");

        FilterHolder filterHolder = new FilterHolder(new RequestCachingServletFilter());
        filterHolder.setName("request-caching-filter");
        servletHandler.addFilter(filterHolder, filterMapping);
    }
422424
public void filterTable(String filter) {

        m_container.removeAllContainerFilters();
        if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(filter)) {
            m_container.addContainerFilter(
                new Or(
                    new SimpleStringFilter(PROP_NAME, filter, true, false),
                    new SimpleStringFilter(PROP_DESCRIPTION, filter, true, false)));
        }
        if ((getValue() != null) & !((Set<CmsUUID>)getValue()).isEmpty()) {
            setCurrentPageFirstItemId(((Set<CmsUUID>)getValue()).iterator().next());
        }
    }
195540
public Filter getFilter()
        throws CacheReloadException
    {
        final IWhere where = eqlStmt.getQuery().getWhere();
        final IOrder order = eqlStmt.getOrder();
        return Filter.get(where, order, getTypes().toArray(new Type[getTypes().size()]));
    }
287305
public void addFilter(Filter filter) {
    filter.setInitialContext(initialContext);

    int minIndex = Integer.MAX_VALUE;
    String[] before = filter.before();
    for (int i = 0; i < before.length; i++) {
        String s = before[i];
        int index = index(activeFilters, s);
        if (index < minIndex) {
          minIndex = index;
        }
      }
      if (minIndex == Integer.MAX_VALUE) {
        // -1 is more usable for not-found than MAX_VALUE
        minIndex = -1;
      }

    if (contains(filter.before(), FIRST_IN_PIPE)) {
      activeFilters.add(0, filter);
    } else if (minIndex != -1) {
      activeFilters.add(minIndex, filter);
    } else {
      activeFilters.add(filter);
    }
  }