Package org.ojalgo.type.function
Interface AutoConsumer<T>
-
- All Superinterfaces:
java.lang.AutoCloseable
,AutoFunctional
,java.util.function.Consumer<T>
- All Known Subinterfaces:
ScoredDualConsumer<T>
,ToFileWriter<T>
- All Known Implementing Classes:
DataWriter
,ManagedConsumer
,MappedConsumer
,QueuedConsumer
,ShardedConsumer
,ShardedConsumer.GeneralShardedConsumer
,ShardedConsumer.PowerOf2ShardedConsumer
,TextLineWriter
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface public interface AutoConsumer<T> extends java.lang.AutoCloseable, java.util.function.Consumer<T>, AutoFunctional
Utilities forAutoCloseable
Consumer
:s
-
-
Field Summary
Fields Modifier and Type Field Description static AutoConsumer<?>
NULL
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default void
accept(T item)
default void
close()
static <T> AutoConsumer<T>
managed(java.lang.String name, java.util.function.Consumer<T> consumer)
Will create a JMX bean, with the given name, that keeps track of the consumer's throughput.static <T> AutoConsumer<T>
managed(Throughput manager, java.util.function.Consumer<T> consumer)
If you want that throughput manager to be registered as a JMX bean, that's up to you.static <S,T>
AutoConsumer<S>mapped(java.util.function.Function<S,T> mapper, java.util.function.Consumer<T> consumer)
Map/transform and then consumestatic <T> AutoConsumer<T>
queued(java.util.concurrent.ExecutorService executor, java.util.concurrent.BlockingQueue<T> queue, java.util.function.Consumer<T>... consumers)
Put on the queue, and then the consumers work off that queue.static <T> AutoConsumer<T>
sharded(java.util.function.ToIntFunction<T> distributor, java.util.function.Consumer<T>... consumers)
Distribute to 1 of the consumersvoid
write(T item)
Write the item to the consumer.default void
writeBatch(java.lang.Iterable<? extends T> batch)
Write the batch (collection of items) to the consumer.
-
-
-
Field Detail
-
NULL
static final AutoConsumer<?> NULL
-
-
Method Detail
-
managed
static <T> AutoConsumer<T> managed(java.lang.String name, java.util.function.Consumer<T> consumer)
Will create a JMX bean, with the given name, that keeps track of the consumer's throughput.
-
managed
static <T> AutoConsumer<T> managed(Throughput manager, java.util.function.Consumer<T> consumer)
If you want that throughput manager to be registered as a JMX bean, that's up to you.
-
mapped
static <S,T> AutoConsumer<S> mapped(java.util.function.Function<S,T> mapper, java.util.function.Consumer<T> consumer)
Map/transform and then consume
-
queued
static <T> AutoConsumer<T> queued(java.util.concurrent.ExecutorService executor, java.util.concurrent.BlockingQueue<T> queue, java.util.function.Consumer<T>... consumers)
Put on the queue, and then the consumers work off that queue. There will be 1 thread (executor task) per consumer.
-
sharded
static <T> AutoConsumer<T> sharded(java.util.function.ToIntFunction<T> distributor, java.util.function.Consumer<T>... consumers)
Distribute to 1 of the consumers
-
accept
default void accept(T item)
- Specified by:
accept
in interfacejava.util.function.Consumer<T>
- See Also:
write(Object)
-
close
default void close() throws java.lang.Exception
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Throws:
java.lang.Exception
-
write
void write(T item)
Write the item to the consumer.- Parameters:
item
- The item to be written
-
writeBatch
default void writeBatch(java.lang.Iterable<? extends T> batch)
Write the batch (collection of items) to the consumer.- Parameters:
batch
- The batch to be written
-
-