KNIME custom type serialization error

Hi All

I believe I may have made a silly mistake with a new type. 

 

Here is the serialization code:

 

 

public static final DataCellSerializer<NetworkCell> getCellSerializer()
{
return new DataCellSerializer<NetworkCell>()
{
@Override
public void serialize(NetworkCell cell, DataCellDataOutput output)
throws IOException
{
try
{
output.writeDataCell(cell);
} catch (Exception e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@Override
public NetworkCell deserialize(DataCellDataInput input)
throws IOException
{
DataCell cell = input.readDataCell();
NetworkCell networkCell = cell.getClass() == NetworkCell.class ? (NetworkCell) cell : null;
return networkCell;
}
};
}
 
this line: output.writeDataCell(cell); causes an error on saving a workflow where a NetworkCell has been created. 
 
 
Error output:
ERROR Buffer CODING PROBLEM Writing cells to temporary buffer must not throw StackOverflowError
DEBUG Buffer Writing cells to temporary buffer must not throw StackOverflowError
java.lang.StackOverflowError
at org.knime.core.data.container.CellClassInfo.get(CellClassInfo.java:96)
at org.knime.core.data.container.CellClassInfo.get(CellClassInfo.java:84)
at org.knime.core.data.container.Buffer.writeDataCell(Buffer.java:1260)
at org.knime.core.data.container.DCObjectOutputVersion2$DCLongUTFDataOutputStream.writeDataCell(DCObjectOutputVersion2.java:202)
at org.lhasalimited.knime.ulysses.cellltypes.NetworkCell$1.serialize(NetworkCell.java:102)
at org.lhasalimited.knime.ulysses.cellltypes.NetworkCell$1.serialize(NetworkCell.java:1)
at org.knime.core.data.container.DCObjectOutputVersion2.writeDataCellPerKNIMESerializer(DCObjectOutputVersion2.java:117)
at org.knime.core.data.container.Buffer.writeDataCell(Buffer.java:1282)
at org.knime.core.data.container.DCObjectOutputVersion2$DCLongUTFDataOutputStream.writeDataCell(DCObjectOutputVersion2.java:202)
at org.lhasalimited.knime.ulysses.cellltypes.NetworkCell$1.serialize(NetworkCell.java:102)
at org.lhasalimited.knime.ulysses.cellltypes.NetworkCell$1.serialize(NetworkCell.java:1)
at org.knime.core.data.container.DCObjectOutputVersion2.writeDataCellPerKNIMESerializer(DCObjectOutputVersion2.java:117)
at org.knime.core.data.container.Buffer.writeDataCell(Buffer.java:1282)
...
 
ERROR SaveWorkflowRunnable Could not save workflow
DEBUG SaveWorkflowRunnable Could not save workflow
java.lang.RuntimeException: Error while writing to buffer, failed to write to file "knime_container_20130114_291775523467660858.bin.gz": No details available
at org.knime.core.data.container.Buffer.addRow(Buffer.java:629)
at org.knime.core.data.container.Buffer.addToZipFile(Buffer.java:1673)
at org.knime.core.data.container.ContainerTable.saveToFile(ContainerTable.java:184)
at org.knime.core.node.BufferedDataTable.save(BufferedDataTable.java:466)
at org.knime.core.node.NodePersistorVersion200.saveBufferedDataTable(NodePersistorVersion200.java:435)
at org.knime.core.node.NodePersistorVersion200.savePort(NodePersistorVersion200.java:335)
at org.knime.core.node.NodePersistorVersion200.savePorts(NodePersistorVersion200.java:254)
at org.knime.core.node.NodePersistorVersion200.save(NodePersistorVersion200.java:202)
at org.knime.core.node.workflow.SingleNodeContainerPersistorVersion200.save(SingleNodeContainerPersistorVersion200.java:283)
at org.knime.core.node.workflow.WorkflowPersistorVersion200.saveNodeContainer(WorkflowPersistorVersion200.java:777)
...
 
 
 
All help appreciated
 
Cheers
 
Sam
 
 
 

It doesn't make sense to call writeDataCell in a serializer with the cell itself, because this will lead to endless recursion as in your case (this only makes sense for e.g. collection data cells, for which you can delegate serialization to already existing serializers).

In your case, you need to de/serialize your cell content using the writeInt, writeString, ... methods, i.e. write/read only primitive data types (and strings).

Thanks, I've switched to reading/writing the XML version of the network.