Commit Graph

60 Commits

Author SHA1 Message Date
Duarte Nunes
d7ae25c572 range: Make transform template arguments deductable
This patch makes it so that the template arguments of
range<T>::transform are more easily deducible by the compiler.

Signed-off-by: Duarte Nunes <duarte@scylladb.com>
2016-07-18 23:58:31 +00:00
Pekka Enberg
38a54df863 Fix pre-ScyllaDB copyright statements
People keep tripping over the old copyrights and copy-pasting them to
new files. Search and replace "Cloudius Systems" with "ScyllaDB".

Message-Id: <1460013664-25966-1-git-send-email-penberg@scylladb.com>
2016-04-08 08:12:47 +03:00
Pekka Enberg
e56bf8933f Improve not implemented errors
Print out the function name where we're throwing the exception from to
make it easier to debug such exceptions.
2015-12-18 10:51:37 +01:00
Avi Kivity
d5cf0fb2b1 Add license notices 2015-09-20 10:43:39 +03:00
Avi Kivity
987294a412 Add missing copyrights 2015-09-20 10:16:11 +03:00
Paweł Dziepak
33e395d677 cql3: align error message for null partition key with origin
Fixes #328.

Signed-off-by: Paweł Dziepak <pdziepak@cloudius-systems.com>
2015-09-16 08:31:20 +02:00
Pekka Enberg
9f2bcc6a77 cql3: Change bind_and_get() return type to bytes_view_opt
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-08-24 09:06:13 +03:00
Paweł Dziepak
80fc1b1408 cql3: allow IN restriction only on last restricted column
2.2 allows IN on any column and it seems that we support that fine, but
DTESTs except us to reject such queries.

Signed-off-by: Paweł Dziepak <pdziepak@cloudius-systems.com>
2015-08-13 11:34:26 +02:00
Paweł Dziepak
486387bff8 cql3: sort and remove duplicates from clustering key restrictions
Signed-off-by: Paweł Dziepak <pdziepak@cloudius-systems.com>
2015-08-13 10:55:12 +02:00
Paweł Dziepak
9966a2eac6 cql3: sort and remove duplicates in multi-column IN restrictions
Values inside IN clause should be sorted and duplicates removed if the
restricted columns are part of the clustering key, which is always true
for multi column restrictions.

Signed-off-by: Paweł Dziepak <pdziepak@cloudius-systems.com>
2015-08-13 10:52:42 +02:00
Paweł Dziepak
0069040eb3 cql3: enable multi column restrictions
Signed-off-by: Paweł Dziepak <pdziepak@cloudius-systems.com>
2015-08-04 10:59:13 +02:00
Paweł Dziepak
c27acf56d3 cql3: translate MultiColumnRestriction.java to C++
Signed-off-by: Paweł Dziepak <pdziepak@cloudius-systems.com>
2015-08-04 10:58:53 +02:00
Paweł Dziepak
38ba7edf53 cql3: add method to_string() to term_slice
Signed-off-by: Paweł Dziepak <pdziepak@cloudius-systems.com>
2015-08-04 10:58:26 +02:00
Tomasz Grabiec
e5feff5d71 dht: ring_position: Switch to total ordering
range::is_wrap_around() and range::contains() rely on total ordering
on values to work properly. Current ring_position_comparator was only
imposing a weak ordering (token positions equal to all key positions
with that token).

range::before() and range::after() can't work for weak ordering. If
the bound is exclusive, we don't know if user-provided token position
is inside or outside.

Also, is_wrap_around() can't properly detect wrap around in all
cases. Consider this case:

 (1) ]A; B]
 (2) [A; B]

For A = (tok1) and B = (tok1, key1), (1) is a wrap around and (2) is
not. Without total ordering between A and B, range::is_wrap_around() can't
tell that.

I think the simplest soution is to define a total ordering on
ring_position by making token positions positioned either before or
after all keys with that token.
2015-07-24 16:08:41 +02:00
Paweł Dziepak
53b6c2cdfa cql3: drop reverse_primary_key_restrictions
Signed-off-by: Paweł Dziepak <pdziepak@cloudius-systems.com>
2015-07-23 02:38:38 +02:00
Tomasz Grabiec
76bf7b228c cql: token_restriction: Fix range produced for contradicting restrictions
We want to return no results in this case, so we should return no
range instead of range open on both sides, which yields all data.
2015-07-22 17:55:50 +02:00
Tomasz Grabiec
47e006bfae cql: token_restriction: Fix the check detecting contradicting restrictions
The condition is incorrect after 9b52f5bf2b.

We no longer express the full range as (min, min], and missing upper
bound as bound as (x, min] so we don't need to exclude those cases in
the check.
2015-07-22 17:55:42 +02:00
Tomasz Grabiec
9b52f5bf2b storage_proxy: Make range splitting never produce a wrap around range
Origin has no notion of a maximum token so a range without upper bound
is represented as (x; min]. The splitting code is supposed to produce
only non-wrapping ranges, but (x; min] looks like a wrapping range, so
database code which consumes it would have to special-case for it. A
simpler solution is to change the splitting code to never produce a
wrapping range.
2015-07-22 10:27:48 +02:00
Calle Wilund
73421cb413 TokenRestriction: Java->c++ 2015-07-08 10:02:31 +02:00
Calle Wilund
4a5a5359b0 cql3::restrictions - refactor and clean up
Needed to reasonably cleanly implement token restrictions. 

* Fixed constness for various virtuals. 
* primary_key_restrictions now inherit abstract_restriction,
  similuar to Origin (for better or for worse), to avoid 
  duplicating attributes etc. 
* primary_key_restrictions bounds & values renamed (so not to
  collide with restriction), and some logic pushed downwards 
  (building bounds), to avoid abstraction breakage in 
  statement_restrictions
* primary_key_restrictions merging is now potentially replacing
  to make dispatching token/multicolumn restrictions simpler
2015-07-08 10:02:31 +02:00
Tomasz Grabiec
3779506990 db: query: Make partition_range hold ring_position
Current model was not really correct because Origin doesn't support
querying of partition ranges by their value. We can query slices
according to dht::decorated_key ordering, which orders partitions
first by token then by key value.

ring_position encapsulates range constraint. Key value is optional, in
which case only token is constrained.
2015-06-18 15:47:40 +02:00
Tomasz Grabiec
0c45deeadf cql3: statement_restrictions: move definitions to source file 2015-06-18 15:47:39 +02:00
Avi Kivity
97f689eb03 cql3: convert single_column_restriction::IN_with_marker to C++ 2015-04-28 18:00:35 +03:00
Avi Kivity
3d38708434 cql3: pass a database& instance to most foo::raw::prepare() variants
To prepare a user-defined type, we need to look up its name in the keyspace.
While we get the keyspace name as an argument to prepare(), it is useless
without the database instance.

Fix the problem by passing a database reference along with the keyspace.
This precolates through the class structure, so most cql3 raw types end up
receiving this treatment.

Origin gets along without it by using a singleton.  We can't do this due
to sharding (we could use a thread-local instance, but that's ugly too).

Hopefully the transition to a visitor will clean this up.
2015-04-20 16:15:34 +03:00
Tomasz Grabiec
00f99cefd4 db: split query.hh to reduce header dependencies 2015-04-15 20:44:59 +02:00
Tomasz Grabiec
09cd4c4cf0 cql3: Enable 'in' restriction
Adds support for queries like this:

  select * from cf where key in (1, 2);
2015-03-30 18:38:26 +02:00
Tomasz Grabiec
7c104a733e cql3: Optimize binding of a single value
This saves us an allocation of vector for single column restrictions.
2015-03-30 09:07:00 +02:00
Tomasz Grabiec
2902395129 Relax includes 2015-03-30 09:01:59 +02:00
Tomasz Grabiec
61c4d5150c cql3: Fix error message
single_column_primary_key_restrictions are used for both partition key
and clustering key restrictions.
2015-03-26 10:46:53 +01:00
Tomasz Grabiec
cd7e607a07 cql3: Optimize bounds() calculation for all EQ restrictions case 2015-03-26 10:46:53 +01:00
Tomasz Grabiec
38c9cd4400 cql3: Optimize iteration over column restrictions 2015-03-26 10:46:53 +01: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
e3422525c0 Use column_definition via const reference 2015-03-24 12:03:00 +01:00
Tomasz Grabiec
403355398a cql3: Convert SingleColumnRestriction.Slice 2015-03-20 18:59:29 +01:00
Tomasz Grabiec
f006b10349 cql3: Convert TermSlice 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
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
Tomasz Grabiec
5458d7bf7f cql3: Convert StatementRestrictions 2015-03-11 16:01:10 +01:00
Tomasz Grabiec
e202a13fff cql3: Convert SingleColumnPrimaryKeyRestrictions 2015-03-11 14:56:11 +01:00
Tomasz Grabiec
f2b9bbe74a cql3: Convert ReversePrimaryKeyRestrictions 2015-03-11 14:56:11 +01:00
Tomasz Grabiec
ff8adf93a2 cql3: Convert ForwardingPrimaryKeyRestrictions 2015-03-11 14:56:11 +01:00
Tomasz Grabiec
b49dc80eb5 cql3: Convert SingleColumnRestrictions 2015-03-11 14:56:11 +01:00
Tomasz Grabiec
25db056a8b cql3: Convert SingleColumnRestriction.Contains 2015-03-11 14:56:10 +01:00
Tomasz Grabiec
3e1c3a6b09 cql3: Convert Restrictions and PrimaryKeyRestrictions 2015-03-11 14:56:10 +01:00
Tomasz Grabiec
2946bff496 cql3: Remove AbstractPrimaryKeyRestrictions.java
It will not be used in converted code.
2015-03-11 14:56:10 +01:00
Tomasz Grabiec
3556ee9d45 cql3: Expose restricion::merge_with() 2015-03-11 14:56:10 +01:00
Tomasz Grabiec
a80a9a7253 cql3: Add restriction::to_string() 2015-03-11 14:56:10 +01:00
Tomasz Grabiec
bbe32bf26b cql3: Take vector by const& in abstract_restricion::uses_function() 2015-03-11 14:56:10 +01:00
Tomasz Grabiec
71756de650 cql3: single_column_restriction: keep column_definition& as const 2015-03-11 14:56:10 +01:00