kudu::client::KuduScanBatch Class Reference

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

#include <scan_batch.h>

List of all members.

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
Getters for integral type columns by column name.

Parameters:
[in] col_name The name of the target column.
[out] val Placeholder 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_index The index of the column.
[out] val Pointer 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_name Name of the column.
[out] val Pointer 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_index The index of the column.
[out] val Pointer 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
struct SliceKeysTestSetup
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) {
     KuduScanBatch::RowPtr row(*it);
     ...
   }

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_idx The index of the column.
Returns:
Raw cell data for the specified index.
KuduScanBatch::const_iterator kudu::client::KuduScanBatch::end (  )  const [inline]
Returns:
Forward iterator to the end of the rows in the batch.
bool kudu::client::KuduScanBatch::IsNull ( int  col_idx  )  const
Parameters:
[in] col_idx Index of the column.
Returns:
true iff the specified column of the row has NULL value.
bool kudu::client::KuduScanBatch::IsNull ( const Slice col_name  )  const
Parameters:
[in] col_name Name 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] other The 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++ ( int   )  [inline]

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

Returns:
A copy of the iterator pointing to the pre-increment position.
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.
bool kudu::client::KuduScanBatch::operator== ( const const_iterator &  other  )  const [inline]

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

Parameters:
[in] other The 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] idx The 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:
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines