0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
Hypertable::TableMutator Class Reference

Provides the ability to mutate a table in the form of adding and deleting rows and cells. More...

#include <TableMutator.h>

Inheritance diagram for Hypertable::TableMutator:
Inheritance graph
[legend]
Collaboration diagram for Hypertable::TableMutator:
Collaboration graph
[legend]

Public Types

enum  { FLAG_NO_LOG_SYNC = Table::MUTATOR_FLAG_NO_LOG_SYNC, FLAG_NO_LOG = Table::MUTATOR_FLAG_NO_LOG }
 

Public Member Functions

 TableMutator (PropertiesPtr &props, Comm *comm, Table *table, RangeLocatorPtr &range_locator, uint32_t timeout_ms, uint32_t flags=0)
 Constructs the TableMutator object. More...
 
virtual ~TableMutator ()
 Destructor for TableMutator object Make sure buffers are flushed and unsynced rangeservers get synced. More...
 
virtual void set (const KeySpec &key, const void *value, uint32_t value_len)
 Inserts a cell into the table. More...
 
void set (const KeySpec &key, const char *value)
 Convenient helper for null-terminated values. More...
 
void set (const KeySpec &key, const std::string &value)
 Convenient helper for std::string values. More...
 
virtual void set_delete (const KeySpec &key)
 Deletes an entire row, a column family in a particular row, or a specific cell within a row. More...
 
virtual void set_cells (const Cells &cells)
 Insert a bunch of cells into the table (atomically if cells are in the same range/row) More...
 
virtual void flush ()
 Flushes the accumulated mutations to their respective range servers. More...
 
virtual bool retry (uint32_t timeout_ms=0)
 Retries the last operation. More...
 
virtual bool need_retry ()
 Checks for failed mutations. More...
 
virtual uint64_t memory_used ()
 Returns the amount of memory used by the collected mutations. More...
 
uint64_t get_resend_count ()
 There are certain circumstances when mutations get flushed to the wrong range server due to stale range location information. More...
 
virtual void get_failed (FailedMutations &failed_mutations)
 Returns the failed mutations. More...
 
std::ostream & show_failed (const Exception &, std::ostream &=std::cout)
 Show failed mutations. More...
 
void update_ok ()
 
void update_error (int error, FailedMutations &failures)
 
int32_t get_last_error ()
 
- Public Member Functions inherited from Hypertable::ClientObject
virtual ~ClientObject ()
 Destructor. More...
 

Private Types

enum  Operation { SET = 1, SET_CELLS, SET_DELETE, FLUSH }
 

Private Member Functions

void auto_flush ()
 
void wait_for_flush_completion (TableMutatorAsync *mutator)
 
void set_last_error (int32_t error)
 
void save_last (const KeySpec &key, const void *value, size_t value_len)
 
void save_last (Cells::const_iterator it, Cells::const_iterator end)
 
void set_cells (Cells::const_iterator start, Cells::const_iterator end)
 
void handle_exceptions ()
 
void retry_flush ()
 

Private Attributes

std::mutex m_mutex
 
std::mutex m_queue_mutex
 
std::condition_variable m_cond
 
PropertiesPtr m_props
 
Commm_comm
 
TablePtr m_table
 
SchemaPtr m_schema
 
RangeLocatorPtr m_range_locator
 
TableIdentifierManaged m_table_identifier
 
uint64_t m_memory_used
 
uint64_t m_max_memory
 
TableCallback m_callback
 
TableMutatorQueuePtr m_queue
 
TableMutatorAsyncPtr m_mutator
 
uint32_t m_timeout_ms
 
uint32_t m_flags
 
uint32_t m_flush_delay
 
int32_t m_last_error
 
int m_last_op
 
KeySpec m_last_key
 
const void * m_last_value
 
uint32_t m_last_value_len
 
Cells::const_iterator m_last_cells_it
 
Cells::const_iterator m_last_cells_end
 
bool m_refresh_schema
 
bool m_unflushed_updates
 
FailedMutations m_failed_mutations
 
CellsBuilderPtr m_failed_cells
 

Static Private Attributes

static const uint32_t ms_max_sync_retries = 5
 

Friends

class TableMutatorAsync
 

Detailed Description

Provides the ability to mutate a table in the form of adding and deleting rows and cells.

Objects of this class are used to collect mutations and periodically flush them to the appropriate range servers. There is a 1 MB buffer of mutations for each range server. When one of the buffers fills up all the buffers are flushed to their respective range servers.

Definition at line 55 of file TableMutator.h.

Member Enumeration Documentation

anonymous enum
Enumerator
FLAG_NO_LOG_SYNC 
FLAG_NO_LOG 

Definition at line 58 of file TableMutator.h.

Enumerator
SET 
SET_CELLS 
SET_DELETE 
FLUSH 

Definition at line 201 of file TableMutator.h.

Constructor & Destructor Documentation

TableMutator::TableMutator ( PropertiesPtr props,
Comm comm,
Table table,
RangeLocatorPtr range_locator,
uint32_t  timeout_ms,
uint32_t  flags = 0 
)

Constructs the TableMutator object.

Parameters
propsreference to properties smart pointer
commpointer to the Comm layer
tablepointer to the table object
range_locatorsmart pointer to range locator
timeout_msmaximum time in milliseconds to allow methods to execute before throwing an exception
flagsrangeserver client update command flags

Definition at line 59 of file TableMutator.cc.

TableMutator::~TableMutator ( )
virtual

Destructor for TableMutator object Make sure buffers are flushed and unsynced rangeservers get synced.

Definition at line 74 of file TableMutator.cc.

Member Function Documentation

void TableMutator::auto_flush ( )
private

Definition at line 149 of file TableMutator.cc.

void TableMutator::flush ( )
virtual

Flushes the accumulated mutations to their respective range servers.

Reimplemented in Hypertable::TableMutatorShared.

Definition at line 171 of file TableMutator.cc.

virtual void Hypertable::TableMutator::get_failed ( FailedMutations failed_mutations)
inlinevirtual

Returns the failed mutations.

Parameters
failed_mutationsreference to vector of Cell/error pairs

Reimplemented in Hypertable::TableMutatorShared.

Definition at line 173 of file TableMutator.h.

int32_t Hypertable::TableMutator::get_last_error ( )
inline

Definition at line 184 of file TableMutator.h.

uint64_t Hypertable::TableMutator::get_resend_count ( )
inline

There are certain circumstances when mutations get flushed to the wrong range server due to stale range location information.

When the correct location information is discovered, these mutations get resent to the proper range server. This method returns the number of mutations that were resent.

Returns
number of mutations that were resent

Definition at line 166 of file TableMutator.h.

void TableMutator::handle_exceptions ( )
private

Definition at line 40 of file TableMutator.cc.

virtual uint64_t Hypertable::TableMutator::memory_used ( )
inlinevirtual

Returns the amount of memory used by the collected mutations.

Returns
amount of memory used by the collected mutations.

Reimplemented in Hypertable::TableMutatorShared.

Definition at line 155 of file TableMutator.h.

virtual bool Hypertable::TableMutator::need_retry ( )
inlinevirtual

Checks for failed mutations.

Reimplemented in Hypertable::TableMutatorShared.

Definition at line 145 of file TableMutator.h.

bool TableMutator::retry ( uint32_t  timeout_ms = 0)
virtual

Retries the last operation.

Parameters
timeout_mstimeout in milliseconds, 0 means use default timeout
Returns
true if successfully flushed, false otherwise

Reimplemented in Hypertable::TableMutatorShared.

Definition at line 223 of file TableMutator.cc.

void TableMutator::retry_flush ( )
private

Definition at line 256 of file TableMutator.cc.

void Hypertable::TableMutator::save_last ( const KeySpec key,
const void *  value,
size_t  value_len 
)
inlineprivate

Definition at line 208 of file TableMutator.h.

void Hypertable::TableMutator::save_last ( Cells::const_iterator  it,
Cells::const_iterator  end 
)
inlineprivate

Definition at line 214 of file TableMutator.h.

void TableMutator::set ( const KeySpec key,
const void *  value,
uint32_t  value_len 
)
virtual

Inserts a cell into the table.

Parameters
keykey of the cell being inserted
valuepointer to the value to store in the cell
value_lenlength of data pointed to by value

Reimplemented in Hypertable::TableMutatorShared.

Definition at line 86 of file TableMutator.cc.

void Hypertable::TableMutator::set ( const KeySpec key,
const char *  value 
)
inline

Convenient helper for null-terminated values.

Definition at line 96 of file TableMutator.h.

void Hypertable::TableMutator::set ( const KeySpec key,
const std::string &  value 
)
inline

Convenient helper for std::string values.

Definition at line 106 of file TableMutator.h.

virtual void Hypertable::TableMutator::set_cells ( const Cells cells)
inlinevirtual

Insert a bunch of cells into the table (atomically if cells are in the same range/row)

Parameters
cellsa list of cells

Reimplemented in Hypertable::TableMutatorShared.

Definition at line 124 of file TableMutator.h.

void TableMutator::set_cells ( Cells::const_iterator  start,
Cells::const_iterator  end 
)
private

Definition at line 108 of file TableMutator.cc.

void TableMutator::set_delete ( const KeySpec key)
virtual

Deletes an entire row, a column family in a particular row, or a specific cell within a row.

Parameters
keykey of the row or cell(s) being deleted

Reimplemented in Hypertable::TableMutatorShared.

Definition at line 129 of file TableMutator.cc.

void Hypertable::TableMutator::set_last_error ( int32_t  error)
inlineprivate

Definition at line 196 of file TableMutator.h.

std::ostream & TableMutator::show_failed ( const Exception e,
std::ostream &  out = std::cout 
)

Show failed mutations.

Definition at line 278 of file TableMutator.cc.

void TableMutator::update_error ( int  error,
FailedMutations failures 
)

Definition at line 306 of file TableMutator.cc.

void TableMutator::update_ok ( )

Definition at line 298 of file TableMutator.cc.

void TableMutator::wait_for_flush_completion ( TableMutatorAsync mutator)
private

Definition at line 195 of file TableMutator.cc.

Friends And Related Function Documentation

friend class TableMutatorAsync
friend

Definition at line 193 of file TableMutator.h.

Member Data Documentation

TableCallback Hypertable::TableMutator::m_callback
private

Definition at line 236 of file TableMutator.h.

Comm* Hypertable::TableMutator::m_comm
private

Definition at line 229 of file TableMutator.h.

std::condition_variable Hypertable::TableMutator::m_cond
private

Definition at line 227 of file TableMutator.h.

CellsBuilderPtr Hypertable::TableMutator::m_failed_cells
private

Definition at line 253 of file TableMutator.h.

FailedMutations Hypertable::TableMutator::m_failed_mutations
private

Definition at line 252 of file TableMutator.h.

uint32_t Hypertable::TableMutator::m_flags
private

Definition at line 240 of file TableMutator.h.

uint32_t Hypertable::TableMutator::m_flush_delay
private

Definition at line 241 of file TableMutator.h.

Cells::const_iterator Hypertable::TableMutator::m_last_cells_end
private

Definition at line 248 of file TableMutator.h.

Cells::const_iterator Hypertable::TableMutator::m_last_cells_it
private

Definition at line 247 of file TableMutator.h.

int32_t Hypertable::TableMutator::m_last_error
private

Definition at line 242 of file TableMutator.h.

KeySpec Hypertable::TableMutator::m_last_key
private

Definition at line 244 of file TableMutator.h.

int Hypertable::TableMutator::m_last_op
private

Definition at line 243 of file TableMutator.h.

const void* Hypertable::TableMutator::m_last_value
private

Definition at line 245 of file TableMutator.h.

uint32_t Hypertable::TableMutator::m_last_value_len
private

Definition at line 246 of file TableMutator.h.

uint64_t Hypertable::TableMutator::m_max_memory
private

Definition at line 235 of file TableMutator.h.

uint64_t Hypertable::TableMutator::m_memory_used
private

Definition at line 234 of file TableMutator.h.

TableMutatorAsyncPtr Hypertable::TableMutator::m_mutator
private

Definition at line 238 of file TableMutator.h.

std::mutex Hypertable::TableMutator::m_mutex
private

Definition at line 225 of file TableMutator.h.

PropertiesPtr Hypertable::TableMutator::m_props
private

Definition at line 228 of file TableMutator.h.

TableMutatorQueuePtr Hypertable::TableMutator::m_queue
private

Definition at line 237 of file TableMutator.h.

std::mutex Hypertable::TableMutator::m_queue_mutex
private

Definition at line 226 of file TableMutator.h.

RangeLocatorPtr Hypertable::TableMutator::m_range_locator
private

Definition at line 232 of file TableMutator.h.

bool Hypertable::TableMutator::m_refresh_schema
private

Definition at line 250 of file TableMutator.h.

SchemaPtr Hypertable::TableMutator::m_schema
private

Definition at line 231 of file TableMutator.h.

TablePtr Hypertable::TableMutator::m_table
private

Definition at line 230 of file TableMutator.h.

TableIdentifierManaged Hypertable::TableMutator::m_table_identifier
private

Definition at line 233 of file TableMutator.h.

uint32_t Hypertable::TableMutator::m_timeout_ms
private

Definition at line 239 of file TableMutator.h.

bool Hypertable::TableMutator::m_unflushed_updates
private

Definition at line 251 of file TableMutator.h.

const uint32_t Hypertable::TableMutator::ms_max_sync_retries = 5
staticprivate

Definition at line 249 of file TableMutator.h.


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