Commit Graph

35 Commits

Author SHA1 Message Date
Tomasz Grabiec
b28d26bc9f murmur_hash: Drop static qualifier from template definition
To avoid multiple definitions in different compilation units. Pointed
out by Avi.
2015-04-30 16:49:50 +02:00
Tomasz Grabiec
5fc149d454 utils: murmur_hash: Add input iterator based hash3_x64_128() version 2015-04-30 11:16:53 +02:00
Tomasz Grabiec
9197914697 utils: Fix indentation in murmur_hash.hh
We don't indent namespaces.
2015-04-30 11:16:53 +02:00
Tomasz Grabiec
a9972b4b28 Relax header dependencies 2015-04-24 18:01:01 +02:00
Asias He
ea08c7e000 utils: Fix bounded_stats_deque::add 2015-04-23 14:55:26 +08:00
Tomasz Grabiec
957544f69b utils: UUID_gen: Add support for name-based UUIDs (type 3) 2015-04-17 14:19:07 +02:00
Tomasz Grabiec
b79d2008c0 utils: UUID_gen: Fix comment about get_UUID()
UUID can hold not only type 1 UUIDs, but any UUID.
2015-04-17 14:19:07 +02:00
Gleb Natapov
d0a1e35a86 class factory
In Java it is possible to create an object by knowing its class name in
runtime. Replication strategies are created this way (I presume class
name comes from configuration somehow), so when I translated the code to
urchin I wrote replication_strategy_registry class to map a class name to
a factory function. Now I see that this is used in other places too (I
see that snitch class created in the same way), so instead of repeating
the same code for each class hierarchy that is created from its name in
origin this patch tries to introduce an infrastructure to do that easily.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
2015-04-15 22:37:28 +03:00
Tomasz Grabiec
878a740b9d db: Write query results in serialized form
This gives about 30% increase in tps in:

  build/release/tests/perf/perf_simple_query -c1 --query-single-key

This patch switches query result format from a structured one to a
serialized one. The problems with structured format are:

  - high level of indirection (vector of vectors of vectors of blobs), which
    is not CPU cache friendly

  - high allocation rate due to fine-grained object structure

On replica side, the query results are probably going to be serialized
in the transport layer anyway, so this change only subtracts
work. There is no processing of the query results on replica other
than concatenation in case of range queries. If query results are
collected in serialized form from different cores, we can concatenate
them without copying by simply appending the fragments into the
packet. This optimization is not implemented yet.

On coordinator side, the query results would have to be parsed from
the transport layer buffers anyway, so this also doesn't add work, but
again saves allocations and copying. The CQL server doesn't need
complex data structures to process the results, it just goes over it
linearly consuming it. This patch provides views, iterators and
visitors for consuming query results in serialized form. Currently the
iterators assume that the buffer is contiguous but we could easily
relax this in future so that we can avoid linearization of data
received from seastar sockets.

The coordinator side could be optimized even further for CQL queries
which do not need processing (eg. select * from cf where ...)  we
could make the replica send the query results in the format which is
expected by the CQL binary protocol client. So in the typical case the
coordinator would just pass the data using zero-copy to the client,
prepending a header.

We do need structure for prefetched rows (needed by list
manipulations), and this change adds query result post-processing
which converts serialized query result into a structured one, tailored
particularly for prefetched rows needs.

This change also introduces partition_slice options. In some queries
(maybe even in typical ones), we don't need to send partition or
clustering keys back to the client, because they are already specified
in the query request, and not queried for. The query results hold now
keys as optional elements. Also, meta-data like cell timestamp and
ttl is now also optional. It is only needed if the query has
writetime() or ttl() functions in it, which it typically won't have.
2015-04-15 20:44:50 +02:00
Tomasz Grabiec
d287fd4c39 utils: Extend data_input() with more methods 2015-04-15 20:33:49 +02:00
Tomasz Grabiec
e0720e8a9b utils: Make UUID ostream-printable 2015-04-15 20:33:47 +02:00
Tomasz Grabiec
5300caadf6 utils: Fix UUID::get_time_UUID() creating conflicting UUIDs in SMP
UUID_gen::create_time_safe() does not synchronize across cores. The
comment says that it assumes it runs on a single core. This is no
longer true, we can run urchin on many cores. This easily leads to
UUID conflicts with more than one core. Fix by adding a per-core
unique number to the node part of the UUID.
2015-04-15 20:33:47 +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
f1489bf325 Add data_output interface
For slight abstraction and OO-ification of serialization.
2015-04-01 10:08:00 +02:00
Calle Wilund
ef807ed53f Add data_input interface
Wrapper around bytes_view for input data marshalling
For more OO-style deserialization...
2015-04-01 10:08:00 +02:00
Calle Wilund
2be0cbf683 Add tuple/pair hash helper. 2015-04-01 09:43:47 +02:00
Tomasz Grabiec
2902395129 Relax includes 2015-03-30 09:01:59 +02:00
Avi Kivity
24506efc43 uuid: fix serialization of least significant bytes
Shift amount was incorrect.
2015-03-23 22:42:34 +02:00
Tomasz Grabiec
f321b9e9b5 util: Make hash functions work on bytes_view 2015-03-17 15:56:28 +01:00
Dor Laor
a9e77e1211 uuid: add 'bytes' serialization helpers 2015-03-16 06:58:30 +02:00
Avi Kivity
b5125cc03e uuid: remove debug print 2015-03-11 14:42:42 +02:00
Avi Kivity
835c8b693c uuid: fix uuidgen thread safety
The instance must be thread local since it is mutable (last_nanos).
2015-03-11 14:42:42 +02:00
Asias He
5ddab29a3c utils: Convert utils/BoundedStatsDeque.java to C++ 2015-03-10 16:04:24 +08:00
Asias He
0ffdd1896f utils: Import utils/BoundedStatsDeque.java 2015-03-10 15:11:36 +08:00
Calle Wilund
d92971a2b4 Add hash function to UUID.
Signed-off-by: Calle Wilund <calle@cloudius-systems.com>
2015-03-05 11:02:46 +02: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
Nadav Har'El
7c87c6cc27 UUID: add to_sstring() method
Add UUID::to_sstring() method, analogous to the Java UUID.toString(),
and I verified that it generates the same output as the original Java
method.

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
[avi: make it build, using sprint() instead of sprintf()]
2015-01-14 14:43:45 +02:00
Avi Kivity
904db75cbb utils: add make_random_uuid() 2015-01-12 14:20:28 +02:00
Avi Kivity
63055f0306 uuid: add missing include 2015-01-12 14:19:33 +02:00
Avi Kivity
07947764b2 uuid: convert UUID_gen::get_UUID() 2015-01-11 15:46:03 +02:00
Nadav Har'El
31a982b41e Convert time (version 1) UUID to C++
Convert Cassandra's UUIDGen class, which generates time-dependent UUID,
and parts of the java.util.UUID which I thought we need, to C++.

It is possible I missed some needed features of java.util.UUID that we'll
need to add later.

Also, part of the version-1 UUID is supposed to be node-unique (so that
if two nodes happen to boot at the same time and get a UUID at exactly
the same time, they still get different UUIDs). Cassandra uses for this
a hash function of the IP address, we should use in the future the MAC
address (from Seastar's network stack). But currently we just use 0.
Left a FIXME to fix that.

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
[avi: add to ./configure.py]
2015-01-07 16:13:42 +02:00
Asias He
516ef9e63b utils: Convert utils/FBUtilities.java 2015-01-06 17:23:46 +08:00
Asias He
3a5314bec8 utils: Import utils/FBUtilities.java 2015-01-06 16:59:16 +08:00
Nadav Har'El
774579d8b4 Move murmur_hash to the right directory
In the original Java code, MurmurHash was in the "utils" package, not
"util", so move it to a new "utils" directory (and namespace), not
"util".

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
2014-12-30 17:43:30 +02:00