org.knime.core.data.container
Class CopyOnAccessTask

java.lang.Object
  extended by org.knime.core.data.container.CopyOnAccessTask

final class CopyOnAccessTask
extends Object

Opens (on demand) a zip file from the workspace location and copies the binary data content to temp for further reading. This class creates a Buffer which reads from the temp file.

Think of this class as an runnable that is executed once on demand. It helps to delay the copy process of the data to speed up the loading of saved workflows.

Author:
Bernd Wiswedel, University of Konstanz

Constructor Summary
CopyOnAccessTask(ReferencedFile fileRef, DataTableSpec spec, int bufferID, Map<Integer,ContainerTable> tblRep, DataContainer.BufferCreator creator)
          Keeps reference, nothing else.
 
Method Summary
(package private)  Buffer createBuffer()
          Called to start the copy process.
(package private)  Buffer createBuffer(InputStream in)
          Called to start the copy process.
(package private)  int getBufferID()
          Get this buffer's ID.
(package private)  String getFileName()
          Get name of file to copy from.
(package private)  Map<Integer,ContainerTable> getTableRepository()
          Get table repository in workflow for blob (de)serialization.
(package private)  void setRestoreIntoMemory()
          Requests the buffer to read its content into memory once it has been created.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CopyOnAccessTask

CopyOnAccessTask(ReferencedFile fileRef,
                 DataTableSpec spec,
                 int bufferID,
                 Map<Integer,ContainerTable> tblRep,
                 DataContainer.BufferCreator creator)
Keeps reference, nothing else.

Parameters:
fileRef - To read from.
spec - The spec to the table in file.
bufferID - The buffer's id used for blob (de)serialization.
tblRep - Repository of tables for blob (de)serialization.
creator - To instantiate the buffer object.
Method Detail

createBuffer

Buffer createBuffer()
              throws IOException
Called to start the copy process. Is only called once.

Returns:
The buffer instance reading from the temp file.
Throws:
IOException - If the file can't be accessed.

createBuffer

Buffer createBuffer(InputStream in)
              throws IOException
Called to start the copy process. Is only called once.

Parameters:
in - To read from, will instantiate a zip input stream on top of it, which will call close() eventually
Returns:
The buffer instance reading from the temp file.
Throws:
IOException - If the file can't be accessed.

getFileName

String getFileName()
Get name of file to copy from. Used for better error messages.

Returns:
source file

getBufferID

int getBufferID()
Get this buffer's ID.

Returns:
the buffer ID or -1

setRestoreIntoMemory

void setRestoreIntoMemory()
Requests the buffer to read its content into memory once it has been created.


getTableRepository

Map<Integer,ContainerTable> getTableRepository()
Get table repository in workflow for blob (de)serialization.

Returns:
table repository reference


Copyright, 2003 - 2010. All rights reserved.
University of Konstanz, Germany.
Chair for Bioinformatics and Information Mining, Prof. Dr. Michael R. Berthold.
You may not modify, publish, transmit, transfer or sell, reproduce, create derivative works from, distribute, perform, display, or in any way exploit any of the content, in whole or in part, except as otherwise expressly permitted in writing by the copyright owner or as specified in the license file distributed with this product.