Logging from C++

As with Java, Deephaven supports native logging of data from C++ applications.

The Deephaven C++ logging libraries require C++11 because they require support for variadic template arguments. Deephaven uses gcc 4.8 and newer, but any compiler supporting C++11 should work.

There are two components to a new C++ logger:

  1. A constructor, which defines the column names and types.
  2. A function to log a row of data, with arguments that match the column types. This function simply wraps illumon::binarystore::BinaryStoreWriter::writeRow. (Calling writeRow directly with incorrect arguments will compile, but will fail at runtime. Calling the wrapper function with incorrect arguments will fail during compilation.)

Source Code

The source code for the Deephaven C++ loggers is available in a ZIP archive.

In addition to the source code for the C++ logging framework, the ZIP archive contains the complete TradeWriter example referenced in the Example section below. The archive's "examples" directory includes the full implementation of TradeWriter, along with a usage example and sample data.

The example files are:

  • TradeWriter.hpp — the logger class's header.
  • TradeWriter.cpp — the logger class's implementation.
  • TradeWriterExample.cpp — an example application that reads CSV data and writes it using the TradeWriter class.
  • trades.csv — example market trade data, to be read by TradeWriterExample and written in Deephaven's binary format.
  • trades-in.bin — the example data, stored in Deephaven's binary format.

Null Values

Deephaven uses reserved constants to represent null values for each primitive type. These are defined by BinaryStoreWriter.hpp under illumon::binarystore.

Example

An abridged version of an example C++ logger, TradeWriter, is provided below. The TradeWriter demonstrates how to use Deephaven's BinaryStoreWriter to log stock market data. This example logs data for a table's Timestamp, Exchange, USym, Sym, Price, and Size columns.

Note that the table's partitioning column, Date, is excluded from the logger, since a table's partition value is determined by the Data Import Server.

TradeWriter.hpp

TradeWriter.cpp