Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagejava
themeConfluence
firstline0
titleWriter
linenumberstrue
/**
 * The Writerinterface is responsible for writing data and handling any potential tmp area used to write yet un-staged data, e.g. in-progress files.
 
* As soon as some data is ready to commit, they (or metadata pointing to where the actual data is staged) are shipped to an operator who knows knows whenwhen to commit them.
 *
 * @param <IN> 			           The type of the writer's input
 * @param <CommT> 		The type of the committable data
* @param <StateT> 		The type of the writer'scommittable statedata
 * @param <SharedStateT><WriterStateT> The type of the writer's shared state
 */
public interface Writer<IN, CommT, StateT, SharedStateT>WriterStateT> {

	/**
	 * Add an element to the writer.
	 * @param element The input record.
	 * @param ctx     TheThe additional information about the input record
	 * @param output  The committable data could be shipped to the the committercommitter by this.
	* @throws Exception
	*/
	void write(IN element, Context ctx, WriterOutput<CommT> output) throws Exception;

	/**
	 * Prepare for a commit.
	 * Snapshot the writer's state.
	 @param flush  whether flushing the un-staged committable or not
	 * @param output output The committable data could be shipped to the committerthe committer by this.
	* @return The writer's state.
	*/
	List<StateT>void snapshotStateprepareCommit(boolean flush, WriterOutput<CommT> output) throws Exception;

	/**
	* Snapshot the writer's shared state.
	* @return Thethe writer's shared state.
	*/
	SharedStateT snapshotSharedState() throws Exception;

	/**
	* Flush all the data which is un-staged to the committer.
	* @param output
	*/
	voidList<WriterStateT> flushsnapshotState(WriterOutput<CommT> output) throws Exception;

	interface Context {

		long currentProcessingTime();

		long currentWatermark();

		Long timestamp();
	}
}

...