Commit Graph

43077 Commits

Author SHA1 Message Date
Avi Kivity
66138dc189 cql3: convert NativeAggregateFunction to C++
Requires virtual inheritence from functions::function due to an
inheritence diamond.
2014-12-30 09:00:22 +02:00
Avi Kivity
9a2c40c931 cql3: convert AggregateFunction to C++ 2014-12-30 09:00:22 +02:00
Avi Kivity
a4f64e980c cql3: convert NativeFunction to C++ 2014-12-30 09:00:22 +02:00
Avi Kivity
8be65f234d Merge branch 'log' into db
Basic sl4j compatible logger.
2014-12-29 19:02:54 +02:00
Nadav Har'El
6710a97537 Convert util/MurmurHash.java to C++
Port the Murmur hash functions from Java to C++. This is ironic,
because these functions actually originated in C code, which the
Cassandra guys converted to Java :-)

The Murmur hash is used in Cassandra for several things, including the
bloom filter (which is part of each sstable), and the default
data partitioner (Murmur3Partitioner).

I tested on some example string that all three methods (hash32, hash2_64
and hash3_x64_128) produce exactly the same output in the new C++ code as
they do in the original Java functions. This is important, because we want
the C++ node to be able to run alongside Java nodes, so they have to agree
on the same hash function.

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
[avi: update configure.py]
2014-12-29 19:01:12 +02:00
Avi Kivity
eee158ed22 Merge branch 'master' of github.com:cloudius-systems/seastar into db
Merge seastar framework fixes.
2014-12-29 17:49:04 +02:00
Nadav Har'El
7a84dff0b2 sstring: constructor from C string
The constructor from "const char_type *" wouldn't really work when
char_type != char, because strlen() won't work on such pointers.

It is more convenient to have a constructor from an ordinary const char *
(e.g., a C string literal), and solve the type problem with an ugly cast.

This only makes sense when sizeof(char_type)==1 (i.e., it is char, unsigned
char, or signed char), but I think we make this assumption in other places
as well (e.g., in determining the size we need to allocate).

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
2014-12-29 17:29:32 +02:00
Nadav Har'El
f7fbf8ba02 sstring: add operator[]
std::string has an operator[] to get access (read or modify) to one
character in the string. This patch adds the same operator for our
sstring.

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
2014-12-29 17:29:10 +02:00
Nadav Har'El
9be5590fcd sstring: fix character type
The basic_sstring<> template allows picking char_type - which instead of
being just "char" could be chosen to be something similar, like "unsigned char"
or "signed char".

Unfortunately some hard-coded uses of "char" were left in the code. This
did not cause any problems for existing code because of implicit conversions,
but it does cause problems once I try to implement operator[] when char_type
is not char. This results in an attempt to return a reference to the result
of a conversion, which is not allowed.

So this patch fixes the leftover uses of "char" to "char_type".

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
2014-12-29 17:29:06 +02:00
Avi Kivity
0362800e8d log: add slf4j-compatible logger class
Supports variadic logging with placeholders, e.g.

  logger.error("what happened? x = {}, y = {}", x, y);

Instantiate loggers as static thread_local, e.g.

  class foo {
      static thread_local logging::logger logger;
  };

  thread_local logging::logger foo::logger{logging::logger_for<foo>};
2014-12-29 17:09:41 +02:00
Avi Kivity
d4217da768 Merge branch 'thrift' into db
Add partial support for get_slice().  With this, the cassandra-stress read
test can complete in thrift mode (yielding 78krps on my desktop).

Reviewed-by: Pekka Enberg <penberg@cloudius-systems.com>
2014-12-29 15:00:05 +02:00
Avi Kivity
fa3ae18dcf cql: make function_name more similar to origin
- make members const
- drop overeager assert
2014-12-29 14:27:10 +02:00
Gleb Natapov
f0cdc47a3a net: do not sleep while waiting for link in dpdk
Use promise and seastar timers instead.
2014-12-29 13:06:10 +02:00
Gleb Natapov
a445b8174e net: wait for link to be ready before creating network stack 2014-12-29 13:06:10 +02:00
Avi Kivity
073d6062a4 tcp: protect continuations launched from tcb against its destruction
If the tcb is destroyed (by, say, the connection being closed and an RST),
then any continuation launched from it would see it destroyed when it
executes.

Fix by protecting the tcb using a shared pointer reference.
2014-12-29 11:12:44 +02:00
Avi Kivity
b05f33cf63 tcp: drop two useless continuations
They do nothing.
2014-12-29 11:12:33 +02:00
Avi Kivity
3cecef365f shared_ptr: implement enable_shared_from_this<>
Mirrors std::enable_shared_from_this<>.
2014-12-29 11:02:31 +02:00
Gleb Natapov
efd6c33af0 reactor: remove no longer needed thread_pool function 2014-12-28 18:19:20 +02:00
Gleb Natapov
3eefc1ada2 reactor: replace thread_pool poller with signal notification
Drops one poller since now signal poller is used to process thread_pool
completions.
2014-12-28 18:19:18 +02:00
Avi Kivity
27955d47f6 Merge branch 'gleb/nopoll' of github.com:cloudius-systems/seastar-dev
Remove pre-poll-mode code, from Gleb:

"This series moves most of eventfd users to use other form of notification
which can be polled without entering the kernel and moving epoll in its own
poller which is enabled only if there is an fd that needs to be polled."

[avi: add -lrt to linker command line]
2014-12-28 15:34:36 +02:00
Gleb Natapov
367bbd75f3 reactor: move epoll to its own poller
Enable it only if there is fd to poll.
2014-12-28 14:54:43 +02:00
Gleb Natapov
889cc69a28 reactor: remove non polling mode 2014-12-28 14:54:43 +02:00
Gleb Natapov
7d3fb282c5 reactor: poll thread pool for completion instead of using eventfd 2014-12-28 14:54:43 +02:00
Gleb Natapov
d329a0a614 net: remove non polling mode from virtio-net 2014-12-28 14:54:43 +02:00
Gleb Natapov
a57e75ab9f reactor: move timers to use signals instead of timerfd to signal a completion 2014-12-28 14:54:43 +02:00
Gleb Natapov
51b56d90f2 reactor: poll for signals completion instead of using signalfd 2014-12-28 14:54:43 +02:00
Avi Kivity
1ce15a9466 thrift: partial support for get_slice() 2014-12-28 13:42:25 +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
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
Gleb Natapov
3d374110c6 reactor: poll for aio completion instead of using eventfd
io_getevents() avoids system call if timeout is zero and there is no
completed event.
2014-12-28 13:39:59 +02:00
Avi Kivity
db256216ec Merge branch 'master' into db
Merge latest seastar fixes into db.
2014-12-28 13:39:15 +02:00
Gleb Natapov
6d7916a9f8 reactor: disable batching during engine termination
SMP messages that are send while engine is been stopped should be
sent immediately because after the engine is stopped they will not be.
2014-12-28 13:37:25 +02:00
Avi Kivity
efe6e4f5eb sstring: fix conversion to std::string with NUL bytes
sstring's std::string conversion uses c_str() to construct the value,
but the conversion is broken if the value contains NUL - both sstring and
std::string can contain NULs, but C strings use them as a terminator.

Fix by using the size+length std::string constructor.
2014-12-28 13:30:24 +02:00
Raphael S. Carvalho
48019c2df2 memcache: fix cache::item_footprint()
size of the sstring _ascii_prefix should also be added when computing
item footprint. Without this change, reclaimer would end up evicting
more than needed.

Signed-off-by: Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
2014-12-28 10:24:09 +02:00
Avi Kivity
f1fa69470c Merge branch 'thrift'
This patchset extends the database and thrift layers sufficiently to
pass the cassandra-stress insert test in thrift mode.  I see 70krps
on my desktop (posix stack), likely limited by the client.
2014-12-28 10:03:46 +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
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
Avi Kivity
2733813c87 db: add a "bytes" type, corresponding to ByteBuffer (serialized values)
Using sstring can lead to confusion with UTF8 strings.

The Java byte type is signed, so make bytes' internal type be signed as
well (even though Cassandra tries to treat it as unsigned).

While we should use int8_t, sstring is not perfectly compatible with this
yet, so add a FIXME and use char instead.
2014-12-28 10:01:41 +02:00
Gleb Natapov
466acedcb2 timer: cancel all timers during reactor destruction
If a timer is not canceled it will try to cancel itself during
destruction which may happen after engine is already destroyed.
2014-12-25 09:14:42 +02:00
Avi Kivity
bd6623c0cf Merge branch 'cql' into db
Convert some classes from oac.cql3 to C++ (batch 1).
2014-12-24 15:51:09 +02:00
Avi Kivity
fd4a1d074b cql3: convert functions.AbstractFunction to C++ 2014-12-24 14:18:21 +02:00