Commit Graph

81 Commits

Author SHA1 Message Date
Paweł Dziepak
414c37f06f types: implement validation for built-in types
Signed-off-by: Paweł Dziepak <pdziepak@cloudius-systems.com>
2015-07-08 10:02:30 +02:00
Paweł Dziepak
22568a1995 types: implement timestamp_type_impl::from_string()
Signed-off-by: Paweł Dziepak <pdziepak@cloudius-systems.com>
2015-07-06 23:36:18 +02:00
Paweł Dziepak
d993ec69f6 types: implement inet_addr_type_impl::{from, to}_sstring()
Signed-off-by: Paweł Dziepak <pdziepak@cloudius-systems.com>
2015-07-06 23:33:03 +02:00
Paweł Dziepak
bb30e05149 types: implement uuid_type_impl::{from, to}_sstring()
Signed-off-by: Paweł Dziepak <pdziepak@cloudius-systems.com>
2015-07-06 23:31:22 +02:00
Paweł Dziepak
b33a401f01 types: implement timeuuid_type_impl::{from, to}_sstring()
Signed-off-by: Paweł Dziepak <pdziepak@cloudius-systems.com>
2015-07-06 23:30:44 +02:00
Paweł Dziepak
f8598a668a types: implement floating_type_impl::{from, to}_string()
Signed-off-by: Paweł Dziepak <pdziepak@cloudius-systems.com>
2015-07-06 23:26:17 +02:00
Paweł Dziepak
183b6fc6d9 db: do not return already expired cells in queries
Signed-off-by: Paweł Dziepak <pdziepak@cloudius-systems.com>
2015-07-02 17:25:41 +02:00
Tomasz Grabiec
de23b54764 types: Implement to_string()/from_string() for boolean_type 2015-06-23 17:07:37 +03:00
Pekka Enberg
f7f06758a6 types: Fix data type naming
Fix data type naming to follow Origin's conventions so that we can
serialize the names to database.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-06-17 12:25:18 +03:00
Pekka Enberg
fab1289857 types: Add abstract_type::parse_type() helper
Add a parse_type() function for parsing a serialized type name and
returning a data_type for it. Please note that collection types are
handled elsewhere.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-06-17 12:25:18 +03:00
Pekka Enberg
42cfcfb32d 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>
2015-05-27 16:22:35 +03:00
Tomasz Grabiec
2693dd2c7b db: Extract bytes related stuff from database.cc to bytes.cc
Some tests (eg murmur_hash_test) need only byte manipulation
functions. By specifying dependencies precisely we can drastically
reduce recompilation times, which speeds up development cycle.

I managed to reduce recompilation time for murmur_hash_test from 5
minutes to 4 seconds by breaking dependency on whole urchin object
set.
2015-04-29 15:50:16 +03:00
Avi Kivity
6290dee438 db: const correctness for abstract_type and friends
Types are immutable.
2015-04-29 15:40:38 +03:00
Avi Kivity
ab60ed8813 db: s/shared_ptr<abstract_type>/data_type/
Also replace derived types (map_type, collection_type, etc.).

As we'll change data_type's definition, this reduces the number of places
that need to be modified later, and is more readable.
2015-04-29 15:09:04 +03:00
Avi Kivity
3179f05e12 db: implement user types (user_type_impl)
Like a C struct.  Following origin, implemented as a tuple with an additional
vector of field names.

cql3_type integration deferred to the next patch.
2015-04-20 16:15:34 +03:00
Tomasz Grabiec
560c972bb3 Merge tag 'avi/tuples/v3' from seastar-dev.git
Resolved trivial conflicts in:
	cql3/lists.cc
	tests/urchin/cql_query_test.cc
2015-04-15 18:01:37 +02:00
Avi Kivity
7bd1d0b2ad cql3: support for tuple cql3_type 2015-04-15 15:35:30 +03:00
Avi Kivity
4e43fab7f1 db: add tuple_type_impl
cql3_type integration is deferred to the next patch.
2015-04-15 15:35:30 +03:00
Avi Kivity
4abad8f357 db: add collection_type_impl::reserialize()
Allows switching between serialization formats.
2015-04-15 15:35:30 +03:00
Nadav Har'El
bae3cbf7a2 db: fix typo in set_type_impl user-visible name
Noticed this typo while browsing the code. I have no idea what this typo
broke, if anything, but it couldn't have been intentional...

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
2015-04-13 18:53:03 +03:00
Avi Kivity
77552d3407 db: fix float_type's implementation
Was double, should be float.
2015-04-11 00:54:10 +03:00
Avi Kivity
30b40bf7b1 db: make bytes even more distinct from sstring
bytes and sstring are distinct types, since their internal buffers are of
different length, but bytes_view is an alias of sstring_view, which makes
it possible of objects of different types to leak across the abstraction
boundary.

Fix this by making bytes a basic_sstring<int8_t, ...> instead of using char.
int8_t is a 'signed char', which is a distinct type from char, so now
bytes_view is a distinct type from sstring_view.

uint8_t would have been an even better choice, but that diverges from Origin
and would have required an audit.
2015-04-07 10:56:19 +03:00
Avi Kivity
b23d23ac9c db: take into account collection tombstone when converting to value 2015-03-30 14:28:16 +03:00
Avi Kivity
56774f5e38 db: add collection_type_impl::to_bytes(collection_mutation::view) helper 2015-03-30 14:28:16 +03:00
Tomasz Grabiec
e50c5f8305 types: Implement operator<<(ostream&, const bytes_opt&) 2015-03-30 09:07:01 +02:00
Tomasz Grabiec
30c821d585 tombstone: rename ttl to deletion_time
The current name is confusing to say the least.
2015-03-30 09:07:01 +02:00
Tomasz Grabiec
808f70b6c3 collection_type_impl: Introduce is_any_live() 2015-03-30 09:07:00 +02:00
Tomasz Grabiec
300bacb3d9 collection_type_impl: Introduce is_empty() 2015-03-30 09:07:00 +02:00
Tomasz Grabiec
95b71f220c types: collection_type_impl: Introduce serialize_mutation_form_only_live()
For serializing only live elements of the collection. Will be needed
by query path.
2015-03-30 09:07:00 +02:00
Avi Kivity
17b929d739 db: implement as_cql3_type() for collections 2015-03-26 18:14:35 +01:00
Avi Kivity
579a794d14 cql3: de-virtualize cql3_type
cql3_type is a wrapper around data_type, so there's no need for a class
hierarchy -- anything that depends on the actual type can be forwarded
to abstract_type_impl.

We can now use this as a value type (dropping shared_ptr<cql3_type>), but
that is left for later.
2015-03-26 16:04:55 +01:00
Avi Kivity
1c1c4f923a db: fix collection_type_impl::deserialize_mutation_form() types
It accepts a bytes_view instead of the type-safe wrapper.
2015-03-26 14:31:01 +02:00
Avi Kivity
6a8b682c0e db: add collection_type_impl::mutation_view::materialize()
Converts a mutation_view to a mutation, so it can be modified.
2015-03-26 12:14:01 +02:00
Pekka Enberg
ea9dc7062f db: Fix abstract_type and native_cql3_type cyclic dependency
Suggested by Avi.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-03-24 11:24:44 +02:00
Avi Kivity
f983ab41a3 db: get rid of object_opt
As Tomasz noticed, boost::any can be empty, so optional<> functionality is
not needed.
2015-03-24 08:23:34 +01:00
Avi Kivity
c77648da6e db: add collection tombstones 2015-03-23 21:54:22 +02:00
Avi Kivity
62ee57b953 db: wrap collection_type_impl::mutation's vector in a struct
This will allow us to introduce a tombstone alongside.
2015-03-23 21:54:22 +02:00
Avi Kivity
c701152d50 db: don't use stringstream for collection mutation serialization 2015-03-23 21:54:22 +02:00
Tomasz Grabiec
90298af614 db: Cleanup atomic_cell naming
atomic_cell -> atomic_cell_type
atomic_cell::one -> atomic_cell
atomic_cell::view -> atomic_cell_view
2015-03-20 18:59:29 +01:00
Avi Kivity
6fee695095 db: replace most uses of protocol_version with serialization_format
Better type safety.
2015-03-16 18:15:16 +02:00
Avi Kivity
923496056a db: add set_type_impl::serialize_partially_deserialized_form() 2015-03-16 16:36:14 +02:00
Avi Kivity
4bbfc3c23b db: export collection_type_impl::pack() 2015-03-16 16:36:14 +02:00
Avi Kivity
f3d75d3169 db: fix listlike_partial_deserializing_iterator taking reference to temporary 2015-03-16 16:36:14 +02:00
Dor Laor
7921ef406a db: serialize via bytes_iterator instead of std::ostream
Instead of using inefficient std::ostream, use our own 'bytes' iterator class.
Compute ahead of time the length of the byte buffer.
Afterwards serialize the objects into it.

Gives ~X5 boost over previus results (that sometimes don't even
finish in reasonable time)

[avi: add missing include]
2015-03-16 07:07:25 +02:00
Avi Kivity
ca308698df collection_type_impl: add to_value(mutation_view)
Allows collapsing a mutation into a literal.
2015-03-12 10:10:42 +02:00
Avi Kivity
7c5d865aac db: add map_type::serialize_partially_deserialized_from
Add a way to convert a vector of pairs of serialized key/values to
the fully serializied form; useful for map literals.
2015-03-12 10:10:42 +02:00
Avi Kivity
fc9a8d6efd db: add collection_type_impl::pack
A helper function for other operations, as all collections share
the basic serialized format.
2015-03-12 10:10:42 +02:00
Avi Kivity
3c63f77824 db: split collection_type_impl::mutation into an owning and view types
The view type is more efficient, but less safe.
2015-03-12 10:10:42 +02:00
Avi Kivity
362dbd5c94 types: add bytes_view variant of write_collection_value() 2015-03-12 09:56:53 +02:00
Avi Kivity
f226f93120 fix collection_type_impl::merge 2015-03-12 09:56:53 +02:00