predicate
A function or condition that answers true or false about a value, used to filter, search or check data.
In more detail
Predicates are passed to filters, searches and checks, such as the condition given to a filter function. In SQL a predicate is a condition tested on each row, such as price_cents < 4000, and it can also be unknown when a value is missing. Binary search can find where a monotone predicate first becomes true.
Examples
first_true(pred, lo, hi) finds the first integer where pred returns True.tenant_id = current tenant added to every queryJava: the Predicate interface; value -> value % 2 != 0; User::active.value -> value % 2 != 0Related terms
- monotone predicate — A yes-or-no test over ordered values that is False up to some point and True from then on, never switching back.
- binary search — Finding a target in sorted data by comparing it with the middle item and throwing away the half where it cannot be.
- lambda expression — A short anonymous function written inline and passed to other code, such as a condition for a filter.
- Where operator — The LINQ operator that keeps only the items for which a predicate returns true.
- WHERE clause — The part of a query that keeps only the rows for which a condition is true.
- multi-tenancy — One running system serving several separate customers, called tenants, while keeping each one's data and settings apart.
- functional interface — An interface with exactly one abstract method, such as Runnable, Supplier or Predicate, which a lambda or method reference can implement.
- intermediate operation — A stream step, such as filter, map, sorted or distinct, that returns another stream and does no work until a terminal operation runs.
- short-circuiting operation — A stream operation, such as anyMatch or findFirst, that can stop as soon as the answer is known, without looking at every element.
- three-valued logic — SQL's rule that a condition can be true, false or unknown, where unknown comes from comparing with NULL.
- index — A separate, sorted structure a database keeps alongside a table so it can find matching rows without reading them all.
Taught in
- Binary Search And Its Invariant — Algorithms & Data Structures for Working Engineers
- Collections, Generics, and LINQ — Modern .NET Core, C# & Enterprise Microservices
- Multi-Tenant Identity: Tenant Isolation & Middleware — Production Full-Stack Engineering
- The Streams API — Modern Java: Virtual Threads & High-Throughput Services
- Advanced Stream Operations — Modern Java: Virtual Threads & High-Throughput Services
- Lambdas, Functional Interfaces And Method References — Oracle Certified Professional: Java SE 21 Developer (1Z0-830) Exam Prep
- Reduction, Grouping And Partitioning — Oracle Certified Professional: Java SE 21 Developer (1Z0-830) Exam Prep
- Updating And Deleting Safely — PostgreSQL, Indexing & Relational Data Modeling
- Indexes And What They Cost — PostgreSQL, Indexing & Relational Data Modeling
References
- NIST Dictionary of Algorithms and Data Structures: predicate
- Filtering data (LINQ)
- PostgreSQL: The WHERE clause
- Java SE 21 API: Predicate
- PostgreSQL: comparison functions and operators