net.sf.farrago.fennel
Class FennelStorage

java.lang.Object
  extended by net.sf.farrago.fennel.FennelStorage

public class FennelStorage
extends Object

FennelStorage is the JNI interface for calling Fennel from Farrago. Most methods have package access only; other classes in this package expose public wrapper methods.

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

Field Summary
(package private) static int CLOSE_ABORT
           
(package private) static int CLOSE_DEALLOCATE
           
(package private) static int CLOSE_RESULT
           
 
Constructor Summary
FennelStorage()
           
 
Method Summary
static void cancelExecution(long execHandle)
          Cancels execution of a statement associated with an execution handle.
(package private) static void deleteExecutionHandle(long execHandle)
          Deletes the Fennel object corresponding to an execution handle.
(package private) static void deleteObjectHandle(long handle)
          Releases a handle obtained via newObjectHandle.
(package private) static long executeJavaCmd(FemCmd cmd, long execHandle)
          Executes a command represented as a Java object.
(package private) static String getAccessorXmiForTupleDescriptor(FemTupleDescriptor tupleDesc)
          Constructs a FemTupleAccessor for a FemTupleDescriptor.
static int getHandleCount()
           
(package private) static long newExecutionHandle()
          Allocates a new object in Fennel that Farrago will use to communicate execution state information from Farrago to Fennel.
(package private) static long newObjectHandle(Object obj)
          Creates a native handle for a Java object for reference by XML commands.
(package private) static void setObjectHandle(long handle, Object obj)
          Changes the object referenced by a handle.
(package private) static int tupleStreamFetch(long hStream, byte[] byteArray)
          Fetches a buffer of rows from a stream.
(package private) static void tupleStreamGraphClose(long hStreamGraph, int action)
          Closes a stream graph.
(package private) static void tupleStreamGraphGetInputStreams(long hStreamGraph, String node, List<String> inputs)
          Find the input of a given stream node in a stream graph.
(package private) static void tupleStreamGraphOpen(long hStreamGraph, long hTxn, FennelJavaStreamMap javaStreamMap, FennelJavaErrorTarget javaErrorTarget)
          Opens a stream graph.
(package private) static void tupleStreamRestart(long hStream)
          Restarts a stream.
(package private) static int tupleStreamTransformFetch(long hStream, 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

CLOSE_RESULT

static final int CLOSE_RESULT
See Also:
Constant Field Values

CLOSE_ABORT

static final int CLOSE_ABORT
See Also:
Constant Field Values

CLOSE_DEALLOCATE

static final int CLOSE_DEALLOCATE
See Also:
Constant Field Values
Constructor Detail

FennelStorage

public FennelStorage()
Method Detail

newObjectHandle

static long newObjectHandle(Object obj)
Creates a native handle for a Java object for reference by XML commands. After this, the Java object cannot be garbage collected until its owner explicitly calls closeAllocation.

Parameters:
obj - object for which to create a handle, or null to create a placeholder handle
Returns:
native handle

deleteObjectHandle

static void deleteObjectHandle(long handle)
Releases a handle obtained via newObjectHandle. This should only be called from FennelJavaHandle.

Parameters:
handle - the handle to delete

setObjectHandle

static void setObjectHandle(long handle,
                            Object obj)
Changes the object referenced by a handle.

Parameters:
handle - the handle to change
obj - new object

getHandleCount

public static int getHandleCount()
Returns:
count of handles returned by Fennel which have not yet been deleted

getAccessorXmiForTupleDescriptor

static String getAccessorXmiForTupleDescriptor(FemTupleDescriptor tupleDesc)
Constructs a FemTupleAccessor for a FemTupleDescriptor.

Parameters:
tupleDesc - source FemTupleDescriptor
Returns:
XMI string representation of FemTupleAccessor

executeJavaCmd

static long executeJavaCmd(FemCmd cmd,
                           long execHandle)
                    throws SQLException
Executes a command represented as a Java object.

Parameters:
cmd - Java representation of object
execHandle - optional execution handle associated with the command that's used to pass execution state from Farrago to Fennel; set to 0 if there is no handle
Returns:
output object handle if any
Throws:
SQLException

tupleStreamGraphGetInputStreams

static void tupleStreamGraphGetInputStreams(long hStreamGraph,
                                            String node,
                                            List<String> inputs)
Find the input of a given stream node in a stream graph.

Parameters:
hStreamGraph - handle to stream graph
node - stream name
inputs - The names of the input streams are added to this list, in graph edge order.

tupleStreamGraphOpen

static void tupleStreamGraphOpen(long hStreamGraph,
                                 long hTxn,
                                 FennelJavaStreamMap javaStreamMap,
                                 FennelJavaErrorTarget javaErrorTarget)
                          throws SQLException
Opens a stream graph.

Parameters:
hStreamGraph - handle to stream graph
hTxn - handle to txn in which stream is being opened
javaStreamMap - optional FennelJavaStreamMap
javaErrorTarget - error target handles row errors
Throws:
SQLException

tupleStreamFetch

static int tupleStreamFetch(long hStream,
                            byte[] byteArray)
                     throws SQLException
Fetches a buffer of rows from a stream. If unpositioned, this fetches the first rows.

Parameters:
hStream - handle to stream
byteArray - output buffer receives complete tuples
Returns:
number of bytes fetched (at least one tuple should always be fetched, so 0 indicates end of stream)
Throws:
SQLException

tupleStreamTransformFetch

static int tupleStreamTransformFetch(long hStream,
                                     int execStreamInputOrdinal,
                                     byte[] byteArray)
                              throws SQLException
Fetches a buffer of rows from a stream. Specifically, the stream must be a JavaTransformExecStream. If unpositioned, this fetches the first rows. Does not block if no data is available.

Parameters:
hStream - handle to stream
execStreamInputOrdinal - ordinal of the input to fetch from
byteArray - output buffer receives complete tuples
Returns:
number of bytes fetched (0 indicates end of stream, less than 0 indicates no data currently availble)
Throws:
SQLException

tupleStreamRestart

static void tupleStreamRestart(long hStream)
                        throws SQLException
Restarts a stream.

Parameters:
hStream - handle to stream to restart
Throws:
SQLException

tupleStreamGraphClose

static void tupleStreamGraphClose(long hStreamGraph,
                                  int action)
                           throws SQLException
Closes a stream graph.

Parameters:
hStreamGraph - handle to stream graph
action - CLOSE_XXX
Throws:
SQLException

newExecutionHandle

static long newExecutionHandle()
Allocates a new object in Fennel that Farrago will use to communicate execution state information from Farrago to Fennel. Access to that object will be through a handle.

Returns:
the handle that will be used to access the Fennel object

deleteExecutionHandle

static void deleteExecutionHandle(long execHandle)
Deletes the Fennel object corresponding to an execution handle.

Parameters:
execHandle - the execution handle

cancelExecution

public static void cancelExecution(long execHandle)
Cancels execution of a statement associated with an execution handle.

Parameters:
execHandle - the execution handle