0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Result.cc
Go to the documentation of this file.
1 
20 #include "Common/Compat.h"
21 #include "Result.h"
22 
23 #include "TableMutatorAsync.h"
24 #include "TableScannerAsync.h"
25 
26 namespace Hypertable {
27 
28 Result::Result(TableScannerAsync *scanner, ScanCellsPtr &cells) : m_scanner(scanner),
29  m_mutator(0), m_cells(cells), m_error(0), m_isscan(true), m_iserror(false) {
30  return;
31 }
32 
33 Result::Result(TableScannerAsync *scanner, int error, const string &error_msg) :
34  m_scanner(scanner), m_mutator(0), m_error(error), m_error_msg(error_msg), m_isscan(true),
35  m_iserror(true) {
36  return;
37 }
38 
39 Result::Result(TableMutatorAsync *mutator) : m_scanner(0), m_mutator(mutator),
40  m_error(0), m_isscan(false), m_iserror(false) {
41 }
42 
43 Result::Result(TableMutatorAsync *mutator, int error, FailedMutations &failed_mutations)
44  : m_scanner(0), m_mutator(mutator), m_error(error), m_isscan(false), m_iserror(true) {
46 }
47 
49  if (!m_isscan)
50  HT_THROW(Error::NOT_ALLOWED, "Requested scanner for non-scan result");
51  return m_scanner;
52 }
53 
55  if (m_isscan)
56  HT_THROW(Error::NOT_ALLOWED, "Requested mutator for non-scan result");
57  return m_mutator;
58 }
59 
60 void Result::get_cells(Cells &cells) {
61  if (!m_isscan)
62  HT_THROW(Error::NOT_ALLOWED, "Requested scanspec for non-scan result");
63  if (m_iserror)
64  HT_THROW(Error::NOT_ALLOWED, "Requested Cells for scan error");
65  m_cells->get(cells);
66 }
67 
68 void Result::get_error(int &error, string &error_msg) {
69  if (!m_iserror)
70  HT_THROW(Error::NOT_ALLOWED, "Requested error for non-error result");
71  error = m_error;
72  error_msg = m_error_msg;
73  return;
74 }
75 
78  return m_failed_mutations;
79 }
80 
82  if (m_isscan)
83  HT_THROW(Error::NOT_ALLOWED, "Requested failed cells for non-mutator result");
84  if (!m_iserror)
85  HT_THROW(Error::NOT_ALLOWED, "Requested failed cells for successful mutation");
86  m_failed_cells.get(cells);
87 }
88 } // namespace Hypertable
std::vector< Cell, CellAlloc > Cells
Definition: Cells.h:37
ScanCellsPtr m_cells
Definition: Result.h:62
FailedMutations m_failed_mutations
Definition: Result.h:68
CellsBuilder m_failed_cells
Definition: Result.h:67
Asynchronous table scanner.
void get(Cells &cells)
Definition: Cells.h:97
void get_cells(Cells &cells)
Definition: Result.cc:60
Provides the ability to mutate a table in the form of adding and deleting rows and cells...
std::shared_ptr< ScanCells > ScanCellsPtr
Smart pointer to ScanCells.
Definition: ScanCells.h:143
TableScannerAsync * get_scanner()
Definition: Result.cc:48
Compatibility Macros for C/C++.
void copy_failed_mutations(const FailedMutations &src, FailedMutations &dst)
Definition: Cells.h:108
Hypertable definitions
TableMutatorAsync * get_mutator()
Definition: Result.cc:54
FailedMutations & get_failed_mutations()
Definition: Result.cc:77
void get_error(int &error, std::string &m_error_msg)
Definition: Result.cc:68
Result(TableScannerAsync *scanner, ScanCellsPtr &cells)
Definition: Result.cc:28
void get_failed_cells(Cells &cells)
Definition: Result.cc:81
TableMutatorAsync * m_mutator
Definition: Result.h:61
#define HT_THROW(_code_, _msg_)
Definition: Error.h:478
std::vector< FailedMutation > FailedMutations
Definition: Cells.h:39
TableScannerAsync * m_scanner
Definition: Result.h:60
std::string m_error_msg
Definition: Result.h:64