0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
SerializedCellsReader.h
Go to the documentation of this file.
1 /*
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_SERIALIZEDCELLSREADER_H
21 #define HYPERTABLE_SERIALIZEDCELLSREADER_H
22 
23 #include "Hypertable/Lib/KeySpec.h"
24 #include "Hypertable/Lib/Key.h"
25 #include "Hypertable/Lib/Cell.h"
26 
27 #include "SerializedCellsFlag.h"
28 
29 namespace Hypertable {
30 
32  public:
33 
34  SerializedCellsReader(void *buf, uint32_t len) {
35  init((uint8_t *)buf, len);
36  }
37 
38  SerializedCellsReader(const char *buf, uint32_t len) {
39  init((uint8_t *)buf, len);
40  }
41 
42  bool next();
43 
44  void get(KeySpec &key) {
45  key.row = m_row;
46  key.row_len = strlen(m_row);
47  key.column_family = m_column_family;
48  key.column_qualifier = m_column_qualifier;
49  key.column_qualifier_len = m_column_qualifier ? strlen(m_column_qualifier) : 0;
50  key.timestamp = m_timestamp;
51  key.revision = m_revision;
52  }
53 
54  void get(Cell &cell) {
55  cell.row_key = m_row;
56  cell.column_family = m_column_family;
57  cell.column_qualifier = m_column_qualifier;
58  cell.timestamp = m_timestamp;
59  cell.revision = m_revision;
60  cell.value = (uint8_t*)m_value;
61  cell.value_len = m_value_len;
62  cell.flag = m_cell_flag;
63  }
64 
66  Cell cell;
67  get(cell);
68  return cell;
69  }
70 
71  const char *row() { return m_row; }
72  const char *column_family() { return m_column_family; }
73  const char *column_qualifier() { return m_column_qualifier; }
74  const void *value() { return m_value; }
75  const char *value_str() { return (const char *)m_value; }
76  uint32_t value_len() { return m_value_len; }
77  int64_t timestamp() { return m_timestamp; }
78  int8_t cell_flag() { return m_cell_flag; }
79 
80  bool flush() { return (m_flag & SerializedCellsFlag::FLUSH) > 0; }
81  bool eos() { return (m_flag & SerializedCellsFlag::EOS) > 0; }
82 
83  private:
84  void init(uint8_t *buf, uint32_t len) {
85  m_base = m_ptr = (uint8_t *)buf;
86  m_end = m_base + len;
87 
88  size_t remaining = m_end - m_ptr;
89  int32_t version = Serialization::decode_i32(&m_ptr, &remaining);
90  if (version != SerializedCellsVersion::SCVERSION)
92  }
93 
94  const uint8_t *m_base {};
95  const uint8_t *m_ptr {};
96  const uint8_t *m_end {};
97  const char *m_row {};
98  const char *m_column_family {};
99  const char *m_column_qualifier {};
102  const void *m_value {};
103  uint32_t m_value_len {};
105  uint8_t m_flag {};
106  bool m_eob {};
107  const char *m_previous_row {};
108  };
109 
110 }
111 
112 #endif // HYPERTABLE_SERIALIZEDCELLSREADER_H
SerializedCellsReader(const char *buf, uint32_t len)
static const uint32_t FLAG_INSERT
Definition: KeySpec.h:47
uint32_t decode_i32(const uint8_t **bufp, size_t *remainp)
Decode a 32-bit integer in little-endian order.
static const int64_t TIMESTAMP_NULL
Definition: KeySpec.h:36
Hypertable definitions
void init(uint8_t *buf, uint32_t len)
Encapsulates decomposed key and value.
Definition: Cell.h:32
SerializedCellsReader(void *buf, uint32_t len)
#define HT_THROW(_code_, _msg_)
Definition: Error.h:478