bytes and sstring are distinct types, since their internal buffers are of
different length, but bytes_view is an alias of sstring_view, which makes
it possible of objects of different types to leak across the abstraction
boundary.
Fix this by making bytes a basic_sstring<int8_t, ...> instead of using char.
int8_t is a 'signed char', which is a distinct type from char, so now
bytes_view is a distinct type from sstring_view.
uint8_t would have been an even better choice, but that diverges from Origin
and would have required an audit.
cql3_type is a wrapper around data_type, so there's no need for a class
hierarchy -- anything that depends on the actual type can be forwarded
to abstract_type_impl.
We can now use this as a value type (dropping shared_ptr<cql3_type>), but
that is left for later.
Instead of using inefficient std::ostream, use our own 'bytes' iterator class.
Compute ahead of time the length of the byte buffer.
Afterwards serialize the objects into it.
Gives ~X5 boost over previus results (that sometimes don't even
finish in reasonable time)
[avi: add missing include]
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>
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>
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>
Switch to sizeof in preparation for converting int32_type_impl into a
generic integer_type_impl.
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>