org.kitesdk.data
Interface DatasetWriter<E>

Type Parameters:
E - The type of entity accepted by this writer.
All Superinterfaces:
Closeable, Flushable

@NotThreadSafe
public interface DatasetWriter<E>
extends Flushable, Closeable

A stream-oriented dataset writer.

Subsystem-specific implementations of this interface are used to write data to a Dataset. Writers are use-once objects that serialize entities of type E and write them to the underlying system. Normally, users are not expected to instantiate implementations directly. Instead, use the containing dataset's Dataset#getWriter() method to get an appropriate implementation. Users should receive an instance of this interface from a dataset, call open() to prepare for IO operations, invoke write(Object) and flush() as necessary, and close() when they are done, or no more data exists.

Implementations may hold system resources until the close() method is called, so users must follow the normal try / finally pattern to ensure these resources are properly freed when the writer is no longer needed. Do not rely on implementations automatically invoking the close() method upon object finalization (implementations must not do so). All implementations must silently ignore multiple invocations of close() as well as a close of an unopened writer.

If any method throws an exception, the writer is no longer valid, and the only method that may be subsequently called is close().

Implementations of DatasetWriter are typically not thread-safe; that is, the behavior when accessing a single instance from multiple threads is undefined.


Method Summary
 void close()
           Close the writer and release any system resources.
 void flush()
           Force or commit any outstanding data to storage.
 boolean isOpen()
           
 void open()
           Open the writer, allocating any necessary resources required to store entities.
 void write(E entity)
           Writer an entity of type E to the associated dataset.
 

Method Detail

open

void open()

Open the writer, allocating any necessary resources required to store entities.

This method must be invoked prior to any calls of write(Object) or flush().

Throws:
DatasetWriterException

write

void write(E entity)

Writer an entity of type E to the associated dataset.

Implementations may buffer entities internally (see the flush() method). All instances of entity must conform to the dataset's schema and partition. If they don't, implementations should throw an exception, although this is not required.

Parameters:
entity - The entity to write
Throws:
DatasetWriterException

flush

void flush()

Force or commit any outstanding data to storage.

Implementations of this interface must declare their durability guarantees.

Specified by:
flush in interface Flushable
Throws:
DatasetWriterException

close

void close()

Close the writer and release any system resources.

No further operations of this interface (other than additional calls to this method) may be performed, however implementations may choose to permit other method calls. See implementation documentation for details.

Specified by:
close in interface Closeable
Throws:
DatasetWriterException

isOpen

boolean isOpen()


Copyright © 2013–2014. All rights reserved.