# Counting over Range Predicates

DevFeed: [Counting over Range Predicates](<https://devfeed.tech/articles/counting-over-range-predicates-25643.md>)

Original publisher: [Read original article](<https://richardstartin.github.io/posts/range-counts>)

Author: Richard Startin's Blog

Published: 2022-03-27T00:00:00Z

Content type: tutorial

Language: en

Sources: [Richard Startin's Blog](<https://devfeed.tech/sources/richard-startin-s-blog.md>)

Topics: [Java](<https://devfeed.tech/topics/java.md>), [Streams](<https://devfeed.tech/topics/streams.md>), [Sorting](<https://devfeed.tech/topics/sorting.md>), [Benchmark](<https://devfeed.tech/topics/benchmark.md>), [Code](<https://devfeed.tech/topics/code.md>)

Tags: [benchmark](<https://devfeed.tech/tags/benchmark.md>), [effective](<https://devfeed.tech/tags/effective.md>), [filter](<https://devfeed.tech/tags/filter.md>), [inlining](<https://devfeed.tech/tags/inlining.md>), [java](<https://devfeed.tech/tags/java.md>), [modularity](<https://devfeed.tech/tags/modularity.md>), [performance](<https://devfeed.tech/tags/performance.md>), [roaring](<https://devfeed.tech/tags/roaring.md>), [sorting](<https://devfeed.tech/tags/sorting.md>), [streams](<https://devfeed.tech/tags/streams.md>)

## AI overview

This post examines counting objects that satisfy range and other filters when no database is available. It compares Java's Stream API with specialized Java code and finds that exploiting data already sorted by time can make filtering and counting more efficient.

## Source excerpt

This post follows on from my last post about selecting objects satisfying a range predicate, and instead looks at how to count the objects. If you can select objects, you can count them too, but it's a simpler problem so resources can be saved with a specialised solution.