ExecStreamGraph Class Reference

An ExecStreamGraph is a directed graph representing dataflow among ExecStreams. More...

#include <ExecStreamGraph.h>

Inheritance diagram for ExecStreamGraph:

ClosableObject ExecStreamGraphImpl List of all members.

Public Member Functions

virtual ~ExecStreamGraph ()
ExecStreamSchedulergetScheduler () const
 
Returns:
pointer to executing scheduler, or null if there is none.

SharedDynamicParamManager getDynamicParamManager ()
 
Returns:
reference to the DynamicParamManager for this graph.

virtual void setTxn (SharedLogicalTxn pTxn)=0
 Sets the transaction within which this graph should execute.
virtual void setErrorTarget (SharedErrorTarget pErrorTarget)=0
 Sets the ErrorTarget to which this graph's streams should send row errors.
virtual void setScratchSegment (SharedSegment pScratchSegment)=0
 Sets the ScratchSegment from which this graph's streams should allocate memory buffers.
virtual void setResourceGovernor (SharedExecStreamGovernor pResourceGovernor)=0
 Sets the global exec stream governor.
virtual SharedLogicalTxn getTxn ()=0
 
Returns:
the transaction within which this graph is executing

virtual TxnId getTxnId ()=0
 
Returns:
the transaction ID for this graph

virtual void enableDummyTxnId (bool enabled)=0
 Controls whether it is OK to call getTxnId without first calling setTxn.
virtual SharedExecStreamGovernor getResourceGovernor ()=0
 
Returns:
exec stream governor

virtual void addStream (SharedExecStream pStream)=0
 Adds a stream to this graph.
virtual void removeStream (ExecStreamId)=0
 Removes a stream from the graph: deletes the edges, and puts the vertex on a free list to be reallocated.
virtual void addDataflow (ExecStreamId producerId, ExecStreamId consumerId, bool isImplicit=false)=0
 Defines a dataflow relationship between two streams in this graph.
virtual void addOutputDataflow (ExecStreamId producerId)=0
 Defines a dataflow representing external output produced by this graph.
virtual void addInputDataflow (ExecStreamId consumerId)=0
 Defines a dataflow representing external input consumed by this graph.
virtual void mergeFrom (ExecStreamGraph &src)=0
 Adds all the vertices and edges from another graph.
virtual void mergeFrom (ExecStreamGraph &src, std::vector< ExecStreamId > const &nodes)=0
 Adds a subgraph, taken (removed) from another graph.
virtual SharedExecStream findStream (std::string name)=0
 Finds a stream by name.
virtual SharedExecStream findLastStream (std::string name, uint iOutput)=0
 Finds last stream known for name.
virtual void interposeStream (std::string name, uint iOutput, ExecStreamId interposedId)=0
 Interposes an adapter stream.
virtual void prepare (ExecStreamScheduler &scheduler)=0
 Prepares this graph for execution.
virtual void open ()=0
 Opens execution on this graph.
virtual SharedExecStream getStream (ExecStreamId id)=0
 Translates a stream ID to a stream pointer.
virtual uint getInputCount (ExecStreamId streamId)=0
 Determines number of explicit input flows consumed by a stream.
virtual uint getOutputCount (ExecStreamId streamId)=0
 Determines number of explicit output flows produced by a stream.
virtual SharedExecStream getStreamInput (ExecStreamId streamId, uint iInput)=0
 Accesses a stream's input.
virtual SharedExecStreamBufAccessor getStreamInputAccessor (ExecStreamId streamId, uint iInput)=0
 Accesses a stream's input accessor.
virtual SharedExecStream getStreamOutput (ExecStreamId streamId, uint iOutput)=0
 Accesses a stream's output.
virtual SharedExecStreamBufAccessor getStreamOutputAccessor (ExecStreamId streamId, uint iOutput)=0
 Accesses a stream's output accessor.
virtual std::vector< SharedExecStreamgetSortedStreams ()=0
 Gets streams, sorted topologically.
virtual int getStreamCount ()=0
 
Returns:
the number of streams in the graph; can only be called after prepare.

virtual int getDataflowCount ()=0
 
Returns:
the number of dataflows (edges) in the graph; can only be called after prepare.

virtual void renderGraphviz (std::ostream &dotStream)=0
 Renders the graph in the .dot format defined by Graphviz.
virtual bool isAcyclic ()=0
 
Returns:
true if graph has no cycles

virtual void closeProducers (ExecStreamId streamId)=0
 Closes the producers of a stream with a given id.
virtual void declareDynamicParamWriter (ExecStreamId streamId, DynamicParamId dynamicParamId)=0
 Declares that a given stream writes a given dynamic parameter.
virtual void declareDynamicParamReader (ExecStreamId streamId, DynamicParamId dynamicParamId)=0
 Declares that a given stream reads a given dynamic parameter.
virtual const std::vector<
ExecStreamId > & 
getDynamicParamWriters (DynamicParamId dynamicParamId)=0
 Returns a list of stream ids that write a given dynamic parameter.
virtual const std::vector<
ExecStreamId > & 
getDynamicParamReaders (DynamicParamId dynamicParamId)=0
 Returns a list of stream ids that read a given dynamic parameter.
bool isClosed () const
 
Returns:
whether the object has been closed

void close ()
 Closes this object, releasing any unallocated resources.

Static Public Member Functions

static SharedExecStreamGraph newExecStreamGraph ()
 Constructs a new ExecStreamGraph.

Protected Member Functions

 ExecStreamGraph ()
virtual void closeImpl ()=0
 Must be implemented by derived class to release any resources.

Protected Attributes

ExecStreamSchedulerpScheduler
 A Scheduler responsible for executing streams in this graph.
SharedDynamicParamManager pDynamicParamManager
 Manager that handles dynamic parameters for this graph.
bool needsClose

Friends

class ExecStreamScheduler

Detailed Description

An ExecStreamGraph is a directed graph representing dataflow among ExecStreams.

For more information, see ExecStreamDesign.

A stream is always a node is a stream graph, but over its lifetime it may be moved from one graph to another. Specifically, it may be prepared in one graph (see ExecStreamGraphEmbro), executed in another, and finally closed & deleted in a third graph.

A stream has a permanent, unique name. These names are used later to find the streams. When a stream is added to a graph it is assigned an ExecStreamId. This identifier is later used to work with the stream. If the stream is moved to another graph, it obtains a new ExecStreamId.

Definition at line 59 of file ExecStreamGraph.h.


Constructor & Destructor Documentation

ExecStreamGraph::ExecStreamGraph (  )  [explicit, protected]

Definition at line 50 of file ExecStreamGraph.cpp.

00051     : pScheduler(NULL),
00052       pDynamicParamManager(new DynamicParamManager())
00053 {
00054 }

ExecStreamGraph::~ExecStreamGraph (  )  [virtual]

Definition at line 56 of file ExecStreamGraph.cpp.

00057 {
00058 }


Member Function Documentation

SharedExecStreamGraph ExecStreamGraph::newExecStreamGraph (  )  [static]

Constructs a new ExecStreamGraph.

Returns:
new graph

Definition at line 43 of file ExecStreamGraph.cpp.

Referenced by ExecStreamTestBase::newStreamGraph(), and CmdInterpreter::visit().

00044 {
00045     return SharedExecStreamGraph(
00046         new ExecStreamGraphImpl(),
00047         ClosableObjectDestructor());
00048 }

ExecStreamScheduler * ExecStreamGraph::getScheduler (  )  const [inline]

Returns:
pointer to executing scheduler, or null if there is none.

Definition at line 444 of file ExecStreamGraph.h.

References pScheduler.

Referenced by ExecStream::checkAbort(), JavaSinkExecStream::execute(), CorrelationJoinExecStream::execute(), Java_net_sf_farrago_fennel_FennelStorage_tupleStreamFetch(), MergeExecStream::open(), CorrelationJoinExecStream::open(), and JavaSinkExecStream::stuffByteBuffer().

00445 {
00446     return pScheduler;
00447 }

SharedDynamicParamManager ExecStreamGraph::getDynamicParamManager (  )  [inline]

Returns:
reference to the DynamicParamManager for this graph.

Definition at line 449 of file ExecStreamGraph.h.

References pDynamicParamManager.

Referenced by ExecStream::prepare().

00450 {
00451     return pDynamicParamManager;
00452 }

virtual void ExecStreamGraph::setTxn ( SharedLogicalTxn  pTxn  )  [pure virtual]

Sets the transaction within which this graph should execute.

The transaction is reset whenever the graph is closed.

Parameters:
pTxn transaction

Implemented in ExecStreamGraphImpl.

virtual void ExecStreamGraph::setErrorTarget ( SharedErrorTarget  pErrorTarget  )  [pure virtual]

Sets the ErrorTarget to which this graph's streams should send row errors.

Parameters:
pErrorTarget error target

Implemented in ExecStreamGraphImpl.

virtual void ExecStreamGraph::setScratchSegment ( SharedSegment  pScratchSegment  )  [pure virtual]

Sets the ScratchSegment from which this graph's streams should allocate memory buffers.

Parameters:
pScratchSegment scratch segment

Implemented in ExecStreamGraphImpl.

virtual void ExecStreamGraph::setResourceGovernor ( SharedExecStreamGovernor  pResourceGovernor  )  [pure virtual]

Sets the global exec stream governor.

Parameters:
pResourceGovernor exec stream governor

Implemented in ExecStreamGraphImpl.

virtual SharedLogicalTxn ExecStreamGraph::getTxn (  )  [pure virtual]

Returns:
the transaction within which this graph is executing

Implemented in ExecStreamGraphImpl.

Referenced by ExecStream::open().

virtual TxnId ExecStreamGraph::getTxnId (  )  [pure virtual]

Returns:
the transaction ID for this graph

Implemented in ExecStreamGraphImpl.

Referenced by ExecStream::open().

virtual void ExecStreamGraph::enableDummyTxnId ( bool  enabled  )  [pure virtual]

Controls whether it is OK to call getTxnId without first calling setTxn.

Normally, this is a bad idea (since in that case getTxnId will return FIRST_TXN_ID as a dummy, which could lead to concurrency problems), but for non-transactional unit tests, this can be useful. Default is disabled.

Parameters:
enabled whether dummy txn ID's are enabled

Implemented in ExecStreamGraphImpl.

virtual SharedExecStreamGovernor ExecStreamGraph::getResourceGovernor (  )  [pure virtual]

Returns:
exec stream governor

Implemented in ExecStreamGraphImpl.

virtual void ExecStreamGraph::addStream ( SharedExecStream  pStream  )  [pure virtual]

Adds a stream to this graph.

Parameters:
pStream stream to add

Implemented in ExecStreamGraphImpl.

virtual void ExecStreamGraph::removeStream ( ExecStreamId   )  [pure virtual]

Removes a stream from the graph: deletes the edges, and puts the vertex on a free list to be reallocated.

Does not free the ExecStream or its ExecStreamBufAccessors.

Implemented in ExecStreamGraphImpl.

virtual void ExecStreamGraph::addDataflow ( ExecStreamId  producerId,
ExecStreamId  consumerId,
bool  isImplicit = false 
) [pure virtual]

Defines a dataflow relationship between two streams in this graph.

Parameters:
producerId ID of producer stream in this graph
consumerId ID of consumer stream in this graph
isImplicit false (the default) if the edge represents direct dataflow; true if the edge represents an implicit dataflow dependency

Implemented in ExecStreamGraphImpl.

virtual void ExecStreamGraph::addOutputDataflow ( ExecStreamId  producerId  )  [pure virtual]

Defines a dataflow representing external output produced by this graph.

Parameters:
producerId ID of producer stream in this graph

Implemented in ExecStreamGraphImpl.

Referenced by ExecStreamBuilder::buildStreamGraph().

virtual void ExecStreamGraph::addInputDataflow ( ExecStreamId  consumerId  )  [pure virtual]

Defines a dataflow representing external input consumed by this graph.

Parameters:
consumerId ID of consumer stream in this graph

Implemented in ExecStreamGraphImpl.

virtual void ExecStreamGraph::mergeFrom ( ExecStreamGraph src  )  [pure virtual]

Adds all the vertices and edges from another graph.

Assumes the graphs are disjoint, and that both have been prepared. The two graphs are both open, or else both closed.

Parameters:
src the other graph, which is left empty.

Implemented in ExecStreamGraphImpl.

virtual void ExecStreamGraph::mergeFrom ( ExecStreamGraph src,
std::vector< ExecStreamId > const &  nodes 
) [pure virtual]

Adds a subgraph, taken (removed) from another graph.

(Slower than mergeFrom(ExecStreamGraph&), which merges its entire source). Assumes the graphs are disjoint, and that both have been prepared. The two graphs are both open, or else both closed.

Parameters:
src the source graph
nodes identifies source nodes.

Implemented in ExecStreamGraphImpl.

virtual SharedExecStream ExecStreamGraph::findStream ( std::string  name  )  [pure virtual]

Finds a stream by name.

Parameters:
name name of stream to find
Returns:
stream found

Implemented in ExecStreamGraphImpl.

virtual SharedExecStream ExecStreamGraph::findLastStream ( std::string  name,
uint  iOutput 
) [pure virtual]

Finds last stream known for name.

May be original stream or an adapter.

Parameters:
name name of stream to find
iOutput ordinal of output arc
Returns:
stream found

Implemented in ExecStreamGraphImpl.

virtual void ExecStreamGraph::interposeStream ( std::string  name,
uint  iOutput,
ExecStreamId  interposedId 
) [pure virtual]

Interposes an adapter stream.

In the process, creates a dataflow from last stream associated with name to the adapter stream.

Parameters:
name name of stream to adapt
iOutput ordinal of output of stream
interposedId ID of adapter stream within this graph

Implemented in ExecStreamGraphImpl.

virtual void ExecStreamGraph::prepare ( ExecStreamScheduler scheduler  )  [pure virtual]

Prepares this graph for execution.

Only called once (before first open) after all streams and dataflows have been defined.

Parameters:
scheduler ExecStreamScheduler which will execute this graph

Implemented in ExecStreamGraphImpl.

virtual void ExecStreamGraph::open (  )  [pure virtual]

Opens execution on this graph.

A graph may be repeatedly closed and then reopened.

Implemented in ExecStreamGraphImpl.

virtual SharedExecStream ExecStreamGraph::getStream ( ExecStreamId  id  )  [pure virtual]

Translates a stream ID to a stream pointer.

Parameters:
id ID of a stream in this graph
Returns:
shared pointer to the stream

Implemented in ExecStreamGraphImpl.

Referenced by CorrelationJoinExecStream::execute(), and CorrelationJoinExecStream::open().

virtual uint ExecStreamGraph::getInputCount ( ExecStreamId  streamId  )  [pure virtual]

Determines number of explicit input flows consumed by a stream.

Parameters:
streamId ID of stream
Returns:
input count

Implemented in ExecStreamGraphImpl.

virtual uint ExecStreamGraph::getOutputCount ( ExecStreamId  streamId  )  [pure virtual]

Determines number of explicit output flows produced by a stream.

Parameters:
streamId ID of stream
Returns:
output count

Implemented in ExecStreamGraphImpl.

virtual SharedExecStream ExecStreamGraph::getStreamInput ( ExecStreamId  streamId,
uint  iInput 
) [pure virtual]

Accesses a stream's input.

Parameters:
streamId ID of stream
iInput 0-based input explicit flow ordinal
Returns:
upstream producer

Implemented in ExecStreamGraphImpl.

Referenced by CorrelationJoinExecStream::execute(), JavaTransformExecStream::open(), SingleInputExecStream::open(), ConfluenceExecStream::open(), CartesianJoinExecStream::prepare(), and LbmMinusExecStream::restartSubtrahends().

virtual SharedExecStreamBufAccessor ExecStreamGraph::getStreamInputAccessor ( ExecStreamId  streamId,
uint  iInput 
) [pure virtual]

Accesses a stream's input accessor.

Parameters:
streamId ID of stream
iInput 0-based input explicit flow ordinal
Returns:
accessor used by upstream producer

Implemented in ExecStreamGraphImpl.

Referenced by Java_net_sf_farrago_fennel_FennelStorage_tupleStreamTransformFetch().

virtual SharedExecStream ExecStreamGraph::getStreamOutput ( ExecStreamId  streamId,
uint  iOutput 
) [pure virtual]

Accesses a stream's output.

Parameters:
streamId ID of stream
iOutput 0-based output explicit flow ordinal
Returns:
downstream consumer

Implemented in ExecStreamGraphImpl.

virtual SharedExecStreamBufAccessor ExecStreamGraph::getStreamOutputAccessor ( ExecStreamId  streamId,
uint  iOutput 
) [pure virtual]

Accesses a stream's output accessor.

Parameters:
streamId ID of stream
iOutput 0-based output explicit flow ordinal
Returns:
accessor used by downstream consumer

Implemented in ExecStreamGraphImpl.

virtual std::vector<SharedExecStream> ExecStreamGraph::getSortedStreams (  )  [pure virtual]

Gets streams, sorted topologically.

Can only be called after prepare.

Returns:
vector of sorted streams

Implemented in ExecStreamGraphImpl.

Referenced by SimpleExecStreamGovernor::requestResources().

virtual int ExecStreamGraph::getStreamCount (  )  [pure virtual]

Returns:
the number of streams in the graph; can only be called after prepare.

Implemented in ExecStreamGraphImpl.

virtual int ExecStreamGraph::getDataflowCount (  )  [pure virtual]

Returns:
the number of dataflows (edges) in the graph; can only be called after prepare.

Implemented in ExecStreamGraphImpl.

virtual void ExecStreamGraph::renderGraphviz ( std::ostream &  dotStream  )  [pure virtual]

Renders the graph in the .dot format defined by Graphviz.

Parameters:
dotStream ostream on which to write .dot representation

Implemented in ExecStreamGraphImpl.

virtual bool ExecStreamGraph::isAcyclic (  )  [pure virtual]

Returns:
true if graph has no cycles

Implemented in ExecStreamGraphImpl.

virtual void ExecStreamGraph::closeProducers ( ExecStreamId  streamId  )  [pure virtual]

Closes the producers of a stream with a given id.

Parameters:
streamId stream id of the stream whose producers will be closed

Implemented in ExecStreamGraphImpl.

virtual void ExecStreamGraph::declareDynamicParamWriter ( ExecStreamId  streamId,
DynamicParamId  dynamicParamId 
) [pure virtual]

Declares that a given stream writes a given dynamic parameter.

Parameters:
streamId Stream id
dynamicParamId Dynamic parameter id

Implemented in ExecStreamGraphImpl.

Referenced by ExecStreamBuilder::buildStream().

virtual void ExecStreamGraph::declareDynamicParamReader ( ExecStreamId  streamId,
DynamicParamId  dynamicParamId 
) [pure virtual]

Declares that a given stream reads a given dynamic parameter.

Parameters:
streamId Stream id
dynamicParamId Dynamic parameter id

Implemented in ExecStreamGraphImpl.

Referenced by ExecStreamBuilder::buildStream().

virtual const std::vector<ExecStreamId>& ExecStreamGraph::getDynamicParamWriters ( DynamicParamId  dynamicParamId  )  [pure virtual]

Returns a list of stream ids that write a given dynamic parameter.

Parameters:
dynamicParamId Dynamic parameter id
Returns:
List of ids of streams that write the parameter

Implemented in ExecStreamGraphImpl.

virtual const std::vector<ExecStreamId>& ExecStreamGraph::getDynamicParamReaders ( DynamicParamId  dynamicParamId  )  [pure virtual]

Returns a list of stream ids that read a given dynamic parameter.

Parameters:
dynamicParamId Dynamic parameter id
Returns:
List of ids of streams that read the parameter

Implemented in ExecStreamGraphImpl.

Referenced by CorrelationJoinExecStream::execute(), and CorrelationJoinExecStream::open().

virtual void ClosableObject::closeImpl (  )  [protected, pure virtual, inherited]

Must be implemented by derived class to release any resources.

Implemented in CacheImpl< PageT, VictimPolicyT >, ByteArrayInputStream, ByteArrayOutputStream, ByteOutputStream, CheckpointThread, Database, BarrierExecStream, DoubleBufferExecStream, ExecStream, ExecStreamGraphImpl, MockResourceExecStream, ReshapeExecStream, ScratchBufferExecStream, SegBufferExecStream, SegBufferReader, SegBufferReaderExecStream, SegBufferWriter, SegBufferWriterExecStream, JavaSinkExecStream, JavaTransformExecStream, FlatFileBuffer, FlatFileExecStreamImpl, BTreeExecStream, BTreeInsertExecStream, BTreePrefetchSearchExecStream, BTreeReadExecStream, BTreeSearchExecStream, FtrsTableWriterExecStream, LhxAggExecStream, LhxJoinExecStream, LbmBitOpExecStream, LbmChopperExecStream, LbmGeneratorExecStream, LbmIntersectExecStream, LbmMinusExecStream, LbmSplicerExecStream, LbmUnionExecStream, LcsClusterAppendExecStream, LcsRowScanBaseExecStream, LcsRowScanExecStream, DelegatingSegment, DynamicDelegatingSegment, ScratchSegment, SegInputStream, Segment, SegOutputStream, SegPageBackupRestoreDevice, SegStream, SegStreamAllocation, SpillOutputStream, and ExternalSortExecStreamImpl.

Referenced by ClosableObject::close().

bool ClosableObject::isClosed (  )  const [inline, inherited]

Returns:
whether the object has been closed

Definition at line 58 of file ClosableObject.h.

00059     {
00060         return !needsClose;
00061     }

void ClosableObject::close (  )  [inherited]

Closes this object, releasing any unallocated resources.

Reimplemented in CollectExecStream, CorrelationJoinExecStream, LcsClusterAppendExecStream, and LcsClusterReplaceExecStream.

Definition at line 39 of file ClosableObject.cpp.

References ClosableObject::closeImpl(), and ClosableObject::needsClose.

Referenced by CacheImpl< PageT, VictimPolicyT >::allocatePages(), LcsRowScanBaseExecStream::closeImpl(), ExecStreamGraphImpl::closeImpl(), FlatFileBuffer::open(), ClosableObjectDestructor::operator()(), and Segment::~Segment().

00040 {
00041     if (!needsClose) {
00042         return;
00043     }
00044     needsClose = false;
00045     closeImpl();
00046 }


Friends And Related Function Documentation

friend class ExecStreamScheduler [friend]

Definition at line 63 of file ExecStreamGraph.h.


Member Data Documentation

ExecStreamScheduler* ExecStreamGraph::pScheduler [protected]

A Scheduler responsible for executing streams in this graph.

(Can be null if the current graph is only building streams, not executing them.) Note that we don't use a weak_ptr for this because it needs to be accessed frequently during execution, and the extra locking overhead would be frivolous.

Definition at line 73 of file ExecStreamGraph.h.

Referenced by getScheduler().

SharedDynamicParamManager ExecStreamGraph::pDynamicParamManager [protected]

Manager that handles dynamic parameters for this graph.

Definition at line 78 of file ExecStreamGraph.h.

Referenced by ExecStreamGraphImpl::closeImpl(), and getDynamicParamManager().

bool ClosableObject::needsClose [protected, inherited]

Definition at line 44 of file ClosableObject.h.

Referenced by SegStreamAllocation::beginWrite(), ExecStreamGraphImpl::clear(), ClosableObject::ClosableObject(), ClosableObject::close(), FlatFileBuffer::open(), ExecStreamGraphImpl::open(), ExecStream::open(), and ClosableObject::~ClosableObject().


The documentation for this class was generated from the following files:
Generated on Mon Jun 22 04:00:30 2009 for Fennel by  doxygen 1.5.1