Kudu C++ client API
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | List of all members
kudu::client::KuduSchemaBuilder Class Reference

Builder API for constructing a KuduSchema object. More...

#include <schema.h>

Public Member Functions

KuduColumnSpecAddColumn (const std::string &name)
KuduSchemaBuilderSetPrimaryKey (const std::vector< std::string > &key_col_names)
Status Build (KuduSchema *schema)

Detailed Description

Builder API for constructing a KuduSchema object.

The API here is a "fluent" style of programming, such that the resulting code looks somewhat like a SQL "CREATE TABLE" statement. For example:


* my_key int not null primary key,
* a float default 1.5
* );

is represented as:

* KuduSchemaBuilder t;
* t.AddColumn("my_key")->Type(KuduColumnSchema::INT32)->NotNull()->PrimaryKey();
* t.AddColumn("a")->Type(KuduColumnSchema::FLOAT)->Default(KuduValue::FromFloat(1.5));
* KuduSchema schema;
* t.Build(&schema);

Member Function Documentation

KuduColumnSpec* kudu::client::KuduSchemaBuilder::AddColumn ( const std::string &  name)

Add a column with the specified name to the schema.

[in]nameName of the column to add.
A KuduColumnSpec object for a new column within the Schema. The returned object is owned by the KuduSchemaBuilder.
Status kudu::client::KuduSchemaBuilder::Build ( KuduSchema schema)

Build the schema based on current configuration of the builder object.

[out]schemaThe placeholder for the result schema. Upon successful completion, the parameter is reset to the result of this builder: literally, calling KuduSchema::Reset() on the parameter.
Operation result status. If the resulting would-be-schema is invalid for any reason (e.g. missing types, duplicate column names, etc.) a bad Status is returned.
KuduSchemaBuilder* kudu::client::KuduSchemaBuilder::SetPrimaryKey ( const std::vector< std::string > &  key_col_names)

Set the primary key of the new Schema based on the given column names.

This may be used to specify a compound primary key.

[in]key_col_namesNames of the columns to include into the compound primary key.
Pointer to the modified object.

The documentation for this class was generated from the following file: