Commit Graph

1694 Commits

Author SHA1 Message Date
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
Tomasz Grabiec
d5a7f37c45 db: Merge api.hh into database.hh 2015-02-09 10:28:44 +01:00
Tomasz Grabiec
e20cc1c1f9 db: Avoid storing schema pointer with each partition 2015-02-09 10:28:44 +01:00
Tomasz Grabiec
48c11a01db db: Add ability to apply mutations into the database
For simplicity partition data is stored using the same object which is
used for mutations: mutation_partition. Later we can introduce a more
efficient version.
2015-02-09 10:28:44 +01:00
Tomasz Grabiec
800ba79efa db: Drop api:: namespace from mutation model classes
In preparation for merging into database.hh
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
3645e983c0 db: Refactor atomic_cell structure
The new structure has common timestamp field extracted, it has the
same meaning for both live and dead cells. It will make it easier to
merge cells this way.
2015-02-09 10:28:44 +01:00
Tomasz Grabiec
1212ad18d0 db: Make setting static vs. clustered cell explicit 2015-02-09 10:28:44 +01:00
Tomasz Grabiec
df8f7279b3 db: Simplify row tombstone management 2015-02-09 10:28:44 +01:00
Tomasz Grabiec
211f52e40a schema: Move to schema.hh 2015-02-09 10:28:44 +01:00
Tomasz Grabiec
9f8ac4ab2a cql3: Implement column_identifier::raw::prepare() 2015-02-09 10:28:43 +01:00
Tomasz Grabiec
87a38b52ef types: Add from_string() stub 2015-02-09 10:28:43 +01:00
Tomasz Grabiec
90604df376 cql3: Move method definition to the source file 2015-02-09 10:28:43 +01:00
Tomasz Grabiec
754976bbec cql3: Convert ParsedUpdate 2015-02-09 10:28:43 +01:00
Tomasz Grabiec
87597ba3a4 cql3: Fix typo in process_where_clause() 2015-02-09 10:28:43 +01:00
Tomasz Grabiec
ef7ce1406f cql3: Make column_identifier ostream-printable 2015-02-09 10:28:41 +01:00
Tomasz Grabiec
73f1c6cb44 cql3: Make name accessors return sstring ref instead of value
To avoid unnecessary copies.
2015-02-09 10:28:10 +01:00
Tomasz Grabiec
987cdaa6cb cql3: Optimise includes 2015-02-09 10:28:09 +01:00
Tomasz Grabiec
12af207219 cql3: Add missing virtual/override 2015-02-09 10:28:09 +01:00
Tomasz Grabiec
208fdfab45 cql3: Move methods from header to source file 2015-02-09 10:28:09 +01:00
Tomasz Grabiec
852afdfb3c validation: Add missing include 2015-02-09 10:28:09 +01:00
Tomasz Grabiec
295fca1c71 Merge remote-tracking branch 'dev/penberg/cql-for-tomek' 2015-02-09 10:12:44 +01:00
Tomasz Grabiec
911c514a70 Merge branch 'master' of github.com:cloudius-systems/seastar 2015-02-09 10:11:15 +01:00
Asias He
f0c1bcdb33 tcp: Switch to debug print for persist timer
It is a left over during development.
2015-02-09 10:58:16 +02:00
Asias He
a192391ac6 tcp: Init timer callback using constructor 2015-02-09 10:58:15 +02:00
Asias He
0ac0e06d32 packet: Linearize after merge
The packet will be merged with the old packet anyway. Linearize after
the merge.
2015-02-09 10:58:15 +02:00
Raphael S. Carvalho
bf41da8974 core: small optimization when constructing std::vector<cpu>
Size of std::vector<cpu> can be pre-determined, then let's reserve memory ahead
of time so that push back calls would be optimized.

Signed-off-by: Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
2015-02-08 19:05:45 +02:00
Avi Kivity
7a704f7a40 sstring: fix truncation in compare()
If the difference between the sizes of the two strings is larger than can
be represented by an int, truncation will occur and the sign of the result
is undefined.

Fix by using explicit tests and return values.
2015-02-08 11:41:22 +02:00