0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
RangeMoveSpec.cc
Go to the documentation of this file.
1 
22 #include "Common/Compat.h"
23 #include "Common/Serialization.h"
24 
25 #include <cstring>
26 #include <iostream>
27 
28 #include "KeySpec.h"
29 #include "RangeMoveSpec.h"
30 
31 using namespace std;
32 using namespace Hypertable;
33 
34 uint8_t RangeMoveSpec::encoding_version() const {
35  return 1;
36 }
37 
38 size_t RangeMoveSpec::encoded_length_internal() const {
39  return table.encoded_length() + range.encoded_length() +
40  Serialization::encoded_length_vstr(source_location) +
41  Serialization::encoded_length_vstr(dest_location) + 5;
42 }
43 
76 void RangeMoveSpec::encode_internal(uint8_t **bufp) const {
77  table.encode(bufp);
78  range.encode(bufp);
79  Serialization::encode_vstr(bufp, source_location);
80  Serialization::encode_vstr(bufp, dest_location);
81  Serialization::encode_i32(bufp, error);
82  Serialization::encode_bool(bufp, complete);
83 }
84 
85 void RangeMoveSpec::decode_internal(uint8_t version, const uint8_t **bufp,
86  size_t *remainp) {
87  table.decode(bufp, remainp);
88  range.decode(bufp, remainp);
89  source_location = Serialization::decode_vstr(bufp, remainp);
90  dest_location = Serialization::decode_vstr(bufp, remainp);
91  error = Serialization::decode_i32(bufp, remainp);
92  complete = Serialization::decode_bool(bufp, remainp);
93 }
94 
96 ostream &Hypertable::operator<<(ostream &os, const RangeMoveSpec &move_spec) {
97  os <<"{RangeMoveSpec: " << move_spec.table << " " << move_spec.range
98  <<" source_location="<< move_spec.source_location
99  <<" dest_location="<< move_spec.dest_location
100  <<" error='" << Error::get_text(move_spec.error)
101  << "' complete=" << (move_spec.complete ? "true" : "false") << "}";
102  return os;
103 }
char * decode_vstr(const uint8_t **bufp, size_t *remainp)
Decode a vstr (vint64, data, null).
TableIdentifierManaged table
Definition: RangeMoveSpec.h:68
STL namespace.
size_t encoded_length_vstr(size_t len)
Computes the encoded length of vstr (vint64, data, null)
uint32_t decode_i32(const uint8_t **bufp, size_t *remainp)
Decode a 32-bit integer in little-endian order.
Range move specification.
Definition: RangeMoveSpec.h:43
bool decode_bool(const uint8_t **bufp, size_t *remainp)
Decodes a boolean value from the given buffer.
Definition: Serialization.h:96
const char * get_text(int error)
Returns a descriptive error message.
Definition: Error.cc:330
RangeSpecManaged range
Definition: RangeMoveSpec.h:69
void encode_i32(uint8_t **bufp, uint32_t val)
Encode a 32-bit integer in little-endian order.
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
Declarations for RangeMoveSpec.
Functions to serialize/deserialize primitives to/from a memory buffer.
void encode_vstr(uint8_t **bufp, const void *buf, size_t len)
Encode a buffer as variable length string (vint64, data, null)
Hypertable definitions
void encode_bool(uint8_t **bufp, bool bval)
Encodes a boolean into the given buffer.
Definition: Serialization.h:84