kdb+ FFI

Kdb+ FFI: Access external libraries more easily from q

22 Nov 2017 | , , ,
Share on:

By Fintan Quill

Following on from the hugely popular Python library and interface embedPy and PyQ, Kx has released an FFI as part of the Fusion for kdb+ interfaces. As with embedPy and PyQ, this FFI is open-sourced under the Apache 2 license.

The kdb+ FFI is a foreign function interface library for loading and calling dynamic libraries from q code. It has been adapted and expanded upon from a library originally written by Alex Belopolsky of Enlightenment Research. With the kdb+ FFI you can now call your favorite C/C++ libraries directly from q without the overhead of having to compile shared objects and load into q using the 2: command.

In order to use the kdb+ FFI, you need to install kdb+ version 3.4 or later as well as libffi3.1+. Instructions are available for installing libffi using your package manager of choice such as apt-get or brew. The kdb+ FFI package then needs to be downloaded and unpacked. Once unpacked, simply load the ffi.q script into your q process and you’re done!

There are two main functions of note within the interface, .ffi.cf to do a once-off call to a function and .ffi.bind binds a C call to a q function for multiple calls.

What are the advantages of using the kdb+ FFI? Users no longer have to write their own C/C++ code or use compiler toolchains to connect to many common libraries. A second advantage is when interacting with the operating system the kdb+ FFI doesn’t carry the overhead of forking an extra process similar to the system command in q.

Within the project are several examples including:

  • PCRE bindings for regular expressions
  • BLAS bindings for common linear algebra operations
  • Rmath bindings for random number generators and probability functions
  • Callback registration

You can check out the project on the Kx Systems’ Github where you can also send feedback and add to the project.

Happy coding!

Fintan Quill is Global Head of Sales Engineering for Kx and is based in New York City.

© 2017 Kx Systems
Kx® and kdb+ are registered trademarks of Kx Systems, Inc., a subsidiary of First Derivatives plc.


Kx collaborating with Fintech startup chartiq

Collaboration: The Dominant Trend in Finance

13 Dec 2017 | , , , ,

In December we are re-blogging some of our favorite content from Kx partners and affiliated companies, starting with this article on the ChartIQ blog. ChartIQ is an agile FinTech company that sells an advanced HTML5 charting library used in technical data analysis, trading configurations and for charting in the capital markets industry. Kx offers a ChartIQ integration as an addition to our Dashboards. In “Collaboration: The Dominant Trend in Finance,” ChartIQ’s Hanni Chehak writes about the rise of FinTech companies, and the role collaboration plays as FinTech companies are increasingly disrupting the traditional banking sector.

Water system workers with kdb+ historical database

Kdb+ Use Case: Machine Learning Water System Maintenance Application

6 Dec 2017 | , , , ,

Kdb+ is being used much more widely in machine learning applications today. Its ability to quickly ingest and process data, particularly large, fragmented datasets, is one way that developers are adding kdb+ to their technology stack of artificial intelligence and machine learning tools.
For Australian kdb+ developer Sherief Khorshid, who also develops machine learning systems, incorporating kdb+ into a predictive maintenance application gave him the edge in a hackathon win that landed him a cash prize and a contract with the Water Corporation of Western Australia.

kdb+ and Python

Kdb+ and Python: embedPy and PyQ

15 Nov 2017 | , , , ,

In September, Kx announced a range of initiatives to put machine learning (ML) capabilities at the heart of future technology development. The first library to be released as part of this initiative is embedPy, which exposes powerful Python functionality to q developers. EmbedPy is the mirror image of PyQ, a set of software components that simplify the running of a Python interpreter alongside a kdb+ server, the rights to which Kx has acquired. Developed by Alexander Belopolsky of Enlightenment Research, PyQ covers all Python libraries, with a primary focus on numerical libraries such as NumPy and SciPy.