0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
ScanBlock.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 
26 
27 #ifndef Hypertable_Lib_ScanBlock_h
28 #define Hypertable_Lib_ScanBlock_h
29 
32 
33 #include <AsyncComm/Event.h>
34 
35 #include <Common/ByteString.h>
36 
37 #include <memory>
38 #include <vector>
39 
40 namespace Hypertable {
41 
44 
50  class ScanBlock {
51  public:
52 
53  typedef std::vector< std::pair<SerializedKey, ByteString> > Vector;
54 
55  ScanBlock();
56 
63  int load(EventPtr &event);
64 
68  size_t size() { return m_vec.size(); }
69 
71  void reset() { m_iter = m_vec.begin(); }
72 
80  bool next(SerializedKey &key, ByteString &value);
81 
85  bool eos() { return !m_response.more(); }
86 
90  bool more() {
91  if (m_iter == m_vec.end())
92  return false;
93  return true;
94  }
95 
100  size_t memory_used() const {
101  if (m_event)
102  return m_event->payload_len;
103  return 0;
104  }
105 
109  int get_scanner_id() { return m_response.id(); }
110 
113 
116 
120 
121  private:
122  int m_error {};
123  Vector m_vec;
124  Vector::iterator m_iter;
127  };
128 
130  typedef std::shared_ptr<ScanBlock> ScanBlockPtr;
131 
133 }
134 
135 #endif // Hypertable_Lib_ScanBlock_h
int get_scanner_id()
Returns scanner ID associated with this scanblock.
Definition: ScanBlock.h:109
size_t memory_used() const
Approximate estimate of memory used by scanblock (returns the size of the event payload) which contai...
Definition: ScanBlock.h:100
const ProfileDataScanner & profile_data()
Returns reference to profile data.
Definition: ScanBlock.h:119
void reset()
Resets iterator to first key/value pair in the scanblock.
Definition: ScanBlock.h:71
bool eos()
Returns true if this is the final scanblock returned by the scanner.
Definition: ScanBlock.h:85
int get_skipped_cells()
Returns number of skipped rows because of a CELL_OFFSET predicate.
Definition: ScanBlock.h:115
std::shared_ptr< Event > EventPtr
Smart pointer to Event.
Definition: Event.h:228
Declarations for Event.
const ProfileDataScanner & profile_data()
Gets profile data.
Definition: CreateScanner.h:83
A class managing one or more serializable ByteStrings.
Definition: ByteString.h:47
Response parameters for acknowledge load function.
Definition: CreateScanner.h:50
Lib::RangeServer::Response::Parameters::CreateScanner m_response
Definition: ScanBlock.h:126
std::shared_ptr< ScanBlock > ScanBlockPtr
Smart pointer to ScanBlock.
Definition: ScanBlock.h:130
std::vector< std::pair< SerializedKey, ByteString > > Vector
Definition: ScanBlock.h:53
Hypertable definitions
Encapsulates a block of scan results.
Definition: ScanBlock.h:50
bool next(SerializedKey &key, ByteString &value)
Returns the next key/value pair in the scanblock.
Definition: ScanBlock.cc:84
int get_skipped_rows()
Returns number of skipped rows because of an OFFSET predicate.
Definition: ScanBlock.h:112
Vector::iterator m_iter
Definition: ScanBlock.h:124
A serializable ByteString.
Declarations for CreateScanner response parameters.
bool more()
Indicates whether or not there are more key/value pairs in block.
Definition: ScanBlock.h:90
int load(EventPtr &event)
Loads scanblock data returned from RangeServer.
Definition: ScanBlock.cc:46
size_t size()
Returns the number of key/value pairs in the scanblock.
Definition: ScanBlock.h:68