Commit Graph

54 Commits

Author SHA1 Message Date
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
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
cbe1a3d403 schema: Introduce schema::get_column_definition() 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
64128dc117 cql3: Convert UpdateParameters 2015-01-29 18:55:24 +01:00
Tomasz Grabiec
333d1f259f Stub schema::is_dense() and schema::is_counter() 2015-01-29 18:55:24 +01:00
Tomasz Grabiec
34616107a9 Add column_definition::is_static() 2015-01-29 18:55:23 +01:00
Tomasz Grabiec
1cfcb5b09c Add column_definition.id
The ID will be used in mutation model.
2015-01-29 18:55:20 +01:00
Tomasz Grabiec
4d41d10d99 Extract schema to a separate class 2015-01-29 15:53:05 +01:00
Tomasz Grabiec
17b9babd91 Extract types related stuff from database.{cc,hh} to types.{cc,hh} 2015-01-29 15:02:19 +01:00
Tomasz Grabiec
c75468160a db: Use memcmp for comparing bytes
My bench-lie shows it's:
  - 1.2x faster for values of size 4 bytes
  - 4x faster for values of size 16 bytes
  - 9x faster for values of size 64 bytes
2015-01-29 14:43:36 +01:00
Asias He
8d737985b0 db: Convert db/composites/AbstractCType.java to C++ 2015-01-15 09:05:48 +08:00
Asias He
bf018615b8 Add abstract_type::is_byte_order_comparable 2015-01-15 09:05:48 +08:00
Asias He
20761a3cd9 Add abstract_type::is_compatible_with 2015-01-15 09:05:48 +08:00
Asias He
e4c7b77f1b Add abstract_type::validate_collection_member 2015-01-15 09:05:48 +08:00
Asias He
2dded3459a Add abstract_type::compare() 2015-01-15 09:05:48 +08:00
Asias He
18435837dd Add abstract_type::compare_unsigned() helper 2015-01-15 09:05:48 +08:00
Glauber Costa
7f96fc9509 db: read all keyspaces from directory structure
This patch includes a helper function that executes a function for each entry
in a directory. It is future based and can include in the future, future-based
code to asychronously read, for instance, an sstable.

At the moment, it only scan all keyspaces and make sure they appear in the
keyspaces hash.

Both the database and keyspace classes gain a populate<T> factory that returns a
populated database. At this point, the names found are just listed, but not really
stored anywhere.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-01-13 10:41:13 +02:00
Avi Kivity
99489ff580 db: add uuid type 2015-01-12 14:21:19 +02:00
Avi Kivity
30ba3ecea2 db: add runtime_exception class 2015-01-12 11:19:11 +02:00
Avi Kivity
df83ccec41 db: add bytes_opt (=optional<bytes>) 2015-01-12 11:18:47 +02:00
Avi Kivity
c05640fb5d db: add to_hex(bytes) 2015-01-12 11:18:25 +02:00
Avi Kivity
a7723cf641 db: add timestamp type
Based on db_clock::time_point
2015-01-11 15:46:03 +02:00
Avi Kivity
a5c98d32c3 db: add timeuuid type 2015-01-11 15:46:03 +02:00
Pekka Enberg
b3611b205d db: Add data_type::compose() function
It's part of the AbstractType class signature.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-01-07 17:05:28 +02:00
Pekka Enberg
7c38147c07 db: Add data_type::validate() stub
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-01-07 16:23:48 +02:00
Avi Kivity
aa1e02ab46 Merge branch 'types' into db
More type work.

Reviewed-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-01-07 13:57:15 +02:00
Avi Kivity
cfd86d70f8 db: extract default compare method into a default_less<> helper
The helper is a little more flexible in that it accepts a comparator,
instead of using <.
2015-01-06 15:26:45 +02:00
Avi Kivity
a191d598c2 db: implement boolean type 2015-01-06 15:26:40 +02:00
Glauber Costa
974278203c db: add datadir to the database
This is the directory from which we will read the sstables.
Code to actually parse them will come later.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-01-06 14:54:47 +02:00
Avi Kivity
e733c2a45a db: change abstract_type::deserialize to allow null objects
In some cases, deserialize() can return a null object (if there were zero
input bytes).

In others, it cannot (for string or blob types).

Change the return type to optional<any> and adapt the deserialiation code
to deal with it.
2015-01-06 12:49:47 +02:00
Avi Kivity
d5c9f66009 db: adjust abstract_type indentation 2015-01-05 15:56:29 +02:00
Avi Kivity
1fe6bf687d db: de-pimpl data_type
Since origin tends to cast around, we should allow that too, by exposing
the implementation type and using a shared_ptr instead of a value class.
2015-01-05 15:55:30 +02:00
Avi Kivity
80408329e0 db: rename data types to conform to origin conventions 2015-01-05 13:48:38 +02:00
Avi Kivity
d5491f87c5 db: add abstract_type alias 2015-01-05 13:30:50 +02:00
Avi Kivity
efc868d1e6 db: extend data_type to be able to support dynamic types
Dynamic types come and go, so they need to be reference counted.

Switch data_type to using a shared_ptr<> for its implementation.

Since thread_ptr is not thread safe, the global primitive types must be
thread_local.
2015-01-05 13:26:56 +02:00
Asias He
7d0ef20a80 Add comparator 2015-01-05 14:13:31 +08:00
Avi Kivity
3900173c75 db: add data_type_for<> helper
Converts C++ data type to corresponding data_type class, during compile time.
2014-12-31 16:07:50 +02:00
Avi Kivity
d19043fca2 db: add data_type::decompose
Convert any -> bytes.
2014-12-31 16:07:17 +02:00
Avi Kivity
f09684aba2 db: non-creating find_partition() and find_row()
Find a partition or row using the key, return null if not found.
2014-12-28 13:42:25 +02:00
Avi Kivity
45cd105571 db: sort column names
Cassandra allows even regular columns to be treated as a sorted map
(column name -> value), accessing it with get_slice(), so sort the column
names to support this.
2014-12-28 13:42:25 +02:00
Avi Kivity
58e64ea231 db: add helpers for finding/inserting a row or partition 2014-12-28 10:03:17 +02:00
Avi Kivity
de349cd205 db: store keys and values as serialized bytes, not boost::any
While less efficient, it's similar to what origin does, so will be easier
to follow.
2014-12-28 10:03:17 +02:00
Avi Kivity
ab26aef422 db: add data_type::less()
Compares two values belonging to a data type.
2014-12-28 10:03:17 +02:00
Avi Kivity
415b0f13ec db: add data_type::deserialize(bytes) helper 2014-12-28 10:03:17 +02:00
Avi Kivity
b3a189158b db: add helpers to convert strings to bytes 2014-12-28 10:03:17 +02:00
Avi Kivity
8bde5630f5 db: move row and partition classes around
Make 'data_type' visible to them.
2014-12-28 10:03:17 +02:00
Avi Kivity
36649c4b7d db: implement std::hash<data_type> 2014-12-28 10:03:17 +02:00