Commit Graph

46 Commits

Author SHA1 Message Date
Tomasz Grabiec
4502f01581 thrift: Fix system_add_keyspace()
We should use the same UUID on each core for given column_family,
otherwise they will get different ids on each core.
2015-04-20 12:12:54 +02:00
Tomasz Grabiec
06f198b10c schema: Add id field
It uniquely identifies column_family globally. Will be used for
column_family lookups.
2015-04-15 20:33:48 +02:00
Avi Kivity
30b40bf7b1 db: make bytes even more distinct from sstring
bytes and sstring are distinct types, since their internal buffers are of
different length, but bytes_view is an alias of sstring_view, which makes
it possible of objects of different types to leak across the abstraction
boundary.

Fix this by making bytes a basic_sstring<int8_t, ...> instead of using char.
int8_t is a 'signed char', which is a distinct type from char, so now
bytes_view is a distinct type from sstring_view.

uint8_t would have been an even better choice, but that diverges from Origin
and would have required an audit.
2015-04-07 10:56:19 +03:00
Gleb Natapov
47ac784425 replication strategy
This patch converts (for very small value of 'converts') some
replication related classes. Only static topology is supported (it is
created in keyspace::create_replication_strategy()). During mutation
no replication is done, since messaging service is not ready yet,
only endpoints are calculated.
2015-04-02 16:16:39 +02:00
Calle Wilund
d3fe0c5182 Refactor db/keyspace/column_family toplogy
* database now holds all keyspace + column family object
* column families are mapped by uuid, either generated or explicit
* lookup by name tuples or uuid
* finder functions now return refs + throws on missing obj
2015-04-01 10:08:00 +02:00
Tomasz Grabiec
bdbd5547e3 db: Cleanup key names
clustering_key::one -> clustering_key
clustering_key::prefix::one -> clustering_key_prefix
partition_key::one -> partition_key
clustering_prefix -> exploded_clustering_prefix
2015-03-20 18:59:29 +01: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
1b1af8cdfd db: Introduce types to hold keys
Holding keys and their prefixes as "bytes" is error prone. It's easy
to mix them up (or use wrong types). This change adds wrappers for
keys with accessors which are meant to make misuses as difficult as
possible.

Prefix and full keys are now distinguished. Places which assumed that
the representation is the same (it currently is) were changed not to
do so. This will allow us to introduce more compact storage for non-prefix
keys.
2015-03-17 15:56:29 +01:00
Tomasz Grabiec
89aa2f75e5 thrift: Fix name clash between unimplemented() and namespace "unimplemented" 2015-03-11 14:56:10 +01:00
Avi Kivity
5902243dc5 Merge branch 'master' of github.com:cloudius-systems/seastar into db
Global adjustment due to the removal of future<>::rescue().
2015-03-05 11:00:11 +02:00
Avi Kivity
a49330095a db: wrap bytes in atomic_cell format
We use bytes for many different things, and it is easy to get confused as
to what format the data is actually in.

Fix that for atomic_cell by proving wrappers.  atomic_cell::one corresponds
to a bytes object holding exactly one atomic cell, and atomic_cell::view is
a bytes_view to an atomic_cell.  The static functions of atomic_cell itself
are privatized to prevent the unwashed masses from using them on the wrong
objects.

Since a row entry can hold either a an atomic cell, or a collection,
depending on the schema, also introduce a variant type
atomic_cell_or_collection and allow the user to pick the type explicitly.
Internally both are stored as bytes object.
2015-03-04 15:49:35 +02:00
Avi Kivity
1bf214b7df thrift: stop reading on short buffer
Fixes buffer overrun.  Should perhaps be part of read_exactly().
2015-03-01 17:14:25 +02:00
Tomasz Grabiec
74295a9759 db: Use opaque bytes for cell values instead of boost::any
Storing cells as boost::any objects makes us use expensive
boost::any_cast to access the data. This change replaces boost::any
with bytes object which holds the value in serialized form (the same
as will be used for on-wire format).

If the cell type is atomic, you use fields accessors defined in
atomic_cell class, eg like this:

if (column.type.is_atomic()) {
   if (atomic_cell::is_live(c) {
      auto timestamp = atomic_cell::timestamp(c);
      ...
   }
}

Eventually we could switch to a more officient semi-serialized form
with native byte order but I don't want to introduce it just yet for
simplicity.
2015-02-27 10:59:43 +01:00
Tomasz Grabiec
a61d9ee18e schema: Add static columns to schema 2015-02-27 10:48:56 +01:00
Avi Kivity
2720ba34bf db: shard data
Add database::shard_of() to compute the shard hosting the partition
(with a simplistic algorithm, but perhaps not too bad).

Convert non-metadata invoke_on_all() and local calls on the database
to use shard_of().
2015-02-23 11:37:12 +02:00
Avi Kivity
0db67ff121 thrift: add foreign_ptr<> variant to complete()
Some calls will return complex types, so allow them to return a foreign_ptr<>
to ensure cleanup will happen in the correct place.
2015-02-23 11:37:12 +02:00
Avi Kivity
cb63d16b40 thrift: get rid of useless try/catch
Exceptions are now handled with then_wrapped(), nothing is left to catch.
2015-02-19 18:00:03 +02:00
Avi Kivity
70381a6da5 db: distribute database object
s/database/distributed<database>/ everywhere.

Use simple distribution rules: writes are broadcast, reads are local.
This causes tremendous data duplication, but will change soon.
2015-02-19 17:53:13 +02:00
Avi Kivity
3ec83658f3 thrift: store the keyspace name in set_keyspace()
The keyspace pointer is only valid for the local shard.
2015-02-19 15:55:17 +02:00
Avi Kivity
93818692e1 thrift: add adapter from futures to thrift completion objects
Futures hold either a value or an exception; thrift uses two separate
function objects to signal completion, one for success, the other for
an exception.

Add a helper to pass the result of a future to either of these.
2015-02-19 09:32:18 +02:00
Avi Kivity
96a93a2d8c thrift: add workaround for compile breakage due to thrift code generator 2015-02-19 09:32:18 +02:00
Tomasz Grabiec
2244eab6c1 db: Steal data from mutations when applying
Taking mutations by r-value reference allows us to avoid copies.
2015-02-09 10:28:44 +01:00
Tomasz Grabiec
48c11a01db db: Add ability to apply mutations into the database
For simplicity partition data is stored using the same object which is
used for mutations: mutation_partition. Later we can introduce a more
efficient version.
2015-02-09 10:28:44 +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
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
ef430a605c db: Convert ThriftValidation 2015-01-29 19:40:07 +01:00
Tomasz Grabiec
69ba3de601 thrift: Import ThriftValidation.java 2015-01-29 19:40:07 +01:00
Tomasz Grabiec
4d41d10d99 Extract schema to a separate class 2015-01-29 15:53:05 +01:00
Avi Kivity
d5540bf3da Merge branch 'master' into db 2015-01-27 15:09:31 +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
80408329e0 db: rename data types to conform to origin conventions 2015-01-05 13:48:38 +02:00
Avi Kivity
1b837160f1 thrift: drop unneeded using declaration 2015-01-05 13:26:55 +02:00
Avi Kivity
833d5c2262 thrift: fix get_slice column index calculations
Both lower and upper bound calculations were broken.

Fix by using iterators instead of calculating indices using std::distance().
2014-12-30 15:34:27 +02:00
Avi Kivity
1ce15a9466 thrift: partial support for get_slice() 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
2af5cee699 thrift: drop use of scattered_message
The code attempts to use scattered_message::append_static() to gain zero
copy, claiming that _output protects the data's lifetime, but that's a
false claim - it will remain in the transmit queue waiting for an ACK
while we process (and respond to) the next request.

Fix by just writing the output naturally.  We may zero-copy support later,
though it is dubious it will help thrift, as the code is full of copies
and atomics.
2014-12-28 13:42:25 +02:00
Avi Kivity
39176a9439 thrift: partially implement batch_mutate()
Only mutate case (not deletion) for ordinary columns.
2014-12-28 10:03:17 +02:00
Avi Kivity
baa16f6692 thrift: stub execute_cql3_query()
Allows us to proceed further with cassandra-stress.
2014-12-28 10:03:17 +02:00
Avi Kivity
9951a68836 thrift: add exception helpers
Thrift-generated exceptions lack reasonable constructors, so add helpers.
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
a7360a3ce1 thrift: implement set_keyspace RPC 2014-12-24 09:40:52 +02:00
Avi Kivity
72ab87f41f thrift: support system_add_keyspace 2014-12-23 18:41:29 +02:00
Avi Kivity
4a3f3847e8 thrift: support set_cql_version 2014-12-23 18:41:29 +02:00
Avi Kivity
a49fd99327 thrift: create a database and pass it to the server
Not sharded yet.
2014-12-23 18:41:29 +02:00
Avi Kivity
094329a95e Move apps/seastar/* to top level 2014-12-22 16:15:37 +02:00