Search in sources :

Example 6 with IDataRepository

use of org.knime.core.data.IDataRepository in project knime-core by knime.

the class DictEncodedDataCellInOutDelegateTest method testWriteReadDataCell.

private static void testWriteReadDataCell(final DataCell cell) throws IOException {
    final IDataRepository dataRepository = null;
    final IWriteFileStoreHandler fileStoreHandler = new ValueSchemaTest.DummyWriteFileStoreHandler();
    final var baseBuffer = new ByteArrayOutputStream();
    final var outStream = new DataOutputStream(baseBuffer);
    try (final var out = new DictEncodedDataCellDataOutputDelegator(fileStoreHandler, outStream)) {
        out.writeDataCell(cell);
        final var inStream = new ReadableDataInputStream(new ByteArrayInputStream(baseBuffer.toByteArray()));
        try (final var in = new DictEncodedDataCellDataInputDelegator(dataRepository, inStream, DictEncodedDataCellDataInputDelegator.getSerializedCellNames(cell))) {
            final var readCell = in.readDataCell();
            assertEquals(cell, readCell);
        }
    }
}
Also used : IDataRepository(org.knime.core.data.IDataRepository) IWriteFileStoreHandler(org.knime.core.data.filestore.internal.IWriteFileStoreHandler) ByteArrayInputStream(java.io.ByteArrayInputStream) DataOutputStream(java.io.DataOutputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ReadableDataInputStream(org.knime.core.table.io.ReadableDataInputStream)

Example 7 with IDataRepository

use of org.knime.core.data.IDataRepository in project knime-core by knime.

the class FileStoreUtil method retrieveFileStoreHandlers.

/**
 * @noreference This method is not intended to be referenced by clients.
 */
public static void retrieveFileStoreHandlers(final FileStorePortObject sourceFSObj, final FileStorePortObject resultFSObj, final IWriteFileStoreHandler newHandler) throws IOException {
    List<FileStoreProxy> sourceFSProxies = sourceFSObj.getFileStoreProxies();
    List<FileStoreKey> sourceFSKeys = new ArrayList<FileStoreKey>(sourceFSProxies.size());
    IDataRepository commonDataRepository = null;
    for (FileStoreProxy proxy : sourceFSProxies) {
        FileStoreKey newKey;
        if (newHandler != null) {
            newKey = newHandler.translateToLocal(proxy.getFileStore(), resultFSObj);
        } else {
            newKey = proxy.getFileStoreKey();
        }
        sourceFSKeys.add(newKey);
        IDataRepository dataRepository = proxy.getFileStoreHandler().getDataRepository();
        if (commonDataRepository == null) {
            commonDataRepository = dataRepository;
        } else {
            assert commonDataRepository == dataRepository : "File Stores in port object have different data " + "repositories: " + commonDataRepository + " vs. " + dataRepository;
        }
    }
    IDataRepository resultRepos = newHandler != null ? newHandler.getDataRepository() : commonDataRepository;
    resultFSObj.retrieveFileStoreHandlerFrom(sourceFSKeys, resultRepos);
}
Also used : IDataRepository(org.knime.core.data.IDataRepository) ArrayList(java.util.ArrayList) FileStoreProxy(org.knime.core.data.filestore.internal.FileStoreProxy)

Aggregations

IDataRepository (org.knime.core.data.IDataRepository)7 IWriteFileStoreHandler (org.knime.core.data.filestore.internal.IWriteFileStoreHandler)4 ByteArrayInputStream (java.io.ByteArrayInputStream)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 DataOutputStream (java.io.DataOutputStream)3 ReadableDataInputStream (org.knime.core.table.io.ReadableDataInputStream)3 Test (org.junit.Test)2 ValueSchemaTest (org.knime.core.data.v2.ValueSchemaTest)2 ArrayList (java.util.ArrayList)1 UUID (java.util.UUID)1 MyAdapterCell (org.knime.core.data.AdapterCellTest.MyAdapterCell)1 DataColumnSpec (org.knime.core.data.DataColumnSpec)1 DataColumnSpecCreator (org.knime.core.data.DataColumnSpecCreator)1 DataTableSpec (org.knime.core.data.DataTableSpec)1 FileStoreProxy (org.knime.core.data.filestore.internal.FileStoreProxy)1 ValueSchema (org.knime.core.data.v2.schema.ValueSchema)1 NodeSettings (org.knime.core.node.NodeSettings)1