/** * Adds an {@code ALLOW FILTERING} directive to the {@code SELECT} statement this {@code WHERE} * clause is part of. * * @return the {@code SELECT} statement this {@code WHERE} clause is part of. */ public Select allowFiltering() { return statement.allowFiltering(); } }
protected Collection<Select> queryCondition2Select(Query query, Select select) { // Query by conditions Set<Condition> conditions = query.conditions(); for (Condition condition : conditions) { Clause clause = condition2Cql(condition); select.where(clause); if (Clauses.needAllowFiltering(clause)) { select.allowFiltering(); } } return ImmutableList.of(select); }
/** @test_category queries:builder */ @Test(groups = "unit") public void should_handle_allow_filtering() { assertThat(select().all().from("foo").allowFiltering().toString()) .isEqualTo("SELECT * FROM foo ALLOW FILTERING;"); assertThat(select().all().from("foo").where(eq("x", 42)).allowFiltering().toString()) .isEqualTo("SELECT * FROM foo WHERE x=42 ALLOW FILTERING;"); } }
@Override public SelectBuilder<T> allowFiltering() { select.allowFiltering(); return this; }
select = select().writeTime("a) FROM bar; --").ttl("a").from("foo").allowFiltering(); assertEquals(select.toString(), query); select = select().writeTime("a").ttl("a) FROM bar; --").from("foo").allowFiltering(); assertEquals(select.toString(), query);
select = select().writeTime("a").ttl("a").from("foo").allowFiltering(); assertEquals(select.toString(), query);
.perPartitionLimit(bindMarker()) .limit(3) .allowFiltering() .toString()) .isEqualTo(
protected Collection<Select> queryCondition2Select(Query query, Select select) { // Query by conditions Set<Condition> conditions = query.conditions(); for (Condition condition : conditions) { Clause clause = condition2Cql(condition); select.where(clause); if (Clauses.needAllowFiltering(clause)) { select.allowFiltering(); } } return ImmutableList.of(select); }
private Statement createQueryForRecentlyCreatedApps() { return queryBuilder .select() .all() .from(TABLE_NAME_RECENTLY_CREATED) .limit(200) .allowFiltering(); }
private Statement createQueryForRecentlyCreatedApps() { return QueryBuilder .select() .all() .from(TABLE_NAME_RECENTLY_CREATED) .limit(200) .allowFiltering(); }
private Select createSelect(Query query, CassandraPersistentEntity<?> entity, Filter filter, List<Selector> selectors, CqlIdentifier tableName) { Sort sort = Optional.of(query.getSort()).map(querySort -> getQueryMapper().getMappedSort(querySort, entity)) .orElse(Sort.unsorted()); Select select = createSelectAndOrder(selectors, tableName, filter, sort); query.getQueryOptions().ifPresent(queryOptions -> QueryOptionsUtil.addQueryOptions(select, queryOptions)); if (query.getLimit() > 0) { select.limit(Ints.checkedCast(query.getLimit())); } if (query.isAllowFiltering()) { select.allowFiltering(); } query.getPagingState().ifPresent(select::setPagingState); return select; }
@Override public Iterable<GCAnalyse> analyses(boolean isContinuous) { Statement statement = QueryBuilder.select().all().from(TABLE_NAME).allowFiltering() .where(eq("is_continuous", isContinuous)); return analysesFrom(connector.session().execute(statement)); }
.where(eq("b", 2)) .groupBy("a", "b") .allowFiltering())) .containsExactly(row(1, 2, 6, 2L, 12), row(2, 2, 6, 1L, 6));
/** * This method returns CQL Select query to retrieve data from the table with given fields. * This method is used for Avro Serialization * refer: http://docs.datastax.com/en/cql/3.3/cql/cql_reference/cqlSelect.html * * @param mapping Cassandra Mapping {@link CassandraMapping} * @param fields Given fields to retrieve * @param keyFields key fields * @return CQL Query */ static String getSelectObjectWithFieldsQuery(CassandraMapping mapping, String[] fields, List<String> keyFields) { Select select = QueryBuilder.select(getColumnNames(mapping, Arrays.asList(fields))).from(mapping.getKeySpace().getName(), mapping.getCoreName()); if (Boolean.parseBoolean(mapping.getProperty("allowFiltering"))) { select.allowFiltering(); } String[] columnNames = getColumnNames(mapping, keyFields); return processKeys(columnNames, select); }
/** * This method returns the CQL Select query to retrieve data from the table. * refer: http://docs.datastax.com/en/cql/3.3/cql/cql_reference/cqlSelect.html * * @param mapping Cassandra Mapping {@link CassandraMapping} * @param keyFields key fields * @return CQL Query */ static String getSelectObjectQuery(CassandraMapping mapping, List<String> keyFields) { Select select = QueryBuilder.select().from(mapping.getKeySpace().getName(), mapping.getCoreName()); if (Boolean.parseBoolean(mapping.getProperty("allowFiltering"))) { select.allowFiltering(); } String[] columnNames = getColumnNames(mapping, keyFields); return processKeys(columnNames, select); }
/** * This method returns the CQL Select query to retrieve data from the table. * refer: http://docs.datastax.com/en/cql/3.3/cql/cql_reference/cqlSelect.html * * @param mapping Cassandra Mapping {@link CassandraMapping} * @param keyFields key fields * @return CQL Query */ static String getSelectObjectQuery(CassandraMapping mapping, List<String> keyFields) { Select select = QueryBuilder.select().from(mapping.getKeySpace().getName(), mapping.getCoreName()); if (Boolean.parseBoolean(mapping.getProperty("allowFiltering"))) { select.allowFiltering(); } String[] columnNames = getColumnNames(mapping, keyFields); return processKeys(columnNames, select); }
.and(gt("b", bindMarker())) .perPartitionLimit(bindMarker()) .allowFiltering() .getQueryString(), 2, .orderBy(desc("b")) .perPartitionLimit(bindMarker()) .allowFiltering() .getQueryString(), 2,
/** @test_category queries:builder */ @Test(groups = "unit") public void should_handle_allow_filtering() { assertThat(select().all().from("foo").allowFiltering().toString()) .isEqualTo("SELECT * FROM foo ALLOW FILTERING;"); assertThat(select().all().from("foo").where(eq("x", 42)).allowFiltering().toString()) .isEqualTo("SELECT * FROM foo WHERE x=42 ALLOW FILTERING;"); }
public List<Row> selectAllFromIndexQueryWithFiltering(int limit, String name, Object value) { String search = search().query(all()).refresh(true).toJson(); return execute(QueryBuilder.select() .from(keyspace, table) .where(QueryBuilder.eq(indexColumn, search)) .and(QueryBuilder.eq(name, value)) .limit(limit) .allowFiltering() .setConsistencyLevel(consistencyLevel)); }