Compiling UDX Source Files

After creating and registering one or more new extensions, you need to compile your source files and registration metadata into a single shared object file, or in a JVM environment, build the extension classes into a JAR file you can load into AnzoGraph DB. This topic provides details of tools that are available and how you can compile extensions to create the files needed to run the new extensions.

Documentation on UDX development in JVM environments is in progress and not available at this time.

Compiling UDX files in C++

AnzoGraph DB provides a azg_extfn_compile utility that you can use to compile a single CPP file into a shared object. To compile multiple CPP files into a single shared object, you can use the CMake utility. See the following procedures for information about configuring CMake to compile extensions included in one or more separate CPP files.

UDX CMake Configuration

In the parent CMakeLists.txt configuration file, specify the following compiler and compilation flags to use for compiling user-defined extensions:

cmake_minimum_required(VERSION 3.13.2)
if (NOT DEFINED ENV{AZG})
message("missing environment variable AZG:")
message("defaulting to AZG=root_anzograph_install_dir")
set(AZG root_anzograph_install_dir)
else()
set(AZG $ENV{AZG})
endif()

set(CMAKE_CXX_COMPILER ${AZG}/tools/bin/x86_64-pc-linux-gnu-g++-7.2.0)
add_compile_options(-O3 -Wall -m64 -std=c++17)

For example, the following CMakeLists.txt configures CMake in a Docker environment:

cmake_minimum_required(VERSION 3.13.2)
if (NOT DEFINED ENV{AZG})
message("missing environment variable AZG:")
message("defaulting to AZG=install_dir")
set(AZG install_dir)
else()
set(AZG $ENV{AZG})
endif()

set(CMAKE_CXX_COMPILER ${AZG}/tools/bin/x86_64-pc-linux-gnu-g++-7.2.0)
add_compile_options(-O3 -Wall -m64 -std=c++17)

Compiling a UDX to Create a Shared Object File

Run the following command to use the AnzoGraph DB extension compilation utility (azg_extfn_compile) to compile a single CPP file and generate the shared object (.so) file. The utility invokes the g++ compiler to compile the C++ file.

<install_path>/bin/azg_extfn_compile /path/file_name

After compiling a C++ UDX file, you need to copy the the shared object file along with any other files or libraries on which the UDX is dependent, to a common extension directory on your AnzoGraph DB Server (or leader node in a cluster). When executing the UDX specified in a query, AnzoGraph DB copies the UDX, along with any dependent files or libraries, to all the compute nodes or slices in your system for execution on their respective portions of loaded data.

For example, the following command compiles a divReg.cpp file and generates divReg.so.

./opt/anzograph/bin/azg_extfn_compile /home/user/cpp/divReg.cpp

After generating the shared object files for new extensions, see Loading a UDX to the Database for instructions on loading shared object files into AnzoGraph DB, to register new extensions and make them available from within AnzoGraph DB.

After starting up AnzoGraph DB, you can examine the boot log file to see what extensions have been scanned and registered.