Commit Graph

96 Commits

Author SHA1 Message Date
Avi Kivity
99a15de9e5 logger: de-thread_local-ize logger
The logger class constructor registers itself with the logger registry,
in order to enable dynamically setting log levels.  However, since
thread_local variables may be (and are) initialized at the time of first
use, when the program starts up no loggers are registered.

Fix by making loggers global, not thread_local.  This requires that the
registry use locking to prevent registration happening on different threads
from corrupting the registry.

Note that technically global variables can also be initialized at the
point of first use, and there is no portable way for classes to self-register.
However this is the best we can do.
2015-07-14 17:18:11 +03:00
Tomasz Grabiec
4a1bf56b48 types: Introduce collection_type_impl::mutation::compact_and_expire()
Will be needed by mutation query.
2015-07-12 12:51:38 +02:00
Glauber Costa
4ed027bf89 types: add data_type for inet_address
That was still missing

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-07-09 09:34:30 -04:00
Calle Wilund
6d6052d9d0 types.hh : add data_type_for overload 2015-07-06 08:21:15 +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
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
647d95d170 types: Fix operator== for data_value
We must compare types with ->equal(). Fixes keyspace merging issues
where the merging code mistakenly thinks two keyspaces are different and
calls the alter keyspace path which is not implemented.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-06-05 12:58:52 +03:00
Pekka Enberg
c2675980b9 database: Fix data_value comparison operator
Tomek says:

  "Some types may yield different byte-representations for equal
   values."

Fix that up.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-05-28 11:21:22 +02: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
Pekka Enberg
ea0e1ff3b5 types.hh: Add data_value class
Add a data_value class that also encodes a value type. This makes it
easier to use than plain boost::any for comparing two values.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-05-27 11:49:12 +03:00
Asias He
898233ddcf Remove redundant const in static constexpr const
From http://en.cppreference.com/w/cpp/language/constexpr:

  A constexpr specifier used in an object declaration implies const.
2015-05-25 13:09:23 +03:00
Tomasz Grabiec
0559062893 types: Introduce lexicographical_tri_compare() 2015-04-30 11:16:52 +02: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
23db4e0b54 db: rename db_tuple_type to tuple_type
Now that we reclaimed the tuple_type name, use it for its rightful owner.
2015-04-27 12:27:18 +02: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
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