Working with AE shared libraries
The AE shared library functionality allows shared libraries to be stored in the database so they are available at runtime to UDXs and AEs on the NPS. Originally specific to Linux Shared Libraries (.sofiles), this functionality has been extended so that any type of file can be stored in the database, including executables, Java class files, and text files. In practice, the shared library file is made available to an AE at runtime through an environment variable or the AE API that provides the location of the file on the file system. The file is read-only and should not be modified or deleted.
Although the AE shared library functionality allows file resources required by an AE to be packaged into the NPS system database, the alternative is to place these file resources in the AE export directory tree on a network shared drive. Selection is based on the characteristics of the application. For example, the AE shared library functionality may provide better organizational efficiency. For some applications, it may be used to avoid network contention on the AE export directory tree. However, the AE shared library functionality might become cumbersome if too many files are involved, making the AE export directory tree a better choice.
CREATE OR REPLACE LIBRARY HELLOAE
MANUAL LOAD
EXTERNAL HOST OBJECT '/nz/export/ae/applications/dev/david/host/helloae'
EXTERNAL SPU OBJECT '/nz/export/ae/applications/dev/david/spu/helloae';- MANUAL LOAD tells the Netezza system not to automatically load this AE shared library. Only true Linux .so shared library files should be automatically loaded.
- Both the host and SPU copies of the helloae executable are stored in the database. The database does not maintain a pointer back to the file versions on disk.
- HELLOAE is the external name of this AE shared library.
- For advanced NPS system users, an AE shared library that is not a true .so file should not be a dependency for another library.
--deps inza..LIBNZAEADAPTER,inza..LIBNZAECHILD,HELLOAE
NZAE_EXECUTABLE_PATH=%[HELLOAE]Some notes about this registration:
- The --deps option tells register_ae or nzudxcompile which shared libraries are required by this AE application. HELLOAE has been added to the default list.
- %[HELLOAE] is an example of AE shared library path substitution. At runtime the AE runtime system converts this to a file path pointing to a copy of the shared library. Note the syntax is the percent sign (%) followed by square brackets ([ ]) that enclose the external AE shared library name.
- The AE shared library takes care of placing the host and SPU executables on the appropriate machines. Only one NZAE_EXECUTABLE_PATH without a location prefix is required.
- This AE application, as shown, does not access the AE export directory tree.
The AE shared library functionality can be used for any file type. AE shared library path substitution can be used in any environment value. To view only the XML file associated with the helloae application: /home/david/myxml.xml
CREATE OR REPLACE LIBRARY DAVIDXML
MANUAL LOAD
EXTERNAL HOST OBJECT '/home/david/myxml.xml'
EXTERNAL SPU OBJECT '/home/david/myxml.xml';NZAE_EXECUTABLE_PATH=%[HELLOAE]
NZAE_NUMBER_PARAMETERS=1
NZAE_PARAMETER1=%[DAVIDXML]NZAE_EXECUTABLE_PATH=%[HELLOAE]
MY_XML=%[DAVIDXML]The following, alternative approach, uses an AE environment API call to retrieve the value of MY_XML, which is a full path to a temporary copy of the file (which is read only).