Commit Graph

26 Commits

Author SHA1 Message Date
Avi Kivity
aa1e02ab46 Merge branch 'types' into db
More type work.

Reviewed-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-01-07 13:57:15 +02:00
Avi Kivity
cfd86d70f8 db: extract default compare method into a default_less<> helper
The helper is a little more flexible in that it accepts a comparator,
instead of using <.
2015-01-06 15:26:45 +02:00
Avi Kivity
a191d598c2 db: implement boolean type 2015-01-06 15:26:40 +02:00
Glauber Costa
974278203c db: add datadir to the database
This is the directory from which we will read the sstables.
Code to actually parse them will come later.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-01-06 14:54:47 +02:00
Avi Kivity
e733c2a45a db: change abstract_type::deserialize to allow null objects
In some cases, deserialize() can return a null object (if there were zero
input bytes).

In others, it cannot (for string or blob types).

Change the return type to optional<any> and adapt the deserialiation code
to deal with it.
2015-01-06 12:49:47 +02:00
Avi Kivity
d5c9f66009 db: adjust abstract_type indentation 2015-01-05 15:56:29 +02:00
Avi Kivity
1fe6bf687d db: de-pimpl data_type
Since origin tends to cast around, we should allow that too, by exposing
the implementation type and using a shared_ptr instead of a value class.
2015-01-05 15:55:30 +02:00
Avi Kivity
80408329e0 db: rename data types to conform to origin conventions 2015-01-05 13:48:38 +02:00
Avi Kivity
d5491f87c5 db: add abstract_type alias 2015-01-05 13:30:50 +02:00
Avi Kivity
efc868d1e6 db: extend data_type to be able to support dynamic types
Dynamic types come and go, so they need to be reference counted.

Switch data_type to using a shared_ptr<> for its implementation.

Since thread_ptr is not thread safe, the global primitive types must be
thread_local.
2015-01-05 13:26:56 +02:00
Asias He
7d0ef20a80 Add comparator 2015-01-05 14:13:31 +08:00
Avi Kivity
3900173c75 db: add data_type_for<> helper
Converts C++ data type to corresponding data_type class, during compile time.
2014-12-31 16:07:50 +02:00
Avi Kivity
d19043fca2 db: add data_type::decompose
Convert any -> bytes.
2014-12-31 16:07:17 +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
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
Avi Kivity
858e910fe3 db: implement std::hash<data_type> 2014-12-24 14:18:21 +02:00
Avi Kivity
26461bee58 db: add a "bytes" type, corresponding to ByteBuffer (serialized values)
Using sstring can lead to confusion with UTF8 strings.
2014-12-24 12:16:04 +02:00
Avi Kivity
641c859903 db: add in-memory database
Simplistic database using std::map<> to hold rows, and boost::any to
hold values.

Supports:
  - multiple key spaces
  - multiple column families
  - a few data types

Does not support:
  - container data types
  - secondary indexes
  - composites
  - validators
2014-12-23 18:41:29 +02:00