Commit Graph

696 Commits

Author SHA1 Message Date
Paweł Dziepak
a64e9c5029 cql3: forbid empty non-composite clustering key
Origin forbdis empty values in clustering key only if that clustering
key is non-composite (i.e. there is only one column).

Signed-off-by: Paweł Dziepak <pdziepak@cloudius-systems.com>
2015-08-20 16:28:51 +03:00
Avi Kivity
ddee5e817a Workaround boost::any_cast bug
any_cast<X> is supposed to return X, but boost 1.55's any_cast<X> returns
X&&.  This means the lifetime-extending construct

   auto&& x = boost::any_cast<X>(...);

will not work, because the result of the expression is an rvalue reference,
not a true temporary.

Fix by using a temporary, not a lifetime-extending reference.

Fixes #163.
2015-08-19 09:15:31 +03:00
Avi Kivity
a8f957b692 Merge "CQL3 tuples cleanup" from Paweł
"These are some minor fixes and improvements for issues pointed out
during review."
2015-08-17 10:51:58 +03:00
Paweł Dziepak
fc7062f5d2 cql3: tuples: get rid of lambda in std::transform()
Signed-off-by: Paweł Dziepak <pdziepak@cloudius-systems.com>
2015-08-17 09:26:19 +02:00
Paweł Dziepak
3be8e3638e cql3: add missing std::move() in tuples::in_value()
Signed-off-by: Paweł Dziepak <pdziepak@cloudius-systems.com>
2015-08-17 09:11:53 +02:00
Paweł Dziepak
b74c7824bb cql3: reserve vector capacity in tuple::in_value constructor 2015-08-17 09:07:52 +02:00
Pekka Enberg
ed92f8516c cql3/query_options: Fix formatting
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-08-17 09:48:59 +03:00
Pekka Enberg
b165d22443 cql3/query_options: Move implementation to source file
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-08-17 09:48:59 +03:00
Pekka Enberg
401c3668a4 cql3/query_options: Remove ifdef'd code
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-08-17 09:48:58 +03:00
Pekka Enberg
5b9901d693 cql3/query_options: Encapsulate underlying values
Encapsulate the '_values' vector to make it easier to switch the
underlying type from bytes_opt to bytes_view_opt.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-08-17 09:48:58 +03:00
Paweł Dziepak
50abc62fe2 cql3: use proper token type in token relations
Signed-off-by: Paweł Dziepak <pdziepak@cloudius-systems.com>
2015-08-14 16:12:42 +02:00
Paweł Dziepak
15a0e2e386 cql3: use proper token type in token() function
Signed-off-by: Paweł Dziepak <pdziepak@cloudius-systems.com>
2015-08-14 16:12:38 +02:00
Paweł Dziepak
b42a9d6e6a cql3: translate support of update statements for dense tables
Signed-off-by: Paweł Dziepak <pdziepak@cloudius-systems.com>
2015-08-14 14:53:35 +02:00
Paweł Dziepak
1119141959 cql3: translate validation code for compact storage tables
Signed-off-by: Paweł Dziepak <pdziepak@cloudius-systems.com>
2015-08-14 14:53:35 +02:00
Paweł Dziepak
f6a93be655 cql3: skip compact value columns with no name
Signed-off-by: Paweł Dziepak <pdziepak@cloudius-systems.com>
2015-08-14 14:53:35 +02: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
1402125bd8 cql3: reverse order of bounds for reversed selects
Because of the reverse flag in partition slice rows inside bounds will
be returned in reversed order, however, we still have to make sure
that the bounds are in the expected order.

Signed-off-by: Paweł Dziepak <pdziepak@cloudius-systems.com>
2015-08-13 11:08:20 +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
0afbbb9d44 cql3: fix empty IN () restriction
Values inside IN () restrictions may be either in a vector _in_values or
a marker (_in_marker or _value). To determine which one is appropriate
we check whether _in_values is empty, which is wrong because IN clause
can be empty (and there is no marker in such case). This is fixed by
using the presence of a marker to determine whether a vector of values
or a marker should be used.

Signed-off-by: Paweł Dziepak <pdziepak@cloudius-systems.com>
2015-08-13 10:45:27 +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
6c9a41bfcf cql3/functions/token_fct: Add unimplemented guard for validation 2015-08-05 17:09:08 +02:00
Pekka Enberg
feb6b7d316 service/migration_manager: Remove storage proxy arguments
Use get_storage_proxy() and get_local_storage_proxy() helpers under the
hood to simplify migration manager API users.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-08-05 13:31:46 +03:00
Paweł Dziepak
7a7919a62e cql3: set properly partition_slice for SELECT DISTINCT
Signed-off-by: Paweł Dziepak <pdziepak@cloudius-systems.com>
2015-08-04 15:39:54 +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
f5a9fdfc61 cql3: translate MultiColumnRelation.java to C++
Signed-off-by: Paweł Dziepak <pdziepak@cloudius-systems.com>
2015-08-04 10:59:06 +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
a03b148f54 cql3: make check_[not]_null() validator work with stdx::optional
Signed-off-by: Paweł Dziepak <pdziepak@cloudius-systems.com>
2015-08-04 10:58:32 +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
Paweł Dziepak
9f2fd53a6e cql3: trasnlate remaining parts of tuples.hh to C++
Signed-off-by: Paweł Dziepak <pdziepak@cloudius-systems.com>
2015-08-04 10:58:06 +02:00
Pekka Enberg
a3c95235e6 migration_manager: Make stateful with sharded<>
In preparation for adding listener state to migration manager, use
sharded<> for migration manager.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-08-04 11:23:23 +03:00
Paweł Dziepak
5f2fd9b4dd cql3: cassandra_exceptions shouldn't be logged as errors
Only unexpected server errors should be logged, exception classes
deriving from cassandra_exception do not count as those.

Fixes #60.

Signed-off-by: Paweł Dziepak <pdziepak@cloudius-systems.com>
2015-08-03 11:09:50 +03:00
Paweł Dziepak
690e9b55f4 cql3: set proper expiration of row marker
INSERT statements update row marker ttl and expiry to the same values
which are set to the added/modified cells.

Signed-off-by: Paweł Dziepak <pdziepak@cloudius-systems.com>
2015-07-30 14:10:06 +02:00
Paweł Dziepak
f5fff734ed cq3: update_parameters: add getters for ttl and expiry
Signed-off-by: Paweł Dziepak <pdziepak@cloudius-systems.com>
2015-07-30 14:10:06 +02:00
Paweł Dziepak
87916612bd cql3: set default time to live when building schema
Signed-off-by: Paweł Dziepak <pdziepak@cloudius-systems.com>
2015-07-30 14:09:00 +02:00
Glauber Costa
f49eb92880 schema: speculative retry
When added to the schema and handled by legacy_schema_tables.cc, will then
appear correctly in the respective system tables.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-07-29 18:44:59 -04:00
Glauber Costa
01e5fcad5e schema: memtable flush period
currently set to 0, which is Origin's default

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-07-29 18:44:59 -04:00
Glauber Costa
3bb16fba7e create table: fix creation of compact storage tables
The statement being removed in this patch is wrong, and nonexistent in Origin.
If the list of column aliases is empty, we should leave it this way.

This code was already present before the compact storage series. But because
tables created using the schema_builder directly won't exercise this code path,
I ended up not noticing - specially because it only happens with tables that
lack a clustering key. The ones I tested through cqlsh, all had a clustering
key.

Fixes #45

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-07-28 10:05:05 +02:00
Avi Kivity
2e745bebad Merge "use compaction strategy options" from Raphael 2015-07-27 17:06:43 +03:00
Avi Kivity
095c2f2920 Merge "Fixes for partition_range model" from Tomasz
"range::is_wrap_around() will not work with current ring_position, because it
relies on total ordering. Same for range::contains(). Currently ring_position
is weakly ordered. This series fixes this problem by making ring_position
totally ordered.

Another problem fixed by this series is handling of wrap-around ranges. In
Origin, ]x; x] is treated as a wrap around range covering whole ring."
2015-07-25 17:47:40 +03:00
Avi Kivity
73dfa66b8a remove "reversed_type.hh"
Not used (and fix one accidental use).
2015-07-25 17:34:56 +03:00
Glauber Costa
21fc542af1 create_table_statement: revert reversed types
We have the information that they should be reverted, but we are not yet
reverting them. Go ahead and do it

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-07-24 22:55:12 -04:00
Glauber Costa
5306c70f3f create_table statement: sanity test defined_order
Code-conversion, mainly

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-07-24 22:55:12 -04:00
Glauber Costa
3c0982a01f create_table_statement: adjust _defined_ordering
First of all, we should abide by our convention of prepending member names with
a '_'. (That is the underline character, it just looks like a face)

But more importantly, because we will be searching its contents frequently, a
helper function is provided.

Note that obviously a hash is better suited for this: but because we do need to
keep the fields in order they are inserted, a vector really is the best choice
for that.

A table is not expected to have a lot of clustering keys. So this search should
be cheap. If it turns out to be a problem, we can adjust later.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-07-24 22:55:12 -04: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
Pekka Enberg
78840a690f cql3: Move ut_name implementation to .cc file
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-07-24 10:21:11 +02:00
Pekka Enberg
de6b38e316 cql3: Move column_identifier implementation to .cc file
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-07-24 10:21:11 +02:00
Pekka Enberg
872a7215b2 cql3: Separate column_identifier::raw class
Move column_identifier::raw class definition outside of
column_identifier class.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-07-24 10:21:11 +02:00
Pekka Enberg
1e5fad25d7 cql3: Move attributes implementation to .cc file
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-07-24 10:21:11 +02:00
Pekka Enberg
0e09b2769c cql3: Move abstract_marker implementation to .cc file
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-07-24 10:21:11 +02:00