PHISH WWW Site - PHISH Documentation - Commands

phish_input() function

phish_output() function

C syntax:

void phish_input(int iport, void (*datumfunc)(int), void (*donefunc)(), reqflag)
void phish_output(int iport) 

C examples:

#include "phish.h"

C++ syntax:

void input(int port, void (*datumfunc)(int), void (*donefunc)(), bool required=true)
void output(int port) 

C++ examples:

#include "phish.h.pp"

Python syntax:

def input(iport,datumfunc,donefunc,reqflag)
def output(iport) 

Python examples:

import phish


These are PHISH library functions which can be called from a minnow application. In PHISH lingo, a "minnow" is a stand-alone application which makes calls to the PHISH library.

The phish_input() and phish_output() functions define input and output ports for the minnow. An input port is where datums are sent by other minnows, so they can be read by this minnow. An output port is where the minnow sends datums to route them to the input ports of other minnows. These inter-minnow connections are setup by the hook command in a PHISH input script, as discussed on the doc page.

A minnnow can define and use multiple input and output ports, to send and receive datums of different kinds to different sets of minnows. Both input and output ports are numbered from 0 to Pmax-1, where Pmax = the maximum allowed ports, which is a hard-coded value for MAXPORT in src/phish.cpp. It is currently set to 16; most minnows use 1 or 2. Note that a single port can be used to send or receive datums to many other minnows (processors), depending on the connection style. See the hook command for details.

The minnow should make one call to phish_input() for each input port it uses, whether or not a particular PHISH input script actually connects to the port. Specify reqflag = 1 if a PHISH input script must specify a connection to the input port in order to use the minnow; specify reqflag = 0 if it is optional. The phish_check function will check for compatibility between the PHISH input script and the minnow ports.

Two callback function pointers are passed as arguments to phish_input(). Either or both can be specied as NULL, or None in the Python version, if the minnow does not require a callback. Note that multiple input ports can use the same callback functions.

The first callback is datumfunc, and is called by the PHISH library each time a datum is received on that input port.

The datumfunc function should have the following form:

void datumfunc(int nfields) { } 


def datumfunc(nfields) 

in Python,

where "datumfunc" is replaced by a function name of your choice. The function is passed "nfields" = the # of fields in the received datum. See the phish_unpack and phish_datum doc pages for info on how the received datum can be further processed.

The second callback is donefunc, and is a called by the PHISH library when the input port is closed.

The donefunc function should have the following form:

void donefunc() { } 


def donefunc() 

in Python,

where "donefunc" is replaced by a function name of your choice. A minnow might use the function to print out some statistics about data received thru that input port, or its closure might trigger further data to be sent downstream to other minnows. See the phish_close function and shutdown section of the Minnows doc page, for more discussion of how a school of minnows closes ports and shuts down.

The minnow should make one call to phish_output() for each output port it uses, whether or not a particular PHISH input script actually connects to the port. Usage of an output port by an input script is always optional. This makes it easy to develop and debug a sequence of pipelined operations, one minnow at a time, without requiring a minnow's output to be used by an input script.


These functions cannot be called after phish_check has been called.

Related commands:

phish_check, phish_close