com.metamatrix.common.buffer
Interface BufferManager

All Known Implementing Classes:
BufferManagerImpl

public interface BufferManager

The buffer manager controls how memory is used and how data flows through the system. It uses storage managers to retrieve data, store data, and transfer data. The buffer manager has algorithms that tell it when and how to store data. The buffer manager should also be aware of memory management issues.


Nested Class Summary
static class BufferManager.TupleSourceStatus
           
static class BufferManager.TupleSourceType
           
 
Method Summary
 void addStorageManager(StorageManager storageManager)
          Adds a StorageManager to this BufferManager instance.
 void addStreamablePart(TupleSourceID tupleSourceID, LobChunk streamGlob, int beginRow)
          Add a streamable object to the persistent store.
 void addTupleBatch(TupleSourceID tupleSourceID, TupleBatch tupleBatch)
          Adds a batch of tuples for the specified tuple source
 TupleSourceID createTupleSource(java.util.List elements, java.lang.String[] types, java.lang.String groupName, BufferManager.TupleSourceType tupleSourceType)
          Creates a tuple source based on a schema and properties describing hints about the source
 int getConnectorBatchSize()
          Get the batch size to use when reading data from a connector.
 int getFinalRowCount(TupleSourceID tupleSourceID)
          Gets the final row count if tuple source is FULL, otherwise returns -1.
 int getProcessorBatchSize()
          Get the batch size to use during query processing.
 int getRowCount(TupleSourceID tupleSourceID)
          Gets the current row count
 BufferManager.TupleSourceStatus getStatus(TupleSourceID tupleSourceID)
          Gets the status of the tuple source
 LobChunk getStreamablePart(TupleSourceID tupleSourceID, int beginRow)
          Returns the streamable batch object's part stored with specified identifier
 java.util.List getTupleSchema(TupleSourceID tupleSourceID)
          Gets a tuple source schema by ID
 IndexedTupleSource getTupleSource(TupleSourceID tupleSourceID)
          Gets a tuple source by ID
 void initialize(java.lang.String location, java.util.Properties properties)
          Prompts this implementation to initialize itself with the supplied Properties.
 TupleBatch pinTupleBatch(TupleSourceID tupleSourceID, int beginRow, int maxEndRow)
          Gets a tuple batch by ID and indexes.
 void releasePinnedBatches()
          Release batches that have been pinned by this thread.
 void removeTupleSource(TupleSourceID tupleSourceID)
          Removes a tuple source by ID
 void removeTupleSources(java.lang.String groupName)
          Removes all tuple sources by group name
 void setStatus(TupleSourceID tupleSourceID, BufferManager.TupleSourceStatus status)
          Sets the status of the tuple source
 void stop()
           
 void unpinTupleBatch(TupleSourceID tupleSourceID, int firstRow, int lastRow)
          Unpins a range of rows from the given tuple source
 

Method Detail

initialize

void initialize(java.lang.String location,
                java.util.Properties properties)
                throws MetaMatrixComponentException
Prompts this implementation to initialize itself with the supplied Properties. The implementation Class should document what properties are necessary, if any.

Parameters:
lookup - Class used to determine identity and lookup other managers
properties - Properties required to initialize the Buffer Manager
Throws:
BufferException - if there was a problem initializing
MetaMatrixComponentException

getProcessorBatchSize

int getProcessorBatchSize()
Get the batch size to use during query processing.

Returns:
Batch size (# of rows)

getConnectorBatchSize

int getConnectorBatchSize()
Get the batch size to use when reading data from a connector.

Returns:
Batch size (# of rows)

addStorageManager

void addStorageManager(StorageManager storageManager)
Adds a StorageManager to this BufferManager instance. This method may be called multiple times; it will be first called after the call to initialize(java.lang.String, java.util.Properties).

Parameters:
storageManager - Storage manager to add

createTupleSource

TupleSourceID createTupleSource(java.util.List elements,
                                java.lang.String[] types,
                                java.lang.String groupName,
                                BufferManager.TupleSourceType tupleSourceType)
                                throws MetaMatrixComponentException
Creates a tuple source based on a schema and properties describing hints about the source

Parameters:
elements - Elements of the tuple source
groupName - Tuple source group name
tupleSourceType - Type of tuple source
Returns:
Identifier for tuple source
Throws:
MetaMatrixComponentException - indicating a non-business-related exception (such as a communication exception)

removeTupleSource

void removeTupleSource(TupleSourceID tupleSourceID)
                       throws TupleSourceNotFoundException,
                              MetaMatrixComponentException
Removes a tuple source by ID

Parameters:
tupleSourceID - Tuple source identifier
Throws:
TupleSourceNotFoundException - if tuple source could not be found
MetaMatrixComponentException - indicating a non-business-related exception (such as a communication exception)

removeTupleSources

void removeTupleSources(java.lang.String groupName)
                        throws MetaMatrixComponentException
Removes all tuple sources by group name

Parameters:
groupName - Tuple source group name
Throws:
TupleSourceNotFoundException - if tuple source could not be found
MetaMatrixComponentException - indicating a non-business-related exception (such as a communication exception)

getTupleSource

IndexedTupleSource getTupleSource(TupleSourceID tupleSourceID)
                                  throws TupleSourceNotFoundException,
                                         MetaMatrixComponentException
Gets a tuple source by ID

Parameters:
tupleSourceID - Tuple source identifier
Returns:
Tuple source to get tuples from the specified source
Throws:
TupleSourceNotFoundException - if tuple source could not be found
MetaMatrixComponentException - indicating a non-business-related exception (such as a communication exception)

pinTupleBatch

TupleBatch pinTupleBatch(TupleSourceID tupleSourceID,
                         int beginRow,
                         int maxEndRow)
                         throws TupleSourceNotFoundException,
                                MemoryNotAvailableException,
                                MetaMatrixComponentException
Gets a tuple batch by ID and indexes. Pins this tuple batch in memory until it is unpinned or tuple source is removed. If memory does not exist to pin the batch, a MemoryNotAvailableException is thrown.

Parameters:
tupleSourceID - Tuple source identifier
beginRow - First row index to return
maxEndRow - Maximum last row index to return, may be less actually returned
Returns:
Batch of rows starting from beginRow and not past maxEndRow
Throws:
TupleSourceNotFoundException - if tuple source could not be found
MetaMatrixComponentException - indicating a non-business-related exception (such as a communication exception)
MemoryNotAvailableException - If memory was not available for the pin

unpinTupleBatch

void unpinTupleBatch(TupleSourceID tupleSourceID,
                     int firstRow,
                     int lastRow)
                     throws TupleSourceNotFoundException,
                            MetaMatrixComponentException
Unpins a range of rows from the given tuple source

Parameters:
tupleSourceID - Tuple source identifier
firstRow - First row to unpin
lastRow - Last row to unpin (inclusive)
Throws:
TupleSourceNotFoundException - if tuple source could not be found
MetaMatrixComponentException - indicating a non-business-related exception (such as a communication exception)

getTupleSchema

java.util.List getTupleSchema(TupleSourceID tupleSourceID)
                              throws TupleSourceNotFoundException,
                                     MetaMatrixComponentException
Gets a tuple source schema by ID

Parameters:
tupleSourceID - Tuple source identifier
Returns:
List of ElementSymbol describing elements of tuple source
Throws:
TupleSourceNotFoundException - if tuple source could not be found
MetaMatrixComponentException - indicating a non-business-related exception (such as a communication exception)

addTupleBatch

void addTupleBatch(TupleSourceID tupleSourceID,
                   TupleBatch tupleBatch)
                   throws TupleSourceNotFoundException,
                          MetaMatrixComponentException
Adds a batch of tuples for the specified tuple source

Parameters:
tupleSourceID - Tuple source identifier
tupleBatch - Batch of rows to add
Throws:
TupleSourceNotFoundException - if tuple source could not be found
MetaMatrixComponentException - indicating a non-business-related exception (such as a communication exception)

getRowCount

int getRowCount(TupleSourceID tupleSourceID)
                throws TupleSourceNotFoundException,
                       MetaMatrixComponentException
Gets the current row count

Parameters:
tupleSourceID - Tuple source identifier
Returns:
Current known number of rows in tuple source
Throws:
TupleSourceNotFoundException - if tuple source could not be found
MetaMatrixComponentException - indicating a non-business-related exception (such as a communication exception)

setStatus

void setStatus(TupleSourceID tupleSourceID,
               BufferManager.TupleSourceStatus status)
               throws TupleSourceNotFoundException,
                      MetaMatrixComponentException
Sets the status of the tuple source

Parameters:
tupleSourceID - Tuple source identifier
status - New status
Throws:
TupleSourceNotFoundException - if tuple source could not be found
MetaMatrixComponentException - indicating a non-business-related exception (such as a communication exception)
See Also:
BufferManager.TupleSourceStatus.ACTIVE, BufferManager.TupleSourceStatus.FULL

getStatus

BufferManager.TupleSourceStatus getStatus(TupleSourceID tupleSourceID)
                                          throws TupleSourceNotFoundException,
                                                 MetaMatrixComponentException
Gets the status of the tuple source

Parameters:
tupleSourceID - Tuple source identifier
Returns:
Status of tuple source
Throws:
TupleSourceNotFoundException - if tuple source could not be found
MetaMatrixComponentException - indicating a non-business-related exception (such as a communication exception)
See Also:
BufferManager.TupleSourceStatus.ACTIVE, BufferManager.TupleSourceStatus.FULL

getFinalRowCount

int getFinalRowCount(TupleSourceID tupleSourceID)
                     throws TupleSourceNotFoundException,
                            MetaMatrixComponentException
Gets the final row count if tuple source is FULL, otherwise returns -1.

Parameters:
tupleSourceID - Tuple source identifier
Returns:
Final row count if status == FULL, -1 otherwise
Throws:
TupleSourceNotFoundException
MetaMatrixComponentException

addStreamablePart

void addStreamablePart(TupleSourceID tupleSourceID,
                       LobChunk streamGlob,
                       int beginRow)
                       throws TupleSourceNotFoundException,
                              MetaMatrixComponentException
Add a streamable object to the persistent store. The distinction is made between regular tuple sources and streamable object beacuse, streamable objects are fairly large in size can not be loaded totally into memory, as other tuple sources are done this mechanism allows to stream these objects chunk by chunk.

Parameters:
tupleSourceID -
streamGlob - part of the stream
stream -
Throws:
TupleSourceNotFoundException
MetaMatrixComponentException

getStreamablePart

LobChunk getStreamablePart(TupleSourceID tupleSourceID,
                           int beginRow)
                           throws TupleSourceNotFoundException,
                                  MetaMatrixComponentException
Returns the streamable batch object's part stored with specified identifier

Parameters:
tupleSourceID - - identifier
Returns:
LobChunk a part of the Streamable object stored.
Throws:
TupleSourceNotFoundException
MetaMatrixComponentException

stop

void stop()

releasePinnedBatches

void releasePinnedBatches()
                          throws MetaMatrixComponentException
Release batches that have been pinned by this thread. This method should be called when processing is terminated to ensure that the memory can be freed.

Throws:
MetaMatrixComponentException


Copyright © 2009. All Rights Reserved.