Skip to main content
The following guide provides step-by-step instructions to get started writing C++ applications using Kinetica. This guide demonstrates only a small set of the available API. A detailed description of the complete interface is available under C++ API Reference.

API Download

The source code for the C++ API is available for download from the GitHub repository kineticadb/kinetica-api-cpp. Follow the instructions in the included README file to build the API library.

Connecting to the Database

To connect to the database, instantiate an object of the GPUdb class, providing the connection URL of the database server:

Loading Data

Before any data can be loaded into the system, a Type needs to be defined in the system. The type definition is a JSON string describing the fields (i.e. columns) of the type along with a name for the type. Each field consists of a name and a data type:
The returned object from the Type.create() call contains a unique type identifier allocated by the system. This identifier can then be used in the request to create a new table as follows:
Once the table is created, data can be inserted as follows:

Retrieving Data

Once the table is populated with data, the data can be retrieved from the system by a call to getRecords() as shown below:
For large tables, the data can be easily be retrieved in smaller blocks by using the offset and limit parameters. The returned response also contains the schema (or data type) of the results.

Running Queries

To filter a subset of the records, use the filter() method with an expression as follows:
To filter all the records matching a known list of values:
To retrieve a list of all the unique values for a column or a set of columns or expression:
Kinetica supports various group-by queries. To group by one or more columns and return the count of the unique values, use the aggregateGroupBy() method as shown below. The next query shows how to get the count of records, as well as the sum and average of the values of column col1, within each group:
Kinetica supports grouping numerical data into a histogram. The input range is divided into equal sized bins and the count of objects in each bin are returned:

Complete Sample

Included below is a complete sample program containing all the above queries:
Output from above sample program