0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Result.h
Go to the documentation of this file.
1 /* -*- c++ -*-
2  * Copyright (C) 2007-2015 Hypertable, Inc.
3  *
4  * This file is part of Hypertable.
5  *
6  * Hypertable is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 3
9  * of the License, or any later version.
10  *
11  * Hypertable is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with Hypertable. If not, see <http://www.gnu.org/licenses/>
18  */
19 
20 #ifndef Hypertable_Lib_Result_h
21 #define Hypertable_Lib_Result_h
22 
23 #include "ScanCells.h"
24 
25 #include <memory>
26 
27 namespace Hypertable {
28 
29  using namespace Lib;
30 
31  class TableMutatorAsync;
32  class TableScannerAsync;
33 
34  class Result {
35  public:
36 
37  Result(TableScannerAsync *scanner, ScanCellsPtr &cells);
38  Result(TableScannerAsync *scanner, int error,
39  const std::string &error_msg);
41  Result(TableMutatorAsync *, int error, FailedMutations &failed_mutations);
42 
43  bool is_error() const { return m_iserror; }
44  bool is_scan() const { return m_isscan; }
45  bool is_update() const { return !m_isscan; }
46  TableScannerAsync *get_scanner();
47  TableMutatorAsync *get_mutator();
48  void get_cells(Cells &cells);
49  void get_error(int &error, std::string &m_error_msg);
50  FailedMutations& get_failed_mutations();
51  void get_failed_cells(Cells &cells);
52  size_t memory_used() {
53  if (m_isscan)
54  return (m_cells ? m_cells->memory_used() : 0);
55  else
56  return (m_iserror ? m_failed_cells.memory_used() : 0);
57  }
58 
59  private:
63  int m_error;
64  std::string m_error_msg;
65  bool m_isscan;
66  bool m_iserror;
69  };
70 
72  typedef std::shared_ptr<Result> ResultPtr;
73 }
74 
75 #endif // Hypertable_Lib_Result_h
76 
std::vector< Cell, CellAlloc > Cells
Definition: Cells.h:37
ScanCellsPtr m_cells
Definition: Result.h:62
FailedMutations m_failed_mutations
Definition: Result.h:68
bool is_error() const
Definition: Result.h:43
CellsBuilder m_failed_cells
Definition: Result.h:67
Asynchronous table scanner.
std::shared_ptr< Result > ResultPtr
Smart pointer to Result.
Definition: Result.h:72
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
bool is_update() const
Definition: Result.h:45
bool is_scan() const
Definition: Result.h:44
size_t memory_used()
Definition: Result.h:52
Hypertable definitions
TableMutatorAsync * m_mutator
Definition: Result.h:61
std::vector< FailedMutation > FailedMutations
Definition: Cells.h:39
TableScannerAsync * m_scanner
Definition: Result.h:60
std::string m_error_msg
Definition: Result.h:64