Commit Graph

26 Commits

Author SHA1 Message Date
Nadav Har'El
e24d6c21d9 range: Use std::declval in std::hash<>
Use C++11's std::declval<T>() instead of my ad-hoc scary-looking
idiom *(T*)nullptr.

Both techniques produce an object of type T which is only useful for
unevaluated contexts, only inspecting an object's type and not is value.
For example, in decltype() expressions.

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
2015-07-27 16:46:16 +03:00
Nadav Har'El
cc64e46425 Add equality operator for range
The operator== is needed when actually using a hash table - the hash
function is not enough.

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
2015-07-27 15:55:42 +03:00
Nadav Har'El
afa3d8c2c8 Fix errors in hash function for range
Amazing how many errors a short of piece of code can have, without the
compiler complaining at all. The magic of templates :-)

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
2015-07-27 15:55:41 +03:00
Nadav Har'El
1399087753 Allow range<T> as hash-table key
Some methods in storage_service.cc want to return an
unordered_set<query::range<dht::token>>. This patch adds the missing
hash function for a query::range<T> to make it usable as a hash-table key.

The hash function we used is a trivial linear combination of the range's
start and end hash function - the same function used by Cassandra's
AbstractBounds.hashCode() so it is probably "good enough".

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
2015-07-27 14:44:33 +03:00
Tomasz Grabiec
5e03dea65d range: Fix is_wrap_around()
In Origin, dht.Range() with equal values is considered a full wrap
around. Make our range<> recognize this.

So we have:

 ]x; x] - wrap around, full ring
 [x; x[ - wrap around, full ring
 ]x; x[ - wrap around, excluding x
 [x; x] - not wrap around, only x included
2015-07-24 16:08:41 +02:00
Tomasz Grabiec
1b7ab4f639 range: Introduce unwrap() 2015-07-24 16:08:41 +02:00
Tomasz Grabiec
1c95f646ae range: Make before() and after() public 2015-07-24 16:08:41 +02:00
Tomasz Grabiec
4d06c2aa1d Move to_partition_range() adaptor to global scope
It should be moved to i_partitioner.hh, but to do that range<> has to
be first moved out of query-request.hh to break cyclic dependency.
I didn't want to cause conflicts with in-flight patches to range<>.
2015-07-24 16:08:41 +02:00
Tomasz Grabiec
e5feff5d71 dht: ring_position: Switch to total ordering
range::is_wrap_around() and range::contains() rely on total ordering
on values to work properly. Current ring_position_comparator was only
imposing a weak ordering (token positions equal to all key positions
with that token).

range::before() and range::after() can't work for weak ordering. If
the bound is exclusive, we don't know if user-provided token position
is inside or outside.

Also, is_wrap_around() can't properly detect wrap around in all
cases. Consider this case:

 (1) ]A; B]
 (2) [A; B]

For A = (tok1) and B = (tok1, key1), (1) is a wrap around and (2) is
not. Without total ordering between A and B, range::is_wrap_around() can't
tell that.

I think the simplest soution is to define a total ordering on
ring_position by making token positions positioned either before or
after all keys with that token.
2015-07-24 16:08:41 +02:00
Paweł Dziepak
0f9a740012 query: add parition_slice::option::reversed
Signed-off-by: Paweł Dziepak <pdziepak@cloudius-systems.com>
2015-07-23 02:38:19 +02:00
Tomasz Grabiec
6373987704 partition_range: Introduce is_wrap_around() helper 2015-07-22 13:13:38 +02:00
Tomasz Grabiec
0b0ea04958 range: Remove start_value() and end_value()
It's easy to miss that they may be undefined. start() and end(), which
return optional<bound> const&, make it clear.
2015-07-22 10:27:47 +02:00
Tomasz Grabiec
93d607aac6 range: Make singular ranges transparent
Singular range is a range of the form [x; x]. Internally such ranges
are optimized to avoid storing the value twice, so _end is empty.

Client shouldn't have to special case for it if it's not interested,
so make end() and split() work for singular ranges too.
2015-07-18 11:10:31 +02:00
Gleb Natapov
92a016fe9f add split() for range<ring_position> 2015-07-15 12:41:38 +03:00
Avi Kivity
b89c54df9d query::range: fix call to internal deserialized_size() template
query::range::serialized_size() calls a template method (also
called serialized_size()) within a lambda, however it is called with
a const 'this' while the template is non-const-qualified.  gcc 5
rightly rejects it (nicely annotating the template as a near miss).

Fix by making the template static; it doesn't need 'this' anyway.
2015-07-12 21:18:21 +03:00
Paweł Dziepak
290a7ca1bf query: add timestamp to read_command
Read command needs a timestamp in order to determine which cells have
already expired.

Signed-off-by: Paweł Dziepak <pdziepak@cloudius-systems.com>
2015-07-02 17:01:19 +02:00
Tomasz Grabiec
1b4a72de14 query: Introduce query::max_rows 2015-07-02 13:25:46 +02:00
Gleb Natapov
730170ff1a serialize data structures needed for read clustering 2015-07-01 13:36:28 +03:00
Tomasz Grabiec
9525464f74 Move query::ring_position to dht::ring_position 2015-06-25 18:45:12 +02:00
Tomasz Grabiec
51cae834e3 db: Put all sstables behind single reader
This change abstracts reading from on-disk data sources behind a single
reader which is then composed with memtable readers. This change also
abstracts all data sources behind a single reader obtained via
column_family::make_reader(). That reader is then used by algorithms
like column_family::for_all_partitions() or
column_family::query(). Having those abstractions will make it easier
to add row cache, because it will be encapsulated in a single place.
2015-06-18 16:33:33 +02:00
Tomasz Grabiec
3779506990 db: query: Make partition_range hold ring_position
Current model was not really correct because Origin doesn't support
querying of partition ranges by their value. We can query slices
according to dht::decorated_key ordering, which orders partitions
first by token then by key value.

ring_position encapsulates range constraint. Key value is optional, in
which case only token is constrained.
2015-06-18 15:47:40 +02:00
Tomasz Grabiec
0740f49599 query: range: Introduce transform() 2015-06-18 15:47:39 +02:00
Gleb Natapov
b7155ad862 pass partitions_ranges separately from from read_command
partitions_ranges will be manipulated upon to be split for different
destination, so provide it separately from read_command to not copy the
later for each destination.
2015-06-11 15:18:07 +03:00
Tomasz Grabiec
8fedebd166 db: Add clarifying description to query_command and partition_slice 2015-05-13 08:56:54 +02: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
Tomasz Grabiec
00f99cefd4 db: split query.hh to reduce header dependencies 2015-04-15 20:44:59 +02:00