Commit Graph

2137 Commits

Author SHA1 Message Date
Avi Kivity
d41b4e57ad tests: add test for map literal and setting a map value by key 2015-03-12 10:22:17 +02:00
Avi Kivity
20e616131f cql3: convert grammar for map literals and setting a map value by key 2015-03-12 10:22:17 +02:00
Avi Kivity
6e646efb85 cql3: implement operation::setter::prepare() for maps 2015-03-12 10:22:17 +02:00
Avi Kivity
1172f65d50 cql3: convert maps::setter_by_key to C++ 2015-03-12 10:22:17 +02:00
Avi Kivity
a64cd8f22f cql3: convert maps::literal to C++ 2015-03-12 10:22:17 +02:00
Avi Kivity
0f793f1aa7 cql3: convert maps::delayed_value to C++ 2015-03-12 10:22:15 +02:00
Avi Kivity
561d72879a cql3: convert maps::value to C++ 2015-03-12 10:14:25 +02:00
Avi Kivity
33f6703be6 cql3: move enable_shared_from_this up the cql3::term hierarchy
Casting upwards past an enable_shared_from_this confuses shared_ptr,
so move it to the base of the hierarchy.
2015-03-12 10:10:43 +02:00
Avi Kivity
70d1be8e82 cql3: add stringifying operators
Helps during debugging.
2015-03-12 10:10:43 +02:00
Avi Kivity
08b07f5093 cql3: add helpers to assignment_testable
Less qualification needed.
2015-03-12 10:10:43 +02:00
Avi Kivity
ca308698df collection_type_impl: add to_value(mutation_view)
Allows collapsing a mutation into a literal.
2015-03-12 10:10:42 +02:00
Avi Kivity
7c5d865aac db: add map_type::serialize_partially_deserialized_from
Add a way to convert a vector of pairs of serialized key/values to
the fully serializied form; useful for map literals.
2015-03-12 10:10:42 +02:00
Avi Kivity
fc9a8d6efd db: add collection_type_impl::pack
A helper function for other operations, as all collections share
the basic serialized format.
2015-03-12 10:10:42 +02:00
Avi Kivity
3c63f77824 db: split collection_type_impl::mutation into an owning and view types
The view type is more efficient, but less safe.
2015-03-12 10:10:42 +02:00
Avi Kivity
0bd44deca9 db: add abstract_type::as_less_comparator()
Returns a binary predicate that allows comparing two values belonging
to the type, suitable for STL containers and algorithms.
2015-03-12 10:10:41 +02:00
Avi Kivity
769824655e types: add forward declarations for collection serialization operations 2015-03-12 09:56:53 +02:00
Avi Kivity
362dbd5c94 types: add bytes_view variant of write_collection_value() 2015-03-12 09:56:53 +02:00
Avi Kivity
56d4592e00 atomic_cell: add view::serialize() helper 2015-03-12 09:56:53 +02:00
Avi Kivity
f226f93120 fix collection_type_impl::merge 2015-03-12 09:56:53 +02:00
Avi Kivity
49a93b333b cql: pass operations by reference to specializedColumnOperation
If we want our

   set map[key] = value

operation to work, we better return it from the parser.
2015-03-12 09:56:53 +02:00
Avi Kivity
90ef430d1f tests: add list_type mutation test 2015-03-12 09:56:53 +02:00
Avi Kivity
fb876cb6f2 db: implement list_type 2015-03-12 09:56:53 +02:00
Avi Kivity
6f3e63fb3a tests: add set mutation test 2015-03-12 09:56:53 +02:00
Avi Kivity
488ac10369 db: add set type implementation 2015-03-12 09:56:53 +02:00
Avi Kivity
0535c56735 db: add helper iterator for deserializing list-like types 2015-03-12 09:56:53 +02:00
Avi Kivity
a4e6fcc30c db: change read_collection_value() to return a bytes_view
Faster, and useful with further transforms that return a view.
2015-03-12 09:56:53 +02:00
Avi Kivity
06bd67c221 db: move map_type:impl::mutation and associated helpers to collection_type_impl
Turns out the sets and lists also use the same data type, with sets using
a fake value type, and lists using a fake key type.
2015-03-11 14:42:42 +02:00
Avi Kivity
5f309f4d33 db: add empty_type
Used in sets for the value type.
2015-03-11 14:42:42 +02:00
Avi Kivity
da902a4c17 db: add helper for interning types; use in map_type
Avoid code repetition for other collections.
2015-03-11 14:42:42 +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
Avi Kivity
c4febdeb63 Merge branch 'glommer/index-reader-v4' of github.com:cloudius-systems/seastar-dev into urchin
Sstable index reader, from Glauber.
2015-03-10 20:24:02 +02:00
Glauber Costa
7c96752a46 sstable_tests: add tests for index reads
Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-03-10 15:13:14 -03:00
Glauber Costa
c0ad2a8e0e sstables: parse the index file
We usually don't read the whole file into memory, so the probing interface will
also allow for the specification of boundaries that we should be use for
reading.

The sstable needs to be informed - usually by the schema - of how many columns
the partition key is composed of - 1 for simple keys, more than one, for
composites.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-03-10 15:13:14 -03:00
Glauber Costa
a3febe2ae0 sstable: open data and index files.
Because we're expected to go to those files many times, it doesn't make sense
to keep opening them. Upon sstable load, we will open those files and then move
the reference to the sstable main structure. From this point on, we can just seek
to the position we want.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-03-10 15:13:14 -03:00
Glauber Costa
cea4825642 sstables: change exception message
So it represents all kinds of mismatches. Not only buf < expected.
It will be useful in the index parsing code.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-03-10 15:13:14 -03:00
Glauber Costa
d19abb59fb file_input_stream: accept a shared pointer in the constructor
Right now we will always move the file to create a shared pointer from it.
However, there are situations in which we don't really want to move it, because
it will be still used elsewhere.

One example is the index and data readers, where we will store a file object to
avoid opening the file all the time. In such situation, we can pass a shared
pointer that is already constructed to the file_input_stream.

The alternative to that would have been to store the file_input_stream itself.
That would, however, require us to export that in some header. It's best to
keep it private. Since we will already deal with a shared pointer anyway, it is
best to provide this option.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-03-10 15:03:51 -03:00
Glauber Costa
87e6b7ab56 sstables: signal eof in file_input_stream
We signal that condition in the underlying input_stream. Export that
to the file stream.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-03-10 15:03:51 -03:00
Avi Kivity
0139a210e2 Merge branch 'master' of github.com:cloudius-systems/seastar into db 2015-03-10 17:04:16 +02:00
Shlomi Livne
f8d773dd47 tests: fix future unitest that sometimes fails because of scheduling
Signed-off-by: Shlomi Livne <shlomi@cloudius-systems.com>
2015-03-10 16:38:43 +02:00
Raphael S. Carvalho
3637b2f09c temporary_buffer: add static method aligned
used to allocate a temporary_buffer with an aligned buf.

Signed-off-by: Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
2015-03-10 16:33:38 +02:00
Glauber Costa
7d43e26c58 sstables: use net::packed in potentially unaligned accesses
Fixes debug build test code.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-03-10 15:54:13 +02:00
Avi Kivity
9288b360f6 Merge branch 'master' of github.com:cloudius-systems/seastar into db
Includes adaptation by Nadav for the removal of file_input_stream:

sstables.cc used file_input_stream, which we replaced by the new
make_file_input_stream. We also couldn't make sstables.cc read either
a file_input_stream or the planned compressed_file_input_stream.

So in this patch we implement an API similar to the old "file_input_stream"
based on the new make_file_input_stream. file_input_stream now has a parent
class "random_access_reader", preparing for a future patch to support both
file_input_stream and compressed_file_input_stream in the same code - by making
all the parsers take a random_access_reader reference instead of file_input_stream.

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
2015-03-10 15:50:04 +02:00
Nadav Har'El
7a04d1f662 fstream: refactor file input stream interface
The file_input_stream interface was messy: it was not fiber safe (e.g., code
doing seek() in the middle of an ongoing read_exactly()), and went against
the PIMPL philosophy.

So this patch removes the file_input_stream class, and replaces it with a
completely different design:

We now have in fstream.hh a global function:

input_stream<char>
make_file_input_stream(
        lw_shared_ptr<file> file, uint64_t offset = 0,
	uint64_t buffer_size = 8192);

In other words, instead of "seeking" in an input stream, we just open a new
input stream object at a particular offset of the given file. Multiple input
streams might be concurrently active on the same file.

Note how make_file_input_stream now returns a regular "input_stream", not a
subtype, and it can be used just like any normal input_stream to read the stream
starting at the given position.

This patch makes "input_stream" a "final" type: we no longer subclass it in our
code, and we shouldn't in the future because it goes against the PIMPL design
(the subclass should be of the inner workings, like the data_source_impl, not
of input_stream).

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
2015-03-10 15:39:17 +02:00
Nadav Har'El
20df45de44 scattered_message: Fix include loop
We had an include loop, which can cause problems in some cases:

1. iostream.hh #includes scattered_message.hh #includes reactor.hh
2. reactor.hh #includes iostream.hh

This patch fixes the loop be removing an unnecessary include.

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
2015-03-10 15:01:51 +02:00
Nadav Har'El
e45a507100 Remove unnecessary forward declarations from reactor.hh
reactor.hh includes forward declarations for input_stream, output_stream
template classes. These are unnecessary, because it #include's iostream.hh,
which contains the full definition of these classes.

These unnecessary forward declarations are harmless in the current code, but
they will become harmful if we change the definitions in iostream.hh (e.g., I
wanted to make input_stream a "final" class).

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
2015-03-10 15:01:34 +02:00
Avi Kivity
9639a7207e Merge branch 'master' of github.com:cloudius-systems/seastar into db
Conflicts:
	test.py
2015-03-10 13:06:02 +02:00
Gleb Natapov
8fd570d854 core: use perfect forwarding for function object in apply() 2015-03-10 12:57:13 +02:00
Nadav Har'El
4868bde49e Remove duplicate #include in reactor.hh
core/reactor.hh had two #include lines in the middle of the file, which
duplicate previous #include lines in the top of the file. So remove them.

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
2015-03-10 12:42:11 +02:00
Avi Kivity
8628d98542 shared_ptr: fix reference count loss when creating a derived type with e_s_f_t
make_shared() has a special case for detecting a created class deriving
from enable_shared_from_this<>, so it can point the refcount pointer into
the object's data area instead of creating a shared_ptr_count_base for it.

The code, however, fails to detect a creating class deriving indirectly
from enable_shared_from_this:

   struct base : enable_shared_from_this<base> {};

   struct derived : base {};

   make_shared<derived>();  // <- allocates independent refcount

The result is that the object reference counter lives in two locations.

Fix by detecting the derived class case as well.
2015-03-10 10:56:10 +02:00