Package org.aksw.commons.util.sink
Class BulkingSink<T>
java.lang.Object
org.aksw.commons.util.sink.BulkingSink<T>
- Type Parameters:
T-
- All Implemented Interfaces:
AutoCloseable,Sink<T>
A sink that collects items in a buffer.
Only when the buffer becomes full OR flush is called manually then items are flushed to the delegate in bulk.
Closing does not flush pending items!
This class is not thread-safe.
- Author:
- raven
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected T[]protected BulkConsumerprotected booleanprotected int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidclose()static <T> BulkingSink<T>create(int bulkSize, BulkConsumer delegate) protected voidvoidflush()protected void
-
Field Details
-
buffer
-
delegate
-
nextOffsetInBuffer
protected int nextOffsetInBuffer -
isClosed
protected boolean isClosed
-
-
Constructor Details
-
BulkingSink
-
-
Method Details
-
ensureOpen
protected void ensureOpen() -
create
-
accept
-
flush
public void flush() -
flushActual
protected void flushActual() -
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceSink<T>
-