Commit Graph

58 Commits

Author SHA1 Message Date
Tomasz Grabiec
cce2c648c5 Merge branch 'dev/gleb/for_urchin' from seastar-dev.git
Beginning of read implementation for range queries from Gleb.
2015-07-15 12:53:43 +03:00
Gleb Natapov
253ba71747 add comparison functions for ring_position
Two ring_positions are equal if tokens and keys are equal or tokens are
equal and one or both of them do not specify key. So ring_positions
without a key is a wildcard that equals any ring_positions with the same
token.
2015-07-15 12:41:31 +03:00
Tomasz Grabiec
0a4651cd28 dht: Add field getters to decorated_key 2015-07-14 19:57:37 +02:00
Gleb Natapov
49fb10d640 improve token printout
Add min/max token printout
2015-07-14 12:21:42 +03:00
Paweł Dziepak
351b113913 dht: allow configuration file to choose partitioner
Signed-off-by: Paweł Dziepak <pdziepak@cloudius-systems.com>
2015-07-12 15:14:53 +02:00
Paweł Dziepak
ede9886f50 dht: add byte_ordered_partitioner
Some of the tests in DTEST take advantage of the fact that
ByteOrderedPartitioner guarantees certain ordering of partition keys.

Signed-off-by: Paweł Dziepak <pdziepak@cloudius-systems.com>
2015-07-09 23:43:16 +02:00
Avi Kivity
dd29ac9593 Merge "cqlsh" from Glauber
System table Work to make cqlsh connect.
2015-07-07 19:33:23 +03:00
Glauber Costa
bd13e3995b dht: implement method to convert a token to a string
We need to be able to do it so we can, among other things, create CQL
statements that include the current state of the tokens.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-07-07 11:38:22 -04:00
Glauber Costa
45905ec94d dht: change partitioner name to sstring
It is a better fit for things that are names, not blobs. We have a user that expects
a bytes parameter, but that is for no other reason than the fact that the field used
to be of bytes type.

Let's fix that, and future users will be able to use sstrings

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-07-07 11:38:22 -04:00
Tomasz Grabiec
d035c499b8 db: Move database::shard_of() to dht::shard_of() 2015-07-07 16:56:25 +02:00
Gleb Natapov
730170ff1a serialize data structures needed for read clustering 2015-07-01 13:36:28 +03:00
Tomasz Grabiec
ac333f04e2 dht: Make decorated_key comparable with ring_position 2015-06-25 18:45:12 +02:00
Tomasz Grabiec
9525464f74 Move query::ring_position to dht::ring_position 2015-06-25 18:45:12 +02:00
Tomasz Grabiec
6515cb642b dht: Remove obsolete files 2015-06-25 18:45:12 +02:00
Avi Kivity
ba3fb44bf5 dht: implement more token relational operators 2015-06-25 15:25:37 +03:00
Avi Kivity
e4140a19ed dht: virtualize i_parititoner::midpoint() and implement for murmur3 2015-06-25 15:25:04 +03:00
Avi Kivity
f8e2c13933 dht: rename midpoint() to midpoint_unsigned()
midpoint()'s algorithm only works for unsigned tokens, so rename it
accordingly.
2015-06-25 14:54:40 +03:00
Avi Kivity
d8946d07ed dht: fix token wraparound in midpoint()
midpoint(l, r) where l > r needs to wrap around the end of the ring.  Adjust
the midpoint() function to do this.

Note this is still broken for the murmur3 partitioner, since it doesn't treat
tokens as unsigned.
2015-06-25 13:55:46 +03:00
Avi Kivity
0eb8d7384a Reduce partitioner's dependencies on sstables/*.hh 2015-06-22 19:00:55 +03:00
Shlomi Livne
954c697958 dht: Update name of Murmur3Partitioner to align with org.apache.cassandra.dht.Murmur3Partitioner
In sstables the paritioner name is store for validation. To allow Origin
to process our files we need to comply with Origin's paritioner name or
else Origin's SSTableReader::open fails on paritioner comparison.
2015-06-16 12:20:04 +03:00
Asias He
9649414011 dht: Align token print
Before:
token=df 96 79 87 21 b2 ed 80
token=5c 98 e a0 4f 5e 28 6b

After:
token=df 96 79 87 21 b2 ed 80
token=5c 98 0e a0 4f 5e 28 6b
2015-06-04 17:12:10 +08:00
Asias He
34b3d679ab dht: Do move in token constructor 2015-06-04 17:12:09 +08:00
Asias He
9c5cd2bca8 storage_service: Switch to use unordered_set for tokens
We do not care about the order of the tokens.

Also, in token_metadata, we use unordered_set for tokens as well, e.g.
update_normal_tokens. Unify the usage.
2015-06-04 17:12:09 +08:00
Raphael S. Carvalho
6ae4476427 sstables: collect validation metadata
Validation metadata stores partitioner name and bloom filter chance.
Cassandra gets the partitioner name by getting a object of the class
itself and getting its canonical name.

Signed-off-by: Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
2015-06-02 10:32:12 +03:00
Asias He
8d7aff89e3 storage_service: Reduce default num_tokens to 3
The default value 256 in Origin is too big for debug. We can set it back
when storage_service is maturer.
2015-06-01 11:24:38 +08:00
Asias He
d026ca6852 token: Add constructor token(kind, bytes) 2015-06-01 11:24:38 +08:00
Asias He
aa4a23a248 dht: Virtualize get_random_token
murmur3_partitioner::get_random_token is implemented.
2015-05-27 13:06:33 +08:00
Asias He
a66f06ad44 dht: Specify override on a virtual function in a derived class
The murmur3_partitioner overrides functions in i_partitioner.
2015-05-27 13:06:33 +08:00
Asias He
ee1d79cd2b dht: Convert BootStrapper.java to C++ 2015-05-27 13:06:33 +08:00
Asias He
1c9e88dcb9 dht: Import BootStrapper.java 2015-05-27 13:06:33 +08:00
Glauber Costa
6a8049dce1 dht: add maximum_token
Analogous to minimum_token.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-05-21 16:27:35 -04:00
Tomasz Grabiec
96bbac8a57 dht: Make partitioner work on partition_key_view 2015-05-06 15:52:56 +02:00
Tomasz Grabiec
aec740f895 db: Make decorated_key have ordering compatible with Origin 2015-04-30 12:02:39 +02:00
Tomasz Grabiec
359af7745c dht: murmur3_partitioner: move get_token() implementation to .cc 2015-04-30 11:16:53 +02:00
Avi Kivity
65b8b19ca7 Merge branch 'tgrabiec/order-partitions-by-decorated-key' of github.com:cloudius-systems/seastar-dev into db
Use decorated_key in partition maps, from Tomasz:

"Partitions should be ordered using Origin's ordering, which is the natural
ordering of decorated_key. This is achieved by switching column_family's
partition map to use decorated_key instead of a bare partition_key.

This also includes some cleanups."

[avi] trivial adjustments to sstables/keys.cc
2015-04-25 19:22:51 +03:00
Tomasz Grabiec
71041eb0d6 dht: Implement operator<< for decorated_key 2015-04-24 18:01:01 +02:00
Tomasz Grabiec
841a13da93 dht: Implement operator!= for decorated_key 2015-04-24 18:01:01 +02:00
Glauber Costa
7c7da26347 dht: generate a token from a bytes_view
It has been determined that we will store partition_keys in the decorated_keys.
That is totally fine, but the token needs to be generatable from an sstable::key
as well.

Since both types convert well to a bytes_view - and the first thing get_token() does
is precisely to generate that view, let's generate the token from a bytes_view instead.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-04-24 10:11:49 -04:00
Pekka Enberg
d23b7796f8 dht/i_partitioner.hh: Make decorated key operators visible
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-04-23 10:34:34 +02:00
Gleb Natapov
02fb270fbe token operator<< 2015-04-19 10:15:14 +03: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
Glauber Costa
eee72251d0 add comparison and hash operators for dht::token
Inspired in Gleb's previous patch, this patch adds a hash and comparison
operator for dht::token.

The previous patch, however, had a number of problems. Comparisons were failing
in tokens that were verified (by me) to be equal to the ones Origin was
generating.

The main reasons for that, was that the byte-comparison loop must be unsigned,
not signed.

With the above change, the comparison function would always succeed *except*
when the integer version of _data was that of a signed one.

Looking at Origin, one verifies that the Murmur3Partitioner class overrides the
comparison functions, and just does a Long comparison with the token.

This patch implements a similar mechanism. With that, a list of tokens
generated by origin in ascending order is verified by us to also be in
ascending order.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-04-02 16:16:39 +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
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
f321b9e9b5 util: Make hash functions work on bytes_view 2015-03-17 15:56:28 +01:00
Avi Kivity
678c259c66 murmur3: switch to unsigned types
C++ doesn't define overflow on signed types, so use unsigned types instead.
Luckily all right shifts were unsigned anyway.

Some signed extension was happening (handling remainders after processing
8-byte chunks) but should still be there.

Caught by debug build.
2015-02-24 15:29:08 +02:00
Avi Kivity
6f7dff825c dht: add global partitioner
Skip configuration for now and go for murmur3 instead.
2015-02-23 11:37:12 +02:00
Avi Kivity
d0dae3f938 dht: add murmur3_partitioner
We don't follow origin precisely in normalizing the token (converting a
zero to something else).  We probably should, to allow direct import of
a database.
2015-02-23 11:37:12 +02:00
Avi Kivity
fd9f90f45a dht: implement token minimum and midpoint
Rather than converting to unsigned longs for the fractional computations,
do them it bytes.  The overhead of allocating longs will be larger than
the computation, given that tokens are usually short (8 bytes), and
our bytes type stores them inline.
2015-02-23 10:20:24 +02:00
Avi Kivity
edc4ac4231 dht: de-virtualize token
Origin uses abstract types for Token; for two reasons:

 1. To create a distinction between tokens for keys and tokens
    that represent the end of the range
 2. To use different implementations for tokens belonging to different
    partitioners.

Using abstract types carries a penalty of indirection, more complex
memory management, and performance.  We can eliminate it by using
a concrete type, and defer any differences in the implementation
to the partitioner.  End-of-range token representation is folded into
the token class.
2015-02-23 10:20:24 +02:00