This is a prerelease version.

Predicates API

The Predicates API is a programming interface offered by Hazelcast that is similar to the Java Persistence Query Language (JPQL).

Supported Queries

With the Predicates API, you can run various types of queries to get insight from your data:

  • Ad-hoc queries (also known as point queries or OLTP queries)

  • Batch querying (also known as OLAP queries)

If you need to do streaming or federated queries, see SQL.

Ad-Hoc Queries

Ad-hoc queries allow you to retrieve a small subset of data from a large dataset. Usually these queries are simple and you can have many of them running concurrently in a Hazelcast cluster.

A common use case for ad-hoc queries is individual business transactions where you need to get or update data.

You can run these queries, using projections.

Batch Queries

Batch queries allow you to query large datasets either in a single or multiple systems and/or run aggregations on them to get deeper insights. Usually these queries are complex and you can run a small number of them concurrently in a Hazelcast cluster.

Common uses of OLAP include business reporting functions such as financial analysis, budgeting, and forecast planning.

You can run these queries, using aggregations.

How the Predicates API Works

The predicate is sent to each member in the cluster. Each member looks at its own local entries and filters them according to the predicate. At this stage, key/value pairs of the entries are deserialized and then passed to the predicate. The predicate requester merges all the results coming from each member into a single set.

Distributed query is highly scalable. If you add new members to the cluster, the partition count for each member is reduced and thus the time spent by each member on iterating its entries is reduced. In addition, the pool of partition threads evaluates the entries concurrently in each member and the network traffic is also reduced since only filtered data is sent to the requester.

Next Steps