kudu::client::KuduTableCreator Class Reference

A helper class to create a new table with the desired options. More...

#include <client.h>

List of all members.

Public Types

enum  RangePartitionBound { EXCLUSIVE_BOUND, INCLUSIVE_BOUND }
 

Range partition bound type.

More...

Public Member Functions

KuduTableCreatortable_name (const std::string &name)
KuduTableCreatorschema (const KuduSchema *schema)
KuduTableCreatoradd_hash_partitions (const std::vector< std::string > &columns, int32_t num_buckets)
KuduTableCreatoradd_hash_partitions (const std::vector< std::string > &columns, int32_t num_buckets, int32_t seed)
KuduTableCreatorset_range_partition_columns (const std::vector< std::string > &columns)
KuduTableCreatoradd_range_partition (KuduPartialRow *lower_bound, KuduPartialRow *upper_bound, RangePartitionBound lower_bound_type=INCLUSIVE_BOUND, RangePartitionBound upper_bound_type=EXCLUSIVE_BOUND)
KuduTableCreatoradd_range_partition_split (KuduPartialRow *split_row)
KuduTableCreatorsplit_rows (const std::vector< const KuduPartialRow * > &split_rows)
KuduTableCreatornum_replicas (int n_replicas)
KuduTableCreatortimeout (const MonoDelta &timeout)
KuduTableCreatorwait (bool wait)
Status Create ()

Friends

class KuduClient

Detailed Description

A helper class to create a new table with the desired options.


Member Enumeration Documentation

Range partition bound type.

Enumerator:
EXCLUSIVE_BOUND 

An exclusive bound.

INCLUSIVE_BOUND 

An inclusive bound.


Member Function Documentation

KuduTableCreator& kudu::client::KuduTableCreator::add_hash_partitions ( const std::vector< std::string > &  columns,
int32_t  num_buckets,
int32_t  seed 
)

Add a set of hash partitions to the table (with seed).

This method is exactly the same as add_hash_partitions() above, with the exception of additional seed value, which can be used to randomize the mapping of rows to hash buckets. Setting the seed may provide some amount of protection against denial of service attacks when the hashed columns contain user provided values.

Parameters:
[in] columns Names of columns to use for partitioning.
[in] num_buckets Number of buckets for the hashing.
[in] seed Hash: seed for mapping rows to hash buckets.
Returns:
Reference to the modified table creator.
KuduTableCreator& kudu::client::KuduTableCreator::add_hash_partitions ( const std::vector< std::string > &  columns,
int32_t  num_buckets 
)

Add a set of hash partitions to the table.

Tables must be created with either range, hash, or range and hash partitioning.

For each set of hash partitions added to the table, the total number of tablets is multiplied by the number of buckets. For example, if a table is created with 3 split rows, and 2 hash partitions with 4 and 5 buckets respectively, the total number of tablets will be 80 (4 range partitions * 4 hash buckets * 5 hash buckets).

Parameters:
[in] columns Names of columns to use for partitioning.
[in] num_buckets Number of buckets for the hashing.
Returns:
Reference to the modified table creator.
KuduTableCreator& kudu::client::KuduTableCreator::add_range_partition ( KuduPartialRow lower_bound,
KuduPartialRow upper_bound,
RangePartitionBound  lower_bound_type = INCLUSIVE_BOUND,
RangePartitionBound  upper_bound_type = EXCLUSIVE_BOUND 
)

Add a range partition to the table.

Multiple range partitions may be added, but they must not overlap. All range splits specified by add_range_partition_split must fall in a range partition. The lower bound must be less than or equal to the upper bound.

If this method is not called, the table's range will be unbounded.

Parameters:
[in] lower_bound Row to use as a lower bound. The KuduTableCreator instance takes ownership of this parameter. If row is empty, no lower bound is imposed on the table range. If a column of the lower_bound row is missing a value, the logical minimum value for that column type is used as the default.
[in] upper_bound Row to use as an upper bound. The KuduTableCreator instance takes ownership of this parameter. If row is empty, no upper bound is imposed on the table range. If a column of the upper_bound row is missing a value, the logical maximum value for that column type is used as the default.
[in] lower_bound_type The type of the lower bound, either inclusive or exclusive. Defaults to inclusive.
[in] upper_bound_type The type of the lower bound, either inclusive or exclusive. Defaults to exclusive.
Returns:
Reference to the modified table creator.
KuduTableCreator& kudu::client::KuduTableCreator::add_range_partition_split ( KuduPartialRow split_row  ) 

Add a range partition split at the provided row.

Parameters:
[in] split_row The row to use for partitioning. If the row is missing a value for any of the range partition columns, the logical minimum value for that column type will be used by default. The KuduTableCreator object takes ownership of the parameter.
Returns:
Reference to the modified table creator.
Status kudu::client::KuduTableCreator::Create (  ) 

Create a table in accordance with parameters currently set for the KuduTableCreator instance. Once created, the table handle can be obtained using KuduClient::OpenTable() method.

Precondition:
The following methods of the KuduTableCreator must be called prior to invoking this method:
Returns:
Result status of the CREATE TABLE operation. The return value may indicate an error in the create table operation, or a misuse of the builder. In the latter case, only the last error is returned.
KuduTableCreator& kudu::client::KuduTableCreator::num_replicas ( int  n_replicas  ) 

Set the table replication factor.

Replicated tables can continue to read and write data while a majority of replicas are not failed.

Parameters:
[in] n_replicas Number of replicas to set. This should be an odd number. If not provided (or if <= 0), falls back to the server-side default.
Returns:
Reference to the modified table creator.
KuduTableCreator& kudu::client::KuduTableCreator::schema ( const KuduSchema schema  ) 

Set the schema with which to create the table.

Parameters:
[in] schema Schema to use. Must remain valid for the lifetime of the builder. Must be non-NULL.
Returns:
Reference to the modified table creator.
Remarks:
Calling this method and setting schema for the table-to-be is one of the pre-conditions for calling KuduTableCreator::Create() method.
KuduTableCreator& kudu::client::KuduTableCreator::set_range_partition_columns ( const std::vector< std::string > &  columns  ) 

Set the columns on which the table will be range-partitioned.

Tables must be created with either range, hash, or range and hash partitioning. To force the use of a single tablet (not recommended), call this method with an empty vector and set no split rows and no hash partitions.

Parameters:
[in] columns Names of columns to use for partitioning. Every column must be a part of the table's primary key. If not set, or if called with an empty vector, the table will be created without range partitioning.
Returns:
Reference to the modified table creator.
KuduTableCreator& kudu::client::KuduTableCreator::split_rows ( const std::vector< const KuduPartialRow * > &  split_rows  ) 
Deprecated:
Use add_range_partition_split() instead.
Parameters:
[in] split_rows The row to use for partitioning.
Returns:
Reference to the modified table creator.
KuduTableCreator& kudu::client::KuduTableCreator::table_name ( const std::string &  name  ) 

Set name for the table.

Parameters:
[in] name Name of the target table.
Returns:
Reference to the modified table creator.
Remarks:
Calling this method and setting the name for the table-to-be is one of the pre-conditions for calling KuduTableCreator::Create() method.
Todo:
Should name of the table be a constructor's parameter instead?
KuduTableCreator& kudu::client::KuduTableCreator::timeout ( const MonoDelta timeout  ) 

Set the timeout for the table creation operation.

This includes any waiting after the create has been submitted (i.e. if the create is slow to be performed for a large table, it may time out and then later be successful).

Parameters:
[in] timeout Timeout to set.
Returns:
Reference to the modified table creator.
KuduTableCreator& kudu::client::KuduTableCreator::wait ( bool  wait  ) 

Wait for the table to be fully created before returning.

If not called, defaults to true.

Parameters:
[in] wait Whether to wait for completion of operations.
Returns:
Reference to the modified table creator.

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