Commit Graph

1621 Commits

Author SHA1 Message Date
Pekka Enberg
bb981d4603 cql: Plug in ANTLR-generated CQL parser
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-02-06 10:06:01 +02:00
Pekka Enberg
c77b00b7d8 cql3: Convert top-level 'query' rule to C++
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-02-06 10:06:01 +02:00
Pekka Enberg
34018b2b65 shared_ptr: Fix assignment of polymorphic types
Fix the assignment operator to work with polymorphic types.

Suggested by Nadav.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-02-06 10:06:01 +02:00
Pekka Enberg
a6356bd55e cql: Use sstring instead of std::string
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-02-06 10:06:01 +02:00
Pekka Enberg
4732653538 basic_sstring: Add 'compare' and 'operator<'
Add string comparison functions to basic_sstring that are required for
C++ containers such as std::map and std::multimap.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-02-06 10:06:01 +02:00
Tomasz Grabiec
5a95524af0 Merge branch 'tgrabiec/cql3' from git@github.com:cloudius-systems/seastar-dev.git
CQL3 Conversions and fixes.
2015-02-05 09:55:08 +01:00
Tomasz Grabiec
bad22fe50e cql3: Convert ModificationStatement.Parsed.prepare()
Together with ParsedInsert descendant.
2015-02-04 10:29:05 +01:00
Tomasz Grabiec
89f924f9f9 cql3: Convert parts of SingleColumnRestriction 2015-02-04 10:29:05 +01:00
Tomasz Grabiec
86895390b8 cql3: Stub column_condition::prepare() 2015-02-04 10:29:05 +01:00
Tomasz Grabiec
af26be3e30 cql3: Expose base constructor in constants::setter 2015-02-04 10:29:05 +01:00
Tomasz Grabiec
25a435e398 cql3: Convert Operation::SetValue
I put it in a separate header, operation_impl.hh, to avoid cyclic
dependency between operation.hh and constants.hh.
2015-02-04 10:29:05 +01:00
Tomasz Grabiec
f5e427b80f cql3: Convert more from operation.hh 2015-02-04 10:29:05 +01:00
Tomasz Grabiec
9e6b4e823b cql3: Use move semantics where applicable 2015-02-04 10:29:04 +01:00
Tomasz Grabiec
5d50368f8c cql3: Stub column_condition::collect_marker_specificaton() 2015-02-04 10:29:04 +01:00
Tomasz Grabiec
609f6e0d31 schema: Add is_partition_key() tester 2015-02-04 10:29:04 +01:00
Tomasz Grabiec
77b37a7c03 schema: Add column_specification field to schema
In Origin, some places in CQL3 package treat ColumnDefinition as
ColumnSpecification. Origin solves that by making ColumnDefinition
extend ColumnSpecification.

I find it much simpler to provide an external adapter, which is cached
as a field for efficiency. Another, more important, reason for this
solution is that column_specifications are passed around as
shared_ptrs and I don't want to add unnecessary indirection to
column_definition accesses just because of that, to make it inherit
from column_specification.
2015-02-04 10:29:04 +01:00
Tomasz Grabiec
654372f368 schema: Allow regular column names to have arbitrary type
Regular columns may have names of arbitrary type. See
https://issues.apache.org/jira/browse/CASSANDRA-8178

Primary key columns are UTF8.

This change also does some refactoring of the schema object to make
the change easier to digest (more encapsulation).
2015-02-04 10:29:00 +01:00
Tomasz Grabiec
43dd9250b9 cql3: Expose more column_identifier constructors 2015-02-04 10:29:00 +01:00
Tomasz Grabiec
5d92ef267a types: Expand the interface of abstract_type 2015-02-04 10:29:00 +01:00
Tomasz Grabiec
e589d71a89 cql3: add missing virtual destructors 2015-02-04 10:29:00 +01:00
Tomasz Grabiec
78c6ef8497 cql3: Convert AbstractRestriction.java 2015-02-04 10:29:00 +01:00
Tomasz Grabiec
d243fb7a01 cql3: Pass sstrings as const& where applicable 2015-02-04 10:29:00 +01:00
Tomasz Grabiec
213d029a22 cql3: Make restriction::bounds() return a vector of optionals 2015-02-04 10:29:00 +01:00
Tomasz Grabiec
4478da3c45 cql3: make modification_statement::_column_operations mutable
Note: "final" in Java means that the reference can't change, but the
object pointed to by the reference can.
2015-02-04 10:29:00 +01:00
Tomasz Grabiec
602e6a9c17 cql3: Add missing default implementation of operation::requires_read() 2015-02-04 10:29:00 +01:00
Tomasz Grabiec
792c566c51 cql3: Convert SingleColumnRelation 2015-02-04 10:29:00 +01:00
Tomasz Grabiec
867ec42b59 cql3: Convert Relation 2015-02-04 10:29:00 +01:00
Tomasz Grabiec
ab17520a11 exception: Import UnrecognizedEntityException.java 2015-02-04 10:29:00 +01:00
Tomasz Grabiec
9d2d85ffe6 cql3: Convert Operator.java
"operator" is a reserved name in C++, so I decided to name this class
"operator_type".

Note: NEQ.reverse() returns NEQ in Origin. I'm not sure if it's a bug
or not, I replicated it as is.
2015-02-04 10:29:00 +01:00
Tomasz Grabiec
fc2d98431a cql3: Implement some to_string() methods 2015-02-04 10:29:00 +01:00
Tomasz Grabiec
88e276d272 Introduce to_string() working on vectors of printable 2015-02-04 10:28:59 +01:00
Tomasz Grabiec
3a6cb52c28 cql3: Make cql_statement::prepare() accept a database reference 2015-02-04 10:28:59 +01:00
Tomasz Grabiec
b7cf3a679d Convert ThriftValidation.validateColumnFamily(String,String)
Unlike origin, we don't use global singleton, but accept a database
reference instead.
2015-02-04 10:28:59 +01:00
Tomasz Grabiec
936587fa36 Extract code from validation.hh into .cc file 2015-02-04 10:28:59 +01:00
Tomasz Grabiec
8655825a2a cql3: Remove already converted code 2015-02-04 10:28:59 +01:00
Tomasz Grabiec
a0b04b9149 cql3: Fix typo 2015-02-04 10:28:59 +01:00
Tomasz Grabiec
cbe1a3d403 schema: Introduce schema::get_column_definition() 2015-02-04 10:28:56 +01:00
Tomasz Grabiec
212bb750ac cql3: Expose column_identifier::raw::prepare_column_identifier()
It's a workaround for C++ not supporting covariant return types with
smart pointers.

When callers know that they call prepare() on column_identifier, they
expect shared_ptr<column_identifier>. But prepare() comes form
abstract base class, and is defined to return shared_ptr<selectable>,
where "selectable" is ancestor of column_identifier.

We can avoid dynamic_cast<> here by calling a non-polymorphic
prepare_column_identifier() when the type is known.

Needed from modification_statement::parsed::prepare().
2015-02-04 10:28:56 +01:00
Tomasz Grabiec
6ba3732620 schema: Rename column_kind::PRIMARY -> column_kind::PARTITION
The old name was incorrect.
2015-02-04 10:28:51 +01:00
Tomasz Grabiec
e11e5ff269 cql3: Drop redundant optional<> 2015-02-04 10:28:51 +01:00
Tomasz Grabiec
5710a99f44 cql3: Fix mis-overrides of cql_statement::execute*()
The method may defer so the result is wrapped in future<>.

I think we don't need to wrap arguments in shared_ptr<> because they
may come from the request state object.
2015-02-04 10:28:51 +01:00
Tomasz Grabiec
ed0500e1cd tuple: Remove dead code 2015-02-04 10:28:51 +01:00
Tomasz Grabiec
25cdd44144 types: Fix compare_unsigned()
In lexicographical order length is compared second.
2015-02-04 10:28:51 +01:00
Tomasz Grabiec
1610a58293 types: Relax include 2015-02-04 10:28:47 +01:00
Tomasz Grabiec
a89ea75494 validation: Fix incorrect format specifier 2015-02-04 10:24:08 +01:00
Pekka Enberg
15ae102296 Fix startup error reporting if data directory is missing
If data directory does not exist, Urchin starts up without printing
anything and hangs. Make sure the error is shown to user by terminating
the application.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
2015-02-03 15:42:31 +01:00
Pekka Enberg
2a7da21481 CQL binary protocol
This patch implement initial support for CQL binary protocol versions 1,
2, 3, and 4. The CQL server is able to handshake with cqlsh and
cassandra-stress from Cassandra 2.1 which uses the STARTUP and OPTIONS
messages. Queries or other functionality is not supported.

To try it out, start Urchin:

  $ build/release/seastar --smp 1 --datadir data
  CQL server listening on port 9042 ...
  Thrift server listening on port 9160 ...

Then try to login with cqlsh:

  $ ./bin/cqlsh 127.0.0.1

Urchin side will fail with:

  CQL_VERSION => 3.2.0
  warning: ignoring event registration
  warning: ignoring query SELECT peer, data_center, rack, tokens, rpc_address, schema_version FROM system.peers
  seastar: cql/server.cc:222: future<> cql_server::connection::process_query(uint16_t, temporary_buffer<char>&): Assertion `0' failed.
  Aborted (core dumped)

TODO:

  - Compression is not supported.

  - Authentication is not supported.

  - Supported options are defined to make cqlsh and cassandra-stress
    happy. We really need to decide which CQL versions and compression
    algorithms we want to support.

  - std::string is used everywhere because sstring does not work with
    std::map, std::multimap, and others.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
2015-02-02 19:28:31 +01:00
Tomasz Grabiec
5049ed8ae6 Merge branch 'master' of github.com:cloudius-systems/seastar 2015-01-30 09:34:58 +01:00
Tomasz Grabiec
af7f315339 Merge branch 'tgrabiec/cql3' of github.com:cloudius-systems/seastar-dev
Mutation data model and cql3 conversions.
2015-01-30 08:42:49 +01:00
Tomasz Grabiec
e38fb6bdbf cql3: Convert DeleteStatement 2015-01-29 19:41:00 +01:00