spark.data.io
Interface SparkWriter

All Known Implementing Classes:
JSONWriter, SONWriter

public interface SparkWriter

Classes that implement this interface can be used to write Spark values out to some external form. There will be a class implementing this interface for each form of output.

Author:
olsen

Method Summary
 void close()
          this will close the stream and flush any output buffers.
 void flush()
          This will flush the stream's buffers
 TypeFactory getTypeFactory()
          This will return the TypeFactory currently being used.
 boolean isPretty()
          This returns true if the output is being pretty printed for human consumption rather than condensed for files and network message uses.
 void setOutput(java.io.OutputStream output)
          This will set the OutputStream to which the data is to be written.
 void setPretty(boolean pretty)
          This tells the writer whether the output should be pretty-printed for human consumption or condensed for system communication or storage.
 void setTypeFactory(TypeFactory factory)
          This is the type factory to be used when converting internal Java classes into an external form.
 java.lang.String toString(SV value)
          This will write the value to a String.
 void write(SV value)
          This is the heart of the SparkWriter.
 

Method Detail

setTypeFactory

void setTypeFactory(TypeFactory factory)
This is the type factory to be used when converting internal Java classes into an external form.

Parameters:
factory - the type factory to be used.

getTypeFactory

TypeFactory getTypeFactory()
This will return the TypeFactory currently being used.

Returns:
a TypeFactory

setOutput

void setOutput(java.io.OutputStream output)
This will set the OutputStream to which the data is to be written.

Parameters:
output - where the output is to be sent.

write

void write(SV value)
This is the heart of the SparkWriter. This method will write the value in an external form to the Output

Parameters:
value - the value to be written.

toString

java.lang.String toString(SV value)
This will write the value to a String. This is useful for short values the can be printed to the console or used in some other fashion.

Parameters:
value - the value to be written out.
Returns:
The string representation of the value.
Throws:
java.lang.RuntimeException - if a particular SparkWriter class does not generate string output.

isPretty

boolean isPretty()
This returns true if the output is being pretty printed for human consumption rather than condensed for files and network message uses.

Returns:
whether or not pretty printed indentation is set.

setPretty

void setPretty(boolean pretty)
This tells the writer whether the output should be pretty-printed for human consumption or condensed for system communication or storage. This is just a suggestion to the writer. The syntax remains the same either way. The common use for this is if pretty is false, extraneous white spaces are removed.

Parameters:
pretty - true if the output is for human consumption.

close

void close()
this will close the stream and flush any output buffers.


flush

void flush()
This will flush the stream's buffers