database: Remove compose() function

Convert code to use the deserialize() function and drop the duplicate
compose() wrapper that we inherited from Origin.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
This commit is contained in:
Pekka Enberg
2015-05-27 16:04:05 +03:00
committed by Avi Kivity
parent 6673b510d0
commit 42cfcfb32d
6 changed files with 10 additions and 16 deletions

View File

@@ -78,7 +78,7 @@ public:
} catch (exceptions::marshal_exception e) {
throw exceptions::invalid_request_exception("Invalid timestamp value");
}
return boost::any_cast<int64_t>(data_type_for<int64_t>()->compose(*tval));
return boost::any_cast<int64_t>(data_type_for<int64_t>()->deserialize(*tval));
}
int32_t get_time_to_live(const query_options& options) {
@@ -97,7 +97,7 @@ public:
throw exceptions::invalid_request_exception("Invalid TTL value");
}
auto ttl = boost::any_cast<int32_t>(data_type_for<int32_t>()->compose(*tval));
auto ttl = boost::any_cast<int32_t>(data_type_for<int32_t>()->deserialize(*tval));
if (ttl < 0) {
throw exceptions::invalid_request_exception("A TTL must be greater or equal to 0");
}

View File

@@ -73,7 +73,7 @@ public:
if (!values[0]) {
return;
}
_sum += boost::any_cast<Type>(data_type_for<Type>()->compose(*values[0]));
_sum += boost::any_cast<Type>(data_type_for<Type>()->deserialize(*values[0]));
}
};
@@ -115,7 +115,7 @@ public:
return;
}
++_count;
_sum += boost::any_cast<Type>(data_type_for<Type>()->compose(*values[0]));
_sum += boost::any_cast<Type>(data_type_for<Type>()->deserialize(*values[0]));
}
};
@@ -152,7 +152,7 @@ public:
if (!values[0]) {
return;
}
auto val = boost::any_cast<Type>(data_type_for<Type>()->compose(*values[0]));
auto val = boost::any_cast<Type>(data_type_for<Type>()->deserialize(*values[0]));
if (!_max) {
_max = val;
} else {
@@ -199,7 +199,7 @@ public:
if (!values[0]) {
return;
}
auto val = boost::any_cast<Type>(data_type_for<Type>()->compose(*values[0]));
auto val = boost::any_cast<Type>(data_type_for<Type>()->deserialize(*values[0]));
if (!_min) {
_min = val;
} else {

View File

@@ -53,7 +53,7 @@ make_min_timeuuid_fct() {
if (!bb) {
return {};
}
auto ts_obj = timestamp_type->compose(*bb);
auto ts_obj = timestamp_type->deserialize(*bb);
if (ts_obj.empty()) {
return {};
}
@@ -73,7 +73,7 @@ make_max_timeuuid_fct() {
if (!bb) {
return {};
}
auto ts_obj = timestamp_type->compose(*bb);
auto ts_obj = timestamp_type->deserialize(*bb);
if (ts_obj.empty()) {
return {};
}

View File

@@ -113,7 +113,7 @@ BOOST_AUTO_TEST_CASE(test_tuple) {
return t->decompose(v);
};
auto bytes_to_native = [t] (bytes v) {
return boost::any_cast<native_type>(t->compose(v));
return boost::any_cast<native_type>(t->deserialize(v));
};
auto c_to_bytes = [=] (c_type v) {
return native_to_bytes(c_to_native(v));

View File

@@ -1618,7 +1618,7 @@ tuple_type_impl::make_name(const std::vector<data_type>& types) {
sstring
user_type_impl::get_name_as_string() const {
return boost::any_cast<sstring>(utf8_type->compose(_name));
return boost::any_cast<sstring>(utf8_type->deserialize(_name));
}
shared_ptr<cql3::cql3_type>

View File

@@ -268,12 +268,6 @@ protected:
return is_compatible_with(other);
}
public:
virtual boost::any compose(const bytes& v) const {
return deserialize(v);
}
data_value compose_value(const bytes& v) const {
return deserialize_value(v);
}
bytes decompose(const boost::any& value) const {
bytes b(bytes::initialized_later(), serialized_size(value));
auto i = b.begin();