This page explains all of the elements needed to develop and plug-in a new MADlib® module.

  1. Module files overview (source tree perspective)
  2. Module files explained
  3. Configuration
  4. Adding support for other DB platforms

 1. Module files overview (source tree perspective)

Say you want to write a new MADlib module called NewModule (code name: newmod).  Use the following directory tree structure as a reference for your module:

./src/
    modules/
        newmod/              # (optional) new directory for the module code
            newmod.cpp       # (optional) C/C++ code for this module
            newmod.hpp       # (optional) C/C++ header for this module
            ...
    ports/
        postgres/
            modules/
                newmod/
                    newmod.sql_in    # (REQUIRED) SQL file to create DB objects
                    newmod.py_in     # (optional) Python code (helpful for iterative algorithms)
                    test/            # (optional) directory for SQL test scripts
                        newmod.sql_in    # (optional) test scripts that will be run during install-check
                    ...

 2. Module files explained

3. Configuration:

In order to include the new module in the generic (not database dependent) installation, only the following config file must be edited: ./config/Modules.yml. New name element must be added with an optional depends item:

- name:    newmod
  depends: ['othermod1', 'othermod2']

4. Adding support for other DB platforms:

If you must adjust any of the code to a particular database platform the files which requires changes must be replicated under a dedicated ./port/<portid>/module directory, see below. The database <portid> you will be referring to must be already defined in ./config/Ports.yml config file.

./ports/
    greenplum/                   # Example port id: greenplum
        modules/
            newmod/              # (REQUIRED) new directory for the module code
                newmod.sql_in    # (optional) SQL file to create DB objects
                newmod.py_in     # (optional) Python code
                ...