A makefile is provided to build the examples.
- Ensure your development workstation conforms to the guidelines stated in Build Tools and Dependencies.
-
Find the example you wish to build. Here, we'll show how to build echo_input.c. Change the working directory to the echo_input example directory. Here, we'll assume the path is:
cd ~/dev/stage/sqlmr-sdk/example/c/echo_input
-
Build the example. Type "make" followed by the setting of the SQLMR_SDK environment variable to your SQL-MapReduce SDK directory. In our example set-up, this looks like:
# make SQLMR_SDK=~/dev/stage/sqlmr-sdk
This builds your function (echo_input.so, in this case) and places it in the build directory. It also creates the build directory if needed. At this point, you could install and use the function in an Aster instance if you like, but it is a good idea to test your code locally, first.
-
Build and run the test for the example:
make SQLMR_SDK=~/dev/stage/sqlmr-sdk test
This builds the function, builds its corresponding test program, and runs the test. You will see messages at the command line indicating the success or failure of each stage. For example, a successful test run shows lines similar to:
Loaded 'sqlmr_functionModuleInfo' symbol from build/echo_input.so: 0x2b2158d2ce30 Loaded function entries for module 'build/echo_input.so' (with matching API version 3) Function completed operating without error Task reported as completed
-
Inspect the test output. Change the working directory to the build/testoutput directory (the complete path will be like ~/dev/stage/sqlmr-sdk/example/c/echo_input/build/testoutput) and view:
- testrun.out, the output data file that contains the actual output the function produced based on the test input data.
-
contract.out, the completed runtime contract file that provides a list of the output columns of the SQL-MapReduce function, and the datatype of each.
As with most makefiles, you can type make clean to delete all built files and test output, so that you can revise your code and test again.
- If you like, you can install the .so file on the cluster and use your function there. See Install and Use a Sample Function.