OUT
- Type of the elements to write.public abstract class CassandraOutputFormatBase<OUT> extends RichOutputFormat<OUT>
Constructor and Description |
---|
CassandraOutputFormatBase(String insertQuery,
ClusterBuilder builder) |
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes all resources used.
|
void |
configure(Configuration parameters)
Configures this output format.
|
protected abstract Object[] |
extractFields(OUT record) |
protected void |
onWriteFailure(Throwable t)
Callback that is invoked when failing to write to Cassandra.
|
protected void |
onWriteSuccess(com.datastax.driver.core.ResultSet ignored)
Callback that is invoked after a record is written to Cassandra successfully.
|
void |
open(int taskNumber,
int numTasks)
Opens a Session to Cassandra and initializes the prepared statement.
|
void |
writeRecord(OUT record)
Adds a record to the output.
|
getRuntimeContext, setRuntimeContext
public CassandraOutputFormatBase(String insertQuery, ClusterBuilder builder)
public void configure(Configuration parameters)
OutputFormat
This method is always called first on a newly instantiated output format.
parameters
- The configuration with all parameters.public void open(int taskNumber, int numTasks) throws IOException
taskNumber
- The number of the parallel instance.numTasks
- The number of parallel tasks.IOException
- Thrown, if the output could not be opened due to an I/O problem.public void writeRecord(OUT record) throws IOException
OutputFormat
When this method is called, the output format it guaranteed to be opened.
record
- The records to add to the output.IOException
- Thrown, if the records could not be added to to an I/O problem.protected void onWriteSuccess(com.datastax.driver.core.ResultSet ignored)
Subclass can override to provide its own logic.
ignored
- the result.protected void onWriteFailure(Throwable t)
Subclass can override to provide its own failure handling logic.
t
- the exceptionpublic void close() throws IOException
IOException
- Thrown, if the input could not be closed properly.Copyright © 2014–2021 The Apache Software Foundation. All rights reserved.