Kudu C++ client API
Loading...
Searching...
No Matches
Public Member Functions | 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)
 
KuduColumnSpecComment (const std::string &comment)
 
Operations only relevant for decimal columns.
KuduColumnSpecPrecision (int8_t precision)
 
KuduColumnSpecScale (int8_t scale)
 
Operation only relevant for VARCHAR columns.
KuduColumnSpecLength (uint16_t length)
 
Operations only relevant for Create Table
KuduColumnSpecPrimaryKey ()
 
KuduColumnSpecNonUniquePrimaryKey ()
 
KuduColumnSpecNotNull ()
 
KuduColumnSpecNullable ()
 
KuduColumnSpecImmutable ()
 
KuduColumnSpecMutable ()
 
KuduColumnSpecType (KuduColumnSchema::DataType type)
 
Operations only relevant for Alter Table
KuduColumnSpecRemoveDefault ()
 
KuduColumnSpecRenameTo (const std::string &new_name)
 

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

◆ BlockSize()

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.

◆ Comment()

KuduColumnSpec * kudu::client::KuduColumnSpec::Comment ( const std::string &  comment)

Set the comment of the column.

Parameters
[in]commentThe comment for the column.
Returns
Pointer to the modified object.

◆ Compression()

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.

◆ Default()

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.

◆ Encoding()

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.

◆ Immutable()

KuduColumnSpec * kudu::client::KuduColumnSpec::Immutable ( )

Set the column to be immutable.

Returns
Pointer to the modified object.

◆ Length()

KuduColumnSpec * kudu::client::KuduColumnSpec::Length ( uint16_t  length)

Set the length for a column.

Clients can specify a length for VARCHAR columns. Length represents the maximum length of a VARCHAR column in characters.

The length must be greater than 0 and less than 65536. If no length is provided a default length of 65535 is used.

Parameters
[in]lengthDesired length to set.
Returns
Pointer to the modified object.

◆ Mutable()

KuduColumnSpec * kudu::client::KuduColumnSpec::Mutable ( )

Set the column to be mutable (the default).

Returns
Pointer to the modified object.

◆ NonUniquePrimaryKey()

KuduColumnSpec * kudu::client::KuduColumnSpec::NonUniquePrimaryKey ( )

Set the column to be a non-unique primary key of the table.

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

Note
Non-unique primary keys may not be changed after a table is created.
By specifying non-unique primary key, an auto incrementing column is created automatically. They form together the effective primary key. The auto incrementing field is populated on the server side, it must not be specified during insertion. All subsequent operations like scans will contain the auto incrementing column by default. If one wants to omit the auto incrementing column, it can be accomplished through existing projection methods.
A call to PrimaryKey() or NonUniquePrimaryKey() overrides any previous call to these two methods.
Returns
Pointer to the modified object.

◆ NotNull()

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.

◆ Nullable()

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.

◆ Precision()

KuduColumnSpec * kudu::client::KuduColumnSpec::Precision ( int8_t  precision)

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.

Parameters
[in]precisionDesired precision to set.
Returns
Pointer to the modified object.

◆ PrimaryKey()

KuduColumnSpec * kudu::client::KuduColumnSpec::PrimaryKey ( )

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.
A call to PrimaryKey() or NonUniquePrimaryKey() overrides any previous call to these two methods.
Returns
Pointer to the modified object.

◆ RemoveDefault()

KuduColumnSpec * kudu::client::KuduColumnSpec::RemoveDefault ( )

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.

◆ RenameTo()

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.

◆ Scale()

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.

Parameters
[in]scaleDesired scale to set.
Returns
Pointer to the modified object.

◆ Type()

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: