use of com.infiniteautomation.mango.db.iterators.PointValueIterator in project ma-core-public by MangoAutomation.
the class PointValueDao method streamPointValues.
/**
* Stream the point values for a single point, for the time range {@code [from,to)}.
* Values are streamed in either ascending or descending time order.
*
* <p>The values should be lazily fetched from the underlying database. If this is not supported, the values should be
* pre-fetched in chunks of size {@link #chunkSize()} and buffered out.</p>
*
* <p>The limit can often be omitted, as it is only useful for implementations which pre-fetch and buffer
* with small limits (i.e. less than the {@link #chunkSize()}).</p>
*
* <p>The returned {@link Stream} <strong>must</strong> be closed, use a try-with-resources block.</p>
* <pre>{@code
* try (var stream = streamPointValues(point, from, to, null, ASCENDING)) {
* // use stream
* }
* }</pre>
*
* @param vo the data point
* @param from from time (epoch ms), inclusive
* @param to to time (epoch ms), exclusive
* @param limit maximum number of values to return (if null, no limit is applied)
* @param sortOrder time order in which to return point values
* @throws IllegalArgumentException if vo is null, if to is less than from
*/
default Stream<IdPointValueTime> streamPointValues(DataPointVO vo, @Nullable Long from, @Nullable Long to, @Nullable Integer limit, TimeOrder sortOrder, int chunkSize) {
PointValueDao.validateNotNull(vo);
PointValueDao.validateTimePeriod(from, to);
PointValueDao.validateLimit(limit);
PointValueDao.validateNotNull(sortOrder);
PointValueDao.validateChunkSize(chunkSize);
if (limit != null) {
chunkSize = Math.min(limit, chunkSize);
}
PointValueIterator it = new PointValueIterator(this, vo, from, to, chunkSize, sortOrder);
Spliterator<IdPointValueTime> spliterator = Spliterators.spliteratorUnknownSize(it, Spliterator.ORDERED | Spliterator.NONNULL | Spliterator.DISTINCT | Spliterator.SORTED);
return StreamSupport.stream(spliterator, false);
}
use of com.infiniteautomation.mango.db.iterators.PointValueIterator in project ma-core-public by infiniteautomation.
the class PointValueDao method streamPointValues.
/**
* Stream the point values for a single point, for the time range {@code [from,to)}.
* Values are streamed in either ascending or descending time order.
*
* <p>The values should be lazily fetched from the underlying database. If this is not supported, the values should be
* pre-fetched in chunks of size {@link #chunkSize()} and buffered out.</p>
*
* <p>The limit can often be omitted, as it is only useful for implementations which pre-fetch and buffer
* with small limits (i.e. less than the {@link #chunkSize()}).</p>
*
* <p>The returned {@link Stream} <strong>must</strong> be closed, use a try-with-resources block.</p>
* <pre>{@code
* try (var stream = streamPointValues(point, from, to, null, ASCENDING)) {
* // use stream
* }
* }</pre>
*
* @param vo the data point
* @param from from time (epoch ms), inclusive
* @param to to time (epoch ms), exclusive
* @param limit maximum number of values to return (if null, no limit is applied)
* @param sortOrder time order in which to return point values
* @throws IllegalArgumentException if vo is null, if to is less than from
*/
default Stream<IdPointValueTime> streamPointValues(DataPointVO vo, @Nullable Long from, @Nullable Long to, @Nullable Integer limit, TimeOrder sortOrder, int chunkSize) {
PointValueDao.validateNotNull(vo);
PointValueDao.validateTimePeriod(from, to);
PointValueDao.validateLimit(limit);
PointValueDao.validateNotNull(sortOrder);
PointValueDao.validateChunkSize(chunkSize);
return new PointValueIterator(this, vo, from, to, limit, sortOrder, chunkSize).toStream();
}
Aggregations