Module Management
This page introduces the module framework in KDB-X and explains what modules are and why they matter.
Module framework
The module framework is the foundation for extensibility in KDB-X. It gives you a consistent way to build, import, and manage modules in both KDB-X and the q language.
Its purpose is to make the platform easier to extend and adapt, whether you're scaling to bigger data, pulling in new types of datasets, or experimenting with new workflows.
What it does
The module framework enables you to:
-
Build and import modules easily. You can write your own functionality in q, package it up as a module, and load it into KDB-X.
-
Tap into a shared ecosystem. Many modules are open source, and KX is creating a central place for developers to share and reuse them.
What are modules
Modules are a unit of encapsulation in KDB-X. They have access to their own local namespace that can contain internal and external functions and variables for the module, as opposed to designating a fixed global namespace as it is often done for pre-module libraries.
The module can expose variables and functions using the export variable, which can then be imported by code with the use function and assigned to an arbitrary name. Modules can be written in q or using the C API.
Module properties
A module shows the following properties:
-
It is isolated
-
In-memory: A module should only write to its own private namespace.
-
On-disk: Everything required to load the module fits into one file or directory.
-
-
It is portable
-
In-memory: Its source code should be free of absolute path literals like
.a.b:.c.d. Module-relative namespace paths are used within a module. However, if necessary, computed absolute paths provided by other modules can be used. -
On-disk: The module's fully qualified name is derived from its file/directory path. Renaming or moving the module should not change this behavior unless the module depends on a parent.
-
Next steps
Check out the Quickstart guide for more details on how to get started with the module framework: