Search in sources :

Example 1 with Buffer

use of org.knime.core.data.container.Buffer in project knime-core by knime.

the class AbstractTableStoreReader method iteratorWithFilter.

/**
 * Provides a {@link TableStoreCloseableRowIterator} that is filtered according to a given {@link TableFilter} and
 * can be iterated over. During iteration, a given {@link ExecutionMonitor} will update its progress.
 *
 * @param filter the filter to be applied
 * @param exec the execution monitor that shall be updated with progress or null if no progress updates are desired
 * @return a filtered iterator
 * @since 4.0
 */
@SuppressWarnings("resource")
public TableStoreCloseableRowIterator iteratorWithFilter(final TableFilter filter, final ExecutionMonitor exec) {
    final TableStoreCloseableRowIterator delegate = iterator();
    final long size = getBuffer() == null ? Long.MAX_VALUE : getBuffer().size();
    final FilterDelegateRowIterator filterDelegate = new FilterDelegateRowIterator(delegate, filter, size, exec);
    return new TableStoreCloseableRowIterator() {

        @Override
        public DataRow next() {
            return filterDelegate.next();
        }

        @Override
        public boolean hasNext() {
            return filterDelegate.hasNext();
        }

        @Override
        public void setBuffer(final Buffer buffer) {
            super.setBuffer(buffer);
            delegate.setBuffer(buffer);
        }

        @Override
        public boolean performClose() throws IOException {
            return delegate.performClose();
        }
    };
}
Also used : Buffer(org.knime.core.data.container.Buffer) FilterDelegateRowIterator(org.knime.core.data.container.filter.FilterDelegateRowIterator)

Example 2 with Buffer

use of org.knime.core.data.container.Buffer in project knime-core by knime.

the class AbstractTableStoreReader method createBlobWrapperCell.

/**
 * Method for deserializig blob cells.
 *
 * @param address the address of the blob
 * @param type the type of the blob cell
 * @return the deserialized blob cell
 * @throws IOException if something goes wrong during deserialization
 */
public final BlobWrapperDataCell createBlobWrapperCell(final BlobAddress address, final CellClassInfo type) throws IOException {
    Buffer blobBuffer = getBuffer();
    if (address.getBufferID() != blobBuffer.getBufferID()) {
        Optional<ContainerTable> cnTbl = blobBuffer.getDataRepository().getTable(address.getBufferID());
        if (!cnTbl.isPresent()) {
            throw new IOException("Unable to retrieve table that owns the blob cell");
        }
        blobBuffer = ((BufferedContainerTable) cnTbl.get()).getBuffer();
    }
    return new BlobWrapperDataCell(blobBuffer, address, type);
}
Also used : Buffer(org.knime.core.data.container.Buffer) BlobWrapperDataCell(org.knime.core.data.container.BlobWrapperDataCell) IOException(java.io.IOException) ContainerTable(org.knime.core.data.container.ContainerTable) BufferedContainerTable(org.knime.core.data.container.BufferedContainerTable)

Aggregations

Buffer (org.knime.core.data.container.Buffer)2 IOException (java.io.IOException)1 BlobWrapperDataCell (org.knime.core.data.container.BlobWrapperDataCell)1 BufferedContainerTable (org.knime.core.data.container.BufferedContainerTable)1 ContainerTable (org.knime.core.data.container.ContainerTable)1 FilterDelegateRowIterator (org.knime.core.data.container.filter.FilterDelegateRowIterator)1