Package com.clickhouse.data
Class ClickHouseDataStreamFactory
java.lang.Object
com.clickhouse.data.ClickHouseDataStreamFactory
Factory class for creating objects to handle data stream.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static final class -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreatePipedOutputStream(int bufferSize, int queueSize, int timeout) createPipedOutputStream(int bufferSize, int queueSize, int timeout, ClickHouseWriter writer) createPipedOutputStream(int bufferSize, int queueSize, int timeout, Runnable postCloseAction) Creates a piped output stream.createPipedOutputStream(ClickHouseDataConfig config, ClickHouseWriter writer) Creates a piped output stream.createPipedOutputStream(ClickHouseDataConfig config, Runnable postCloseAction) Creates a piped output stream.Gets default executor service for running blocking tasks.static ClickHouseDataStreamFactoryGets instance of the factory class.getProcessor(ClickHouseDataConfig config, ClickHouseInputStream input, ClickHouseOutputStream output, Map<String, Serializable> settings, List<ClickHouseColumn> columns) Gets data processor according to givenClickHouseDataConfigand settings.Gets default scheduled executor service for scheduled tasks.static voidhandleCustomAction(Runnable postCloseAction) Handles custom action.<T> CompletableFuture<T>runBlockingTask(Supplier<T> supplier) Executes a blocking task usingCompletableFuture.supplyAsync(Supplier)and customExecutorService.scheduleTask(Runnable task, long delay, TimeUnit unit) Schedules a task usingScheduledExecutorService.schedule(Runnable, long, TimeUnit)and customScheduledExecutorService.
-
Field Details
-
ERROR_NO_DESERIALIZER
- See Also:
-
ERROR_NO_SERIALIZER
- See Also:
-
ERROR_UNSUPPORTED_FORMAT
- See Also:
-
-
Constructor Details
-
ClickHouseDataStreamFactory
public ClickHouseDataStreamFactory()
-
-
Method Details
-
handleCustomAction
Handles custom action.- Parameters:
postCloseAction- post close action, could be null- Throws:
IOException- when failed to execute post close action
-
getInstance
Gets instance of the factory class.- Returns:
- instance of the factory class
-
getExecutor
Gets default executor service for running blocking tasks.- Returns:
- non-null executor service
-
getScheduler
Gets default scheduled executor service for scheduled tasks.- Returns:
- non-null scheduled executor service
-
runBlockingTask
Executes a blocking task usingCompletableFuture.supplyAsync(Supplier)and customExecutorService.- Returns:
- non-null future to get result
-
scheduleTask
Schedules a task usingScheduledExecutorService.schedule(Runnable, long, TimeUnit)and customScheduledExecutorService.- Returns:
- non-null future to get result
-
getProcessor
public ClickHouseDataProcessor getProcessor(ClickHouseDataConfig config, ClickHouseInputStream input, ClickHouseOutputStream output, Map<String, Serializable> settings, List<ClickHouseColumn> columns) throws IOExceptionGets data processor according to givenClickHouseDataConfigand settings.- Parameters:
config- non-null configuration containing information likeClickHouseFormatinput- input stream for deserialization, must not be null whenoutputis nulloutput- output stream for serialization, must not be null wheninputis nullsettings- nullable settingscolumns- nullable list of columns- Returns:
- data processor, which might be null
- Throws:
IOException- when failed to read columns from input stream
-
createPipedOutputStream
Creates a piped output stream.- Parameters:
config- non-null configuration- Returns:
- piped output stream
-
createPipedOutputStream
public ClickHousePipedOutputStream createPipedOutputStream(ClickHouseDataConfig config, Runnable postCloseAction) Creates a piped output stream.- Parameters:
config- non-null configurationpostCloseAction- custom action will be performed right after closing the output stream- Returns:
- piped output stream
-
createPipedOutputStream
public ClickHousePipedOutputStream createPipedOutputStream(ClickHouseDataConfig config, ClickHouseWriter writer) Creates a piped output stream.- Parameters:
config- non-null configurationwriter- non-null custom writer- Returns:
- piped output stream
-
createPipedOutputStream
public final ClickHousePipedOutputStream createPipedOutputStream(int bufferSize, int queueSize, int timeout) -
createPipedOutputStream
public ClickHousePipedOutputStream createPipedOutputStream(int bufferSize, int queueSize, int timeout, Runnable postCloseAction) -
createPipedOutputStream
public ClickHousePipedOutputStream createPipedOutputStream(int bufferSize, int queueSize, int timeout, ClickHouseWriter writer)
-