org.knime.core.data.container
Class DCObjectOutputVersion2

java.lang.Object
  extended by org.knime.core.data.container.DCObjectOutputVersion2
All Implemented Interfaces:
KNIMEStreamConstants

 class DCObjectOutputVersion2
extends Object
implements KNIMEStreamConstants

Object writing the binary stream of a Buffer.

This class provides functionality to write DataCell objects in both possibles modes: Using a custom DataCellSerializer (for DataCell class that offer it) as well as plain (and slow) java serialization.

The general stream layout is as follows: Objects of this class write to a BlockableOutputStream in order to write DataCells to an isolated sandbox. Each DataCell entry is preceded by one or more control bytes, which are written by the associated Buffer. The Buffer also decides when to close a block. DataCell which need to be java serialized are written a freshly created ObjectOutputStream (for each cell a new stream).

Author:
Bernd Wiswedel, University of Konstanz

Field Summary
 
Fields inherited from interface org.knime.core.data.container.KNIMEStreamConstants
BYTE_ROW_SEPARATOR, BYTE_TYPE_MISSING, BYTE_TYPE_SERIALIZATION, BYTE_TYPE_START, DUMMY_ROW_KEY, TC_ESCAPE, TC_TERMINATE
 
Constructor Summary
DCObjectOutputVersion2(OutputStream out, Buffer ownerBuffer)
          Setups a new output stream.
 
Method Summary
 void close()
          Closes the underlying streams.
(package private)  void endBlock()
          Marks the end of the block.
(package private)  void endRow()
          Writes the row end identifier.
 void flush()
          Flushes the underlying streams.
(package private)  void writeBlobAddress(BlobDataCell.BlobAddress address)
          Writes a given blob address to the stream.
(package private)  void writeControlByte(int controlByte)
          Writes the argument byte.
(package private)  void writeDataCellPerJavaSerialization(DataCell cell)
          Writes a cell using java serialization.
(package private)  void writeDataCellPerKNIMESerializer(DataCellSerializer<DataCell> serializer, DataCell cell)
          Writes a data cell using the serializer.
(package private)  void writeRowKey(RowKey key)
          Writes a row key by writing the underlying string to the stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DCObjectOutputVersion2

public DCObjectOutputVersion2(OutputStream out,
                              Buffer ownerBuffer)
Setups a new output stream.

Parameters:
out - The stream to write to (the file)
ownerBuffer - the associated buffer.
Method Detail

writeDataCellPerKNIMESerializer

void writeDataCellPerKNIMESerializer(DataCellSerializer<DataCell> serializer,
                                     DataCell cell)
                               throws IOException
Writes a data cell using the serializer. No blocking is done (not here).

Parameters:
serializer - The factory being used to write the cell.
cell - The cell to be written.
Throws:
IOException - If that fails.
See Also:
DataCellSerializer.serialize(DataCell, DataCellDataOutput)

writeDataCellPerJavaSerialization

void writeDataCellPerJavaSerialization(DataCell cell)
                                 throws IOException
Writes a cell using java serialization. This method will create a new ObjectOutputStream for this single cell.

Parameters:
cell - The cell to write.
Throws:
IOException - If any exception occur.

writeBlobAddress

void writeBlobAddress(BlobDataCell.BlobAddress address)
                throws IOException
Writes a given blob address to the stream.

Parameters:
address - to write out.
Throws:
IOException - if that fails

writeRowKey

void writeRowKey(RowKey key)
           throws IOException
Writes a row key by writing the underlying string to the stream.

Parameters:
key - Key to write
Throws:
IOException - In case of stream corruption.

writeControlByte

void writeControlByte(int controlByte)
                throws IOException
Writes the argument byte.

Parameters:
controlByte - The byte to write.
Throws:
IOException - In case of stream corruption.

endBlock

void endBlock()
        throws IOException
Marks the end of the block.

Throws:
IOException - In case of stream corruption.

endRow

void endRow()
      throws IOException
Writes the row end identifier.

Throws:
IOException - In case of stream corruption.

close

public void close()
           throws IOException
Closes the underlying streams.

Throws:
IOException - If the stream closing causes IO problems.

flush

public void flush()
           throws IOException
Flushes the underlying streams.

Throws:
IOException - If the stream flush causes IO problems.


Copyright, 2003 - 2010. All rights reserved.
University of Konstanz, Germany.
Chair for Bioinformatics and Information Mining, Prof. Dr. Michael R. Berthold.
You may not modify, publish, transmit, transfer or sell, reproduce, create derivative works from, distribute, perform, display, or in any way exploit any of the content, in whole or in part, except as otherwise expressly permitted in writing by the copyright owner or as specified in the license file distributed with this product.