0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
QualifiedRangeSpec.cc
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; 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 
28 
29 #include <Common/Compat.h>
30 
31 #include "QualifiedRangeSpec.h"
32 
33 #include <Common/Logger.h>
34 #include <Common/Properties.h>
35 #include <Common/Serialization.h>
36 #include <Common/StringExt.h>
37 #include <Common/md5.h>
38 
39 using namespace std;
40 using namespace Hypertable;
41 using namespace Serialization;
42 
43 bool QualifiedRangeSpec::is_root() const {
44  bool start_null = (range.start_row == 0) || (strlen(range.start_row)==0);
45  return (table.is_metadata() && start_null);
46 }
47 
49  if (!strcmp(table.id, other.table.id))
50  return (range < other.range);
51  else
52  return strcmp(table.id, other.table.id) < 0;
53 }
54 
56  return (table == other.table && range == other.range);
57 }
58 
59 
60 uint8_t QualifiedRangeSpec::encoding_version() const {
61  return 1;
62 }
63 
64 size_t QualifiedRangeSpec::encoded_length_internal() const {
65  return table.encoded_length() + range.encoded_length();
66 }
67 
84 void QualifiedRangeSpec::encode_internal(uint8_t **bufp) const {
85  table.encode(bufp);
86  range.encode(bufp);
87 }
88 
89 void QualifiedRangeSpec::decode_internal(uint8_t version, const uint8_t **bufp,
90  size_t *remainp) {
91  HT_TRY("decoding qualified range spec ",
92  table.decode(bufp, remainp);
93  range.decode(bufp, remainp));
94 }
95 
97  if (table == other.table)
98  return (range < other.range);
99  else
100  return (table < other.table);
101 }
102 
103 void QualifiedRangeSpecManaged::decode_internal(uint8_t version, const uint8_t **bufp,
104  size_t *remainp) {
105  QualifiedRangeSpec::decode_internal(version, bufp, remainp);
106  *this = *this;
107 }
108 
110 ostream &Hypertable::operator<<(ostream &os, const QualifiedRangeSpec &qualified_range) {
111  os << qualified_range.table << qualified_range.range;
112  return os;
113 }
114 
116 ostream &Hypertable::operator<<(ostream &os, const QualifiedRangeSpecManaged &qualified_range) {
117  os << qualified_range.m_table << qualified_range.m_range;
118  return os;
119 }
120 
Qualified (with table identifier) range specification, with storage.
Program options handling.
STL namespace.
Declarations for QualifiedRangeSpec and QualifiedRangeSpecManaged.
Logging routines and macros.
Compatibility Macros for C/C++.
std::ostream & operator<<(std::ostream &os, const crontab_entry &entry)
Helper function to write crontab_entry to an ostream.
Definition: Crontab.cc:301
Functions to serialize/deserialize primitives to/from a memory buffer.
bool operator==(const directory_entry< _Key, _Tp > &lhs, const directory_entry< _Key, _Tp > &rhs)
Definition: directory.h:112
bool operator<(const directory_entry< _Key, _Tp > &lhs, const directory_entry< _Key, _Tp > &rhs)
Definition: directory.h:128
Hypertable definitions
Qualified (with table identifier) range specification.
#define HT_TRY(_s_, _code_)
Definition: Error.h:517
String extensions and helpers: sets, maps, append operators etc.
md5 digest routines.