Commit Graph

82 Commits

Author SHA1 Message Date
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
Avi Kivity
90d732b2ab db: make serialization-format-dependent collection serdes functions virtual
Allow use in a polymorphic context.
2015-04-15 15:35:30 +03:00
Avi Kivity
b280592e88 db: add tri_compare_opt()
Like tri_compare(), but allows optional inputs.  Useful for tuples, where
NULLs are represented by null optionals.
2015-04-15 15:35:18 +03:00
Avi Kivity
6d402ab2a0 db: allow read_simple_exactly with const input
As read_simple_exactly consumes all its input, there is no need to adjust
it to communicate the amount of data consumed.
2015-04-12 15:13:54 +03:00
Avi Kivity
e9774fe1e1 db: adjust lexicographical_tri_compare to take a bounded type list
When comparing tuples, we don't want to overrun the type list.
2015-04-10 22:26:41 +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
32aadac87b db: implement abstract_type::is_compatible_with() 2015-04-01 20:58:56 +03:00
Avi Kivity
afe2ef6e39 db: implement abstract_type::equals()
At present, no overloads are needed because collections are interned, and
all other implemented data types are singletons.  Tuples and user defined
types will need an overload.
2015-04-01 20:57:37 +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
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
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
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
Tomasz Grabiec
0330568977 db: Handle range queries on clustering key
That also includes prefix range queries (partially constrained keys).
2015-03-20 19:20:59 +01:00
Tomasz Grabiec
c656674ab6 types: Introduce tri_compare() 2015-03-20 18:59:58 +01: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
Tomasz Grabiec
49b7a166a8 keys: Make key components non-optional 2015-03-19 14:54:41 +01:00
Tomasz Grabiec
3e230bd42c types: Introduce equal() and less_compare()
For use with sequence comparators like lexicographical_compare().
2015-03-19 14:54:41 +01:00
Tomasz Grabiec
cb4c874bf9 types: Introduce lexicographical_tri_compare() 2015-03-19 14:54:29 +01:00
Tomasz Grabiec
fffa35ac6b types: Make abstract_type::validate() work on bytes_view 2015-03-17 15:56:29 +01:00
Tomasz Grabiec
4b33888c23 types: Add algorithms for comparing optional types 2015-03-17 15:56:28 +01:00
Tomasz Grabiec
e3a04ae21b types: Introduce generic is_prefixed_by() 2015-03-17 15:56:28 +01:00
Tomasz Grabiec
1d5de9e428 types: Introduce lexicographical_compare() version with third sequence 2015-03-17 15:56:28 +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
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
Tomasz Grabiec
2ee58d66d6 Merge tag 'avi/collections/v3'
Conflicts:
	tests/urchin/cql_query_test.cc

[tgrabiec: fixed compilation error in cql3/maps.hh]
2015-03-12 11:30:17 +01: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
0bd44deca9 db: add abstract_type::as_less_comparator()
Returns a binary predicate that allows comparing two values belonging
to the type, suitable for STL containers and algorithms.
2015-03-12 10:10:41 +02:00
Avi Kivity
769824655e types: add forward declarations for collection serialization operations 2015-03-12 09:56:53 +02:00
Avi Kivity
fb876cb6f2 db: implement list_type 2015-03-12 09:56:53 +02:00
Avi Kivity
488ac10369 db: add set type implementation 2015-03-12 09:56:53 +02:00
Tomasz Grabiec
76c3509501 transport: Handle result_message::rows in CQL3 server 2015-03-11 16:01:13 +01:00
Tomasz Grabiec
6b30b4a2cd types: Introduce types::is_reversed() 2015-03-11 14:56:10 +01:00
Tomasz Grabiec
5f6d02df62 types: Make underlying_type() return shared_ptr<abstract_type> 2015-03-11 14:56:10 +01:00
Avi Kivity
06bd67c221 db: move map_type:impl::mutation and associated helpers to collection_type_impl
Turns out the sets and lists also use the same data type, with sets using
a fake value type, and lists using a fake key type.
2015-03-11 14:42:42 +02:00
Avi Kivity
5f309f4d33 db: add empty_type
Used in sets for the value type.
2015-03-11 14:42:42 +02:00