use of org.knime.core.node.NodeSettings in project knime-core by knime.
the class SerializeUtilTest method testStoreAndLoadJavaToDataCell.
@Test
public void testStoreAndLoadJavaToDataCell() throws InvalidSettingsException {
Optional<JavaToDataCellConverterFactory<Integer>> factory = JavaToDataCellConverterRegistry.getInstance().getConverterFactories(Integer.class, IntCell.TYPE).stream().findFirst();
assumeTrue(factory.isPresent());
final NodeSettings testSettings = new NodeSettings(getClass().getName());
SerializeUtil.storeConverterFactory(factory.get(), testSettings, "the-factory2");
final Optional<JavaToDataCellConverterFactory<?>> loadedFactory = SerializeUtil.loadJavaToDataCellConverterFactory(testSettings, "the-factory2");
assertTrue(loadedFactory.isPresent());
assertEquals(factory.get(), loadedFactory.get());
}
use of org.knime.core.node.NodeSettings in project knime-core by knime.
the class SerializeUtilTest method testPlaceholders.
@Test
public void testPlaceholders() throws InvalidSettingsException {
final NodeSettings testSettings = new NodeSettings(getClass().getName());
final DefinitelyNotRegisteredFactory theMissingFactory = new DefinitelyNotRegisteredFactory();
SerializeUtil.storeConverterFactory(theMissingFactory, testSettings, "missing-factory");
Optional<DataCellToJavaConverterFactory<?, ?>> missingFactory = SerializeUtil.loadDataCellToJavaConverterFactory(testSettings, "missing-factory");
assertFalse(missingFactory.isPresent());
final FactoryPlaceholder placeholder = SerializeUtil.getPlaceholder(testSettings, "missing-factory");
assertEquals(theMissingFactory.getName(), placeholder.getName());
assertEquals(theMissingFactory.getSourceType().getName(), placeholder.getSourceTypeName());
assertEquals(theMissingFactory.getDestinationType().getName(), placeholder.getDestinationTypeName());
assertEquals(theMissingFactory.getIdentifier(), placeholder.getIdentifier());
}
use of org.knime.core.node.NodeSettings in project knime-core by knime.
the class SerializeUtilTest method testStoreAndLoadDataCellToJava.
@Test
public void testStoreAndLoadDataCellToJava() throws InvalidSettingsException {
final Optional<? extends DataCellToJavaConverterFactory<? extends DataValue, Integer>> factory = DataCellToJavaConverterRegistry.getInstance().getConverterFactories(IntCell.TYPE, Integer.class).stream().findFirst();
assumeTrue(factory.isPresent());
final NodeSettings testSettings = new NodeSettings(getClass().getName());
SerializeUtil.storeConverterFactory(factory.get(), testSettings, "the-factory");
final Optional<DataCellToJavaConverterFactory<?, ?>> loadedFactory = SerializeUtil.loadDataCellToJavaConverterFactory(testSettings, "the-factory");
assertTrue(loadedFactory.isPresent());
assertEquals(factory.get(), loadedFactory.get());
}
use of org.knime.core.node.NodeSettings in project knime-core by knime.
the class Buffer method closeInternal.
/**
* Closes by creating shortcut array for file access.
*/
void closeInternal() {
assert Thread.holdsLock(this);
// everything is in the list, i.e. in memory
if (m_outputWriter == null) {
// disallow modification
List<BlobSupportDataRow> newList = Collections.unmodifiableList(m_list);
m_list = newList;
if (!m_list.isEmpty()) {
registerMemoryAlertListener();
}
} else {
try {
flushBuffer();
m_outputWriter.close();
NodeSettings nodeSettings = new NodeSettings("table-format-meta-info");
m_outputWriter.writeMetaInfoAfterWrite(nodeSettings);
m_list = null;
double sizeInMB = m_binFile.length() / (double) (1 << 20);
String size = NumberFormat.getInstance().format(sizeInMB);
LOGGER.debug("Buffer file (" + m_binFile.getAbsolutePath() + ") is " + size + "MB in size");
initOutputReader(nodeSettings, IVERSION);
} catch (IOException ioe) {
throw new RuntimeException("Cannot close stream of file \"" + m_binFile.getName() + "\"", ioe);
} catch (InvalidSettingsException ex) {
throw new RuntimeException("Cannot init reader after buffer is closed", ex);
}
}
m_localRepository = null;
}
use of org.knime.core.node.NodeSettings in project knime-core by knime.
the class SetOperatorNodeModel method saveInternals.
/**
* {@inheritDoc}
*/
@Override
protected void saveInternals(final File nodeInternDir, final ExecutionMonitor exec) throws IOException {
if (m_enableHilite.getBooleanValue()) {
final NodeSettings config0 = new NodeSettings("hilite_mapping");
final DefaultHiLiteMapper mapper0 = (DefaultHiLiteMapper) m_trans0.getMapper();
if (mapper0 != null) {
mapper0.save(config0);
}
config0.saveToXML(new FileOutputStream(new File(nodeInternDir, HILITE_MAPPING0)));
final NodeSettings config1 = new NodeSettings("hilite_mapping");
final DefaultHiLiteMapper mapper1 = (DefaultHiLiteMapper) m_trans1.getMapper();
if (mapper1 != null) {
mapper1.save(config1);
}
config1.saveToXML(new FileOutputStream(new File(nodeInternDir, HILITE_MAPPING1)));
}
}
Aggregations