Allow enable_shared_from_this<T>::shared_from_this() to return
a shared_ptr<const T> when called on a const object.
Reviewed-by: Pekka Enberg <penberg@cloudius-systems.com>
Use commit log in database, from Calle:
"Initial" usage of the commitlog in database mutation path.
A commitlog is created in "work" dirs when initing the db
from a datadir. However, since we have neither disk data storage,
nor replay capability yet (and no real db config), the settings
are basically to just write in-memory serialization, write them to
disk and then discard them. So in fact, pointless. But at least using
the log...
* A commitlog is created in "work" dirs when initing the db
from a datadir. However, since we have neither disk data storage,
nor replay capability yet (and no real db config), the settings
are basically to just write in-memory serialization, write them to
disk and then discard them. So in fact, pointless. But at least using
the log...
* Moved the actual "apply" of mutation into database. If a commitlog
is active, add an entry to it before applying mutation.
From Pekka:
"This patch series converts LegacySchemaTables keyspace merging code to
C++. After this series, keyspaces are actually created as demonstrated
by the newly added test in cql_query_test.cc."
Add a query::result_set class that contains per-row cells that can be
accessed by column name. Partition keys, clustering keys, and static
values are duplicated for every row for convenience.
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
This patch adds support to reading deleted cells (a.k.a. cell tombstones)
from the SSTable.
The way deleted cells are encoded in the sstable is explained in the
"Cell tombstone" section of
https://github.com/cloudius-systems/urchin/wiki/SSTables-interpretation-in-Urchin
This more-or-less completes the low-level SSTable row reading code - the
only remaining untreated case are counters, which we agreed to leave to
later. If counters are found in the SSTable, we'll throw an exception.
This patch adds a new callback, consume_deleted_cell, taking the name of
the cell and its deletion_time (as usual, deletion_time includes both a
64-bit timestamp, for ordering events, and a 32-bit "local_deletion_time"
used to schedule gc of old tombstones).
This patch also adds a test SSTable with deleted cell, created by the
following Cassandra Commands:
CREATE TABLE deleted (
name text,
age int,
PRIMARY KEY (name)
);
INSERT INTO deleted (name, age) VALUES ('nadav', 40);
<flush table - the second table is what we're after>
DELETE age FROM deleted WHERE name = 'nadav';
We test our ability to read this sstable, and see the deleted cell
and its expected deletion time.
Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
This patch adds support to reading sstable cells with expiration time.
It adds two more parameters to the row_consumer::consume_cell() - "ttl"
and "expiration". The "ttl" is the original TTL set on the cell in seconds,
the "expiration" is the absolute time (in seconds since the Unix epoch) when
this cell is set to expire. I don't know why both values are needed...
When a cell has no expiration time set (most cells will be like that), the
callback with will be called expiration==0 (and ttl==0).
This patch also adds a test SSTable with cells with set TTL, created by
the following Cassandra commands:
CREATE TABLE ttl (
name text,
age int,
PRIMARY KEY (name)
);
INSERT INTO ttl (name, age) VALUES ('nadav', 40) USING TTL 3600;
And tests our ability to read the resulting sstable, and get the expected
expiration time.
Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
We didn't handle properly the case when the last component of a
prefixable compound was empty. Because we do not encode component's
length, we did not distinguish a compound with last element empty from
a compound without the last element.
The fix is to always encode lengths in prefixable tuples.
The foreign_ptr wrapper needs 'element_type' to be present in
shared_ptr to be able to access the data.
Fixes the following compilation failure when trying to use shared_ptr
with foreign_ptr:
In file included from tests/foreign_ptr_test.cc:24:0:
./core/distributed.hh: In instantiation of ‘class foreign_ptr<shared_ptr<basic_sstring<char, unsigned int, 15u> > >’:
tests/foreign_ptr_test.cc:28:54: required from here
./core/distributed.hh:272:56: error: no type named ‘element_type’ in ‘class shared_ptr<basic_sstring<char, unsigned int, 15u> >’
using element_type = typename PtrType::element_type;
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
Unmarshalling function should not throw, but in case it does move
connection to an error state and report the error to an rpc client.
Currently all errors are reported as rpc::closed_error().