Commit Graph

41 Commits

Author SHA1 Message Date
Gleb Natapov
48ab0bd613 Make constructor from bytes for partition_key and clustering_key_prefix public
Make constructor from bytes public since serializer will use it.
2016-01-24 12:45:41 +02:00
Tomasz Grabiec
13974234a4 db/serializer: Spread serializers to relax header dependencies 2016-01-08 21:10:26 +01:00
Tomasz Grabiec
a6084ee007 mutation: Make hashable
The computed hash is independent of any internal representation thus
can be used as a digest across nodes and versions.
2016-01-08 21:10:26 +01:00
Tomasz Grabiec
c009fe5991 keys: Add missing clustering_key_prefix_view::get_compound_type() 2016-01-08 21:10:26 +01:00
Paweł Dziepak
64f50a4f40 db: make clustering_key a prefix
Schemas using compact storage can have clustering keys with the trailing
components not set and effectively being a clustering key prefixes
instead of full clustering keys.

Signed-off-by: Paweł Dziepak <pdziepak@scylladb.com>
2015-12-10 05:46:47 +01:00
Paweł Dziepak
77c7ed6cc5 keys: add prefix_equality_less_compare for prefixes
Signed-off-by: Paweł Dziepak <pdziepak@scylladb.com>
2015-12-10 05:46:26 +01:00
Paweł Dziepak
220a3b23c0 keys: allow creating partial views of prefixes
Signed-off-by: Paweł Dziepak <pdziepak@scylladb.com>
2015-12-10 05:46:26 +01:00
Avi Kivity
2c3591cbd9 data_value de-any-fication
We use boost::any to convert to and from database values (stored in
serlialized form) and native C++ values.  boost::any captures information
about the data type (how to copy/move/delete etc.) and stores it inside
the boost::any instance.  We later retrieve the real value using
boost::any_cast.

However, data_value (which has a boost::any member) already has type
information as a data_type instance.  By teaching data_type intances about
the corresponding native type, we can elimiante the use of boost::any.

While boost::any is evil and eliminating it improves efficiency somewhat,
the real goal is growing native type support in data_type.  We will use that
later to store native types in the cache, enabling O(log n) access to
collections, O(1) access to tuples, and more efficient large blob support.
2015-10-30 17:38:51 +01:00
Pekka Enberg
f43f0d6f04 keys: Add compound_wrapper::from_singular()
Clean up code by adding a from_singular() helper function to compound
wrapper and use it in.
2015-09-28 16:29:44 +02:00
Avi Kivity
d5cf0fb2b1 Add license notices 2015-09-20 10:43:39 +03:00
Paweł Dziepak
f0040c2af1 keys: use resize() to fill missing values
Signed-off-by: Paweł Dziepak <pdziepak@cloudius-systems.com>
2015-08-16 14:41:56 +03:00
Paweł Dziepak
83b18597d9 keys: allow incomplete keys in from_clustering_prefix()
Signed-off-by: Paweł Dziepak <pdziepak@cloudius-systems.com>
2015-08-14 14:10:36 +02:00
Tomasz Grabiec
c4acdb2068 db: Switch from bytes to managed_bytes for storing data
We need a container which can be used with compacting
allocators. "bytes" can't be used with compacting allocator because it
can't handle its external storage being moved.
2015-08-06 14:05:16 +02:00
Tomasz Grabiec
bad7602299 keys: Introduce ring_order_tri_compare() 2015-07-22 10:27:48 +02:00
Tomasz Grabiec
2ae6e91956 keys: Make comparators work on views rather than const&
More generic.
2015-07-12 12:54:38 +02:00
Tomasz Grabiec
431958c621 keys: Fix make_empty()
make_empty() is used from thrift to create a clustering_key for a
table's row without clustering key columns. The implementation was
misleading because it seemed to be handling any number of components in
the key while only no-component case is supposed to work.
2015-05-13 08:56:53 +02:00
Tomasz Grabiec
0bc0071373 keys: Introduce view wrappers
We now have partition_key_view, clustering_key_view, etc.
Database APIs will be extended to also accept views.

This will alows us to avoid allocations in certain scenarios.
2015-05-06 15:52:56 +02:00
Tomasz Grabiec
82882779b6 keys: Expose compatibility layer with Origin in partition_key 2015-04-30 11:16:52 +02:00
Tomasz Grabiec
6f536382b8 compound: Mark and document component iterator as InputIterator 2015-04-30 11:16:52 +02:00
Tomasz Grabiec
08a17496a3 keys: Move get_component() to compound_wrapper
It's an operation which is valid for any compound, not only
partition_key.
2015-04-30 11:16:52 +02:00
Tomasz Grabiec
cae462c534 Merge remote-tracking branch 'dev/penberg/keyspace-merging/v5' from seastar-dev.git
From Pekka:

"This patch series converts LegacySchemaTables keyspace merging code to
C++. After this series, keyspaces are actually created as demonstrated
by the newly added test in cql_query_test.cc."
2015-04-28 18:06:23 +02:00
Pekka Enberg
bba798c1ab keys: Add partition_key::get_component() helper
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-04-28 15:49:34 +03:00
Avi Kivity
f779c54d75 db: rename tuple_type family to compound_type
tuples already have a meaning in Cassandra and in C++, let's not overload
the word even more.  Use compound, which is the word used in Origin as well.
2015-04-27 12:27:18 +02:00
Tomasz Grabiec
88b9966c38 keys: Avoid unnecessary lw_shared_ptr copy 2015-04-24 18:01:01 +02:00
Tomasz Grabiec
731a63e371 schema: Embed raw_schema inside schema
Public fields got encapsulated.
2015-04-24 18:01:01 +02:00
Tomasz Grabiec
22e379e786 keys: Move operator<< functions to .cc file 2015-04-22 19:01:16 +02:00
Tomasz Grabiec
bacede04b2 types: Expose component iterators in tuple_wrapper
This automatically exposes them in partition_key and clustering_key too.

The iterators return bytes_view to components.

For example:

  schema s;
  partition_key k;

  for (bytes_view component : boost::make_iterator_range(key.begin(s), key.end(s))) {
     // ...
  }
2015-04-16 14:04:04 +02:00
Tomasz Grabiec
5ef11d113a types: Improve code readability 2015-04-16 14:04:04 +02:00
Tomasz Grabiec
4c418ddef8 types: Use enum rather than bool in tuple_type template parameter
The 'bool' type doesn't hold any meaning on its own, which makes the
template instantiation sites not very readable:

  tuple_type<true>

To improve that, we can introduce an enum class which is meaningful in
every context:

  tuple_type<allow_prefixes::yes>
2015-04-16 14:57:21 +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
a9ce81a2f8 db: add ostream operator for exploded_clustering_prefix 2015-04-01 20:12:39 +03:00
Tomasz Grabiec
7a6dd463dd types: Optimize serialization of single-element tuples
There are two sides of this optimization:

 1) We don't store the length of the last component, so the
    representation is now shorter.

 2) A single-element tuple is serialized exactly as the component it
    holds, which allows us to optimize conversions for such keys.
2015-03-26 10:21:48 +01: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
3176be2610 keys: Use trichotomic comparators where possible
Trichotomic version reduces comparison count almost by half.
2015-03-20 18:59:58 +01:00
Tomasz Grabiec
d8fd79a072 keys: Fix prefixable_full_tuple::is_prefixed_by()
Spotted during code review.
2015-03-20 18:59:57 +01:00
Tomasz Grabiec
ebfc1ffb20 query: Add facilities for printing query request 2015-03-20 18:59:29 +01:00
Tomasz Grabiec
bdbd5547e3 db: Cleanup key names
clustering_key::one -> clustering_key
clustering_key::prefix::one -> clustering_key_prefix
partition_key::one -> partition_key
clustering_prefix -> exploded_clustering_prefix
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
300a9572bd types: De-virtualize tuple_type
tuple_type is for managing our internal representation of keys. It
shares some interface with abstract_type, but the latter is a basis
for types of data stored in cells. tuple_type does not need to hide
behind a virtual interface.

Note: there is a TupleType in Origin, but it serves a different purpose.
2015-03-19 12:55:28 +01:00
Tomasz Grabiec
6197c5306d db: Optimize range tombstone lookups
From O(N) to O(log(N)) where N is the number of range tombstones.
2015-03-17 15:56:29 +01:00
Tomasz Grabiec
1b1af8cdfd db: Introduce types to hold keys
Holding keys and their prefixes as "bytes" is error prone. It's easy
to mix them up (or use wrong types). This change adds wrappers for
keys with accessors which are meant to make misuses as difficult as
possible.

Prefix and full keys are now distinguished. Places which assumed that
the representation is the same (it currently is) were changed not to
do so. This will allow us to introduce more compact storage for non-prefix
keys.
2015-03-17 15:56:29 +01:00