Commit Graph

83 Commits

Author SHA1 Message Date
Glauber Costa
cb4a4e4ce3 schema: fix regular column count
There is a small but potentially serious mistake in the way we are computing
the number of regular columns. We are using an incorrect offset, and the
number of regular columns in a table like this:

    schema(...,
            {{"pk", utf8_type}},
            {{"ck", utf8_type}, {"ck2", utf8_type}},
            {
                {"reg1", long_type},
                {"reg2", long_type},
            },
            {{"static", utf8_type}},
            utf8_type,
            "comment"
    );

is being reported as 3.

Fix this

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-08-01 10:11:59 +03:00
Tomasz Grabiec
c68c37ae2f Revert "schema: support dropped columns"
This reverts commit 9887bc5f5f.

Breaks "CREATE TABLE" statement.
2015-07-30 10:56:01 +02:00
Glauber Costa
9887bc5f5f schema: support dropped columns
Because we don't support alter table, we won't have anyone actually manipulating this.
But we will set up so it appears properly as an empty map in queries.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-07-29 18:44:59 -04: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
438a3f8619 storage_proxy: move speculative_retry type to schema
It will be stored in the schema, so move there, where it belongs.  We'll need
to do more than just store a type, so provide a class that encapsulates it.

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
6624dd7491 schema: add default value to compaction strategy class
Because we will do from and to sstring operations on it, it needs
a default value. The lack of it is causing our tests to fail.

This should have been included in the original patch but I have somehow
missed it. Sorry.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-07-23 20:34:20 +03:00
Glauber Costa
2c3463cf1f schema: handle compaction strategy options
We will store the options in the schema, but it is not yet used by
the compaction code.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-07-23 00:02:11 -04:00
Glauber Costa
d1496944d9 sstables: handle compaction strategy
Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-07-23 00:02:11 -04:00
Glauber Costa
5cc955d69c comparator: functions to manipulate a compound type
Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-07-22 23:10:21 -04:00
Glauber Costa
ddf6a2d8d5 schema: add a new column_kind
Origin has another column_kind, that we lack: compact_value. This kind is
used to identify regular columns of dense tables.

Take for instance, the following table:

CREATE TABLE ks2.compact (
    ks text,
    cl1 text,
    cl2 text,
    PRIMARY KEY (ks, cl1)
) WITH COMPACT STORAGE

cqlsh> select keyspace_name, columnfamily_name, column_name, type from system.schema_columns \
       where keyspace_name='ks2' and columnfamily_name='compact';

 keyspace_name | columnfamily_name | column_name | type
---------------+-------------------+-------------+----------------
           ks2 |           compact |         cl1 | clustering_key
           ks2 |           compact |         cl2 |  compact_value
           ks2 |           compact |          ks |  partition_key

We will treat those columns as regular columns for most purposes. Because of
that, we don't need to separate them from the regular columns when we sort
initially, for instance. All we have to do is change its type.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-07-22 23:10:21 -04:00
Glauber Costa
10436c29c1 thrift: implement compound comparator test
Now that we do that for the main schema, we can just copy the result for
thrift.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-07-22 23:10:20 -04:00
Glauber Costa
aa4b1dcc58 schema: add a field for compound
We are deviating a bit from Origin here: In Origin, we would store a full
comparator class. However, due to the fact that our types are very different,
and as a consequence we will not call a serializer directly on the cell name,
that is not necessary.

The only information that we will need to store is whether or not the table is
compound. Some functions to manipulate it will be presented in the next patch.
Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-07-22 23:09:05 -04:00
Raphael S. Carvalho
e57fe36249 compaction: get compaction threshold from schema instead
Get values from cf->schema instead of using hardcoded threshold
values. In addition, move DEFAULT_MIN_COMPACTION_THRESHOLD and
DEFAULT_MAX_COMPACTION_THRESHOLD to schema.hh so as not to have
knowledge duplicated.

Signed-off-by: Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
2015-07-22 18:03:23 +03:00
Glauber Costa
443178ef81 schema: remove set_default_time_to_live
Make calls go through the builder. Current caller is patched.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-07-17 20:40:40 -04:00
Glauber Costa
8b68fb5ff6 schema: remove set_gc_grace_period
Make all callers go through the builder. Current callers - there are many
in the system tables code, are patched.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-07-17 20:40:40 -04:00
Glauber Costa
4d6457ba18 schema: remove set_comment
There are no more callers left, all already happens through the builder.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-07-17 20:29:21 -04:00
Glauber Costa
2d1561d4d2 schema: remove set_id
Pass it through the builder. Existing caller is patched.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-07-17 20:29:21 -04:00
Glauber Costa
75ffcefd90 schema: remove set_compressor_params
use the builder instead. Sole current user is patched

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-07-17 20:29:21 -04:00
Glauber Costa
d3e539e868 schema: delete set_bloom_filter_fp_chance
We do this through the builder now, and there are no more callers to
this one.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-07-17 20:29:21 -04:00
Paweł Dziepak
54268889a1 schema: allow specifying column component index
The order of columns that belong to partition key or clustering key
needs to be preserved.

Signed-off-by: Paweł Dziepak <pdziepak@cloudius-systems.com>
2015-07-14 19:34:27 +02:00
Glauber Costa
39ca76fd03 schema: allow for the setting of default time to live
We have been leaving all the setter functions in the schema_builder, which is
usually fine.

The system tables, however, are not built this way, which means we need set
properties needed by them in some other way.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-07-13 23:58:03 -04:00
Glauber Costa
5165e8b439 schema: allow for the setting of gc grace period
We have been leaving all the setter functions in the schema_builder, which is
usually fine.

The system tables, however, are not built this way, which means we need set
properties needed by them in some other way.

Most properties are right there in the constructor, but I argue that this one
does not belong there.

Instead, provide a set method so that the system tables which need it can call.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-07-13 23:30:27 -04:00
Glauber Costa
fe370ec848 schema: read_repair_chance
Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-07-10 10:29:02 -04:00
Glauber Costa
ea17f6d76f schema: max and min index interval
Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-07-10 10:29:02 -04:00
Glauber Costa
aa270a149f schema: compaction strategy
Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-07-10 10:29:02 -04:00
Glauber Costa
b75bd9ef53 schema: add local_repair_chance parameter
Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-07-10 10:29:02 -04:00
Glauber Costa
8218c819a5 schema: access gc_grace_seconds
Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-07-10 10:29:02 -04:00
Glauber Costa
f84148c335 schema: support cf type, and is_super
All CFMetaData has a type, either Standard or Super. Right now, we do not
support Super, but we still would like to query for it, and use that information
to build our schemas.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-07-10 10:29:02 -04:00
Glauber Costa
9a691503ff add default_validator to schema_builder
We eventually need to wire them all up. This one is needed for describe
keyspaces to work.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-07-09 00:12:08 -04:00
Calle Wilund
9c4c9eff50 schema: add outstream << op to print column_definition pointers
- since these are typically non-smart.
2015-07-08 10:02:31 +02:00
Pekka Enberg
86d913954a db/legacy_schema_tables: Store CF "is_dense" to system tables
Persist column family's "is_dense" value to system tables. Please note
that we throw an exception if "is_dense" is null upon read. That needs
to be fixed later by inferring the value from other information like
Origin does.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-07-07 12:36:50 +02:00
Pekka Enberg
c24b7d42ce db/legacy_schema_tables: Store CF key validator in system tables
Store the column family key validator in system tables. Please note that
we derive the validator from CQL partition keys and never actually read
it from the database. This is different from Origin which uses
CompositeType that is both stored and read from the system tables.

Fixes #7.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
Tested-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-07-06 20:33:05 +03:00
Paweł Dziepak
89ede1fc00 schema: rename [set, get]_compressor to [set, get]_compressor_params
Compressor type is only a part of the information kept in compressor
parameters and things like schema.get_compressor().get_compressor()
do not look very good.

Signed-off-by: Paweł Dziepak <pdziepak@cloudius-systems.com>
2015-06-25 17:05:53 +02:00
Paweł Dziepak
51e3f2bcea cql3: use default compressor if none specified
Signed-off-by: Paweł Dziepak <pdziepak@cloudius-systems.com>
2015-06-25 14:17:46 +02:00
Paweł Dziepak
6845cc0ee5 cql3: propagate compression info to schema and sstables code
Signed-off-by: Paweł Dziepak <pdziepak@cloudius-systems.com>
2015-06-25 13:33:00 +02:00
Paweł Dziepak
c5e617ea78 schema: add NAME_LENGTH constant
It's probably not the best place for this constant, but that's where
it is in origin.

Signed-off-by: Paweł Dziepak <pdziepak@cloudius-systems.com>
2015-06-23 16:17:45 +02:00
Pekka Enberg
9ea291deb3 schema: Add column_definition::position() helper
Add a position() helper function that returns component index if there
is one and zero if there isn't. This is similar to what
ColumnDefinition.position() does in Origin. We will use this for a table
creation mutation.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-06-17 11:18:53 +02:00
Raphael S. Carvalho
d1ed0744f0 schema: add sstable compressor property
The field compressor is about saying which compressor algorithm
must be used in compression of sstable data file.
This is a small step towards compressed sstable data file.

Signed-off-by: Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
2015-06-09 11:18:56 +03:00
Pekka Enberg
5df4b51589 schema: Add comparison operators for column_definition and schema
Table merging code needs to compare schema_ptrs for equality so add
comparison operators for column_definition and schema classes.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-06-08 14:42:36 +03:00
Calle Wilund
71d4f3fb9b Add column_definition::is_on_all_components()
Most likely an incomplete emulation of the origin behaviour, but maybe
sufficient for now.
2015-06-03 10:13:53 +02:00
Calle Wilund
15b8267dab Add thrift_schema and placeholder "has_compound_comparator()"
thrift_schema == place to collect thrift compatibility aspects of
schema definition.
2015-06-03 10:13:53 +02:00
Calle Wilund
3b6fc56cb5 Make schema_builder constructible from schema
* Make schema_builder use schema::raw_schema to ensure it carries the
same info
* Make it constructible from schema to allow modify-replace flows
2015-06-02 11:22:42 +02:00
Calle Wilund
20648b242a Schema: make columns single vector
* Keep all column_definitions in single, sorted vector + offsets for
  specific types
* Make schema constructible from raw_schema
2015-06-02 11:22:42 +02:00
Calle Wilund
138ca9d2cd Add index_info + use in column_definition 2015-06-02 11:22:42 +02:00
Calle Wilund
1d30b85ac6 Unify column_definition::column_kind and ::column_kind enums 2015-06-02 11:22:41 +02:00
Glauber Costa
64d1538b7c schema: add filter false positive chance
Add methods to get and manipulate the current bloom filter false positive
chance - this is a per-cf field that lives in CFMetaData for Origin, so we'll
have it in the schema.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-05-17 12:38:36 +03:00
Avi Kivity
bc669add40 schema: const correctness
Make schema accessors const, and make schema_ptr refer to a const schema.
2015-05-06 13:52:59 +02: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
Tomasz Grabiec
ac576bf1dc schema: Remove thrift_schema
It's not used for anything so it only causes confusion.
2015-04-29 10:21:40 +03:00