kudu::client::KuduSchemaBuilder Class Reference

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

#include <schema.h>

List of all members.

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:

SQL:

   CREATE TABLE t (
     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.

Parameters:
[in] name Name of the column to add.
Returns:
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.

Parameters:
[out] schema The 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.
Returns:
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.

Parameters:
[in] key_col_names Names of the columns to include into the compound primary key.
Returns:
Pointer to the modified object.

The documentation for this class was generated from the following file:
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines