Kudu C++ client API
Public Member Functions | Friends | List of all members
kudu::KuduPartialRow Class Reference

A row which may only contain values for a subset of the columns. More...

#include <partial_row.h>

Public Member Functions

 KuduPartialRow (const Schema *schema)
 
 KuduPartialRow (const KuduPartialRow &other)
 
KuduPartialRowoperator= (KuduPartialRow other)
 
Status SetNull (const Slice &col_name) WARN_UNUSED_RESULT
 
Status SetNull (int col_idx) WARN_UNUSED_RESULT
 
Status Unset (const Slice &col_name) WARN_UNUSED_RESULT
 
Status Unset (int col_idx) WARN_UNUSED_RESULT
 
bool IsColumnSet (const Slice &col_name) const
 
bool IsColumnSet (int col_idx) const
 
bool IsNull (const Slice &col_name) const
 
bool IsNull (int col_idx) const
 
Status EncodeRowKey (std::string *encoded_key) const
 
std::string ToEncodedRowKeyOrDie () const
 
bool IsKeySet () const
 
bool AllColumnsSet () const
 
std::string ToString () const
 
const Schema * schema () const
 
Setters for integral type columns by name.

Set value for a column by name.

Parameters
[in]col_nameName of the target column.
[in]valThe value to set.
Returns
Operation result status.
Status SetBool (const Slice &col_name, bool val) WARN_UNUSED_RESULT
 
Status SetInt8 (const Slice &col_name, int8_t val) WARN_UNUSED_RESULT
 
Status SetInt16 (const Slice &col_name, int16_t val) WARN_UNUSED_RESULT
 
Status SetInt32 (const Slice &col_name, int32_t val) WARN_UNUSED_RESULT
 
Status SetInt64 (const Slice &col_name, int64_t val) WARN_UNUSED_RESULT
 
Status SetTimestamp (const Slice &col_name, int64_t micros_since_utc_epoch) WARN_UNUSED_RESULT
 
Status SetFloat (const Slice &col_name, float val) WARN_UNUSED_RESULT
 
Status SetDouble (const Slice &col_name, double val) WARN_UNUSED_RESULT
 
Setters for integral type columns by index.

Set value for a column by index.

These setters are the same as corresponding column-name-based setters, but with numeric column indexes. These are faster since they avoid hashmap lookups, so should be preferred in performance-sensitive code (e.g. bulk loaders).

Parameters
[in]col_idxThe index of the target column.
[in]valThe value to set.
Returns
Operation result status.
Status SetBool (int col_idx, bool val) WARN_UNUSED_RESULT
 
Status SetInt8 (int col_idx, int8_t val) WARN_UNUSED_RESULT
 
Status SetInt16 (int col_idx, int16_t val) WARN_UNUSED_RESULT
 
Status SetInt32 (int col_idx, int32_t val) WARN_UNUSED_RESULT
 
Status SetInt64 (int col_idx, int64_t val) WARN_UNUSED_RESULT
 
Status SetTimestamp (int col_idx, int64_t micros_since_utc_epoch) WARN_UNUSED_RESULT
 
Status SetFloat (int col_idx, float val) WARN_UNUSED_RESULT
 
Status SetDouble (int col_idx, double val) WARN_UNUSED_RESULT
 
Setters for binary/string columns by name (copying).

Set the binary/string value for a column by name, copying the specified data immediately.

Parameters
[in]col_nameName of the target column.
[in]valThe value to set.
Returns
Operation result status.
Status SetBinary (const Slice &col_name, const Slice &val) WARN_UNUSED_RESULT
 
Status SetString (const Slice &col_name, const Slice &val) WARN_UNUSED_RESULT
 
Status SetBinaryCopy (const Slice &col_name, const Slice &val) WARN_UNUSED_RESULT
 
Status SetStringCopy (const Slice &col_name, const Slice &val) WARN_UNUSED_RESULT
 
Setters for binary/string columns by index (copying).

Set the binary/string value for a column by index, copying the specified data immediately.

These setters are the same as the corresponding column-name-based setters, but with numeric column indexes. These are faster since they avoid hashmap lookups, so should be preferred in performance-sensitive code (e.g. bulk loaders).

Parameters
[in]col_idxThe index of the target column.
[in]valThe value to set.
Returns
Operation result status.
Status SetBinary (int col_idx, const Slice &val) WARN_UNUSED_RESULT
 
Status SetString (int col_idx, const Slice &val) WARN_UNUSED_RESULT
 
Status SetStringCopy (int col_idx, const Slice &val) WARN_UNUSED_RESULT
 
Status SetBinaryCopy (int col_idx, const Slice &val) WARN_UNUSED_RESULT
 
Setters for binary/string columns by name (non-copying).

Set the binary/string value for a column by name, not copying the specified data.

Note
The specified data must remain valid until the corresponding RPC calls are completed to be able to access error buffers, if any errors happened (the errors can be fetched using the KuduSession::GetPendingErrors() method).
Parameters
[in]col_nameName of the target column.
[in]valThe value to set.
Returns
Operation result status.
Status SetBinaryNoCopy (const Slice &col_name, const Slice &val) WARN_UNUSED_RESULT
 
Status SetStringNoCopy (const Slice &col_name, const Slice &val) WARN_UNUSED_RESULT
 
Setters for binary/string columns by index (non-copying).

Set the binary/string value for a column by index, not copying the specified data.

These setters are the same as the corresponding column-name-based setters, but with numeric column indexes. These are faster since they avoid hashmap lookups, so should be preferred in performance-sensitive code (e.g. bulk loaders).

Note
The specified data must remain valid until the corresponding RPC calls are completed to be able to access error buffers, if any errors happened (the errors can be fetched using the KuduSession::GetPendingErrors() method).
Parameters
[in]col_idxThe index of the target column.
[in]valThe value to set.
Returns
Operation result status.
Status SetBinaryNoCopy (int col_idx, const Slice &val) WARN_UNUSED_RESULT
 
Status SetStringNoCopy (int col_idx, const Slice &val) WARN_UNUSED_RESULT
 
Getters for integral type columns by column name.

Get value of the column specified by name.

Returns
Operation result status. Return a bad Status if at least one of the following is true:
  • The type does not match.
  • The value is unset.
  • The value is NULL.
Status GetBool (const Slice &col_name, bool *val) const WARN_UNUSED_RESULT
 
Status GetInt8 (const Slice &col_name, int8_t *val) const WARN_UNUSED_RESULT
 
Status GetInt16 (const Slice &col_name, int16_t *val) const WARN_UNUSED_RESULT
 
Status GetInt32 (const Slice &col_name, int32_t *val) const WARN_UNUSED_RESULT
 
Status GetInt64 (const Slice &col_name, int64_t *val) const WARN_UNUSED_RESULT
 
Status GetTimestamp (const Slice &col_name, int64_t *micros_since_utc_epoch) const WARN_UNUSED_RESULT
 
Status GetFloat (const Slice &col_name, float *val) const WARN_UNUSED_RESULT
 
Status GetDouble (const Slice &col_name, double *val) const WARN_UNUSED_RESULT
 
Getters for column of integral type by column index.

Get value of a column of integral type by column index.

These getters are the same as the corresponding column-name-based getters, but with numeric column indexes. These are faster since they avoid hashmap lookups, so should be preferred in performance-sensitive code (e.g. bulk loaders).

Parameters
[in]col_idxThe index of the target column.
Returns
Operation result status. Return a bad Status if at least one of the following is true:
  • The type does not match.
  • The value is unset.
  • The value is NULL.
Status GetBool (int col_idx, bool *val) const WARN_UNUSED_RESULT
 
Status GetInt8 (int col_idx, int8_t *val) const WARN_UNUSED_RESULT
 
Status GetInt16 (int col_idx, int16_t *val) const WARN_UNUSED_RESULT
 
Status GetInt32 (int col_idx, int32_t *val) const WARN_UNUSED_RESULT
 
Status GetInt64 (int col_idx, int64_t *val) const WARN_UNUSED_RESULT
 
Status GetTimestamp (int col_idx, int64_t *micros_since_utc_epoch) const WARN_UNUSED_RESULT
 
Status GetFloat (int col_idx, float *val) const WARN_UNUSED_RESULT
 
Status GetDouble (int col_idx, double *val) const WARN_UNUSED_RESULT
 
Getters for string/binary column by column name.

Get the string/binary value for a column by its name.

Parameters
[in]col_nameName of the column.
[out]valPointer to the placeholder to put the resulting value. Note that the method does not copy the value. Callers should copy the resulting Slice if necessary.
Returns
Operation result status. Return a bad Status if at least one of the following is true:
  • The type does not match.
  • The value is unset.
  • The value is NULL.
Status GetString (const Slice &col_name, Slice *val) const WARN_UNUSED_RESULT
 
Status GetBinary (const Slice &col_name, Slice *val) const WARN_UNUSED_RESULT
 
Getters for string/binary column by column index.

Get the string/binary value for a column by its index.

These methods are faster than their name-based counterparts since they use indices to avoid hashmap lookups, so index-based getters should be preferred in performance-sensitive code.

Parameters
[in]col_indexThe index of the column.
[out]valPointer to the placeholder to put the resulting value. Note that the method does not copy the value. Callers should copy the resulting Slice if necessary.
Returns
Operation result status. Return a bad Status if at least one of the following is true:
  • The type does not match.
  • The value is unset.
  • The value is NULL.
Status GetString (int col_idx, Slice *val) const WARN_UNUSED_RESULT
 
Status GetBinary (int col_idx, Slice *val) const WARN_UNUSED_RESULT
 

Friends

class client::KuduWriteOperation
 
class KeyUtilTest
 
class PartitionSchema
 
class RowOperationsPBDecoder
 
class RowOperationsPBEncoder
 
class TestScanSpec
 
template<typename KeyTypeWrapper >
struct client::SliceKeysTestSetup
 
template<typename KeyTypeWrapper >
struct client::IntKeysTestSetup
 

Detailed Description

A row which may only contain values for a subset of the columns.

This object contains a normal contiguous row, plus a bitfield indicating which columns have been set. Additionally, this type may optionally own copies of indirect data for variable length columns.

Constructor & Destructor Documentation

kudu::KuduPartialRow::KuduPartialRow ( const Schema *  schema)
explicit
Parameters
[in]schemaSchema to use for the row. The given Schema object must remain valid for the lifetime of this row.
kudu::KuduPartialRow::KuduPartialRow ( const KuduPartialRow other)

Create a copy of KuduPartialRow instance.

Parameters
[in]otherKuduPartialRow instance to copy from.

Member Function Documentation

bool kudu::KuduPartialRow::AllColumnsSet ( ) const
Returns
true if all column values have been set.
Status kudu::KuduPartialRow::EncodeRowKey ( std::string *  encoded_key) const

Encode a row key.

The result is suitable for use as a tablet split key, an encoded key range, etc.

Precondition
All of the key columns must be set.
Parameters
[out]encoded_keyThe encoded key (i.e. the result of the encoding).
Returns
Operation result status. In particular, this method returns InvalidArgument if not all the key columns are set.
bool kudu::KuduPartialRow::IsColumnSet ( const Slice col_name) const

Check whether the specified column is set for the row.

Parameters
[in]col_nameName of the column.
Returns
true iff the given column has been specified.
bool kudu::KuduPartialRow::IsColumnSet ( int  col_idx) const

Check whether the specified column is set for the row.

Parameters
[in]col_idxThe index of the column.
Returns
true iff the given column has been specified.
bool kudu::KuduPartialRow::IsKeySet ( ) const
Returns
true if all key column values have been set for this mutation.
bool kudu::KuduPartialRow::IsNull ( const Slice col_name) const

Check whether the specified column is NULL for the row.

Parameters
[in]col_nameName of the target column.
Returns
true iff the given column's value is NULL.
bool kudu::KuduPartialRow::IsNull ( int  col_idx) const

Check whether the specified column is NULL for the row.

Parameters
[in]col_idxThe index of the column.
Returns
true iff the given column's value is NULL.
KuduPartialRow& kudu::KuduPartialRow::operator= ( KuduPartialRow  other)

Overwrite this KuduPartialRow instance with data from other instance.

Parameters
[in]otherKuduPartialRow instance to assign from.
Returns
Reference to the updated object.
const Schema* kudu::KuduPartialRow::schema ( ) const
inline
Returns
The schema object for the partial row.
Status kudu::KuduPartialRow::SetNull ( const Slice col_name)

Set column value to NULL; the column is identified by its name.

This will only succeed on nullable columns. Use Unset() to restore column value to its default.

Parameters
[in]col_nameName of the target column.
Returns
Operation result status.
Status kudu::KuduPartialRow::SetNull ( int  col_idx)

Set column value to NULL; the column is identified by its index.

This will only succeed on nullable columns. Use Unset() to restore column value to its default.

Parameters
[in]col_idxThe index of the target column.
Returns
Operation result status.
std::string kudu::KuduPartialRow::ToEncodedRowKeyOrDie ( ) const

Convenience method which is similar to EncodeRowKey.

This is equivalent to the EncodeRowKey, but triggers a FATAL error on failure.

Returns
The encoded key.
std::string kudu::KuduPartialRow::ToString ( ) const
Returns
String representation for the partial row.
Status kudu::KuduPartialRow::Unset ( const Slice col_name)

Unset the given column by name, restoring its default value.

Note
This is different from setting it to NULL.
Parameters
[in]col_nameName of the target column.
Returns
Operation result status.
Status kudu::KuduPartialRow::Unset ( int  col_idx)

Unset the given column by index, restoring its default value.

Note
This is different from setting it to NULL.
Parameters
[in]col_idxThe index of the target column.
Returns
Operation result status.

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