public interface Reduction<T> extends ExcerptListener
ExcerptListener.| Modifier and Type | Interface and Description |
|---|---|
static interface |
Reduction.DoubleReductionBuilder
DoubleReductionBuilder is an interface that defines the contract for creating Reductions specialized for handling double data types.
|
static interface |
Reduction.LongReductionBuilder
LongReductionBuilder is an interface that defines the contract for creating Reductions specialized for handling long data types.
|
static interface |
Reduction.ReductionBuilder<E>
ReductionBuilder is an interface that defines the contract for creating new Reductions using a specific collector.
|
| Modifier and Type | Method and Description |
|---|---|
default long |
accept(@NotNull MarshallableIn tailer)
Accepts the input of the provided
tailer and reduces (folds) the contents of it
into this Reduction returning the last seen index or -1 if no index was seen. |
static <E> Reduction.ReductionBuilder<E> |
of(@NotNull DocumentExtractor<E> extractor)
Creates and returns a new
ReductionBuilder that will use the provided
extractor to extract elements of type E. |
static Reduction.DoubleReductionBuilder |
ofDouble(@NotNull ToDoubleDocumentExtractor extractor)
Creates and returns a new
DoubleReductionBuilder that will use the provided
extractor to extract elements of type double. |
static Reduction.LongReductionBuilder |
ofLong(@NotNull ToLongDocumentExtractor extractor)
Creates and returns a new
LongReductionBuilder that will use the provided
extractor to extract elements of type long. |
void |
onExcerpt(@NotNull Wire wire,
long index)
Consumes an excerpt from the provided
wire at the index at the provided index. |
T |
reduction()
Returns a view of the underlying reduction.
|
andThenvoid onExcerpt(@NotNull
@NotNull Wire wire,
long index)
throws net.openhft.chronicle.core.io.InvalidMarshallableException
wire at the index at the provided index.
If this method throws an Exception, it is relayed to the call site. Therefore, care should be taken to minimise the probability of throwing Exceptions.
If this method is referenced as an ExcerptListener then the Reduction must be
thread-safe.
onExcerpt in interface ExcerptListenerwire - representing access to the excerpt that was stored (non-null).index - in the queue where the except was placed (non-negative)net.openhft.chronicle.core.io.InvalidMarshallableException@NotNull T reduction()
default long accept(@NotNull
@NotNull MarshallableIn tailer)
throws net.openhft.chronicle.core.io.InvalidMarshallableException
tailer and reduces (folds) the contents of it
into this Reduction returning the last seen index or -1 if no index was seen.
This method can be used to initialise a Reduction before appending new values.
It is the responsibility of the caller to make sure no simultaneous appenders are using this Reduction during the entire fold operation.
tailer - to reduce (fold) fromNullPointerException - if the provided tailer is nullnet.openhft.chronicle.core.io.InvalidMarshallableExceptionstatic <E> Reduction.ReductionBuilder<E> of(@NotNull @NotNull DocumentExtractor<E> extractor)
ReductionBuilder that will use the provided
extractor to extract elements of type E.
This method initializes a generic reduction builder suitable for custom element types.
E - the element typeextractor - the document extractor used to extract elements, must not be nullReductionBuilder instanceReduction.LongReductionBuilder,
Reduction.DoubleReductionBuilderstatic Reduction.LongReductionBuilder ofLong(@NotNull @NotNull ToLongDocumentExtractor extractor)
LongReductionBuilder that will use the provided
extractor to extract elements of type long.
This method initializes a reduction builder specifically for handling long values.
extractor - the document extractor for long values, must not be nullLongReductionBuilder instanceofDouble(ToDoubleDocumentExtractor)static Reduction.DoubleReductionBuilder ofDouble(@NotNull @NotNull ToDoubleDocumentExtractor extractor)
DoubleReductionBuilder that will use the provided
extractor to extract elements of type double.
This method initializes a reduction builder specifically for handling double values.
extractor - the document extractor for double values, must not be nullDoubleReductionBuilder instanceof(DocumentExtractor),
ofLong(ToLongDocumentExtractor)Copyright © 2024. All rights reserved.