Class GPUdbRecord

class gpudb.GPUdbRecord(record_type, column_values)[source]

Bases: object

Represent the data for a given record in GPUdb. Has convenience functions for encoding/decoding the data.

Create a GPUdbRecord object which holds the data for a given record.

Parameters

record_type (GPUdbRecordType) –
A GPUdbRecordType object that describes the columns of this record.
column_values (dict or list) –
Either a dict or a list that contains the values for the columns. In either case, must contain values for ALL columns. If a list, then the columns must be in the correct order.
static decode_binary_data(record_type_schema_string, binary_data)[source]

Decode binary encoded data (generally returned by GPUdb) using the schema for the data. Return the decoded data.

Parameters

record_type_schema_string (str) –
The schema string for the record type.
binary_data (obj or list) –
The binary encoded data. Could be a single object or a list of data.

Returns

The decoded data (a single object or a list)
static decode_json_string_data(json_string_data)[source]

Decode binary encoded data in string form (generally returned by GPUdb). Return the decoded data.

Parameters

json_string_data (str) –
The stringified json encoded data. Could be a single object or a list of data.

Returns

The decoded data (a single object or a list)
static convert_data_col_major_to_row_major(col_major_data, col_major_schema_str)[source]

Given some column major data, convert it to row major data.

Parameters

col_major_data (OrderedDict) –
An OrderedDict of arrays containing the data by column names.
col_major_schema_str (str) –
A JSON schema string describing the column major data.

Returns

A list of GPUdbRecord objects.
record_type

The type for this record.

column_values

The values for this record.

data

The values for this record.

binary_data

The binary encoded values for this record.

json_data_string

The stringified JSON encoded values for this record.

keys()[source]

Return a list of the column names of the record.

values()[source]

Return a list of the values of the record.

insert_record(gpudb, table_name, encoding='binary', options=None)[source]

Insert this record into GPUdb.

Parameters

gpudb (GPUdb) –
A GPUdb client handle.
table_name (str) –
The name of the table into which we need to insert the record.
encoding (str) –
Optional encoding with which to perform the insertion. Default is binary encoding.
options (dict) –
Optional parameter. If given, use the options for the insertion function.

Returns

The response from GPUdb.