0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
TableScanner.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; version 3 of the
9  * 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 this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19  * 02110-1301, USA.
20  */
21 
22 #ifndef Hypertable_Lib_TableScanner_h
23 #define Hypertable_Lib_TableScanner_h
24 
30 
31 #include <list>
32 
33 namespace Hypertable {
34 
37 
39  class TableScanner : public ClientObject {
40 
41  public:
42 
50  TableScanner(Comm *comm, Table *table, RangeLocatorPtr &range_locator,
51  const ScanSpec &scan_spec, uint32_t timeout_ms);
52 
57  virtual ~TableScanner() {
58  try {
59  m_scanner->cancel();
60  if (!m_scanner->is_complete()) {
61  ScanCellsPtr cells;
62  int error=Error::OK;
63  std::string error_msg;
64  while (!m_scanner->is_complete())
65  m_queue->next_result(cells, &error, error_msg);
66  }
67  }
68  catch(Exception &e) {
69  HT_ERROR_OUT << e << HT_END;
70  }
71  }
72 
77  bool next(Cell &cell);
78 
86  void unget(const Cell &cell);
87 
91  void get_profile_data(ProfileDataScanner &profile_data) {
92  m_scanner->get_profile_data(profile_data);
93  }
94 
95  private:
96 
97  friend class TableCallback;
98 
102  void scan_ok(ScanCellsPtr &cells);
103 
108  void scan_error(int error, const std::string &error_msg);
109 
117  int m_error;
118  std::string m_error_msg;
119  bool m_eos;
121  };
122 
124  typedef std::shared_ptr<TableScanner> TableScannerPtr;
125 
126  void copy(TableScanner &scanner, CellsBuilder &b);
127  inline void copy(TableScannerPtr &p, CellsBuilder &v) { copy(*p.get(), v); }
128 
130 
131 }
132 
133 #endif // Hypertable_Lib_TableScanner_h
std::shared_ptr< TableScannerQueue > TableScannerQueuePtr
Shared smart pointer to TableScannerQueue.
TableScannerAsyncPtr m_scanner
Definition: TableScanner.h:112
std::shared_ptr< TableScannerAsync > TableScannerAsyncPtr
Smart pointer to TableScannerAsync.
ProfileDataScanner m_profile_data
Definition: TableScanner.h:114
std::shared_ptr< RangeLocator > RangeLocatorPtr
Smart pointer to RangeLocator.
Definition: RangeLocator.h:198
virtual ~TableScanner()
Destructor.
Definition: TableScanner.h:57
TableScannerQueuePtr m_queue
Definition: TableScanner.h:111
std::shared_ptr< TableScanner > TableScannerPtr
Smart pointer to TableScanner.
Definition: TableScanner.h:124
void unget(const Cell &cell)
Ungets one cell.
Definition: TableScanner.cc:87
Scan predicate and control specification.
Definition: ScanSpec.h:56
Represents an open table.
Definition: Table.h:58
Represents an open table.
Definition: TableCallback.h:34
std::shared_ptr< ScanCells > ScanCellsPtr
Smart pointer to ScanCells.
Definition: ScanCells.h:143
bool next(Cell &cell)
Gets the next cell.
Definition: TableScanner.cc:49
Declarations for ClientObject.
#define HT_END
Definition: Logger.h:220
Synchronous table scanner.
Definition: TableScanner.h:39
#define HT_ERROR_OUT
Definition: Logger.h:301
Base class for Hypertable client objects.
Definition: ClientObject.h:44
Hypertable definitions
void copy(TableDumper &, CellsBuilder &)
Definition: TableDumper.cc:129
Entry point to AsyncComm service.
Definition: Comm.h:61
TableScanner(Comm *comm, Table *table, RangeLocatorPtr &range_locator, const ScanSpec &scan_spec, uint32_t timeout_ms)
Constructor.
Definition: TableScanner.cc:35
void get_profile_data(ProfileDataScanner &profile_data)
Gets profile data.
Definition: TableScanner.h:91
This is a generic exception class for Hypertable.
Definition: Error.h:314
Encapsulates decomposed key and value.
Definition: Cell.h:32
void scan_error(int error, const std::string &error_msg)
Callback for scan errors.
Definition: TableScanner.cc:98
TableCallback m_callback
Definition: TableScanner.h:110
void scan_ok(ScanCellsPtr &cells)
Callback for successful scan.
Definition: TableScanner.cc:94