use of org.knime.core.data.container.BlobDataCell in project knime-core by knime.
the class PortObjectRepository method copy.
/**
* Copies the argument object by means of the associated serializer.
* @param object The port object to be copied.
* @param exec Host for BDTs being created
* @param progress For progress/cancelation
* @return The deep copy.
* @throws IOException In case of exceptions while accessing the streams
* @throws CanceledExecutionException If canceled.
*/
public static final PortObject copy(final PortObject object, final ExecutionContext exec, final ExecutionMonitor progress) throws IOException, CanceledExecutionException {
if (object instanceof BufferedDataTable) {
// need to copy the table cell by cell
// this is to workaround the standard knime philosophy according
// to which tables are referenced. A row-based copy will not work
// as it still will reference blobs
BufferedDataTable in = (BufferedDataTable) object;
BufferedDataContainer con = exec.createDataContainer(in.getSpec(), true, 0);
final long rowCount = in.size();
long row = 0;
boolean hasLoggedCloneProblem = false;
for (DataRow r : in) {
DataCell[] cells = new DataCell[r.getNumCells()];
for (int i = 0; i < cells.length; i++) {
// deserialize blob
DataCell c = r.getCell(i);
if (c instanceof BlobDataCell) {
try {
c = cloneBlobCell(c);
} catch (Exception e) {
if (!hasLoggedCloneProblem) {
LOGGER.warn("Can't clone blob object: " + e.getMessage(), e);
hasLoggedCloneProblem = true;
LOGGER.debug("Suppressing futher warnings.");
}
}
}
cells[i] = c;
}
con.addRowToTable(new DefaultRow(r.getKey(), cells));
progress.setProgress(row / (double) rowCount, "Copied row " + row + "/" + rowCount);
progress.checkCanceled();
row++;
}
con.close();
return con.getTable();
}
return Node.copyPortObject(object, exec);
}
use of org.knime.core.data.container.BlobDataCell in project knime-core by knime.
the class BlobSupportDataCellList method init.
private void init(final Collection<? extends DataCell> coll) {
ArrayList<DataCell> cellList = new ArrayList<DataCell>(coll.size());
DataType commonType = null;
for (DataCell c : coll) {
if (c == null) {
throw new NullPointerException("List element must not be null");
}
DataType cellType;
if (c instanceof BlobWrapperDataCell) {
m_containsBlobWrapperCells = true;
cellList.add(c);
cellType = DataType.getType(((BlobWrapperDataCell) c).getBlobClass());
} else if (c instanceof BlobDataCell) {
m_containsBlobWrapperCells = true;
cellList.add(new BlobWrapperDataCell((BlobDataCell) c));
cellType = c.getType();
} else {
cellList.add(c);
cellType = c.getType();
}
if (!c.isMissing()) {
if (commonType == null) {
commonType = cellType;
} else {
commonType = DataType.getCommonSuperType(commonType, cellType);
}
}
}
if (commonType == null) {
m_elementType = DataType.getMissingCell().getType();
} else {
m_elementType = commonType;
}
m_cellList = cellList;
}
use of org.knime.core.data.container.BlobDataCell in project knime-core by knime.
the class BlobSupportDataCellSet method init.
/**
* @param cells
*/
private void init(final Collection<? extends DataCell> cells) {
LinkedHashSet<Wrapper> cellSet = new LinkedHashSet<Wrapper>();
DataType commonType = null;
for (DataCell c : cells) {
if (c == null) {
throw new NullPointerException("Collection element must not be null");
}
DataType cellType;
Wrapper element;
if (c instanceof BlobWrapperDataCell) {
m_containsBlobWrapperCells = true;
element = new Wrapper(c);
cellType = DataType.getType(((BlobWrapperDataCell) c).getBlobClass());
} else if (c instanceof BlobDataCell) {
m_containsBlobWrapperCells = true;
element = new Wrapper(new BlobWrapperDataCell((BlobDataCell) c));
cellType = c.getType();
} else {
element = new Wrapper(c);
cellType = c.getType();
}
cellSet.add(element);
if (!c.isMissing()) {
if (commonType == null) {
commonType = cellType;
} else {
commonType = DataType.getCommonSuperType(commonType, cellType);
}
}
}
if (commonType == null) {
m_elementType = DataType.getMissingCell().getType();
} else {
m_elementType = commonType;
}
m_set = Collections.unmodifiableSet(cellSet);
}
Aggregations