Commit Graph

73 Commits

Author SHA1 Message Date
Pekka Enberg
3afd7f39b5 cql3: Wire up functions for floating-point types
Fixes #2168
Message-Id: <1489661748-13924-1-git-send-email-penberg@scylladb.com>
2017-03-16 11:04:59 +00:00
Pekka Enberg
be0351b49c cql3: Introduce raw_value and raw_value_view types
Currently, the code is using bytes_opt and bytes_view_opt to represent
CQL values, which can hold a value or null. In preparation for
supporting a third state, unset value introduced in CQL v4, introduce
new raw_value and raw_value_view types and use them instead.

The new types are based on boost::variant<> and are capable of holding
null, unset values, and blobs that represent a value.
2017-01-26 13:50:04 +02:00
Tomasz Grabiec
ddfee57c97 Replace iostream include with iosfwd in headers
Message-Id: <1484656119-8386-4-git-send-email-tgrabiec@scylladb.com>
2017-01-17 14:52:44 +02: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
78c6fdf429 cql3/functions: Fix is_pure() for native scalar functions
Every native scalar function is already tagged whether they're pure or
not but because we don't implement the is_pure() function, all functions
end up being advertised as pure. This means that functions like now()
that are *not* pure, end up being evaluated only once.

Fixes #571.
Message-Id: <1456227171-461-1-git-send-email-penberg@scylladb.com>
2016-02-23 12:37:32 +01:00
Tomasz Grabiec
9d11968ad8 Rename serialization_format to cql_serialization_format 2016-02-15 16:53:56 +01:00
Tomasz Grabiec
e061eb02df cql3: Avoid using partition_key::from_bytes()
serialize() and from_bytes() is a low level interface, which in this
case can be replaced with a partition_key static factory method
resulting in cleaner code.
2016-02-15 16:53:55 +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
Avi Kivity
91a8cfc029 cql3: don't declare counter-related functions
This works now, but fails when an in-progress patch I'm working on calls
one of the type's methods.
2015-10-30 09:06:48 +02:00
Avi Kivity
d5cf0fb2b1 Add license notices 2015-09-20 10:43:39 +03:00
Pekka Enberg
8307fe7c85 cql3: Kill Java code
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-08-24 11:15:41 +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
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
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
Calle Wilund
a18889380e cql3::functions::functions: dispatch token function 2015-07-08 10:02:31 +02:00
Calle Wilund
b17c3bf6df TokenFct Java->C++ 2015-07-08 10:02:31 +02:00
Paweł Dziepak
296a77b7f3 cql3: fix *asblob() and blobas*() functions names
Signed-off-by: Paweł Dziepak <pdziepak@cloudius-systems.com>
2015-07-08 10:02:30 +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
d50139351f cql3: Use pragma once everywhere
There's no benefit to using C include guards so switch to pragma once
everywhere for consistency.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-05-12 16:32:56 +03: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
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
d87fbe9eb8 cql3: Fix references to obsolete collection types
The code was using the wrong version of list_type_impl and
collection_type_impl.
2015-04-17 15:08:06 +02:00
Avi Kivity
5f05fa7087 cql3: move function_call.hh code to .cc file 2015-04-11 17:31:54 +03:00
Avi Kivity
e4276784b1 cql3: unprotect some 'class function' methods
'protected' is more strict in C++ than in Java, and these functions need
to be accessed from elsewhere.
2015-04-05 15:48:42 +03:00
Avi Kivity
adcd5e09c7 cql3: convert aggregate functions to serialization_format 2015-04-05 15:48:01 +03:00
Avi Kivity
86c09046fd cql3: allow null function arguments and return types
Change function argument types and return values to bytes_opt.

Note: a comment in the code says that NULL arguments are not supported,
but it seems prudent to prepare for the day they will be.
2015-04-03 12:16:19 +02:00
Avi Kivity
22ee20c751 cql3: move functions.hh code into .cc 2015-04-03 00:30:49 +03:00
Avi Kivity
4f3aaa988c cql3: make function_name friendlier to ANTLR
ANTLR wants default constructors, and to modify fields afterwards.
2015-04-01 21:02:00 +03:00
Avi Kivity
c2f3b90ef1 cql3: convert function_call.hh to C++ some more 2015-04-01 21:01:20 +03:00
Avi Kivity
89b3883783 cql3: fix too eager move in functions.hh
Can't use f and move it in the same expression.
2015-04-01 20:54:54 +03:00
Avi Kivity
db1df139e2 cql3: convert functions.hh to C++ some more 2015-04-01 20:52:21 +03:00
Avi Kivity
84b0a71716 cql3: convert function_name to C++ some more (native_function bits) 2015-04-01 20:49:35 +03:00
Avi Kivity
a59d8b384f cql3: convert scalar_functions from protocol_version to serialization_format 2015-04-01 20:48:07 +03:00
Avi Kivity
03bbcf55c2 cql3: fix max() function
Registration was done with a null shared_ptr<> instead of make_shared(),
and as a result the max template wasn't even instantiated, so it did not
even build.
2015-04-01 20:17:10 +03:00
Tomasz Grabiec
2902395129 Relax includes 2015-03-30 09:01:59 +02:00
Avi Kivity
579a794d14 cql3: de-virtualize cql3_type
cql3_type is a wrapper around data_type, so there's no need for a class
hierarchy -- anything that depends on the actual type can be forwarded
to abstract_type_impl.

We can now use this as a value type (dropping shared_ptr<cql3_type>), but
that is left for later.
2015-03-26 16:04:55 +01: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
Tomasz Grabiec
9e6b4e823b cql3: Use move semantics where applicable 2015-02-04 10:29:04 +01:00
Tomasz Grabiec
d243fb7a01 cql3: Pass sstrings as const& where applicable 2015-02-04 10:29:00 +01:00
Tomasz Grabiec
d8982abf81 cql3: Allow bind_and_get() to return an optional value
In Origin it can be null and it has a different meaning than empty
value. See org.apache.cassandra.cql3.Constants.Setter#execute.
2015-01-29 19:41:00 +01:00
Tomasz Grabiec
3c3e3e5140 cql3: add missing multi-inclusion guard to function_call.hh 2015-01-25 18:46:15 +01:00
Avi Kivity
dad0858f5f cql: partially convert Functions to C++ 2015-01-14 17:12:08 +02:00
Avi Kivity
08a7425b4a cql: fix minor build errors 2015-01-14 11:38:41 +02:00
Avi Kivity
3a039188cf cql: fix bytes_conversion_fcts build errors 2015-01-14 11:38:41 +02:00
Avi Kivity
2e6004a3ce cql: fix aggregate_fcts build errors 2015-01-14 11:38:41 +02:00
Avi Kivity
73d9d3fd64 cql: switch from unique_ptr<function> to shared_ptr<function>
The Functions class wants to store functions in a map and hand them out later,
so we need a shared_ptr.

(could have had a map of name -> function factory, maybe one day)
2015-01-14 11:38:41 +02:00
Avi Kivity
69f61e31ea cql3: convert BytesConversionFcts 2015-01-13 11:34:29 +02:00