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
fb876cb6f2
db: implement list_type
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
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
5bff24c292
db: constify standard data_types
...
Lest someone accidentally move them away or assign into them.
2015-03-05 22:20:04 +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
98f2a51df9
db: implement collection mutation merging
...
Only for maps, as they are the only collection implemented at present.
2015-03-05 18:11:37 +02:00
Avi Kivity
b5571e4c18
db: implement map_type (partial)
2015-03-05 15:31:50 +02:00
Avi Kivity
56d5c24a6a
db: implement CollectionType (partial)
2015-03-05 14:04:19 +02:00
Avi Kivity
853d0b2ca0
abstract_type: implement freeze()
2015-03-05 14:03:35 +02:00
Asias He
0036ee16d8
types: Add read_simple_short_string
...
bytes_view version of deserialize_string
2015-03-05 18:25:24 +08: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
Nadav Har'El
6f2a2529a2
add "double" and "float" types
...
Implement "double" and "float" cql types.
This implementation doesn't touch serialization.hh (which should be
eventually removed) and rather follows the other examples in types.cc.
It is relatively ugly, because of all the cleverness of our "general"
byte swapping implementation actually works only for integer types, and
we need to get it to work for float/double as well.
Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com >
2015-03-04 10:54:19 +01:00
Pekka Enberg
99a09020e8
types: Fix bytes_type_impl string conversion
...
Tomek points out that:
Origin calls org.apache.cassandra.utils.Hex#hexToBytes here, which is
not what to_bytes() does. BytesType.getSerializer().toString() calls
ByteBufferUtil.bytesToHex(value), so you should call to_hex() here.
Fix that up.
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com >
2015-03-02 10:38:27 +01:00
Tomasz Grabiec
1f9d22f7e3
types: Fix read_simple*() variants to work for unaligned positions
...
Since types can be embedded at any position in memory we cannot assume
alignment.
Side note: It seems that on x86 access to the variable via packed<>
does not result in any extra instructions.
2015-02-27 10:48:56 +01:00
Tomasz Grabiec
00984609cb
types: Add abstract_tyep::is_value_compatible_with() method
2015-02-27 10:48:56 +01:00
Nadav Har'El
8701273006
Add inet type
...
In v2: rebase, and add a more descriptive exception if trying to deserialize
an ipv6 address.
Add to list of types the Internet address type, known as INET in CQL
or as InetAddressType in the Cassandra code.
I based this code on stuff I found in InetAddressType and
InetAddressSerializer in the Cassandra code.
Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com >
2015-02-25 15:57:05 +01:00
Avi Kivity
a2519926a6
db: add some iostream output operators
...
Helps debugging
2015-02-19 15:56:26 +02:00
Tomasz Grabiec
245f4dfe00
types: Avoid allocation in simple_type_impl::less()
2015-02-17 12:43:15 +02:00
Tomasz Grabiec
700799e965
types: Make deserialize() work on bytes_view
2015-02-17 12:43:15 +02:00
Tomasz Grabiec
6cde02cbc7
types: Make equal/hash/less work on bytes_view
...
The serialized value is not always a standalone "bytes" object, it can
be embedded in a larger chunk. It's much faster to work on the data
in-place.
2015-02-17 12:43:15 +02:00
Tomasz Grabiec
63d152ece8
types: Introduce abstract_type::as_cql3_type()
...
Origin also has it.
2015-02-12 19:40:58 +01:00
Tomasz Grabiec
863d305a66
types: Make from_string() work on sstring_view
2015-02-12 19:40:58 +01:00
Tomasz Grabiec
3aea084f2b
types: Add sstring_view type alias
2015-02-12 19:40:58 +01:00
Tomasz Grabiec
0a5bf555ea
types: Introduce tuple_type::is_prefix_of()
2015-02-09 10:28:45 +01:00
Tomasz Grabiec
f1c9f64a25
types: Implement string conversions for int32_type and string_type
2015-02-09 10:28:44 +01:00
Tomasz Grabiec
19e89a6057
db: Introduce mutation_partition::apply(const mutation_partition&)
...
It merges two partition mutations together. It is assumed that the first
one (invocation target) is much larger.
2015-02-09 10:28:44 +01:00
Tomasz Grabiec
87a38b52ef
types: Add from_string() stub
2015-02-09 10:28:43 +01:00
Tomasz Grabiec
5d92ef267a
types: Expand the interface of abstract_type
2015-02-04 10:29:00 +01:00
Tomasz Grabiec
25cdd44144
types: Fix compare_unsigned()
...
In lexicographical order length is compared second.
2015-02-04 10:28:51 +01:00
Tomasz Grabiec
22b7010c6d
types: Introduce non-polymorphic serialization/deserialization helper functions
...
All usages I could find which deserialize value are
non-polymorphic. So there is no need to use boost::any() indirection
and polymorphic calls in most, if not all, cases.
Let the type class define deserialize_value/serialize_value
non-polymorphic members which work direclty on "value_type" and not
boost::any.
2015-01-29 15:02:27 +01:00
Tomasz Grabiec
37ef4bf635
types: Rename simple_compare to serialized_compare
...
To be in line with serialized_equal and serialized_hash
2015-01-29 15:02:27 +01:00
Tomasz Grabiec
65d2707794
types: Add support for equality and hashing of serialized values
2015-01-29 15:02:27 +01:00
Tomasz Grabiec
c14891adfd
types: Mark is_byte_order_comparable() as const
2015-01-29 15:02:26 +01:00
Tomasz Grabiec
17b9babd91
Extract types related stuff from database.{cc,hh} to types.{cc,hh}
2015-01-29 15:02:19 +01:00