Commit Graph

54 Commits

Author SHA1 Message Date
Paweł Dziepak
fce6e0987f cql3: selection: do not panic when seeing counters
At this stage counters cells are already long_type values, so no special
handling is necessary.
2017-02-02 10:35:14 +00:00
Tomasz Grabiec
bc6486b304 Use gc_clock instead of db_clock where possible
Some code paths were obtaining db_clock timestamp to only convert it
to gc_clock later. Avoid this. In the future we could make gc_clock
cheaper cause it has low precision.

Message-Id: <1482401190-2035-1-git-send-email-tgrabiec@scylladb.com>
2016-12-22 13:27:55 +02:00
Pekka Enberg
e1e8ca2788 cql3: Fix selecting same column multiple times
Under the hood, the selectable::add_and_get_index() function
deliberately filters out duplicate columns. This causes
simple_selector::get_output_row() to return a row with all duplicate
columns filtered out, which triggers and assertion because of row
mismatch with metadata (which contains the duplicate columns).

The fix is rather simple: just make selection::from_selectors() use
selection_with_processing if the number of selectors and column
definitions doesn't match -- like Apache Cassandra does.

Fixes #1367
Message-Id: <1477989740-6485-1-git-send-email-penberg@scylladb.com>
2016-11-01 09:09:01 +00:00
Duarte Nunes
cb0516a76c schema: Remove compact_column concept
This is a confusing one, and can be replaced the fact that dense
schemas have a single regular column.

Ref #1542

Signed-off-by: Duarte Nunes <duarte@scylladb.com>
2016-08-03 17:21:41 +00:00
Duarte Nunes
529c3a3ae6 column_kind: Drop compact_column
A compact column is a dense schema's single regular column. The fact
that it is a different column_kind has lead to various bugs (#1535,
derived by the schema being dense and the column being regular.

Fixes #1542

Signed-off-by: Duarte Nunes <duarte@scylladb.com>
2016-08-03 17:21:37 +00:00
Avi Kivity
0135b4d5cd cql3: constify metadata users
Metadata usually doesn't change after it is created; make that visible in
the code, allowing further optimizations to be applied later.
Message-Id: <1464334638-7971-3-git-send-email-avi@scylladb.com>
2016-05-31 09:12:11 +03:00
Gleb Natapov
f3b515052b udt: fix error generation if accessed type is not udt
Fixes #1198
Message-Id: <1460884314-3717-2-git-send-email-gleb@scylladb.com>
2016-04-18 12:45:03 +03:00
Duarte Nunes
ece89069dd udt: Implement to_string() for selectable
Signed-off-by: Duarte Nunes <duarte@scylladb.com>
Message-Id: <1460884314-3717-1-git-send-email-gleb@scylladb.com>
2016-04-18 12:44:48 +03: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
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
9d11968ad8 Rename serialization_format to cql_serialization_format 2016-02-15 16:53:56 +01:00
Tomasz Grabiec
916a91c913 query: Split send_timestamp_and_expiry into two separate options
It's cleaner that way. They don't need to come together.
2016-02-15 16:53:56 +01:00
Paweł Dziepak
ed7d9d4996 schema: change has_collections() to has_multi_column_collections()
All users of schema::has_collections() aren't really interested in
frozen ones.

Signed-off-by: Paweł Dziepak <pdziepak@scylladb.com>
2016-01-05 10:46:42 +01:00
Paweł Dziepak
3287022000 cql3: do not assume that clustering key is full
In case of schemas that use compact storage it is possible that trailing
components of clustering keys are not set.

Signed-off-by: Paweł Dziepak <pdziepak@scylladb.com>
2015-12-10 05:46:26 +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
Calle Wilund
4a1a17defc cql3::selection: Move result set building visitor to result_set_builder
Allows its use (and partial override - hint hint) in more place than
one.
2015-11-10 13:12:33 +01:00
Calle Wilund
23b6240dad cql3::selection: Fix some constness correctness 2015-11-10 13:12:33 +01:00
Avi Kivity
d5cf0fb2b1 Add license notices 2015-09-20 10:43:39 +03: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
a6d0ed205b cql3: use api::missing_timestamp for missing timestamps
A missing timestamp is a missing one, not the smallest one.

Signed-off-by: Paweł Dziepak <pdziepak@cloudius-systems.com>
2015-07-16 16:23:03 +02:00
Pekka Enberg
11b633208d cql3: Remove Java imports from C++ files
Remove left-over Java imports from files that are already translated to
C++.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-05-12 16:41:12 +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
Tomasz Grabiec
5ba1486ae7 db: Rename "ttl" to "expiry" when it's used as time point
To avoid confusion with "ttl" the duration.
2015-05-06 17:27:22 +02:00
Avi Kivity
6290dee438 db: const correctness for abstract_type and friends
Types are immutable.
2015-04-29 15:40:38 +03:00
Tomasz Grabiec
731a63e371 schema: Embed raw_schema inside schema
Public fields got encapsulated.
2015-04-24 18:01:01 +02:00
Avi Kivity
f841a05475 cql3: convert selectable::with_field_selection to C++
Due to circular dependencies (selectable::with_field_selection ->
  column_identifier -> selectable) a new header file was created.
2015-04-20 16:15:34 +03:00
Avi Kivity
fa961f1e5e cql3: convert field_selector to C++ 2015-04-20 16:15:34 +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
ee906471ab cql3: Move method implementations to .cc 2015-04-15 20:44:59 +02:00
Tomasz Grabiec
00f99cefd4 db: split query.hh to reduce header dependencies 2015-04-15 20:44:59 +02:00
Tomasz Grabiec
878a740b9d db: Write query results in serialized form
This gives about 30% increase in tps in:

  build/release/tests/perf/perf_simple_query -c1 --query-single-key

This patch switches query result format from a structured one to a
serialized one. The problems with structured format are:

  - high level of indirection (vector of vectors of vectors of blobs), which
    is not CPU cache friendly

  - high allocation rate due to fine-grained object structure

On replica side, the query results are probably going to be serialized
in the transport layer anyway, so this change only subtracts
work. There is no processing of the query results on replica other
than concatenation in case of range queries. If query results are
collected in serialized form from different cores, we can concatenate
them without copying by simply appending the fragments into the
packet. This optimization is not implemented yet.

On coordinator side, the query results would have to be parsed from
the transport layer buffers anyway, so this also doesn't add work, but
again saves allocations and copying. The CQL server doesn't need
complex data structures to process the results, it just goes over it
linearly consuming it. This patch provides views, iterators and
visitors for consuming query results in serialized form. Currently the
iterators assume that the buffer is contiguous but we could easily
relax this in future so that we can avoid linearization of data
received from seastar sockets.

The coordinator side could be optimized even further for CQL queries
which do not need processing (eg. select * from cf where ...)  we
could make the replica send the query results in the format which is
expected by the CQL binary protocol client. So in the typical case the
coordinator would just pass the data using zero-copy to the client,
prepending a header.

We do need structure for prefetched rows (needed by list
manipulations), and this change adds query result post-processing
which converts serialized query result into a structured one, tailored
particularly for prefetched rows needs.

This change also introduces partition_slice options. In some queries
(maybe even in typical ones), we don't need to send partition or
clustering keys back to the client, because they are already specified
in the query request, and not queried for. The query results hold now
keys as optional elements. Also, meta-data like cell timestamp and
ttl is now also optional. It is only needed if the query has
writetime() or ttl() functions in it, which it typically won't have.
2015-04-15 20:44:50 +02:00
Tomasz Grabiec
a22a9bd3fb cql3: Cache contains_static_columns() 2015-04-15 20:33:49 +02:00
Tomasz Grabiec
f9afd82231 cql3: Remove unnecessary indirection to result_set_builder 2015-04-15 20:33:49 +02:00
Tomasz Grabiec
4f774c3053 cql3: Reset timestamp and ttl when adding missing cell 2015-04-15 20:33:48 +02:00
Avi Kivity
33038a625f cql3: convert selectable::writetime_or_ttl to C++
Moved to new file to avoid cyclic dependencies.
2015-04-07 16:17:56 +03:00
Avi Kivity
1f15b4a73e cql3: convert writetime_or_ttl_selector to C++ 2015-04-07 16:17:56 +03:00
Avi Kivity
ae5c847326 cql3: add timestamp and ttl accessors to result_set 2015-04-07 16:17:56 +03:00
Avi Kivity
aa0e7c4b23 cql3: fix result_set_builder skipping empty rows
result_set_builder's API is:

  new_row
  add
  add
  add
  new_row
  add
  add
  add
  new_row
  add
  add
  add
  build

Since there is no end_row, it relies on an internal flag to see (in new_row
and in build) whether we need to end a previous row.  The problem is that
we check if the row is empty(), which is true both for the first row, and
for an empty row (if add() is never called, e.g. "SELECT COUNT(*) FROM tab".

Fix by using optional<> to mark whether the row exists (new_row has been
called).  This is ugly, but matches origin.  We should improve that by
adding an explicit end_row().
2015-04-06 19:04:39 +03:00
Avi Kivity
58dda6256e cql3: convert selectable::with_function to C++ 2015-04-05 16:07:31 +03:00
Avi Kivity
48978fd0b4 cql3: convert *_function_selector to C++
Due to cyclic dependencies, three classes are converted at once:

  abstract_function_selector
  scalar_function_selector
  aggregate_function_selector
2015-04-05 16:07:31 +03:00
Avi Kivity
8c60bf0495 cql3: move some selector.hh code to .cc
Breaks cyclic dependencies on column_identifier.
2015-04-05 16:07:31 +03:00
Avi Kivity
31d44569ca cql3: make selector::column_name() return by value
Returning by reference only works for simple cases, not for function
selectors.
2015-04-05 15:58:03 +03:00
Avi Kivity
874249800d cql3: provide ostream operator for assignment_testable
To prevent name clashes, we don't call the virtual function implementing
this to_string(), but rather assignment_testable_source_context(), as its
use will be error reporting.
2015-04-01 20:12:39 +03:00
Avi Kivity
9eeb35b5b3 cql3: support collections in result_set 2015-03-30 14:28:16 +03:00
Avi Kivity
86f378e4d7 cql3: convert result set to use serialization format rather than protocol_version 2015-03-30 14:28:16 +03:00
Tomasz Grabiec
2902395129 Relax includes 2015-03-30 09:01:59 +02:00
Tomasz Grabiec
90298af614 db: Cleanup atomic_cell naming
atomic_cell -> atomic_cell_type
atomic_cell::one -> atomic_cell
atomic_cell::view -> atomic_cell_view
2015-03-20 18:59:29 +01:00
Tomasz Grabiec
8912417dd0 cql3: Convert classes from org.cassandra.cql3.selection package 2015-03-11 14:56:10 +01:00
Pekka Enberg
d895a5768b cql3: Convert RawSelector to C++
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-02-06 10:46:12 +02:00
Tomasz Grabiec
159099e854 cql3: use our schema classes instead of the converts from config:: 2015-01-29 18:55:24 +01:00