Commit Graph

160 Commits

Author SHA1 Message Date
Pekka Enberg
4dc488afb2 database: Store metadata in 'struct keyspace'
Store a lw_shared_ptr<keyspace_metadata> in struct keyspace so callers
in migration manager, for example, can look it up.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-05-25 09:12:29 +02:00
Avi Kivity
ff42d58881 db: use CoW to modify the memtable list in column_family
Allow memtables to be removed from a column_family while a running query
continues to use them.
2015-05-20 16:00:00 +03:00
Avi Kivity
1342553fed db: remove column_family::testonly_all_memtables()
Unused and gets in the way.
2015-05-20 15:28:53 +03:00
Avi Kivity
f8f6e979ef db: use CoW to modify the sstable table in column_family
Allow sstables to be removed from a column_family while a running query
continues to use them.
2015-05-20 15:17:35 +03:00
Tomasz Grabiec
137b3beb2f Merge tag 'avi/readpath-prep/v1' from seastar-dev.git
From Avi:

"This patchset prepares for adding sstables to the read path.  Because sstables
involve I/O, their APIs return futures, which means that APIs that may call
those sstable APIs also need to return futures.

This patchset uses the two-space indent + do_with + reference aliases trick
to make patches more readable.  Cleanup patches will follow once it is merged."
2015-05-19 20:39:36 +02:00
Pekka Enberg
56d6fdacfe database: Simplify replication strategy initialization
Initialize replication strategy when keyspace is being created now that
we have access to keyspace_metadata.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-05-19 15:27:47 +03:00
Pekka Enberg
cd35617855 database: Use keyspace_metadata for creation functions
Use the keyspace_metadata type for keyspace creation functions. This is
needed to be able to have a mapping from keyspace name to keyspace
metadata for various call-sites.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-05-19 15:27:47 +03:00
Avi Kivity
db04bba208 db: futurize the single partition query path
Prepare for disk reads.
2015-05-19 15:13:09 +03:00
Avi Kivity
738be63b28 db: define column_family move constructor in .cc
Allows using it from files that do not include sstable.hh.
2015-05-19 15:13:09 +03:00
Pekka Enberg
8380df84b4 database: Rename ks_meta_data to keyspace_metadata
Follow the naming convention set by user_types_metadata and rename
ks_meta_data to keyspace_metadata.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-05-19 11:24:06 +03:00
Pekka Enberg
7a84b53d61 database: Use lw_shared_ptr for user types metadata
Use lw_shared_ptr for user types metadata member in ks_meta_data.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-05-19 11:17:55 +03:00
Pekka Enberg
a225439fdb database: Inline ks_meta_data implementation
The implementation part of ks_meta_data is just few lines of code.
Inline that to the database.hh header file.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-05-19 11:07:14 +03:00
Pekka Enberg
032af4d53b database: Move ks_meta_data definition to database.hh
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-05-19 11:03:28 +03:00
Avi Kivity
07d7f410f3 Merge branch 'memtable' into db
Conflicts:
	database.hh
	memtable changes moved to memtable.hh
2015-05-18 15:50:24 +03:00
Avi Kivity
875148dae6 db: create keyspace/column_family directory structure
This is slightly awkwards, since the directory structure is not sharded.
This requires some processing to occur outside the shard, while the rest
is sharded.
2015-05-18 15:34:41 +03:00
Avi Kivity
20775b9d5c db: store a column_family's memtables in a list instead of a vector
A vector can cause memtables to be move()d around, which breaks any
code that captures a memtable's this pointer.

Fix by using a linked list.
2015-05-18 15:34:25 +03:00
Avi Kivity
394e0d3a8c db: make database::add_keyspace() return void
Returning a reference to the keyspace is dangerous in that the keyspace can
be moved away, when we start futurizing the add_keyspace() process.  Make
it return void and look up the keyspace at the point of use.
2015-05-18 15:34:25 +03:00
Avi Kivity
d8fed7e211 db: add simple memtable sealing policy
Need to be replaced with something better, but we lack the infrastructure so
far (region memory allocator).
2015-05-18 15:34:25 +03:00
Avi Kivity
0eb842dc5b db: write memtable after sealing it
Still missing handling after write completes.
2015-05-18 15:00:33 +03:00
Avi Kivity
ca49d73f97 db: allow configuring a column family to be memory-only
Useful for tests.
2015-05-18 15:00:33 +03:00
Avi Kivity
dda5cbfd0d db: make column_family and keyspace configurable
Currently used for the data directory.
2015-05-18 15:00:31 +03:00
Avi Kivity
7842113cb6 db: prune some unused column_familiy methods
Made redundant by switching tests to using memtable directly.
2015-05-18 14:59:02 +03:00
Glauber Costa
2174285c31 db: move memtable definition to its own file
Following what happened to others: we can now include memtable.hh
without including database.hh

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-05-17 12:38:32 +03:00
Avi Kivity
40c2d91cd8 db: add memtable::find_or_create_row_slow()
Useful for tests that do not need a column_family.
2015-05-17 10:31:22 +03:00
Tomasz Grabiec
f7abbda156 db: Apply frozen_mutation directly
We don't convert it back to mutation before applying.

mutation_partition has now apply() which works on
mutation_partition_view.
2015-05-08 09:19:02 +02:00
Tomasz Grabiec
4ab66de0ae db: Introduce frozen_mutation
The immediate motivation for introducing frozen_mutation is inability
to deserialize current "mutation" object, which needs schema reference
at the time it's constructed. It needs schema to initialize its
internal maps with proper key comparators, which depend on schema.

frozen_mutation is an immutable, compact form of a mutation. It
doesn't use complex in-memory strucutres, data is stored in a linear
buffer. In case of frozen_mutation schema needs to be supplied only at
the time mutation partition is visited. Therefore it can be trivially
deserialized without schema.
2015-05-08 09:19:01 +02:00
Tomasz Grabiec
a854163f71 db: Cleanup unimplemented method 2015-05-08 09:19:01 +02:00
Avi Kivity
ef5c661d11 db: add variant of column_family::for_all_partitions() for unit tests
Since it's for tests, we can pass a slower std::function<>.
2015-05-06 15:43:06 +03:00
Avi Kivity
1d6ac071c0 db: add API to seal current active memtable 2015-05-06 15:39:31 +03:00
Avi Kivity
22969aeb18 db: support for multiple memtables
Each column family now contains multiple memtables, with one designated as
"active" receiving all writes, while the others only serve reads.
2015-05-06 15:39:29 +03:00
Avi Kivity
5e81b92dc0 db: split column_family::partitions into a new memtable class
In preparation for multiple memtables, move column_family::partitions into
its own class, and forward relevant calls from column_family.

A testonly_all_memtables() function was added to support sstable_test.
2015-05-06 15:35:14 +03:00
Avi Kivity
e811690588 db: return smart pointers for column_family read-side lookups
A lookup can cause several data sources to be merged, in which case we will
have to return a temporary (containing data from all the data sources).

For simplicity, we start by always returning a temporary.
2015-05-05 20:21:04 +03:00
Avi Kivity
8028fb441a db: make column_family a class, not a struct
Don't expose privates in public.
2015-05-05 20:21:03 +03:00
Avi Kivity
3a0de14aa8 db: more const correctness for column_family and component types
Ensure that read-side accessors are const.  This is important in preparation
for multiple memtables (and later, sstables) since a read-side
mutation_partition may be a temporary object coming from multiple memtables
(and sstables) while a write-side mutation_partition is guaranteed to belong
to a single memtable (and thus, not be temporary).

Since writers will want non-const mutation_partitions to write to, they won't
be able to use the read-side accessors by accident.
2015-05-05 19:37:21 +03:00
Tomasz Grabiec
aec740f895 db: Make decorated_key have ordering compatible with Origin 2015-04-30 12:02:39 +02:00
Tomasz Grabiec
51d26620ca db: Remove comment above partitions map
I think the types are explicit enough now.
2015-04-30 11:16:53 +02:00
Calle Wilund
2f4e7a00f6 Use db/config object in main, database etc
* Uses config object to augument/impl options parsing
* Database now holds config obj
* Commitlog can now be inited with global config obj.
2015-04-29 18:01:17 +02:00
Avi Kivity
3162873d7f Merge branch 'calle/commitlog' of github.com:cloudius-systems/seastar-dev into db
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...
2015-04-29 11:28:05 +03:00
Calle Wilund
aeb83f2874 Add commitlog to db + use it in storage_proxy/handler
* 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.
2015-04-29 10:10:21 +02:00
Tomasz Grabiec
cae462c534 Merge remote-tracking branch 'dev/penberg/keyspace-merging/v5' from seastar-dev.git
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."
2015-04-28 18:06:23 +02:00
Pekka Enberg
33ceac5643 database: add database::delete_keyspace() stub
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-04-28 15:49:33 +03:00
Tomasz Grabiec
6e78344c87 Merge tag 'avi/usertypes-addendum/v1' from seastar-dev.git 2015-04-27 12:53:00 +02:00
Avi Kivity
f779c54d75 db: rename tuple_type family to compound_type
tuples already have a meaning in Cassandra and in C++, let's not overload
the word even more.  Use compound, which is the word used in Origin as well.
2015-04-27 12:27:18 +02:00
Pekka Enberg
cf1d6197d6 database: add database::update_keyspace() stub
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-04-27 11:39:57 +03:00
Avi Kivity
ba0afecf2e db: implement user_types_metadata
This is a simple map of type names to types, with the slight complication
of checking for compatibility when replacing a type.
2015-04-26 18:33:25 +03:00
Tomasz Grabiec
5a7e3d3278 db: Order partitions by decorated_key
Partitions should be ordered using Origin's ordering, which is first
by token, then by Origin's representation of the key. That is the
natural ordering of decorated_key.

This also changes mutation class to hold decorated_key, to avoid
decoration overhead at different layers.
2015-04-24 18:01:01 +02:00
Tomasz Grabiec
1c3275c950 mutation: Encapsulate fields 2015-04-24 18:01:01 +02:00
Tomasz Grabiec
4641bc6f95 database: Move implementation to source file 2015-04-24 18:01:01 +02:00
Tomasz Grabiec
0d4821009c db: Move mutation and mutation_partition to separate headers and compilation units 2015-04-22 18:42:33 +02:00
Tomasz Grabiec
a5c201a685 db: Move column_family::get_partition_slice() to mutation_partition::query()
There's nothing column_family-specific there.
2015-04-22 17:40:02 +02:00