-
Write your script in the language of your choice.
To write the function, write a script or program that reads rows from its input stream (stdin) and writes rows to its output stream (stdout).
In the output, your program must delimit each row with a newline (\n) character and delimit each column with the character expected by your queries (read the description of the DELIMITER clause for an explanation). By default, the column delimiter is a tab (\t) character.
- Ensure that the script exits with exit(0) after a successful execution.
-
Run ACT and connect to your Aster instance:
$ act -U beehive -h IP_address_of_queen
-
Install your script as a file in the Aster instance.
To do this, use the \install command at the ACT SQL prompt. (See Manage Functions and Files in an Aster Instance for more details.)
For example, to install the mapper.py Python script, enter this command:
beehive=> \install mapper.py;
The script, mapper.py, is a sample shown in Running a Python Script. - [Optional] Use the \install command to install any other file needed by your script.
-
To invoke a Stream function, enter the SQL-MapReduce query that calls the STREAM API.
For example:
beehive=> SELECT * FROM STREAM beehive->(ON (SELECT content FROM input_table) beehive->SCRIPT ('python mapper.py') beehive->OUTPUTS ('word varchar', 'count int'));