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

A batch of zero or more rows returned by a scan operation. More...

#include <scan_batch.h>

Inheritance diagram for kudu::client::KuduScanBatch:

Public Types

typedef RowPtr value_type
 A handy typedef for the RowPtr.
 

Public Member Functions

int NumRows () const
 
KuduScanBatch::RowPtr Row (int idx) const
 
const_iterator begin () const
 
const_iterator end () const
 
const KuduSchemaprojection_schema () const
 
 RowPtr ()
 
bool IsNull (const Slice &col_name) const
 
bool IsNull (int col_idx) const
 
const void * cell (int col_idx) const
 
std::string ToString () const
 
KuduScanBatch::RowPtr operator* () const
 
const_iterator & operator++ ()
 
const_iterator operator++ (int)
 
bool operator== (const const_iterator &other) const
 
bool operator!= (const const_iterator &other) const
 
Advanced/Unstable API

There are no guarantees on the stability of the format returned by these methods, which might change at any given time.

Note
The Slices returned by both direct_data() and indirect_data() are only valid for the lifetime of the KuduScanBatch.
Slice direct_data () const
 
Slice indirect_data () const
 
Getters for integral type columns by column name.
Parameters
[in]col_nameThe name of the target column.
[out]valPlaceholder for the result value.
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 GetUnixTimeMicros (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 integral type columns by column index.

These methods are faster than their name-based counterparts since using indices avoids a hashmap lookup, 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.
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 GetUnixTimeMicros (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 using indices avoids a hashmap lookup, 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 KuduScanner
 
class tools::ReplicaDumper
 
class KuduScanBatch
 
template<typename KeyTypeWrapper >
struct SliceKeysTestSetup
 
template<typename KeyTypeWrapper >
struct IntKeysTestSetup
 

Detailed Description

A batch of zero or more rows returned by a scan operation.

Every call to KuduScanner::NextBatch() returns a batch of zero or more rows. You can iterate over the rows in the batch using:

range-foreach loop (C++11):

* for (KuduScanBatch::RowPtr row : batch) {
* ... row.GetInt(1, ...)
* ...
* }
*

regular for loop (C++03):

* for (KuduScanBatch::const_iterator it = batch.begin(), it != batch.end();
* ++i) {
* ...
* }
*

or

* for (int i = 0, num_rows = batch.NumRows();
* i < num_rows;
* i++) {
* KuduScanBatch::RowPtr row = batch.Row(i);
* ...
* }
*
Note
In the above example, NumRows() is only called once at the beginning of the loop to avoid extra calls to the non-inlined method.

Member Function Documentation

KuduScanBatch::const_iterator kudu::client::KuduScanBatch::begin ( ) const
inline
Returns
Forward iterator to the start of the rows in the batch.
const void* kudu::client::KuduScanBatch::cell ( int  col_idx) const

Get the column's row data.

Note
Should be avoided unless absolutely necessary.
Parameters
[in]col_idxThe index of the column.
Returns
Raw cell data for the specified index.
Slice kudu::client::KuduScanBatch::direct_data ( ) const

Return a slice that points to the direct row data received from the server. Users of this API must have knowledge of the data format in order to decode the data.

Returns
a Slice that points to the raw direct row data.
KuduScanBatch::const_iterator kudu::client::KuduScanBatch::end ( ) const
inline
Returns
Forward iterator to the end of the rows in the batch.
Slice kudu::client::KuduScanBatch::indirect_data ( ) const

Like the method above, but for indirect data.

Returns
a Slice that points to the raw indirect row data.
bool kudu::client::KuduScanBatch::IsNull ( const Slice col_name) const
Parameters
[in]col_nameName of the column.
Returns
true iff the specified column of the row has NULL value.
bool kudu::client::KuduScanBatch::IsNull ( int  col_idx) const
Parameters
[in]col_idxIndex of the column.
Returns
true iff the specified column of the row has NULL value.
int kudu::client::KuduScanBatch::NumRows ( ) const
Returns
The number of rows in this batch.
bool kudu::client::KuduScanBatch::operator!= ( const const_iterator &  other) const
inline

An operator to check whether two iterators are 'not equal'.

Parameters
[in]otherThe iterator to compare with.
Returns
true iff the other iterator points to a different row in the same batch, or to a row belonging to a different batch altogether.
KuduScanBatch::RowPtr kudu::client::KuduScanBatch::operator* ( ) const
inline
Returns
The row in the batch the iterator is pointing at.
const_iterator& kudu::client::KuduScanBatch::operator++ ( )
inline

Prefix increment operator: advances the iterator to the next position.

Returns
The reference to the iterator, pointing to the next position.
const_iterator kudu::client::KuduScanBatch::operator++ ( int  )
inline

Postfix increment operator: advances the iterator to the next position.

Returns
A copy of the iterator pointing to the pre-increment position.
bool kudu::client::KuduScanBatch::operator== ( const const_iterator &  other) const
inline

An operator to check whether two iterators are 'equal'.

Parameters
[in]otherThe iterator to compare with.
Returns
true iff the other iterator points to the same row of the same batch.
const KuduSchema* kudu::client::KuduScanBatch::projection_schema ( ) const
Returns
The projection schema for this batch. All KuduScanBatch::RowPtr returned by this batch are guaranteed to have this schema.
KuduScanBatch::RowPtr kudu::client::KuduScanBatch::Row ( int  idx) const

Get a row at the specified index.

Parameters
[in]idxThe index of the row to return.
Returns
A reference to one of the rows in this batch. The returned object is only valid for as long as this KuduScanBatch object is valid.
kudu::client::KuduScanBatch::RowPtr ( )
inline

Construct an invalid RowPtr. Before use, you must assign a properly-initialized value.

std::string kudu::client::KuduScanBatch::ToString ( ) const
Returns
String representation for this row.

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