net.sf.farrago.fennel
Class FennelStreamGraph

java.lang.Object
  extended by net.sf.farrago.fennel.FennelStreamGraph
All Implemented Interfaces:
FarragoAllocation, ClosableAllocation

public class FennelStreamGraph
extends Object
implements FarragoAllocation

FennelStreamGraphs are FarragoAllocations for FemStreamGraphHandles.

Version:
$Id: //open/dev/farrago/src/net/sf/farrago/fennel/FennelStreamGraph.java#22 $
Author:
John V. Sichi

Field Summary
private  FennelDbHandle fennelDbHandle
           
private  long streamGraphHandle
           
private static Logger tracer
           
 
Constructor Summary
FennelStreamGraph(FennelDbHandle fennelDbHandle, FemStreamGraphHandle streamGraphHandle)
           
 
Method Summary
 void abort()
          Aborts the current execution (but does not close the graph).
 void close()
          Closes the stream graph (but does not deallocate it).
 void closeAllocation()
          Closes this object.
 int fetch(FennelStreamHandle streamHandle, byte[] byteArray)
          Fetches a buffer of rows from a stream.
 FennelStreamHandle findStream(FarragoMetadataFactory metadataFactory, String streamName, boolean isInput)
          Finds a particular stream within the graph.
 String[] getInputStreams(String streamName)
          Find the inputs of a specified stream in the graph.
 long getLongHandle()
           
 FemStreamGraphHandle getStreamGraphHandle()
           
 void open(FennelTxnContext fennelTxnContext, FennelJavaStreamMap javaStreamMap, FennelJavaErrorTarget javaErrorTarget)
          Opens a prepared stream graph.
 void restart(FennelStreamHandle streamHandle)
          Restarts a particular stream in this graph.
private  void traceGraphHandle(String operation)
           
private  void traceStreamHandle(String operation, FennelStreamHandle streamHandle)
           
private  void traceStreamHandle(String operation, FennelStreamHandle streamHandle, int execStreamInputOrdinal)
           
 int transformFetch(FennelStreamHandle streamHandle, int execStreamInputOrdinal, byte[] byteArray)
          Fetches a buffer of rows from a stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

tracer

private static final Logger tracer

fennelDbHandle

private final FennelDbHandle fennelDbHandle

streamGraphHandle

private long streamGraphHandle
Constructor Detail

FennelStreamGraph

FennelStreamGraph(FennelDbHandle fennelDbHandle,
                  FemStreamGraphHandle streamGraphHandle)
Method Detail

findStream

public FennelStreamHandle findStream(FarragoMetadataFactory metadataFactory,
                                     String streamName,
                                     boolean isInput)
Finds a particular stream within the graph.

Parameters:
metadataFactory - factory for creating Fem instances
streamName - name of stream to find
isInput -
Returns:
handle to stream

getInputStreams

public String[] getInputStreams(String streamName)
Find the inputs of a specified stream in the graph.

Parameters:
streamName - names a stream
Returns:
a list of the names of the inputs, in input-edge order.

getStreamGraphHandle

public FemStreamGraphHandle getStreamGraphHandle()
Returns:
the underlying FemStreamGraphHandle

getLongHandle

public long getLongHandle()
Returns:
native handle to underlying graph

traceGraphHandle

private void traceGraphHandle(String operation)

traceStreamHandle

private void traceStreamHandle(String operation,
                               FennelStreamHandle streamHandle)

traceStreamHandle

private void traceStreamHandle(String operation,
                               FennelStreamHandle streamHandle,
                               int execStreamInputOrdinal)

open

public void open(FennelTxnContext fennelTxnContext,
                 FennelJavaStreamMap javaStreamMap,
                 FennelJavaErrorTarget javaErrorTarget)
Opens a prepared stream graph.

Parameters:
fennelTxnContext - transaction context in which stream graph should participate
javaStreamMap - optional FennelJavaStreamMap
javaErrorTarget - error target handles row errors

fetch

public int fetch(FennelStreamHandle streamHandle,
                 byte[] byteArray)
Fetches a buffer of rows from a stream. If unpositioned, this fetches the first rows.

Parameters:
streamHandle - handle to stream from which to fetch
byteArray - output buffer receives complete tuples
Returns:
number of bytes fetched (at least one tuple should always be fetched if any are available, so 0 indicates end of stream)

transformFetch

public int transformFetch(FennelStreamHandle streamHandle,
                          int execStreamInputOrdinal,
                          byte[] byteArray)
Fetches a buffer of rows from a stream. If unpositioned, this fetches the first rows.

Parameters:
streamHandle - handle to JavaTransformExecStream from which to fetch
execStreamInputOrdinal - ordinal of the stream's input
byteArray - output buffer receives complete tuples
Returns:
number of bytes fetched (0 indicates end of stream, less than 0 indicates no data currently available)

close

public void close()
Closes the stream graph (but does not deallocate it).


abort

public void abort()
Aborts the current execution (but does not close the graph).


closeAllocation

public void closeAllocation()
Description copied from interface: ClosableAllocation
Closes this object.

Specified by:
closeAllocation in interface ClosableAllocation

restart

public void restart(FennelStreamHandle streamHandle)
Restarts a particular stream in this graph.

Parameters:
streamHandle - handle to stream to restart