0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
ScanCells.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_ScanCells_h
23 #define Hypertable_Lib_ScanCells_h
24 
25 #include <Hypertable/Lib/Cells.h>
29 #include <Hypertable/Lib/Schema.h>
30 
31 #include <Common/StringExt.h>
32 
33 #include <memory>
34 #include <vector>
35 
36 namespace Hypertable {
38 namespace Lib {
39 
40  using namespace std;
41 
46  class ScanCells {
47 
48  public:
49  ScanCells() : m_eos(false){}
50 
51  void get(Cells &cells) {
52  if (m_cells) {
53  m_cells->get(cells);
54  }
55  else {
56  cells.clear();
57  }
58  }
59  void get_cell_unchecked(Cell &cc, size_t ii) { m_cells->get_cell(cc, ii); }
60  void set_eos(bool eos = true) { m_eos = eos; }
61  bool get_eos() const { return m_eos; }
62  size_t size() const {
63  if (m_cells)
64  return m_cells->size();
65  else
66  return 0;
67  }
68 
69  bool empty() const {
70  return size() == 0;
71  }
72 
73  size_t memory_used() const {
74  size_t mem_used=0;
75  for (const auto &v : m_scanblocks) {
76  mem_used += v->memory_used();
77  }
78  return mem_used;
79  }
80 
83  ProfileDataScanner &profile_data() { return m_profile_data; }
84 
90  bool add(EventPtr &event, int *scanner_id);
91 
96  void add(Cell &cell, bool own = true);
97 
108  bool load(SchemaPtr &schema, const std::string &end_row, bool end_inclusive,
109  ScanLimitState *limit_state, CstrSet &rowset,
110  int64_t *bytes_scanned, Key *lastkey);
111 
116  for (const auto &v : m_scanblocks) {
117  if (v->get_skipped_rows())
118  return (v->get_skipped_rows());
119  }
120  return 0;
121  }
122 
127  for (const auto &v : m_scanblocks) {
128  if (v->get_skipped_cells())
129  return (v->get_skipped_cells());
130  }
131  return 0;
132  }
133 
134  protected:
135 
136  vector<ScanBlockPtr> m_scanblocks;
139  bool m_eos {};
140  };
141 
143  typedef std::shared_ptr<ScanCells> ScanCellsPtr;
144 
145 }}
146 
147 #endif // Hypertable_Lib_ScanCells_h
ProfileDataScanner & profile_data()
Returns reference to profile data.
Definition: ScanCells.h:83
size_t memory_used() const
Definition: ScanCells.h:73
ProfileDataScanner m_profile_data
Definition: ScanCells.h:138
std::vector< Cell, CellAlloc > Cells
Definition: Cells.h:37
void get_cell_unchecked(Cell &cc, size_t ii)
Definition: ScanCells.h:59
int get_skipped_cells()
get number of cells that were skipped because of a CELL_OFFSET predicate
Definition: ScanCells.h:126
int get_skipped_rows()
get number of rows that were skipped because of an OFFSET predicate
Definition: ScanCells.h:115
std::shared_ptr< Event > EventPtr
Smart pointer to Event.
Definition: Event.h:228
STL namespace.
void add(const Key &key, uint8_t flag, const void *value, uint32_t value_len, TableMutatorAsync *value_index_mutator, TableMutatorAsync *qualifier_index_mutator)
Definition: IndexTables.cc:34
Declarations for Schema.
std::shared_ptr< ScanCells > ScanCellsPtr
Smart pointer to ScanCells.
Definition: ScanCells.h:143
std::set< const char *, LtCstr > CstrSet
STL Set managing c-style strings.
Definition: StringExt.h:52
Declarations for ProfileDataScanner.
bool get_eos() const
Definition: ScanCells.h:61
CellsBuilderPtr m_cells
Definition: ScanCells.h:137
std::shared_ptr< CellsBuilder > CellsBuilderPtr
Smart pointer to CellsBuilder.
Definition: Cells.h:137
Hypertable definitions
Tracks row and cell limits used to enforce scan limit predicates.
Provides access to internal components of opaque key.
Definition: Key.h:40
vector< ScanBlockPtr > m_scanblocks
Definition: ScanCells.h:136
size_t size() const
Definition: ScanCells.h:62
Declarations for ScanBlock.
Declaration of ScanLimitState This file contains the type declaration for ScanLimitState, a class to track limits during a scan.
std::shared_ptr< Schema > SchemaPtr
Smart pointer to Schema.
Definition: Schema.h:465
Encapsulates decomposed key and value.
Definition: Cell.h:32
void set_eos(bool eos=true)
Definition: ScanCells.h:60
String extensions and helpers: sets, maps, append operators etc.
This class takes allows vector access to a set of cells contained in an EventPtr without any copying...
Definition: ScanCells.h:46