Commit Graph

48 Commits

Author SHA1 Message Date
Paweł Dziepak
7604b926e1 atomic_cell: add COUNTER_IN_PLACE_REVERT flag
The general algorithm for merging counter cells involves allocating a
new buffer for the shards. However, it is expected that most of the
applies are just updating the values of existing shards and not adding
new ones, therefore can be done in place.
However, reverting the general and in-place applies requires different
logic, hence the need for an additional flag to differentiate between
them.
2017-03-02 09:05:11 +00:00
Paweł Dziepak
2db92e92b2 atomic_cell: introduce atomic_cell_mutable_view 2017-03-02 09:05:11 +00:00
Paweł Dziepak
37485e5b29 counters: optimise counter_cell_builder
This patch attempts to avoid excessive allocations and copies when
constructing counter cells using counter_cell_builder. That involves
adding serializer interface to atomic_cell so that the counter cell can
be directly serialized to the buffer allocated for atomic cell.

counter_cell_builder::from_single_shard() is added as well to avoid
std::vector<> overhead when creating a counter cell from a single shard.
2017-03-02 09:05:10 +00:00
Paweł Dziepak
bdac487b5a do not use long_type for counter update 2017-03-01 16:33:37 +00:00
Paweł Dziepak
0c93d01232 atomic_cell: make sure upper level tombstones cover counters
Support for deletion of counters is limited in a way that once deleted
they cannot be used again (i.e. tombstone always wins, regardless of the
timestamp). Logic responsible for merging two counter cells already
makes sure that tombstones are handled properly, but it is also
necessary to ensure that higher level tombstones always cover counters.
2017-02-02 10:35:14 +00:00
Paweł Dziepak
0a8f00c159 atomic_cell: add flag for recognizing counter updates
A counter cell may be either a collection of shards or just a delta. The
former can only appear in certain places on coordinator and leader.
2017-02-02 10:35:13 +00:00
Tomasz Grabiec
ddfee57c97 Replace iostream include with iosfwd in headers
Message-Id: <1484656119-8386-4-git-send-email-tgrabiec@scylladb.com>
2017-01-17 14:52:44 +02:00
Paweł Dziepak
2c5ec44281 atomic_cell: add overloads taking const bytes&
Deserialization code is going to use a proxy object that will be casted
to either bytes or bytes_ostream depending on the demand. It cannot be
casted directly to bytes_view though as it won't extend the lifetime of
the buffer appropriately. The simples solution is just to add overloads
that accept const bytes&.

Signed-off-by: Paweł Dziepak <pdziepak@scylladb.com>
2016-08-22 09:31:33 +01:00
Pekka Enberg
38a54df863 Fix pre-ScyllaDB copyright statements
People keep tripping over the old copyrights and copy-pasting them to
new files. Search and replace "Cloudius Systems" with "ScyllaDB".

Message-Id: <1460013664-25966-1-git-send-email-penberg@scylladb.com>
2016-04-08 08:12:47 +03:00
Tomasz Grabiec
c9d4f5a49c atomic_cell_or_collection: Introduce as_atomic_cell_ref()
Needed for setting the REVERT flag on existing cell.
2016-03-21 19:25:54 +01:00
Tomasz Grabiec
bfc6413414 atomic_cell: Add REVERT flag
Needed to make atomic cells ReversiblyMergeable.
2016-03-21 18:41:27 +01:00
Tomasz Grabiec
bc9ee083dd db: Move atomic_cell_or_collection to separate header
To break future cyclic dependency:

  atomic_cell.hh -> schema.hh (new) -> types.hh -> atomic_cell.hh
2016-01-08 21:10:25 +01:00
Avi Kivity
ad975ad629 atomic_cell_or_collection: linearize(), unlinearize()
Add linearize() and unlinearize() methods that allow making an
atomic_cell_or_collection object temporarily contiguous, so we can examine
it as a bytes_view.
2015-12-08 15:17:09 +02:00
Avi Kivity
79f7431a03 db: change collection_mutation::{one,view} not to use nested classes
Nested classes cannot be forward-declared, so change the naming
not to use them.  Follows atomic_cell{,_view}.
2015-11-13 17:13:07 +02:00
Avi Kivity
d5cf0fb2b1 Add license notices 2015-09-20 10:43:39 +03:00
Paweł Dziepak
c8b8136941 atomic_cell_or_collection: add cast to bool
Signed-off-by: Paweł Dziepak <pdziepak@cloudius-systems.com>
2015-08-31 17:27:20 +02:00
Paweł Dziepak
4f58f12cac atomic_cell_or_collection: make default constructor public
Signed-off-by: Paweł Dziepak <pdziepak@cloudius-systems.com>
2015-08-31 17:27:20 +02:00
Paweł Dziepak
3758a6d0a9 atomic_cell_or_collection: add operator==()
Signed-off-by: Paweł Dziepak <pdziepak@cloudius-systems.com>
2015-08-31 17:27:20 +02:00
Tomasz Grabiec
2bfb138910 Fix typos 2015-08-25 17:07:35 +03:00
Tomasz Grabiec
831cdf74c4 db: Avoid allocation of temporary bytes object
We're storing data inside managed_bytes now, so conversion to "bytes"
is futile.
2015-08-06 18:56:48 +02:00
Tomasz Grabiec
c4acdb2068 db: Switch from bytes to managed_bytes for storing data
We need a container which can be used with compacting
allocators. "bytes" can't be used with compacting allocator because it
can't handle its external storage being moved.
2015-08-06 14:05:16 +02:00
Tomasz Grabiec
c975e7fb56 db: atomic_cell: Fix misnamed parameter 2015-07-09 19:46:30 +02:00
Tomasz Grabiec
33778231d9 db: atomic_cell: Introduce is_covered_by() helper 2015-07-09 19:46:29 +02:00
Paweł Dziepak
7dbcdb4a9e atomic_cell_base: remove unused function is_dead()
Signed-off-by: Paweł Dziepak <pdziepak@cloudius-systems.com>
2015-07-02 17:26:18 +02:00
Paweł Dziepak
61aae4a278 atomic_cell: add checks for expired cells
Signed-off-by: Paweł Dziepak <pdziepak@cloudius-systems.com>
2015-07-02 17:01:19 +02:00
Paweł Dziepak
9992795a5c atomic_cell: move common logic to atomic_cell_base
Signed-off-by: Paweł Dziepak <pdziepak@cloudius-systems.com>
2015-07-02 16:47:18 +02:00
Tomasz Grabiec
eaceb61801 db: Add atomic_cell::deletion_time()
Deleted cells store deletion time not expiry time. This change makes
expiry() valid only for live cells with TTL and adds deletion_time(),
which is inteded to be used with deleted cells.
2015-05-10 12:03:26 +03:00
Tomasz Grabiec
b1e45e4401 db: Store ttl in atomic_cell
Origin does that, so should we. Both ttl and expiry time are stored in
sstables. The value of ttl seems to be used to calculate the read
digest (expiry is not used for that).

The API for creating atomic_cells changed a bit.

To create a non-expiring cell:

  atomic_cell::make_live(timestamp, value);

To create an expiring cell:

  atomic_cell::make_live(timestamp, value, expiry, ttl);

or:

  // Expiry is calculated based on current clock reading
  atomic_cell::make_live(timestamp, value, ttl_optional);
2015-05-06 19:42:38 +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
2ab006949a atomic_cell: Extend interface of collection_mutation wrappers 2015-05-06 16:40:48 +02:00
Tomasz Grabiec
45f66c5c9f atomic_cell: Add missing header 2015-05-06 16:40:48 +02:00
Tomasz Grabiec
b34cdd76ae db: Make the whole database printable
For debugging purposes.
2015-04-15 20:33:48 +02:00
Tomasz Grabiec
66924090c6 Merge tag 'avi/functions/v1'
From Avi:

This patchsets completes the conversion of scalar functions (TOKEN is still
missing, and maybe others, but the infrastructure is there).

Conflicts:
	database.cc
2015-04-02 12:48:21 +02:00
Avi Kivity
bb4b303bba db: add ostream operators for atomic_cell 2015-04-01 20:12:39 +03:00
Calle Wilund
6f6f924c9c Serializer object(s) for internal use
For serializing to commit log, and potentially internal wire messaging.

Note: intentionally incompatible with stock C wire/serial format.

Note: intentionally separate from the CQL-centric serialization
for a few reasons.

1.) Need "bulk serializers" for internal objects (mutation etc)
which might not fit well into the "types.hh" serializer schemes.
2.) No need for polymorphism/virtual type parameters since we know
exactly what we serialize and to where.
2015-04-01 10:08:00 +02:00
Tomasz Grabiec
69b4dd76e8 atomic_cell: Add is_live() version which takes a tombstone
It determines if the cell is live given its cointainer has this
tombstone.
2015-03-30 09:07:00 +02:00
Avi Kivity
6f7187fa43 db: drop unused atomic_cell::is_dead() parameter 2015-03-23 21:54:22 +02:00
Tomasz Grabiec
90298af614 db: Cleanup atomic_cell naming
atomic_cell -> atomic_cell_type
atomic_cell::one -> atomic_cell
atomic_cell::view -> atomic_cell_view
2015-03-20 18:59:29 +01:00
Avi Kivity
56d4592e00 atomic_cell: add view::serialize() helper 2015-03-12 09:56:53 +02:00
Tomasz Grabiec
3db3207b85 Merge branch seastar-dev.git 'collections'
Collections support from Avi.
2015-03-05 20:25:48 +01:00
Avi Kivity
42a9c0f7d3 atomic_cell: export merge_column 2015-03-05 19:03:29 +02:00
Avi Kivity
df22293baf atomic_cell: export compare_atomic_cell_for_merge
Will be used for merging maps.
2015-03-05 18:11:37 +02:00
Avi Kivity
57b6d4ada5 atomic_cell: add collection support
We leave interpretation to the backing type (map/set/list), so there is
not much code here.
2015-03-05 14:03:36 +02:00
Avi Kivity
2f8be37fca atomic_cell_or_collection: allow construction from atomic_cell
Since an atomic_cell has an is-a relationship to atomic_cell_or_collection,
we can allow direct conversion.  Type information is only lost, not added.
2015-03-05 14:03:36 +02:00
Avi Kivity
76d1256565 atomic_cell: add serialize() method
Since atomic_cell is already in serialized form, the implementation is
simple.
2015-03-05 14:03:36 +02:00
Avi Kivity
7eba98f18c atomic_cell: add missing include 2015-03-05 11:17:43 +02:00
Tomasz Grabiec
55fae09bf9 db: Remove unused parameter from atomic_cell::view::is_dead() 2015-03-05 10:09:38 +01:00
Avi Kivity
6d18aa8f20 Decompose database.hh, types.hh into smaller headers
Avoid include hell for new code.
2015-03-04 16:18:48 +02:00