use of org.knime.core.data.v2.schema.ValueSchema in project knime-core by knime.
the class ValueSchemaTest method testSchemaSaveLoadDataType.
private static void testSchemaSaveLoadDataType(final DataType type, final Class<?> factoryClass) throws InvalidSettingsException {
final DataColumnSpec columnSpec = new DataColumnSpecCreator("0", type).createSpec();
final DataTableSpec tableSpec = new DataTableSpec(columnSpec);
final IDataRepository dataRepository = null;
final IWriteFileStoreHandler fileStoreHandler = new DummyWriteFileStoreHandler();
// Create the schema and check
final ValueSchema schema = ValueSchemaUtils.create(tableSpec, RowKeyType.NOKEY, fileStoreHandler);
assertEquals(2, schema.numFactories());
var rowKeyFactory = schema.getValueFactory(0);
assertEquals(VoidRowKeyFactory.class, rowKeyFactory.getClass());
var dataFactory = schema.getValueFactory(1);
assertEquals(factoryClass, dataFactory.getClass());
// Save to some note settings
final NodeSettings settings = new NodeSettings("valueSchema");
ValueSchemaUtils.save(schema, settings);
var columnarSchema = //
DefaultColumnarSchema.builder().addColumn(rowKeyFactory.getSpec(), //
ValueFactoryUtils.getTraits(rowKeyFactory)).addColumn(dataFactory.getSpec(), //
ValueFactoryUtils.getTraits(dataFactory)).build();
var loadContext = mock(ValueSchemaLoadContext.class);
when(loadContext.getTableSpec()).thenReturn(tableSpec);
when(loadContext.getDataRepository()).thenReturn(dataRepository);
when(loadContext.getSettings()).thenReturn(settings);
// Load back and check
final ValueSchema loadedSchema = ValueSchemaUtils.load(columnarSchema, loadContext);
assertEquals(VoidRowKeyFactory.class, rowKeyFactory.getClass());
assertEquals(2, loadedSchema.numFactories());
assertEquals(factoryClass, loadedSchema.getValueFactory(1).getClass());
}
use of org.knime.core.data.v2.schema.ValueSchema in project knime-core by knime.
the class BufferedTableBackend method create.
@Override
public RowContainer create(final ExecutionContext context, final DataTableSpec spec, final DataContainerSettings settings, final IDataRepository repository, final IWriteFileStoreHandler handler) {
final BufferedDataContainer container = context.createDataContainer(spec, settings.getInitializeDomain(), settings.getMaxCellsInMemory());
final ValueSchema schema = ValueSchemaUtils.create(spec, RowKeyType.CUSTOM, handler);
return new BufferedRowContainer(container, schema);
}
Aggregations