MXQuery 0.6.0 API Documentation - Copyright 2006-2009 ETH Zurich

ch.ethz.mxquery.sms.MMimpl
Class TokenBufferStore

java.lang.Object
  extended by ch.ethz.mxquery.sms.MMimpl.FIFOStore
      extended by ch.ethz.mxquery.sms.MMimpl.TokenBufferStore
All Implemented Interfaces:
Source, ActiveStore, AppendUpdate, StreamStore, MXQueryAppendUpdate
Direct Known Subclasses:
FTTokenBufferStore

public class TokenBufferStore
extends FIFOStore

Simple TokenBuffer to materialize a stream. Additional a index on the node id's is created to allow easy jumping between nodes.


Field Summary
 int level
           
static int MAX_NODE_ID
           
 int myId
           
 Token[] tokenBuffer
           
 
Fields inherited from class ch.ethz.mxquery.sms.MMimpl.FIFOStore
iterator, readThread
 
Constructor Summary
TokenBufferStore(int id, WindowBuffer container)
           
TokenBufferStore(XDMIterator sourceStream, int id, WindowBuffer container)
          Creates a new TokenBuffer for a stream with standard paras
 
Method Summary
 void buffer(Token tok, int event)
          Materialize the given token into the store instance
 int compare(Source store)
           
 Source copySource(Context ctx, java.util.Vector nestedPredCtxStack)
           
 void deleteItems(int olderThanItemId)
          Simple garbage collection; deletes all nodes that are older than the parameter
 Token get(int tokenId)
          Returns the Token for a given token id
 Token get(int tokenId, int maxNodeId)
          Returns the token for a given tokenId.
 int getAttributePosFromNodeId(java.lang.String attrName, int nodeId)
           
 int getAttributePosFromTokenId(java.lang.String attrName, int activeTokenId)
           
 int getMaxNodeId()
          Returns the current materialized nodeId
 int getMaxTokenId()
          Returns the current materialized tokenId
 int getMyId()
          Returns the store id (mostly for debugging)
 int getNodeIdFromTokenId(int tokenId)
          Returns the NodeId for the given Token Id; The first node has the id = 0.
 int getNodeIdFromTokenId(int minNodeId, int tokenId)
          Like getNodeIdFromPosition(int position) but we give a additional information that makes the search for the right nodeId faster.
 int getSize()
           
 int getTokenIdForNode(int nodeId)
          Returns the position for a given NodePosition.
 java.lang.String getURI()
          Returns the URI of the source.
 boolean hasNode(int node)
          Checks if a node exists
 void newItem()
          Specify the beginning of a new item
 void printBuffer()
           
 void setContext(Context context)
          Sets the context of the source stream.
 void setIterator(XDMIterator it)
          For pull stores, add the iterator from which they should pull their data
 void start()
          Start the gathering of the active store
 
Methods inherited from class ch.ethz.mxquery.sms.MMimpl.FIFOStore
getCurrentTokenId, getIterator, setContainer
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_NODE_ID

public static final int MAX_NODE_ID
See Also:
Constant Field Values

level

public int level

tokenBuffer

public Token[] tokenBuffer

myId

public int myId
Constructor Detail

TokenBufferStore

public TokenBufferStore(XDMIterator sourceStream,
                        int id,
                        WindowBuffer container)
Creates a new TokenBuffer for a stream with standard paras

Parameters:
sourceStream - Source Stream

TokenBufferStore

public TokenBufferStore(int id,
                        WindowBuffer container)
Method Detail

start

public void start()
Description copied from interface: ActiveStore
Start the gathering of the active store


setIterator

public void setIterator(XDMIterator it)
Description copied from interface: StreamStore
For pull stores, add the iterator from which they should pull their data

Specified by:
setIterator in interface StreamStore
Overrides:
setIterator in class FIFOStore

setContext

public void setContext(Context context)
                throws MXQueryException
Sets the context of the source stream. This is especially necassary if the window iterator is used for external variables

Specified by:
setContext in interface MXQueryAppendUpdate
Overrides:
setContext in class FIFOStore
Parameters:
context -
Throws:
MXQueryException

getTokenIdForNode

public int getTokenIdForNode(int nodeId)
                      throws MXQueryException
Returns the position for a given NodePosition. If the node id is higher than the availabe source nodes the latest position is returned

Specified by:
getTokenIdForNode in interface MXQueryAppendUpdate
Overrides:
getTokenIdForNode in class FIFOStore
Parameters:
nodeId -
Returns:
the token id
Throws:
MXQueryException

hasNode

public boolean hasNode(int node)
                throws MXQueryException
Checks if a node exists

Specified by:
hasNode in interface MXQueryAppendUpdate
Overrides:
hasNode in class FIFOStore
Parameters:
node - a node id
Returns:
true if the node for the given id exists
Throws:
MXQueryException

getNodeIdFromTokenId

public int getNodeIdFromTokenId(int tokenId)
                         throws MXQueryException
Returns the NodeId for the given Token Id; The first node has the id = 0. If the position is not reachable, the last node id is returned.

Parameters:
tokenId -
Returns:
the node id >=0
Throws:
MXQueryException

getNodeIdFromTokenId

public int getNodeIdFromTokenId(int minNodeId,
                                int tokenId)
                         throws MXQueryException
Like getNodeIdFromPosition(int position) but we give a additional information that makes the search for the right nodeId faster.

Specified by:
getNodeIdFromTokenId in interface MXQueryAppendUpdate
Overrides:
getNodeIdFromTokenId in class FIFOStore
Parameters:
minNodeId -
tokenId -
Returns:
the nodeId
Throws:
MXQueryException

printBuffer

public void printBuffer()

get

public Token get(int tokenId)
          throws MXQueryException
Returns the Token for a given token id

Specified by:
get in interface StreamStore
Specified by:
get in interface MXQueryAppendUpdate
Overrides:
get in class FIFOStore
Parameters:
tokenId -
Returns:
the token for this Id
Throws:
MXQueryException

get

public Token get(int tokenId,
                 int maxNodeId)
          throws MXQueryException
Returns the token for a given tokenId. If the token is corresponds to a higher nodeId than maxNodeId, the END_SEQUENCE token is returned.

Specified by:
get in interface MXQueryAppendUpdate
Overrides:
get in class FIFOStore
Parameters:
tokenId - Token Id
maxNodeId - Max Token Id
Returns:
the token, or END_SEQENCE if out of range
Throws:
MXQueryException

getMaxNodeId

public int getMaxNodeId()
Returns the current materialized nodeId

Returns:
the node id of the last materialized node

getMaxTokenId

public int getMaxTokenId()
Returns the current materialized tokenId

Returns:
the token id of the last materialized node

getSize

public int getSize()
Overrides:
getSize in class FIFOStore

deleteItems

public void deleteItems(int olderThanItemId)
                 throws MXQueryException
Simple garbage collection; deletes all nodes that are older than the parameter

Specified by:
deleteItems in interface AppendUpdate
Overrides:
deleteItems in class FIFOStore
Parameters:
olderThanItemId -
Throws:
MXQueryException

getAttributePosFromTokenId

public int getAttributePosFromTokenId(java.lang.String attrName,
                                      int activeTokenId)
                               throws MXQueryException
Overrides:
getAttributePosFromTokenId in class FIFOStore
Throws:
MXQueryException

getAttributePosFromNodeId

public int getAttributePosFromNodeId(java.lang.String attrName,
                                     int nodeId)
                              throws MXQueryException
Overrides:
getAttributePosFromNodeId in class FIFOStore
Throws:
MXQueryException

getMyId

public int getMyId()
Description copied from interface: StreamStore
Returns the store id (mostly for debugging)

Specified by:
getMyId in interface StreamStore
Overrides:
getMyId in class FIFOStore
Returns:
id of the store given at creation time

buffer

public void buffer(Token tok,
                   int event)
Description copied from interface: StreamStore
Materialize the given token into the store instance

Specified by:
buffer in interface StreamStore
Overrides:
buffer in class FIFOStore

newItem

public void newItem()
Description copied from interface: StreamStore
Specify the beginning of a new item

Specified by:
newItem in interface StreamStore
Overrides:
newItem in class FIFOStore

compare

public int compare(Source store)
Specified by:
compare in interface Source
Overrides:
compare in class FIFOStore

copySource

public Source copySource(Context ctx,
                         java.util.Vector nestedPredCtxStack)
                  throws MXQueryException
Specified by:
copySource in interface Source
Overrides:
copySource in class FIFOStore
Throws:
MXQueryException

getURI

public java.lang.String getURI()
Description copied from interface: Source
Returns the URI of the source.

Specified by:
getURI in interface Source
Overrides:
getURI in class FIFOStore
Returns:
a String representing the URI/Identifier of this source

MXQuery 0.6.0 API Documentation - Copyright 2006-2009 ETH Zurich

MXQuery 0.6.0 API Documentation - Copyright 2006-2009 ETH Zurich