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

Builder API for specifying or altering a column within a table schema. More...

#include <schema.h>

Public Member Functions

KuduColumnSpecDefault (KuduValue *value)
 
KuduColumnSpecCompression (KuduColumnStorageAttributes::CompressionType compression)
 
KuduColumnSpecEncoding (KuduColumnStorageAttributes::EncodingType encoding)
 
KuduColumnSpecBlockSize (int32_t block_size)
 
Operations only relevant for decimal columns.

Set the precision for the column.

Clients must specify a precision for decimal columns. Precision is the total number of digits that can be represented by the column, regardless of the location of the decimal point. For example, representing integer values up to 9999, and fractional values up to 99.99, both require a precision of 4. You can also represent corresponding negative values, without any change in the precision. For example, the range -9999 to 9999 still only requires a precision of 4.

The precision must be between 1 and 38.

Returns
Pointer to the modified object.
KuduColumnSpecPrecision (int8_t precision)
 
KuduColumnSpecScale (int8_t scale)
 
Operations only relevant for Create Table

Set the column to be the primary key of the table.

This may only be used to set non-composite primary keys. If a composite key is desired, use KuduSchemaBuilder::SetPrimaryKey(). This may not be used in conjunction with KuduSchemaBuilder::SetPrimaryKey().

Note
Primary keys may not be changed after a table is created.
Returns
Pointer to the modified object.
KuduColumnSpecPrimaryKey ()
 
KuduColumnSpecNotNull ()
 
KuduColumnSpecNullable ()
 
KuduColumnSpecType (KuduColumnSchema::DataType type)
 
Operations only relevant for Alter Table

Remove the default value for the column.

Without a default, clients must always specify a value for the column when inserting data.

Returns
Pointer to the modified object.
KuduColumnSpecRemoveDefault ()
 
KuduColumnSpecRenameTo (const std::string &new_name)
 

Friends

class KuduSchemaBuilder
 
class KuduTableAlterer
 

Detailed Description

Builder API for specifying or altering a column within a table schema.

An object of this type cannot be constructed directly, but rather is returned from KuduSchemaBuilder::AddColumn() to specify a column within a Schema.

Todo:
KUDU-861: this API will also be used for an improved AlterTable API.

Member Function Documentation

KuduColumnSpec* kudu::client::KuduColumnSpec::BlockSize ( int32_t  block_size)

Set the target block size for the column.

This is the number of bytes of user data packed per block on disk, and represents the unit of IO when reading the column. Larger values may improve scan performance, particularly on spinning media. Smaller values may improve random access performance, particularly for workloads that have high cache hit rates or operate on fast storage such as SSD.

Note
The block size specified here corresponds to uncompressed data. The actual size of the unit read from disk may be smaller if compression is enabled.
It's recommended that this not be set any lower than 4096 (4KB) or higher than 1048576 (1MB).
Todo:
KUDU-1107: move above info to docs
Parameters
[in]block_sizeBlock size (in bytes) to use.
Returns
Pointer to the modified object.
KuduColumnSpec* kudu::client::KuduColumnSpec::Compression ( KuduColumnStorageAttributes::CompressionType  compression)

Set the preferred compression type for the column.

Parameters
[in]compressionThe compression type to use.
Returns
Pointer to the modified object.
KuduColumnSpec* kudu::client::KuduColumnSpec::Default ( KuduValue value)

Set the default value for the column.

When adding a new column to a table, this default value will be used to fill the new column in all existing rows. The default value will also be used when inserting a new row with no value for the column.

Parameters
[in]valueThe value to use as the default. The KuduColumnSpec takes ownership over the passed parameter.
Returns
Pointer to the modified object.
KuduColumnSpec* kudu::client::KuduColumnSpec::Encoding ( KuduColumnStorageAttributes::EncodingType  encoding)

Set the preferred encoding for the column.

Note
Not all encodings are supported for all column types.
Parameters
[in]encodingThe encoding to use.
Returns
Pointer to the modified object.
KuduColumnSpec* kudu::client::KuduColumnSpec::NotNull ( )

Set the column to be not nullable.

Note
Column nullability may not be changed once a table is created.
Returns
Pointer to the modified object.
KuduColumnSpec* kudu::client::KuduColumnSpec::Nullable ( )

Set the column to be nullable (the default).

Note
Column nullability may not be changed once a table is created.
Returns
Pointer to the modified object.
KuduColumnSpec* kudu::client::KuduColumnSpec::RenameTo ( const std::string &  new_name)

Rename the column.

Parameters
[in]new_nameThe new name for the column.
Returns
Pointer to the modified object.
KuduColumnSpec* kudu::client::KuduColumnSpec::Scale ( int8_t  scale)

Set the scale for the column.

Clients can specify a scale for decimal columns. Scale represents the number of fractional digits. This value must be less than or equal to precision. A scale of 0 produces integral values, with no fractional part. If precision and scale are equal, all the digits come after the decimal point, making all the values between 0.9999 and -0.9999.

The scale must be greater than 0 and less than the column's precision. If no scale is provided a default scale of 0 is used.

Returns
Pointer to the modified object.
KuduColumnSpec* kudu::client::KuduColumnSpec::Type ( KuduColumnSchema::DataType  type)

Set the data type of the column.

Note
Column data types may not be changed once a table is created.
Parameters
[in]typeThe data type to set.
Returns
Pointer to the modified object.

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