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);
}
}
}
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);
}
Aggregations