/** * See {@link com.hazelcast.query.Predicates#and(Predicate[])}. */ public static <K, V> Predicate<K, V> and(Predicate<K, V> ... predicates) { return com.hazelcast.query.Predicates.and(predicates); }
public PredicateBuilder and(Predicate predicate) { if (predicate != PredicateBuilder.this) { throw new QueryException("Illegal and statement expected: " + PredicateBuilder.class.getSimpleName() + ", found: " + ((predicate == null) ? "null" : predicate.getClass().getSimpleName())); } int index = lsPredicates.size() - 2; Predicate first = lsPredicates.remove(index); Predicate second = lsPredicates.remove(index); lsPredicates.add(Predicates.and(first, second)); return this; }
public PredicateBuilder and(Predicate predicate) { if (predicate != PredicateBuilder.this) { throw new QueryException("Illegal and statement expected: " + PredicateBuilder.class.getSimpleName() + ", found: " + ((predicate == null) ? "null" : predicate.getClass().getSimpleName())); } int index = lsPredicates.size() - 2; Predicate first = lsPredicates.remove(index); Predicate second = lsPredicates.remove(index); lsPredicates.add(Predicates.and(first, second)); return this; }
@SuppressWarnings({"rawtypes", "unchecked"}) @Override protected Predicate<?, ?> and(Part part, Predicate<?, ?> base, Iterator<Object> iterator) { Predicate<?, ?> criteria = this.from(part, (Iterator<Comparable<?>>) (Iterator) iterator); return Predicates.and(base, criteria); }
@SuppressWarnings("unchecked") public static Predicate<DocumentKey, Document> getQuery(SchemaRepository repo, String pattern) { String[] parts = pattern.split(","); Predicate<DocumentKey, Document> result = null; for (String part: parts) { //logger.trace("getDocumentUris; translating query part: {}", part); Predicate<DocumentKey, Document> query = toPredicate(repo, part.trim()); if (query != null) { if (result == null) { result = query; } else { result = Predicates.and(result, query); } } else { // logger.info("getDocumentUris; cannot translate query part '{}' to Predicate, skipping", part); } } return result; }
@Override protected Set<Map.Entry<String, Path>> getTypedPathWithRegex(String regex, String root) { regex = regex.replaceAll("\\{", Matcher.quoteReplacement("\\{")); regex = regex.replaceAll("\\}", Matcher.quoteReplacement("\\}")); Predicate<String, Path> filter = new RegexPredicate("path", regex); if (root != null) { filter = Predicates.and(filter, Predicates.equal("root", root)); } Set<Map.Entry<String, Path>> entries = pathCache.entrySet(filter); return entries; }
@SuppressWarnings("unchecked") private Set<DocumentKey> getDocumentsOfType(String root) { Predicate<DocumentKey, Document> f = Predicates.and(Predicates.equal(fnRoot, root), Predicates.equal(fnTxFinish, TX_NO)); return docCache.keySet(f); }
private Set<Person> getWithNameAndAge(String name, int age) { Predicate namePredicate = equal("name", name); Predicate agePredicate = equal("age", age); Predicate predicate = and(namePredicate, agePredicate); return (Set<Person>) personMap.values(predicate); }
return Predicates.and(predicatesArray);
@ManagedOperation(description="Calculates the number of unique values on the path specified") @ManagedOperationParameters({ @ManagedOperationParameter(name = "pathId", description = "The path identifier to aggregate on")}) public int aggregatePath(int pathId) { IMap<DataKey, Elements> elts = hzClient.getMap(CN_XDM_ELEMENT); Predicate<DataKey, Elements> q = Predicates.equal("pathId", pathId); Set<DataKey> keys = elts.keySet(q); if (keys.size() > 0) { q = Predicates.and(Predicates.equal("pathId", pathId), new GroupCountPredicate()); elts.keySet(q); } return keys.size(); }
public static void main(String[] args) { // Start the Embedded Hazelcast Cluster Member. HazelcastInstance hz = Hazelcast.newHazelcastInstance(); // Get a Distributed Map called "users" IMap<String, User> users = hz.getMap("users"); // Add some users to the Distributed Map generateUsers(users); // Create a Predicate from a String (a SQL like Where clause) Predicate sqlQuery = new SqlPredicate("active AND age BETWEEN 18 AND 21)"); // Creating the same Predicate as above but with a builder Predicate criteriaQuery = Predicates.and( Predicates.equal("active", true), Predicates.between("age", 18, 21) ); // Get result collections using the two different Predicates Collection<User> result1 = users.values(sqlQuery); Collection<User> result2 = users.values(criteriaQuery); // Print out the results System.out.println(result1); System.out.println(result2); // Shutdown the Hazelcast Cluster Member hz.shutdown(); }
qp = new DocsAwarePredicate(pex, newVal, found); Predicate<DataKey, Elements> f = Predicates.and(pp, qp); Set<DataKey> xdmKeys = local ? xdmCache.localKeySet(f) : xdmCache.keySet(f); logger.trace("queryPathKeys; got {} query results", xdmKeys.size());
public static void main(String[] args) { ClientConfig clientConfig = new ClientConfig(); clientConfig.getSerializationConfig() .addPortableFactory(ThePortableFactory.FACTORY_ID, new ThePortableFactory()); // Start the Hazelcast Client and connect to an already running Hazelcast Cluster on 127.0.0.1 HazelcastInstance hz = HazelcastClient.newHazelcastClient(clientConfig); // Get a Distributed Map called "users" IMap<String, User> users = hz.getMap("users"); // Add some users to the Distributed Map generateUsers(users); // Create a Predicate from a String (a SQL like Where clause) Predicate sqlQuery = new SqlPredicate("active AND age BETWEEN 18 AND 21)"); // Creating the same Predicate as above but with a builder Predicate criteriaQuery = Predicates.and( Predicates.equal("active", true), Predicates.between("age", 18, 21) ); // Get result collections using the two different Predicates Collection<User> result1 = users.values(sqlQuery); Collection<User> result2 = users.values(criteriaQuery); // Print out the results System.out.println(result1); System.out.println(result2); // Shutdown this Hazelcast Client hz.shutdown(); } }