A helper class to create a new table with the desired options. More...
#include <client.h>
Public Types | |
enum | RangePartitionBound { EXCLUSIVE_BOUND, INCLUSIVE_BOUND } |
Range partition bound type. More... | |
Public Member Functions | |
KuduTableCreator & | table_name (const std::string &name) |
KuduTableCreator & | schema (const KuduSchema *schema) |
KuduTableCreator & | add_hash_partitions (const std::vector< std::string > &columns, int32_t num_buckets) |
KuduTableCreator & | add_hash_partitions (const std::vector< std::string > &columns, int32_t num_buckets, int32_t seed) |
KuduTableCreator & | set_range_partition_columns (const std::vector< std::string > &columns) |
KuduTableCreator & | add_range_partition (KuduPartialRow *lower_bound, KuduPartialRow *upper_bound, RangePartitionBound lower_bound_type=INCLUSIVE_BOUND, RangePartitionBound upper_bound_type=EXCLUSIVE_BOUND) |
KuduTableCreator & | add_range_partition_split (KuduPartialRow *split_row) |
KuduTableCreator & | split_rows (const std::vector< const KuduPartialRow * > &split_rows) |
KuduTableCreator & | num_replicas (int n_replicas) |
KuduTableCreator & | timeout (const MonoDelta &timeout) |
KuduTableCreator & | wait (bool wait) |
Status | Create () |
Friends | |
class | KuduClient |
A helper class to create a new table with the desired options.
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.
[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. |
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).
[in] | columns | Names of columns to use for partitioning. |
[in] | num_buckets | Number of buckets for the hashing. |
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.
[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. |
KuduTableCreator& kudu::client::KuduTableCreator::add_range_partition_split | ( | KuduPartialRow * | split_row | ) |
Add a range partition split at the provided row.
[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. |
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.
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.
[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. |
KuduTableCreator& kudu::client::KuduTableCreator::schema | ( | const KuduSchema * | schema | ) |
Set the schema with which to create the table.
[in] | schema | Schema to use. Must remain valid for the lifetime of the builder. Must be non-NULL. |
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.
[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. |
KuduTableCreator& kudu::client::KuduTableCreator::split_rows | ( | const std::vector< const KuduPartialRow * > & | split_rows | ) |
add_range_partition_split()
instead.[in] | split_rows | The row to use for partitioning. |
KuduTableCreator& kudu::client::KuduTableCreator::table_name | ( | const std::string & | name | ) |
Set name for the table.
[in] | name | Name of the target table. |
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).
[in] | timeout | Timeout to set. |
KuduTableCreator& kudu::client::KuduTableCreator::wait | ( | bool | wait | ) |
Wait for the table to be fully created before returning.
If not called, defaults to true
.
[in] | wait | Whether to wait for completion of operations. |