use of org.knime.core.node.NodeSettingsWO in project knime-core by knime.
the class Statistics2Table method save.
/**
* Saves this object to the given settings object.
* @param sett this object is saved to
*/
public void save(final NodeSettingsWO sett) {
m_spec.save(sett.addConfig("spec"));
sett.addDoubleArray("minimum", m_minValues);
sett.addDoubleArray("maximum", m_maxValues);
sett.addDoubleArray("mean", m_meanValues);
sett.addDoubleArray("variance", m_varianceValues);
sett.addDoubleArray("median", m_median);
sett.addDoubleArray("missings", m_missingValueCnt);
sett.addDoubleArray("sums", m_sum);
sett.addInt("row_count", m_rowCount);
for (int c = 0; c < m_nominalValues.length; c++) {
if (m_nominalValues[c] != null) {
NodeSettingsWO subSett = sett.addNodeSettings(m_spec.getColumnSpec(c).getName());
for (Map.Entry<DataCell, Integer> e : m_nominalValues[c].entrySet()) {
NodeSettingsWO nomSett = subSett.addNodeSettings(e.getKey().toString());
nomSett.addDataCell("key", e.getKey());
nomSett.addInt("value", e.getValue());
}
}
}
}
use of org.knime.core.node.NodeSettingsWO in project knime-core by knime.
the class DataContainer method writeToStream.
/**
* Writes a given DataTable permanently to an output stream. This includes also all table spec information, such as
* color, size, and shape properties.
*
* <p>
* The content is saved by instantiating a {@link ZipOutputStream} on the argument stream, saving the necessary
* information in respective zip entries. The stream is not closed by this method.
*
* @param table The table to write.
* @param out The stream to save to. It does not have to be buffered.
* @param exec For progress info.
* @throws IOException If writing fails.
* @throws CanceledExecutionException If canceled.
* @see #readFromStream(InputStream)
*/
public static void writeToStream(final DataTable table, final OutputStream out, final ExecutionMonitor exec) throws IOException, CanceledExecutionException {
Buffer buf;
ExecutionMonitor e = exec;
boolean canUseBuffer = table instanceof ContainerTable;
if (canUseBuffer) {
Buffer b = ((ContainerTable) table).getBuffer();
if (b.containsBlobCells() && b.getBufferID() != -1) {
canUseBuffer = false;
}
}
if (canUseBuffer) {
buf = ((ContainerTable) table).getBuffer();
} else {
exec.setMessage("Archiving table");
e = exec.createSubProgress(0.8);
buf = new Buffer(table.getDataTableSpec(), 0, -1, new HashMap<Integer, ContainerTable>(), new HashMap<Integer, ContainerTable>(), NotInWorkflowWriteFileStoreHandler.create());
int rowCount = 0;
for (DataRow row : table) {
rowCount++;
e.setMessage("Writing row #" + rowCount + " (\"" + row.getKey() + "\")");
e.checkCanceled();
buf.addRow(row, false, false);
}
buf.close(table.getDataTableSpec());
exec.setMessage("Closing zip file");
e = exec.createSubProgress(0.2);
}
final boolean originalOutputIsBuffered = ((out instanceof BufferedOutputStream) || (out instanceof ByteArrayOutputStream));
OutputStream os = originalOutputIsBuffered ? out : new BufferedOutputStream(out);
ZipOutputStream zipOut = new ZipOutputStream(os);
// (part of) bug fix #1141: spec must be put as first entry in order
// for the table reader to peek it
zipOut.putNextEntry(new ZipEntry(ZIP_ENTRY_SPEC));
NodeSettings settings = new NodeSettings("Table Spec");
NodeSettingsWO specSettings = settings.addNodeSettings(CFG_TABLESPEC);
buf.getTableSpec().save(specSettings);
settings.saveToXML(new NonClosableOutputStream.Zip(zipOut));
buf.addToZipFile(zipOut, e);
zipOut.finish();
if (!originalOutputIsBuffered) {
os.flush();
}
}
use of org.knime.core.node.NodeSettingsWO in project knime-core by knime.
the class Buffer method writeMetaToFile.
/**
* Writes internals to the an output stream (using the xml scheme from NodeSettings).
*
* @param out To write to.
* @throws IOException If that fails.
*/
private void writeMetaToFile(final OutputStream out) throws IOException {
NodeSettings settings = new NodeSettings("Table Meta Information");
NodeSettingsWO subSettings = settings.addNodeSettings(CFG_INTERNAL_META);
subSettings.addString(CFG_VERSION, getVersion());
if (size() < Integer.MAX_VALUE) {
subSettings.addInt(CFG_SIZE, (int) size());
} else {
subSettings.addLong(CFG_SIZE_L, size());
}
subSettings.addBoolean(CFG_CONTAINS_BLOBS, m_containsBlobs);
// added between version 8 and 9 - no increment of version number
String fileStoresUUID = null;
if (m_fileStoreHandler instanceof NotInWorkflowWriteFileStoreHandler) {
NotInWorkflowWriteFileStoreHandler notInWorkflowFSH = (NotInWorkflowWriteFileStoreHandler) m_fileStoreHandler;
if (notInWorkflowFSH.hasCopiedFileStores()) {
fileStoresUUID = notInWorkflowFSH.getStoreUUID().toString();
}
}
subSettings.addString(CFG_FILESTORES_UUID, fileStoresUUID);
subSettings.addBoolean(CFG_IS_IN_MEMORY, !usesOutFile());
subSettings.addInt(CFG_BUFFER_ID, m_bufferID);
subSettings.addString(CFG_TABLE_FORMAT, m_outputFormat.getClass().getName());
NodeSettingsWO formatSettings = subSettings.addNodeSettings(CFG_TABLE_FORMAT_CONFIG);
m_outputWriter.writeMetaInfoAfterWrite(formatSettings);
settings.saveToXML(out);
}
use of org.knime.core.node.NodeSettingsWO in project knime-core by knime.
the class TableSpecReplacerTable method saveToFile.
/**
* {@inheritDoc}
*/
@Override
public void saveToFile(final File f, final NodeSettingsWO s, final ExecutionMonitor exec) throws IOException, CanceledExecutionException {
NodeSettingsWO subSettings = s.addNodeSettings(CFG_INTERNAL_META);
subSettings.addInt(CFG_REFERENCE_ID, m_reference.getBufferedTableId());
}
use of org.knime.core.node.NodeSettingsWO in project knime-core by knime.
the class WrappedTable method saveToFile.
/**
* {@inheritDoc}
*/
@Override
public void saveToFile(final File f, final NodeSettingsWO s, final ExecutionMonitor exec) throws IOException, CanceledExecutionException {
NodeSettingsWO subSettings = s.addNodeSettings(CFG_INTERNAL_META);
subSettings.addInt(CFG_REFERENCE_ID, m_table.getBufferedTableId());
}
Aggregations