Commit Graph

1721 Commits

Author SHA1 Message Date
Tomasz Grabiec
0973d7df7c cql3: Avoid unnecessary copy of a string 2015-02-12 19:40:58 +01:00
Tomasz Grabiec
ca4688540f cql3: Drop redundant optional<> around shared_ptr<> 2015-02-12 19:40:58 +01:00
Tomasz Grabiec
d6fcb92dd3 cql3: Add missing set_bound_variables() call
Resulted in nullptr dereference.
2015-02-12 19:40:57 +01:00
Tomasz Grabiec
0b39d284b8 service: Return keyspace name by const&
It should be up to the caller if copy is needed.
2015-02-12 19:40:57 +01:00
Tomasz Grabiec
43e693e72d service: Implement client_state::get_timeout() 2015-02-12 19:40:57 +01:00
Tomasz Grabiec
5359200ee4 cql3: Use @context instead of @members in Cql.g
There is a difference in meaning of @members between Cpp and Java
targets, because of reasons which are not clear to me. In Cpp @members
section is not put inside parser/lexer class definition, so any
varaible definitions declared there become program-global variables
instead of instance-local. We should use @context instead.
2015-02-12 19:40:57 +01:00
Tomasz Grabiec
7c7c23b5b6 service: Stub PagingState 2015-02-12 19:40:57 +01:00
Tomasz Grabiec
b7e3c46a42 service: Import PagingState.java 2015-02-12 19:40:57 +01:00
Tomasz Grabiec
6601e6a24f exceptions: Convert SyntaxException and its base classes 2015-02-12 19:40:57 +01:00
Tomasz Grabiec
c27bdb652b exceptions: Import CassandraException.java 2015-02-12 19:40:57 +01:00
Tomasz Grabiec
59803cce10 exceptions: Import RequestValidationException.java 2015-02-12 19:40:57 +01:00
Tomasz Grabiec
54dbc5de25 exceptions: Import SyntaxException.java 2015-02-12 19:40:57 +01:00
Tomasz Grabiec
09c54d256d excpetions: Convert ExceptionCode 2015-02-12 19:40:57 +01:00
Tomasz Grabiec
e8a4336c55 exceptions: Import TransportException 2015-02-12 19:40:57 +01:00
Tomasz Grabiec
ae725626d5 exceptions: Import ExceptionCode.java 2015-02-12 19:40:57 +01:00
Tomasz Grabiec
f3130d395f cql3: Return shared_ptr<result_message> instead of optional
It's polymorphic type in Origin.
2015-02-12 19:40:57 +01:00
Tomasz Grabiec
e3054daacf cql3: Convert parser rule for INSERT statement 2015-02-12 19:40:57 +01:00
Tomasz Grabiec
3d7122dc90 cql3: Do not fail because of unimplemented check_access()
Turn it into a warning.
2015-02-12 19:40:57 +01:00
Tomasz Grabiec
524c6a4e40 cql3: Implement modification_statement::validate() 2015-02-12 19:40:57 +01:00
Tomasz Grabiec
a7cf24b010 cql3: Take cf_name as shared_ptr<>
It's allocated as one in the parser so it's easier to just pass it
along. Later we may decide to change it to unique_ptr or optional<>.
2015-02-12 19:40:57 +01:00
Tomasz Grabiec
cecf06f44d cql3: Move parser out of cql3 namespace
This moves parser from cql3 to cql3_parser namespace to avoid name
conflicts between parser rules and classes defined in the cql3
namespace. In particular the "term" rule would conflict with the
"term" class, leading to compilation errors. I figured it will be
easier to change namespace than to rename all rule occurances.
2015-02-12 19:40:56 +01:00
Tomasz Grabiec
2f9476d712 cql3: Move parameters into fields rather than copy 2015-02-12 19:40:56 +01:00
Tomasz Grabiec
7ae8406ab2 cql3: Convert constants.NULL_LITERAL 2015-02-12 19:40:56 +01:00
Tomasz Grabiec
3a2bf359b8 cql3: Add to_string() virtual method to terminal class 2015-02-12 19:40:56 +01:00
Tomasz Grabiec
f450264a26 cql3: Remove duplicated definition of bytes_opt 2015-02-12 19:40:56 +01:00
Tomasz Grabiec
06ccaa3b5b db: Move method definitions to source file 2015-02-12 19:40:56 +01:00
Tomasz Grabiec
8d03ebb8a8 to_string: Add missing includes 2015-02-12 19:40:56 +01:00
Tomasz Grabiec
16a4b2f3e0 Introduce enum_set
Allows to take full advantage of compile-time information.

Examples:

  enum class x { A, B, C };
  using my_enum = super_enum<x, x::A, x::B, x::C>;
  using my_enumset = enum_set<my_enum>;

  static_assert(my_enumset::frozen<x::A, x::B>::contains<x::A>(),
  		"it should...");

  assert(my_enumset::frozen<x::A, x::B>::contains(x::A));
2015-02-12 19:40:56 +01:00
Glauber Costa
cba2d24210 keyspace: use emplace instead of the [] operator
It inflicted a lot of pain recently. Avoid it.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-02-11 20:26:20 +02:00
Tomasz Grabiec
81c250e698 transport: Remove invalid and no longer needed include 2015-02-09 18:44:19 +01:00
Avi Kivity
54865773e5 build: avoid generating duplicate build rules for thrift and antlr objects
Use a set to eliminate duplicates due to multiple binaries using the same
grammars and interfaces.
2015-02-09 18:23:09 +01:00
Avi Kivity
196d15d149 transport: de-ragel frame processing
Current ragel-based cql transport processing has a bug, in which it
assumes that frame headers will not cross a fragment boundary.  Rather than
fix it, drop ragel completely.  With a small complication, the frame header
size is known in advance, so we can just read_exactly() it.

The complication is that before the first frame is read, we do not know the
protocol version, which affects the frame header size.  Adjust for that by
reading the first byte, recording the version, and then splicing in the rest
of the frame header.
2015-02-09 18:23:09 +01:00
Avi Kivity
6bf105511b transport: rename cql/ to transport/
cql/, where the binary protocol code resides, is too similar to cql3/, where
the grammar lives.  Rename it to transport/ to reduce confusion.  While the
name isn't perfect, it matches origin.
2015-02-09 18:23:09 +01:00
Tomasz Grabiec
22bb2ac34d Merge branch 'tgrabiec/cql3' from git@github.com:cloudius-systems/seastar-dev.git
CQL3 Conversions, application of mutations into db.
2015-02-09 10:32:15 +01:00
Tomasz Grabiec
fb6941bbee tests: Add test for row tombstones 2015-02-09 10:28:45 +01:00
Tomasz Grabiec
7ea7a6822b db: Fix mutation_partition::apply_row_tombstone()
It was not updating already inserted tombstones.
2015-02-09 10:28:45 +01:00
Tomasz Grabiec
a6f4f2d6aa db: Add mutation_partition::tombstone_for_row() 2015-02-09 10:28:45 +01:00
Tomasz Grabiec
138ed6faac tests: Add test for tuple_type::is_prefix_of() 2015-02-09 10:28:45 +01:00
Tomasz Grabiec
0a5bf555ea types: Introduce tuple_type::is_prefix_of() 2015-02-09 10:28:45 +01:00
Tomasz Grabiec
7b7f63645b db: Make tombstone::operator bool() explicit 2015-02-09 10:28:45 +01:00
Tomasz Grabiec
37599d5d10 db: Define the rest of comparison operators in tombstone 2015-02-09 10:28:45 +01:00
Tomasz Grabiec
0bde5f74e7 db: Introduce tombstone::compare() and express operators using it 2015-02-09 10:28:45 +01:00
Tomasz Grabiec
543cc40d1a tests: Add performance test for in-memory row mutation
It shows that our serialization code, which is using ostringstream
under the hood, is really dragging us down. In the perf profile we can
see dynamic casts high called from iostream classes, called from
abstract_type::decompose()

$ taskset -c 0 build/release/tests/perf/perf_mutation
Timing mutation of single column within once row
83536.54 tps
115157.06 tps
85059.52 tps
60443.80 tps
112878.47 tps

$ perf report
-  11,66%    perf_mutation  libstdc++.so.6.0.20         [.] __cxxabiv1::__si_class_type_info::__do_dyncast(long, __cxxabiv1::__class_type_info::__sub_kind, __cxxabiv1:▒
   + __cxxabiv1::__si_class_type_info::__do_dyncast(long, __cxxabiv1::__class_type_info::__sub_kind, __cxxabiv1::__class_type_info const*, void const*, __cxxabiv1::__c◆
   - __dynamic_cast                                                                                                                                                    ▒
      - 43,58% std::num_get<char, std::istreambuf_iterator<char, std::char_traits<char> > > const& std::use_facet<std::num_get<char, std::istreambuf_iterator<char, std▒
           std::basic_ios<char, std::char_traits<char> >::_M_cache_locale(std::locale const&)                                                                          ▒
         - std::basic_ios<char, std::char_traits<char> >::init(std::basic_streambuf<char, std::char_traits<char> >*)                                                   ▒
              92,70% std::basic_istringstream<char, std::char_traits<char>, std::allocator<char> >::basic_istringstream(std::string const&, std::_Ios_Openmode)        ▒
            + 7,30% abstract_type::decompose(boost::any const&)                                                                                                        ▒
      - 27,36% bool std::has_facet<std::num_put<char, std::ostreambuf_iterator<char, std::char_traits<char> > > >(std::locale const&)                                  ▒
           std::basic_ios<char, std::char_traits<char> >::_M_cache_locale(std::locale const&)                                                                          ▒
         - std::basic_ios<char, std::char_traits<char> >::init(std::basic_streambuf<char, std::char_traits<char> >*)                                                   ▒
              93,14% std::basic_istringstream<char, std::char_traits<char>, std::allocator<char> >::basic_istringstream(std::string const&, std::_Ios_Openmode)        ▒
            + 6,86% abstract_type::decompose(boost::any const&)                                                                                                        ▒
      + 14,54% bool std::has_facet<std::num_get<char, std::istreambuf_iterator<char, std::char_traits<char> > > >(std::locale const&)                                  ▒
      + 14,52% std::num_put<char, std::ostreambuf_iterator<char, std::char_traits<char> > > const& std::use_facet<std::num_put<char, std::ostreambuf_iterator<char, std▒
-   9,97%    perf_mutation  libstdc++.so.6.0.20         [.] __dynamic_cast                                                                                             ▒
   - __dynamic_cast                                                                                                                                                    ▒
      + 19,67% std::num_get<char, std::istreambuf_iterator<char, std::char_traits<char> > > const& std::use_facet<std::num_get<char, std::istreambuf_iterator<char, std▒
      + 18,66% std::num_put<char, std::ostreambuf_iterator<char, std::char_traits<char> > > const& std::use_facet<std::num_put<char, std::ostreambuf_iterator<char, std▒
      + 16,72% bool std::has_facet<std::num_get<char, std::istreambuf_iterator<char, std::char_traits<char> > > >(std::locale const&)                                  ▒
      + 15,16% bool std::has_facet<std::num_put<char, std::ostreambuf_iterator<char, std::char_traits<char> > > >(std::locale const&)                                  ▒
      + 15,04% bool std::has_facet<std::ctype<char> >(std::locale const&)                                                                                              ▒
      + 14,74% std::ctype<char> const& std::use_facet<std::ctype<char> >(std::locale const&)                                                                           ▒
-   7,98%    perf_mutation  libstdc++.so.6.0.20         [.] __cxxabiv1::__vmi_class_type_info::__do_dyncast(long, __cxxabiv1::__class_type_info::__sub_kind, __cxxabiv1▒
   - __cxxabiv1::__vmi_class_type_info::__do_dyncast(long, __cxxabiv1::__class_type_info::__sub_kind, __cxxabiv1::__class_type_info const*, void const*, __cxxabiv1::__▒
   - __dynamic_cast                                                                                                                                                    ▒
      - 77,13% std::ctype<char> const& std::use_facet<std::ctype<char> >(std::locale const&)                                                                           ▒
           std::basic_ios<char, std::char_traits<char> >::_M_cache_locale(std::locale const&)                                                                          ▒
         + std::basic_ios<char, std::char_traits<char> >::init(std::basic_streambuf<char, std::char_traits<char> >*)                                                   ▒
      + 22,87% bool std::has_facet<std::ctype<char> >(std::locale const&)                                                                                              ▒
+   6,45%    perf_mutation  libstdc++.so.6.0.20         [.] std::locale::locale()                                                                                      ▒
+   6,40%    perf_mutation  libstdc++.so.6.0.20         [.] std::locale::~locale()                                                                                     ▒
+   5,02%    perf_mutation  libstdc++.so.6.0.20         [.] std::locale::operator=(std::locale const&)                                                                 ▒
+   4,18%    perf_mutation  libc-2.19.so                [.] __GI___strcmp_ssse3                                                                                        ▒
2015-02-09 10:28:45 +01:00
Tomasz Grabiec
1b66f33455 db: Apply mutations locally from storage_proxy
Eventually we should rather send them to replicas, but for now we just
apply locally.
2015-02-09 10:28:44 +01:00
Tomasz Grabiec
2244eab6c1 db: Steal data from mutations when applying
Taking mutations by r-value reference allows us to avoid copies.
2015-02-09 10:28:44 +01:00
Tomasz Grabiec
9530a372cc cql3: Take reference to storage_proxy and call instance methods 2015-02-09 10:28:44 +01:00
Tomasz Grabiec
28915bf673 tests: Add test for applying mutations 2015-02-09 10:28:44 +01:00
Tomasz Grabiec
ee10d9b437 tests: Add test for int32_type string conversions 2015-02-09 10:28:44 +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
92c95c6c81 types: Add tuple_type::decompose_value() shorthand method 2015-02-09 10:28:44 +01:00