Commit Graph

35 Commits

Author SHA1 Message Date
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
Calle Wilund
0f5ca342b8 lists.cc: setter_by_uuid does not require read before execute
Fixes #1082

Setting by UUID does not need existing data in list,
so need no read before execute

Message-Id: <1459325931-16387-1-git-send-email-calle@scylladb.com>
2016-03-30 11:24:20 +03:00
Calle Wilund
71170f51a8 cql3::lists: Add setter_by_uuid operation
Allows direct setting of list element by UUID key
2016-03-21 12:28:36 +00:00
Calle Wilund
8575f1391f lists.cc: fix update insert of frozen list
Fixes #967

Frozen lists are just atomic cells. However, old code inserted the
frozen data directly as an atomic_cell_or_collection, which in turn
meant it lacked the header data of a cell. When in turn it was
handled by internal serialization (freeze), since the schema said
is was not a (non-frozen) collection, we tried to look at frozen
list data as cell header -> most likely considered dead.
Message-Id: <1457432538-28836-1-git-send-email-calle@scylladb.com>
2016-03-08 13:48:45 +01:00
Tomasz Grabiec
63006e5dd2 query: Serialize collection cells using CQL format
We want the format of query results to be eventually defined in the
IDL and be independent of the format we use in memory to represent
collections. This change is a step in this direction.

The change decouples format of collection cells in query results from
our in-memory representation. We currently use collection_mutation_view,
after the change we will use CQL binary protocol format. We use that because
it requires less transformations on the coordinator side.

One complication is that some list operations need to retrieve keys
used in list cells, not only values. To satisfy this need, new query
option was added called "collections_as_maps" which will cause lists
and sets to be reinterpreted as maps matching their underlying
representation. This allows the coordinator to generate mutations
referencing existing items in lists.
2016-02-15 17:05:55 +01:00
Tomasz Grabiec
383296c05b cql3: Fix handling of lists with static columns
List operations and prefetching were not handling static columns
correctly. One issue was that prefetching was attaching static column
data to row data using ids which might overlap with clustered columns.

Another problem was that list operations were always constructing
clustering key even if they worked on a static column. For static
columns the key would be always empty and lookup would fail.

The effect was that list operations which depend on curent state had
no effect. Similar problem could be observed on C* 2.1.9, but not on 2.2.3.

Fixes #903.
2016-02-15 17:05:55 +01:00
Tomasz Grabiec
9d11968ad8 Rename serialization_format to cql_serialization_format 2016-02-15 16:53:56 +01:00
Avi Kivity
79f7431a03 db: change collection_mutation::{one,view} not to use nested classes
Nested classes cannot be forward-declared, so change the naming
not to use them.  Follows atomic_cell{,_view}.
2015-11-13 17:13:07 +02: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
f4849000c8 cql3: Fix exception message in lists::setter_by_index::execute()
Spotted by C* unit tests.

Signed-off-by: Pekka Enberg <penberg@scylladb.com>
2015-10-29 15:36:56 +02:00
Pekka Enberg
6634f37464 cql3: Fix exception message in lists::discarder_by_index::execute()
Spotted by C* unit tests.

Signed-off-by: Pekka Enberg <penberg@scylladb.com>
2015-10-29 15:36:51 +02:00
Avi Kivity
d5cf0fb2b1 Add license notices 2015-09-20 10:43:39 +03: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
Pekka Enberg
f3118755f8 cql3: Use "auto" for bind_and_get() return value assignment
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-08-24 09:06:13 +03:00
Pekka Enberg
6dee204db2 cql3/query_options: Store values as bytes view
Store values as bytes view when possible. This improves the CQL protocol
option parsing path by avoiding allocating memory and copying individual
values as "bytes" objects.

Please note that we retain the non-view version for internal queries
where performance is not as important.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-08-24 09:06:13 +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
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
6788a7afdb cql3: remove tombstone argument from do_{add, put, append}
Signed-off-by: Paweł Dziepak <pdziepak@cloudius-systems.com>
2015-07-22 15:30:13 +02:00
Paweł Dziepak
69d0eba9c7 cql3: fix setting collections to null
Before this patch the tombstone created in setter::execute() was never
applied if the new collection value was null.

Signed-off-by: Paweł Dziepak <pdziepak@cloudius-systems.com>
2015-07-22 15:29:54 +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
ab60ed8813 db: s/shared_ptr<abstract_type>/data_type/
Also replace derived types (map_type, collection_type, etc.).

As we'll change data_type's definition, this reduces the number of places
that need to be modified later, and is more readable.
2015-04-29 15:09:04 +03:00
Avi Kivity
abca68458e cql3: convert lists::prepender to C++
Note the original code contains a bug, causing the prepended literal to
be reversed.  The conversion (and Origin) are fixed.
2015-04-28 12:13:38 +03:00
Avi Kivity
4736504f4a cql3: convert lists::marker::bind() to C++ 2015-04-28 12:13:38 +03:00
Avi Kivity
9131c094a7 cql3: convert lists::precision_time to C++ 2015-04-28 12:13:38 +03:00
Avi Kivity
dc9e705952 cql3: convert lists::appender to C++ 2015-04-27 14:53:51 +03:00
Tomasz Grabiec
1c3275c950 mutation: Encapsulate fields 2015-04-24 18:01:01 +02: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
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
6a89d8291f cql3: fix multi_item_terminal::get_elements() signature
A tuple is a multi_item_terminal that can contain NULLs, so we need to
return a vector of bytes_opt, not bytes.

Unfortunately the lists code needs to be uglified as a result.
2015-04-15 15:35:30 +03:00
Avi Kivity
5f7f925ca0 cql3: convert lists::discarder_by_index to C++ 2015-04-12 15:13:54 +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
aab6d7a173 cql3: convert lists::discarder to C++
And wire it up.
2015-03-30 14:28:16 +03:00
Tomasz Grabiec
f469dd1234 cql3: Fix setter_by_index::execute() to work with empty cells
The list cell may be not set, in which case we should reurn an error
to the user. Current implementation of get_prefetched_list() was
returning collection_mutaion::view in this case, which had an empty
view. Deserialization is not prepared to get an empty view though. I
think we can stick with having non-empty views in the general case and
return an optional in get_prefetched_list().
2015-03-30 09:07:01 +02: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
79d1980aa3 cql3: move lists.hh code into .cc file 2015-03-24 14:38:55 +02:00