libcouchbase 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/.gitmodules +3 -0
- data/.rspec +1 -0
- data/.travis.yml +35 -0
- data/Gemfile +4 -0
- data/LICENSE +24 -0
- data/README.md +389 -0
- data/Rakefile +75 -0
- data/ext/README.md +6 -0
- data/ext/Rakefile +20 -0
- data/ext/libcouchbase/.gitignore +130 -0
- data/ext/libcouchbase/.travis.yml +19 -0
- data/ext/libcouchbase/CMakeLists.txt +429 -0
- data/ext/libcouchbase/CONTRIBUTING.md +124 -0
- data/ext/libcouchbase/LICENSE +202 -0
- data/ext/libcouchbase/README.markdown +163 -0
- data/ext/libcouchbase/RELEASE_NOTES.markdown +2691 -0
- data/ext/libcouchbase/cmake/Modules/ConfigureDtrace.cmake +27 -0
- data/ext/libcouchbase/cmake/Modules/CopyPDB.cmake +42 -0
- data/ext/libcouchbase/cmake/Modules/DistScript.cmake +17 -0
- data/ext/libcouchbase/cmake/Modules/DownloadLcbDep.cmake +20 -0
- data/ext/libcouchbase/cmake/Modules/FindCouchbaseHdrHistogram.cmake +15 -0
- data/ext/libcouchbase/cmake/Modules/FindCouchbaseLibev.cmake +73 -0
- data/ext/libcouchbase/cmake/Modules/FindCouchbaseLibevent.cmake +52 -0
- data/ext/libcouchbase/cmake/Modules/FindCouchbaseLibuv.cmake +56 -0
- data/ext/libcouchbase/cmake/Modules/FindCouchbaseSnappy.cmake +11 -0
- data/ext/libcouchbase/cmake/Modules/GenerateConfigDotH.cmake +29 -0
- data/ext/libcouchbase/cmake/Modules/GetLibcouchbaseFlags.cmake +133 -0
- data/ext/libcouchbase/cmake/Modules/GetPlatformCCInfo.cmake +45 -0
- data/ext/libcouchbase/cmake/Modules/GetVersionInfo.cmake +70 -0
- data/ext/libcouchbase/cmake/config-cmake.h.in +60 -0
- data/ext/libcouchbase/cmake/configure +357 -0
- data/ext/libcouchbase/cmake/defs.mk.in +8 -0
- data/ext/libcouchbase/cmake/dtrace-instr-link.pl +38 -0
- data/ext/libcouchbase/cmake/source_files.cmake +73 -0
- data/ext/libcouchbase/configure.pl +1 -0
- data/ext/libcouchbase/contrib/cJSON/cJSON.c +624 -0
- data/ext/libcouchbase/contrib/cJSON/cJSON.h +158 -0
- data/ext/libcouchbase/contrib/cbsasl/CMakeLists.txt +9 -0
- data/ext/libcouchbase/contrib/cbsasl/COPYING +202 -0
- data/ext/libcouchbase/contrib/cbsasl/include/cbsasl/cbsasl.h +217 -0
- data/ext/libcouchbase/contrib/cbsasl/src/client.c +205 -0
- data/ext/libcouchbase/contrib/cbsasl/src/common.c +46 -0
- data/ext/libcouchbase/contrib/cbsasl/src/cram-md5/hmac.c +67 -0
- data/ext/libcouchbase/contrib/cbsasl/src/cram-md5/hmac.h +33 -0
- data/ext/libcouchbase/contrib/cbsasl/src/cram-md5/md5.c +296 -0
- data/ext/libcouchbase/contrib/cbsasl/src/cram-md5/md5.h +45 -0
- data/ext/libcouchbase/contrib/cbsasl/src/hash.c +573 -0
- data/ext/libcouchbase/contrib/cbsasl/src/hash.h +15 -0
- data/ext/libcouchbase/contrib/cbsasl/src/util.h +31 -0
- data/ext/libcouchbase/contrib/cliopts/CMakeLists.txt +2 -0
- data/ext/libcouchbase/contrib/cliopts/cliopts.c +747 -0
- data/ext/libcouchbase/contrib/cliopts/cliopts.h +493 -0
- data/ext/libcouchbase/contrib/genhash/genhash.c +372 -0
- data/ext/libcouchbase/contrib/genhash/genhash.h +235 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/CHANGES +157 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/CMakeLists.txt +252 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/CONTRIBUTORS +37 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/LICENSE +28 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/MINIFY.sh +15 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/README +435 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/cmake/internal_utils.cmake +227 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest-death-test.h +294 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest-message.h +250 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest-param-test.h +1421 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest-param-test.h.pump +487 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest-printers.h +855 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest-spi.h +232 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest-test-part.h +179 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest-typed-test.h +259 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest.h +2291 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest_pred_impl.h +358 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest_prod.h +58 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-death-test-internal.h +319 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-filepath.h +206 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-internal.h +1158 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-linked_ptr.h +233 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-param-util-generated.h +5143 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-param-util-generated.h.pump +301 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-param-util.h +619 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-port.h +1947 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-string.h +167 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-tuple.h +1012 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-tuple.h.pump +339 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-type-util.h +3331 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-type-util.h.pump +297 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/src/gtest-all.cc +48 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/src/gtest-death-test.cc +1344 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/src/gtest-filepath.cc +382 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/src/gtest-internal-inl.h +1218 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/src/gtest-port.cc +805 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/src/gtest-printers.cc +363 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/src/gtest-test-part.cc +110 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/src/gtest-typed-test.cc +110 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/src/gtest.cc +5015 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/src/gtest_main.cc +38 -0
- data/ext/libcouchbase/contrib/http_parser/LICENSE-MIT +23 -0
- data/ext/libcouchbase/contrib/http_parser/README.md +178 -0
- data/ext/libcouchbase/contrib/http_parser/http_parser.c +2060 -0
- data/ext/libcouchbase/contrib/http_parser/http_parser.h +321 -0
- data/ext/libcouchbase/contrib/jsonsl/LICENSE +20 -0
- data/ext/libcouchbase/contrib/jsonsl/jsonsl.c +1452 -0
- data/ext/libcouchbase/contrib/jsonsl/jsonsl.h +971 -0
- data/ext/libcouchbase/contrib/lcb-jsoncpp/CMakeLists.txt +6 -0
- data/ext/libcouchbase/contrib/lcb-jsoncpp/LICENSE +55 -0
- data/ext/libcouchbase/contrib/lcb-jsoncpp/lcb-jsoncpp-forwards.h +255 -0
- data/ext/libcouchbase/contrib/lcb-jsoncpp/lcb-jsoncpp.cpp +4892 -0
- data/ext/libcouchbase/contrib/lcb-jsoncpp/lcb-jsoncpp.h +1961 -0
- data/ext/libcouchbase/contrib/snappy/CMakeLists.txt +8 -0
- data/ext/libcouchbase/contrib/snappy/COPYING +28 -0
- data/ext/libcouchbase/contrib/snappy/snappy-c.cc +90 -0
- data/ext/libcouchbase/contrib/snappy/snappy-c.h +138 -0
- data/ext/libcouchbase/contrib/snappy/snappy-internal.h +150 -0
- data/ext/libcouchbase/contrib/snappy/snappy-lcb-msvc.h +5 -0
- data/ext/libcouchbase/contrib/snappy/snappy-sinksource.cc +71 -0
- data/ext/libcouchbase/contrib/snappy/snappy-sinksource.h +137 -0
- data/ext/libcouchbase/contrib/snappy/snappy-stubs-internal.cc +42 -0
- data/ext/libcouchbase/contrib/snappy/snappy-stubs-internal.h +491 -0
- data/ext/libcouchbase/contrib/snappy/snappy-stubs-public.h +98 -0
- data/ext/libcouchbase/contrib/snappy/snappy.cc +1307 -0
- data/ext/libcouchbase/contrib/snappy/snappy.h +184 -0
- data/ext/libcouchbase/contrib/win32-defs/iocpdefs.h +133 -0
- data/ext/libcouchbase/contrib/win32-defs/mingwdefs.h +4396 -0
- data/ext/libcouchbase/contrib/win32-defs/win_stdint.h +258 -0
- data/ext/libcouchbase/example/CMakeLists.txt +37 -0
- data/ext/libcouchbase/example/README.markdown +47 -0
- data/ext/libcouchbase/example/db/db.c +167 -0
- data/ext/libcouchbase/example/db/vb.c +227 -0
- data/ext/libcouchbase/example/instancepool/main.cc +102 -0
- data/ext/libcouchbase/example/instancepool/pool.cc +102 -0
- data/ext/libcouchbase/example/instancepool/pool.h +69 -0
- data/ext/libcouchbase/example/libeventdirect/main.c +148 -0
- data/ext/libcouchbase/example/mcc/mcc.cc +246 -0
- data/ext/libcouchbase/example/minimal/minimal.c +130 -0
- data/ext/libcouchbase/example/observe/observe.c +146 -0
- data/ext/libcouchbase/example/subdoc/subdoc-multi.cc +132 -0
- data/ext/libcouchbase/example/subdoc/subdoc-simple.cc +191 -0
- data/ext/libcouchbase/example/tick/tick.c +119 -0
- data/ext/libcouchbase/example/views/views-example.cc +83 -0
- data/ext/libcouchbase/include/libcouchbase/_cxxwrap.h +150 -0
- data/ext/libcouchbase/include/libcouchbase/api-legacy.h +1689 -0
- data/ext/libcouchbase/include/libcouchbase/api3.h +2 -0
- data/ext/libcouchbase/include/libcouchbase/assert.h +44 -0
- data/ext/libcouchbase/include/libcouchbase/cbft.h +109 -0
- data/ext/libcouchbase/include/libcouchbase/cntl-private.h +356 -0
- data/ext/libcouchbase/include/libcouchbase/cntl.h +937 -0
- data/ext/libcouchbase/include/libcouchbase/configuration.h.in +23 -0
- data/ext/libcouchbase/include/libcouchbase/couchbase.h +3677 -0
- data/ext/libcouchbase/include/libcouchbase/deprecated.h +300 -0
- data/ext/libcouchbase/include/libcouchbase/error.h +595 -0
- data/ext/libcouchbase/include/libcouchbase/http.h +1 -0
- data/ext/libcouchbase/include/libcouchbase/iops.h +1050 -0
- data/ext/libcouchbase/include/libcouchbase/ixmgmt.h +263 -0
- data/ext/libcouchbase/include/libcouchbase/kvbuf.h +132 -0
- data/ext/libcouchbase/include/libcouchbase/n1ql.h +364 -0
- data/ext/libcouchbase/include/libcouchbase/pktfwd.h +270 -0
- data/ext/libcouchbase/include/libcouchbase/plugins/io/bsdio-inl.c +367 -0
- data/ext/libcouchbase/include/libcouchbase/plugins/io/wsaerr-inl.c +76 -0
- data/ext/libcouchbase/include/libcouchbase/plugins/io/wsaerr.h +199 -0
- data/ext/libcouchbase/include/libcouchbase/subdoc.h +312 -0
- data/ext/libcouchbase/include/libcouchbase/sysdefs.h +98 -0
- data/ext/libcouchbase/include/libcouchbase/vbucket.h +643 -0
- data/ext/libcouchbase/include/libcouchbase/views.h +298 -0
- data/ext/libcouchbase/include/libcouchbase/visibility.h +65 -0
- data/ext/libcouchbase/include/memcached/COPYING +30 -0
- data/ext/libcouchbase/include/memcached/README +10 -0
- data/ext/libcouchbase/include/memcached/protocol_binary.h +1916 -0
- data/ext/libcouchbase/include/memcached/vbucket.h +42 -0
- data/ext/libcouchbase/packaging/README +7 -0
- data/ext/libcouchbase/packaging/abicheck/.gitignore +4 -0
- data/ext/libcouchbase/packaging/abicheck/Makefile +17 -0
- data/ext/libcouchbase/packaging/abicheck/README.md +27 -0
- data/ext/libcouchbase/packaging/abicheck/template.xml +3 -0
- data/ext/libcouchbase/packaging/deb/compat +1 -0
- data/ext/libcouchbase/packaging/deb/control +73 -0
- data/ext/libcouchbase/packaging/deb/copyright +10 -0
- data/ext/libcouchbase/packaging/deb/libcouchbase-dev.docs +3 -0
- data/ext/libcouchbase/packaging/deb/package.mk +31 -0
- data/ext/libcouchbase/packaging/deb/rules +46 -0
- data/ext/libcouchbase/packaging/deb/source/format +1 -0
- data/ext/libcouchbase/packaging/distinfo/README +1 -0
- data/ext/libcouchbase/packaging/distinfo/distinfo.cmake.in +4 -0
- data/ext/libcouchbase/packaging/dllversion.rc.in +39 -0
- data/ext/libcouchbase/packaging/libcouchbase.pc.in +10 -0
- data/ext/libcouchbase/packaging/nuget/libcouchbase.autopkg +76 -0
- data/ext/libcouchbase/packaging/parse-git-describe.pl +166 -0
- data/ext/libcouchbase/packaging/rpm/libcouchbase.spec.in +108 -0
- data/ext/libcouchbase/packaging/rpm/package.mk +40 -0
- data/ext/libcouchbase/plugins/io/iocp/CMakeLists.txt +9 -0
- data/ext/libcouchbase/plugins/io/iocp/iocp_iops.c +466 -0
- data/ext/libcouchbase/plugins/io/iocp/iocp_iops.h +217 -0
- data/ext/libcouchbase/plugins/io/iocp/iocp_loop.c +295 -0
- data/ext/libcouchbase/plugins/io/iocp/iocp_timer.c +79 -0
- data/ext/libcouchbase/plugins/io/iocp/iocp_util.c +229 -0
- data/ext/libcouchbase/plugins/io/libev/CMakeLists.txt +29 -0
- data/ext/libcouchbase/plugins/io/libev/libev_io_opts.h +65 -0
- data/ext/libcouchbase/plugins/io/libev/plugin-libev.c +289 -0
- data/ext/libcouchbase/plugins/io/libevent/CMakeLists.txt +29 -0
- data/ext/libcouchbase/plugins/io/libevent/libevent_io_opts.h +67 -0
- data/ext/libcouchbase/plugins/io/libevent/plugin-libevent.c +292 -0
- data/ext/libcouchbase/plugins/io/libuv/CMakeLists.txt +42 -0
- data/ext/libcouchbase/plugins/io/libuv/libuv_compat.h +212 -0
- data/ext/libcouchbase/plugins/io/libuv/libuv_io_opts.h +118 -0
- data/ext/libcouchbase/plugins/io/libuv/plugin-internal.h +148 -0
- data/ext/libcouchbase/plugins/io/libuv/plugin-libuv.c +648 -0
- data/ext/libcouchbase/plugins/io/select/CMakeLists.txt +11 -0
- data/ext/libcouchbase/plugins/io/select/plugin-select.c +448 -0
- data/ext/libcouchbase/plugins/io/select/select_io_opts.h +39 -0
- data/ext/libcouchbase/src/README.md +103 -0
- data/ext/libcouchbase/src/aspend.h +106 -0
- data/ext/libcouchbase/src/auth.cc +74 -0
- data/ext/libcouchbase/src/auth.h +54 -0
- data/ext/libcouchbase/src/bootstrap.c +269 -0
- data/ext/libcouchbase/src/bootstrap.h +129 -0
- data/ext/libcouchbase/src/bucketconfig/bc_cccp.c +495 -0
- data/ext/libcouchbase/src/bucketconfig/bc_file.c +347 -0
- data/ext/libcouchbase/src/bucketconfig/bc_http.c +630 -0
- data/ext/libcouchbase/src/bucketconfig/bc_http.h +82 -0
- data/ext/libcouchbase/src/bucketconfig/bc_mcraw.c +150 -0
- data/ext/libcouchbase/src/bucketconfig/clconfig.h +681 -0
- data/ext/libcouchbase/src/bucketconfig/confmon.c +474 -0
- data/ext/libcouchbase/src/callbacks.c +378 -0
- data/ext/libcouchbase/src/cbft.cc +210 -0
- data/ext/libcouchbase/src/cntl.cc +847 -0
- data/ext/libcouchbase/src/config_static.h +159 -0
- data/ext/libcouchbase/src/connspec.cc +462 -0
- data/ext/libcouchbase/src/connspec.h +105 -0
- data/ext/libcouchbase/src/ctx-log-inl.h +27 -0
- data/ext/libcouchbase/src/dump.c +98 -0
- data/ext/libcouchbase/src/getconfig.c +100 -0
- data/ext/libcouchbase/src/gethrtime.c +109 -0
- data/ext/libcouchbase/src/handler.c +922 -0
- data/ext/libcouchbase/src/hashset.c +164 -0
- data/ext/libcouchbase/src/hashset.h +86 -0
- data/ext/libcouchbase/src/hashtable.c +75 -0
- data/ext/libcouchbase/src/hdr_timings.c +92 -0
- data/ext/libcouchbase/src/hostlist.cc +301 -0
- data/ext/libcouchbase/src/hostlist.h +171 -0
- data/ext/libcouchbase/src/http/http-priv.h +307 -0
- data/ext/libcouchbase/src/http/http.cc +633 -0
- data/ext/libcouchbase/src/http/http.h +34 -0
- data/ext/libcouchbase/src/http/http_io.cc +307 -0
- data/ext/libcouchbase/src/instance.cc +722 -0
- data/ext/libcouchbase/src/internal.h +244 -0
- data/ext/libcouchbase/src/iofactory.c +575 -0
- data/ext/libcouchbase/src/jsparse/parser.cc +519 -0
- data/ext/libcouchbase/src/jsparse/parser.h +173 -0
- data/ext/libcouchbase/src/lcbht/lcbht.c +282 -0
- data/ext/libcouchbase/src/lcbht/lcbht.h +199 -0
- data/ext/libcouchbase/src/lcbio/connect.c +557 -0
- data/ext/libcouchbase/src/lcbio/connect.h +364 -0
- data/ext/libcouchbase/src/lcbio/ctx.c +611 -0
- data/ext/libcouchbase/src/lcbio/ctx.h +405 -0
- data/ext/libcouchbase/src/lcbio/iotable.c +290 -0
- data/ext/libcouchbase/src/lcbio/iotable.h +84 -0
- data/ext/libcouchbase/src/lcbio/ioutils.c +350 -0
- data/ext/libcouchbase/src/lcbio/ioutils.h +203 -0
- data/ext/libcouchbase/src/lcbio/lcbio.h +51 -0
- data/ext/libcouchbase/src/lcbio/manager.c +584 -0
- data/ext/libcouchbase/src/lcbio/manager.h +156 -0
- data/ext/libcouchbase/src/lcbio/protoctx.c +84 -0
- data/ext/libcouchbase/src/lcbio/rw-inl.h +115 -0
- data/ext/libcouchbase/src/lcbio/ssl.h +149 -0
- data/ext/libcouchbase/src/lcbio/timer-ng.h +179 -0
- data/ext/libcouchbase/src/lcbio/timer.c +132 -0
- data/ext/libcouchbase/src/legacy.c +430 -0
- data/ext/libcouchbase/src/list.c +144 -0
- data/ext/libcouchbase/src/list.h +127 -0
- data/ext/libcouchbase/src/logging.c +244 -0
- data/ext/libcouchbase/src/logging.h +86 -0
- data/ext/libcouchbase/src/mc/compress.c +90 -0
- data/ext/libcouchbase/src/mc/compress.h +61 -0
- data/ext/libcouchbase/src/mc/forward.c +186 -0
- data/ext/libcouchbase/src/mc/forward.h +90 -0
- data/ext/libcouchbase/src/mc/iovcursor-inl.h +279 -0
- data/ext/libcouchbase/src/mc/iovcursor.h +66 -0
- data/ext/libcouchbase/src/mc/mcreq-flush-inl.h +111 -0
- data/ext/libcouchbase/src/mc/mcreq.c +954 -0
- data/ext/libcouchbase/src/mc/mcreq.h +977 -0
- data/ext/libcouchbase/src/mcserver/mcserver.c +784 -0
- data/ext/libcouchbase/src/mcserver/mcserver.h +121 -0
- data/ext/libcouchbase/src/mcserver/negotiate.c +656 -0
- data/ext/libcouchbase/src/mcserver/negotiate.h +119 -0
- data/ext/libcouchbase/src/n1ql/ixmgmt.cc +860 -0
- data/ext/libcouchbase/src/n1ql/n1ql-internal.h +22 -0
- data/ext/libcouchbase/src/n1ql/n1ql.cc +729 -0
- data/ext/libcouchbase/src/n1ql/params.cc +215 -0
- data/ext/libcouchbase/src/netbuf/netbuf-defs.h +89 -0
- data/ext/libcouchbase/src/netbuf/netbuf-mblock.h +235 -0
- data/ext/libcouchbase/src/netbuf/netbuf.c +929 -0
- data/ext/libcouchbase/src/netbuf/netbuf.h +452 -0
- data/ext/libcouchbase/src/newconfig.c +385 -0
- data/ext/libcouchbase/src/nodeinfo.cc +194 -0
- data/ext/libcouchbase/src/operations/cbflush.c +71 -0
- data/ext/libcouchbase/src/operations/counter.c +116 -0
- data/ext/libcouchbase/src/operations/durability-cas.c +224 -0
- data/ext/libcouchbase/src/operations/durability-seqno.c +157 -0
- data/ext/libcouchbase/src/operations/durability.c +668 -0
- data/ext/libcouchbase/src/operations/durability_internal.h +199 -0
- data/ext/libcouchbase/src/operations/get.c +409 -0
- data/ext/libcouchbase/src/operations/observe-seqno.c +96 -0
- data/ext/libcouchbase/src/operations/observe.c +340 -0
- data/ext/libcouchbase/src/operations/pktfwd.c +86 -0
- data/ext/libcouchbase/src/operations/remove.c +83 -0
- data/ext/libcouchbase/src/operations/stats.c +461 -0
- data/ext/libcouchbase/src/operations/store.c +360 -0
- data/ext/libcouchbase/src/operations/subdoc.cc +510 -0
- data/ext/libcouchbase/src/operations/touch.c +81 -0
- data/ext/libcouchbase/src/packetutils.c +60 -0
- data/ext/libcouchbase/src/packetutils.h +147 -0
- data/ext/libcouchbase/src/probes.d +211 -0
- data/ext/libcouchbase/src/rdb/bigalloc.c +225 -0
- data/ext/libcouchbase/src/rdb/bigalloc.h +73 -0
- data/ext/libcouchbase/src/rdb/chunkalloc.c +174 -0
- data/ext/libcouchbase/src/rdb/libcalloc.c +94 -0
- data/ext/libcouchbase/src/rdb/rope.c +419 -0
- data/ext/libcouchbase/src/rdb/rope.h +488 -0
- data/ext/libcouchbase/src/retrychk.c +113 -0
- data/ext/libcouchbase/src/retryq.c +424 -0
- data/ext/libcouchbase/src/retryq.h +157 -0
- data/ext/libcouchbase/src/ringbuffer.c +442 -0
- data/ext/libcouchbase/src/ringbuffer.h +100 -0
- data/ext/libcouchbase/src/settings.c +95 -0
- data/ext/libcouchbase/src/settings.h +188 -0
- data/ext/libcouchbase/src/simplestring.c +211 -0
- data/ext/libcouchbase/src/simplestring.h +228 -0
- data/ext/libcouchbase/src/sllist-inl.h +197 -0
- data/ext/libcouchbase/src/sllist.h +76 -0
- data/ext/libcouchbase/src/ssl/CMakeLists.txt +23 -0
- data/ext/libcouchbase/src/ssl/ssl_c.c +415 -0
- data/ext/libcouchbase/src/ssl/ssl_common.c +454 -0
- data/ext/libcouchbase/src/ssl/ssl_e.c +408 -0
- data/ext/libcouchbase/src/ssl/ssl_iot_common.h +180 -0
- data/ext/libcouchbase/src/ssobuf.h +82 -0
- data/ext/libcouchbase/src/strcodecs/base64.c +123 -0
- data/ext/libcouchbase/src/strcodecs/strcodecs.h +285 -0
- data/ext/libcouchbase/src/timings.c +208 -0
- data/ext/libcouchbase/src/trace.h +105 -0
- data/ext/libcouchbase/src/utilities.c +171 -0
- data/ext/libcouchbase/src/vbucket/CMakeLists.txt +2 -0
- data/ext/libcouchbase/src/vbucket/aliases.h +35 -0
- data/ext/libcouchbase/src/vbucket/crc32.h +83 -0
- data/ext/libcouchbase/src/vbucket/hash.h +30 -0
- data/ext/libcouchbase/src/vbucket/json-inl.h +112 -0
- data/ext/libcouchbase/src/vbucket/ketama.c +66 -0
- data/ext/libcouchbase/src/vbucket/rfc1321/global.h +32 -0
- data/ext/libcouchbase/src/vbucket/rfc1321/md5.h +35 -0
- data/ext/libcouchbase/src/vbucket/rfc1321/md5c-inl.h +335 -0
- data/ext/libcouchbase/src/vbucket/vbucket.c +1543 -0
- data/ext/libcouchbase/src/views/docreq.c +194 -0
- data/ext/libcouchbase/src/views/docreq.h +83 -0
- data/ext/libcouchbase/src/views/viewreq.c +358 -0
- data/ext/libcouchbase/src/views/viewreq.h +36 -0
- data/ext/libcouchbase/src/wait.c +161 -0
- data/ext/libcouchbase/tests/CMakeLists.txt +140 -0
- data/ext/libcouchbase/tests/basic/t_base64.cc +81 -0
- data/ext/libcouchbase/tests/basic/t_ccbc103.cc +95 -0
- data/ext/libcouchbase/tests/basic/t_connstr.cc +404 -0
- data/ext/libcouchbase/tests/basic/t_creds.cc +32 -0
- data/ext/libcouchbase/tests/basic/t_ctlcodes.cc +92 -0
- data/ext/libcouchbase/tests/basic/t_hashset.cc +262 -0
- data/ext/libcouchbase/tests/basic/t_host.cc +198 -0
- data/ext/libcouchbase/tests/basic/t_jsparse.cc +137 -0
- data/ext/libcouchbase/tests/basic/t_jsparse.h +589 -0
- data/ext/libcouchbase/tests/basic/t_list.cc +155 -0
- data/ext/libcouchbase/tests/basic/t_logger.cc +65 -0
- data/ext/libcouchbase/tests/basic/t_misc.cc +24 -0
- data/ext/libcouchbase/tests/basic/t_n1qlstrings.cc +18 -0
- data/ext/libcouchbase/tests/basic/t_netbuf.cc +446 -0
- data/ext/libcouchbase/tests/basic/t_packet.cc +222 -0
- data/ext/libcouchbase/tests/basic/t_ringbuffer.cc +278 -0
- data/ext/libcouchbase/tests/basic/t_slist.cc +429 -0
- data/ext/libcouchbase/tests/basic/t_strerror.cc +64 -0
- data/ext/libcouchbase/tests/basic/t_string.cc +112 -0
- data/ext/libcouchbase/tests/basic/t_urlencode.cc +132 -0
- data/ext/libcouchbase/tests/check-all.cc +608 -0
- data/ext/libcouchbase/tests/htparse/t_basic.cc +193 -0
- data/ext/libcouchbase/tests/ioserver/connection.cc +166 -0
- data/ext/libcouchbase/tests/ioserver/future.cc +50 -0
- data/ext/libcouchbase/tests/ioserver/ioserver.cc +104 -0
- data/ext/libcouchbase/tests/ioserver/ioserver.h +478 -0
- data/ext/libcouchbase/tests/ioserver/socket.cc +88 -0
- data/ext/libcouchbase/tests/ioserver/ssl_connection.cc +145 -0
- data/ext/libcouchbase/tests/ioserver/threads-pthreads.cc +119 -0
- data/ext/libcouchbase/tests/ioserver/threads-win32.cc +117 -0
- data/ext/libcouchbase/tests/ioserver/threads.h +66 -0
- data/ext/libcouchbase/tests/iotests/iotests.h +15 -0
- data/ext/libcouchbase/tests/iotests/mock-environment.cc +524 -0
- data/ext/libcouchbase/tests/iotests/mock-environment.h +385 -0
- data/ext/libcouchbase/tests/iotests/mock-unit-test.cc +67 -0
- data/ext/libcouchbase/tests/iotests/mock-unit-test.h +61 -0
- data/ext/libcouchbase/tests/iotests/serverparams.h +76 -0
- data/ext/libcouchbase/tests/iotests/t_arithmetic.cc +143 -0
- data/ext/libcouchbase/tests/iotests/t_behavior.cc +226 -0
- data/ext/libcouchbase/tests/iotests/t_configcache.cc +117 -0
- data/ext/libcouchbase/tests/iotests/t_confmon.cc +241 -0
- data/ext/libcouchbase/tests/iotests/t_durability.cc +1059 -0
- data/ext/libcouchbase/tests/iotests/t_forward.cc +110 -0
- data/ext/libcouchbase/tests/iotests/t_get.cc +512 -0
- data/ext/libcouchbase/tests/iotests/t_http.cc +438 -0
- data/ext/libcouchbase/tests/iotests/t_iops.cc +175 -0
- data/ext/libcouchbase/tests/iotests/t_lock.cc +275 -0
- data/ext/libcouchbase/tests/iotests/t_misc.cc +713 -0
- data/ext/libcouchbase/tests/iotests/t_mutate.cc +609 -0
- data/ext/libcouchbase/tests/iotests/t_n1ql.cc +270 -0
- data/ext/libcouchbase/tests/iotests/t_netfail.cc +654 -0
- data/ext/libcouchbase/tests/iotests/t_obseqno.cc +157 -0
- data/ext/libcouchbase/tests/iotests/t_regression.cc +321 -0
- data/ext/libcouchbase/tests/iotests/t_sched.cc +88 -0
- data/ext/libcouchbase/tests/iotests/t_serverops.cc +230 -0
- data/ext/libcouchbase/tests/iotests/t_smoke.cc +528 -0
- data/ext/libcouchbase/tests/iotests/t_subdoc.cc +822 -0
- data/ext/libcouchbase/tests/iotests/t_syncmode.cc +64 -0
- data/ext/libcouchbase/tests/iotests/t_views.cc +405 -0
- data/ext/libcouchbase/tests/iotests/testutil.cc +250 -0
- data/ext/libcouchbase/tests/iotests/testutil.h +163 -0
- data/ext/libcouchbase/tests/mc/mctest.h +119 -0
- data/ext/libcouchbase/tests/mc/pktmaker.h +101 -0
- data/ext/libcouchbase/tests/mc/t_alloc.cc +269 -0
- data/ext/libcouchbase/tests/mc/t_context.cc +100 -0
- data/ext/libcouchbase/tests/mc/t_flush.cc +185 -0
- data/ext/libcouchbase/tests/mc/t_forward.cc +239 -0
- data/ext/libcouchbase/tests/mc/t_ioflush.cc +102 -0
- data/ext/libcouchbase/tests/mc/t_iovcursor.cc +173 -0
- data/ext/libcouchbase/tests/mocksupport/procutil.c +305 -0
- data/ext/libcouchbase/tests/mocksupport/procutil.h +89 -0
- data/ext/libcouchbase/tests/mocksupport/server.c +391 -0
- data/ext/libcouchbase/tests/mocksupport/server.h +72 -0
- data/ext/libcouchbase/tests/mocksupport/timeout.c +69 -0
- data/ext/libcouchbase/tests/nonio_tests.cc +23 -0
- data/ext/libcouchbase/tests/rdb/rdbtest.h +133 -0
- data/ext/libcouchbase/tests/rdb/t_basic.cc +128 -0
- data/ext/libcouchbase/tests/rdb/t_bigalloc.cc +93 -0
- data/ext/libcouchbase/tests/rdb/t_refs.cc +112 -0
- data/ext/libcouchbase/tests/socktests/socktest.cc +347 -0
- data/ext/libcouchbase/tests/socktests/socktest.h +448 -0
- data/ext/libcouchbase/tests/socktests/t_basic.cc +143 -0
- data/ext/libcouchbase/tests/socktests/t_ctx.cc +73 -0
- data/ext/libcouchbase/tests/socktests/t_manager.cc +179 -0
- data/ext/libcouchbase/tests/socktests/t_putex.cc +256 -0
- data/ext/libcouchbase/tests/socktests/t_read.cc +187 -0
- data/ext/libcouchbase/tests/socktests/t_reentrant.cc +143 -0
- data/ext/libcouchbase/tests/socktests/t_ssl.cc +80 -0
- data/ext/libcouchbase/tests/socktests/t_write.cc +95 -0
- data/ext/libcouchbase/tests/start_mock.bat +15 -0
- data/ext/libcouchbase/tests/start_mock.sh +42 -0
- data/ext/libcouchbase/tests/unit_tests.cc +43 -0
- data/ext/libcouchbase/tests/vbucket/confdata/bad.json +101 -0
- data/ext/libcouchbase/tests/vbucket/confdata/full_25.json +363 -0
- data/ext/libcouchbase/tests/vbucket/confdata/memd_25.json +90 -0
- data/ext/libcouchbase/tests/vbucket/confdata/memd_30.json +1 -0
- data/ext/libcouchbase/tests/vbucket/confdata/memd_45.json +1 -0
- data/ext/libcouchbase/tests/vbucket/confdata/terse_25.json +291 -0
- data/ext/libcouchbase/tests/vbucket/confdata/terse_30.json +1 -0
- data/ext/libcouchbase/tests/vbucket/t_config.cc +341 -0
- data/ext/libcouchbase/tools/CMakeLists.txt +51 -0
- data/ext/libcouchbase/tools/cbc-handlers.h +462 -0
- data/ext/libcouchbase/tools/cbc-n1qlback.cc +439 -0
- data/ext/libcouchbase/tools/cbc-pillowfight.cc +822 -0
- data/ext/libcouchbase/tools/cbc.cc +1541 -0
- data/ext/libcouchbase/tools/common/histogram.cc +43 -0
- data/ext/libcouchbase/tools/common/histogram.h +23 -0
- data/ext/libcouchbase/tools/common/my_inttypes.h +22 -0
- data/ext/libcouchbase/tools/common/options.cc +420 -0
- data/ext/libcouchbase/tools/common/options.h +81 -0
- data/ext/libcouchbase/tools/docgen/docgen.h +469 -0
- data/ext/libcouchbase/tools/docgen/loc.h +210 -0
- data/ext/libcouchbase/tools/docgen/placeholders.h +211 -0
- data/ext/libcouchbase/tools/docgen/seqgen.h +94 -0
- data/lib/libcouchbase.rb +36 -0
- data/lib/libcouchbase/bucket.rb +819 -0
- data/lib/libcouchbase/callbacks.rb +72 -0
- data/lib/libcouchbase/connection.rb +790 -0
- data/lib/libcouchbase/design_docs.rb +86 -0
- data/lib/libcouchbase/error.rb +68 -0
- data/lib/libcouchbase/ext/libcouchbase.rb +1135 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdbase.rb +23 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdcounter.rb +36 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdendure.rb +26 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdfts.rb +24 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdget.rb +30 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdgetreplica.rb +49 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdhttp.rb +58 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdn1ql.rb +40 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdobseqno.rb +33 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdobserve.rb +30 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdstore.rb +40 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdstoredur.rb +45 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdsubdoc.rb +49 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdverbosity.rb +29 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdviewquery.rb +61 -0
- data/lib/libcouchbase/ext/libcouchbase/contigbuf.rb +14 -0
- data/lib/libcouchbase/ext/libcouchbase/create_st.rb +15 -0
- data/lib/libcouchbase/ext/libcouchbase/create_st0.rb +23 -0
- data/lib/libcouchbase/ext/libcouchbase/create_st1.rb +26 -0
- data/lib/libcouchbase/ext/libcouchbase/create_st2.rb +32 -0
- data/lib/libcouchbase/ext/libcouchbase/create_st3.rb +26 -0
- data/lib/libcouchbase/ext/libcouchbase/crst_u.rb +20 -0
- data/lib/libcouchbase/ext/libcouchbase/durability_opts_st_v.rb +11 -0
- data/lib/libcouchbase/ext/libcouchbase/durability_opts_t.rb +14 -0
- data/lib/libcouchbase/ext/libcouchbase/durabilityopt_sv0.rb +63 -0
- data/lib/libcouchbase/ext/libcouchbase/enums.rb +991 -0
- data/lib/libcouchbase/ext/libcouchbase/fragbuf.rb +18 -0
- data/lib/libcouchbase/ext/libcouchbase/ftshandle.rb +7 -0
- data/lib/libcouchbase/ext/libcouchbase/histogram.rb +34 -0
- data/lib/libcouchbase/ext/libcouchbase/http_request_t.rb +7 -0
- data/lib/libcouchbase/ext/libcouchbase/keybuf.rb +20 -0
- data/lib/libcouchbase/ext/libcouchbase/multicmd_ctx.rb +30 -0
- data/lib/libcouchbase/ext/libcouchbase/mutation_token.rb +17 -0
- data/lib/libcouchbase/ext/libcouchbase/n1qlhandle.rb +7 -0
- data/lib/libcouchbase/ext/libcouchbase/n1qlparams.rb +7 -0
- data/lib/libcouchbase/ext/libcouchbase/respbase.rb +29 -0
- data/lib/libcouchbase/ext/libcouchbase/respcounter.rb +32 -0
- data/lib/libcouchbase/ext/libcouchbase/respendure.rb +49 -0
- data/lib/libcouchbase/ext/libcouchbase/respfts.rb +40 -0
- data/lib/libcouchbase/ext/libcouchbase/respget.rb +44 -0
- data/lib/libcouchbase/ext/libcouchbase/resphttp.rb +48 -0
- data/lib/libcouchbase/ext/libcouchbase/respmcversion.rb +38 -0
- data/lib/libcouchbase/ext/libcouchbase/respn1ql.rb +41 -0
- data/lib/libcouchbase/ext/libcouchbase/respobseqno.rb +52 -0
- data/lib/libcouchbase/ext/libcouchbase/respobserve.rb +41 -0
- data/lib/libcouchbase/ext/libcouchbase/respserverbase.rb +32 -0
- data/lib/libcouchbase/ext/libcouchbase/respstats.rb +38 -0
- data/lib/libcouchbase/ext/libcouchbase/respstore.rb +32 -0
- data/lib/libcouchbase/ext/libcouchbase/respstoredur.rb +38 -0
- data/lib/libcouchbase/ext/libcouchbase/respsubdoc.rb +35 -0
- data/lib/libcouchbase/ext/libcouchbase/respviewquery.rb +67 -0
- data/lib/libcouchbase/ext/libcouchbase/sdentry.rb +22 -0
- data/lib/libcouchbase/ext/libcouchbase/sdspec.rb +26 -0
- data/lib/libcouchbase/ext/libcouchbase/t.rb +7 -0
- data/lib/libcouchbase/ext/libcouchbase/valbuf.rb +22 -0
- data/lib/libcouchbase/ext/libcouchbase/valbuf_u_buf.rb +14 -0
- data/lib/libcouchbase/ext/libcouchbase/viewhandle.rb +7 -0
- data/lib/libcouchbase/ext/libcouchbase_iocp.rb +26 -0
- data/lib/libcouchbase/ext/libcouchbase_libuv.rb +18 -0
- data/lib/libcouchbase/ext/tasks.rb +87 -0
- data/lib/libcouchbase/n1ql.rb +73 -0
- data/lib/libcouchbase/query_full_text.rb +147 -0
- data/lib/libcouchbase/query_n1ql.rb +121 -0
- data/lib/libcouchbase/query_view.rb +129 -0
- data/lib/libcouchbase/results_fiber.rb +262 -0
- data/lib/libcouchbase/results_native.rb +211 -0
- data/lib/libcouchbase/version.rb +5 -0
- data/libcouchbase.gemspec +61 -0
- data/spec/bucket_spec.rb +270 -0
- data/spec/connection_spec.rb +277 -0
- data/spec/design_docs_spec.rb +23 -0
- data/spec/error_spec.rb +26 -0
- data/spec/fts_spec.rb +129 -0
- data/spec/n1ql_spec.rb +201 -0
- data/spec/results_libuv_spec.rb +229 -0
- data/spec/results_native_spec.rb +259 -0
- data/spec/seed/2016-10-25T043505Z/2016-10-25T043505Z-full/bucket-default/design.json +1 -0
- data/spec/seed/2016-10-25T043505Z/2016-10-25T043505Z-full/bucket-default/node-127.0.0.1%3A8091/data-0000.cbb +0 -0
- data/spec/seed/2016-10-25T043505Z/2016-10-25T043505Z-full/bucket-default/node-127.0.0.1%3A8091/failover.json +1 -0
- data/spec/seed/2016-10-25T043505Z/2016-10-25T043505Z-full/bucket-default/node-127.0.0.1%3A8091/meta.json +1 -0
- data/spec/seed/2016-10-25T043505Z/2016-10-25T043505Z-full/bucket-default/node-127.0.0.1%3A8091/seqno.json +1 -0
- data/spec/seed/2016-10-25T043505Z/2016-10-25T043505Z-full/bucket-default/node-127.0.0.1%3A8091/snapshot_markers.json +1 -0
- data/spec/view_spec.rb +195 -0
- metadata +775 -0
@@ -0,0 +1,360 @@
|
|
1
|
+
/* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
|
2
|
+
/*
|
3
|
+
* Copyright 2010-2012 Couchbase, Inc.
|
4
|
+
*
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
* you may not use this file except in compliance with the License.
|
7
|
+
* You may obtain a copy of the License at
|
8
|
+
*
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
*
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
* See the License for the specific language governing permissions and
|
15
|
+
* limitations under the License.
|
16
|
+
*/
|
17
|
+
#include "internal.h"
|
18
|
+
#include "mc/compress.h"
|
19
|
+
#include "trace.h"
|
20
|
+
#include "durability_internal.h"
|
21
|
+
|
22
|
+
typedef struct {
|
23
|
+
mc_REQDATAEX base;
|
24
|
+
lcb_t instance;
|
25
|
+
lcb_U16 persist_to;
|
26
|
+
lcb_U16 replicate_to;
|
27
|
+
} DURSTORECTX;
|
28
|
+
|
29
|
+
/** Observe stuff */
|
30
|
+
static void
|
31
|
+
handle_dur_storecb(mc_PIPELINE *pl, mc_PACKET *pkt,
|
32
|
+
lcb_error_t err, const void *arg)
|
33
|
+
{
|
34
|
+
lcb_RESPCALLBACK cb;
|
35
|
+
lcb_RESPSTOREDUR resp = { 0 };
|
36
|
+
lcb_CMDENDURE dcmd = { 0 };
|
37
|
+
const lcb_MUTATION_TOKEN *mt;
|
38
|
+
DURSTORECTX *dctx = (DURSTORECTX *)pkt->u_rdata.exdata;
|
39
|
+
lcb_MULTICMD_CTX *mctx;
|
40
|
+
lcb_durability_opts_t opts = { 0 };
|
41
|
+
const lcb_RESPSTORE *sresp = (const lcb_RESPSTORE *)arg;
|
42
|
+
|
43
|
+
if (err != LCB_SUCCESS) {
|
44
|
+
goto GT_BAIL;
|
45
|
+
}
|
46
|
+
if (sresp->rc != LCB_SUCCESS) {
|
47
|
+
err = sresp->rc;
|
48
|
+
goto GT_BAIL;
|
49
|
+
}
|
50
|
+
|
51
|
+
resp.store_ok = 1;
|
52
|
+
LCB_CMD_SET_KEY(&dcmd, sresp->key, sresp->nkey);
|
53
|
+
dcmd.cas = sresp->cas;
|
54
|
+
|
55
|
+
mt = lcb_resp_get_mutation_token(LCB_CALLBACK_STORE, (const lcb_RESPBASE*)sresp);
|
56
|
+
if (LCB_MUTATION_TOKEN_ISVALID(mt)) {
|
57
|
+
dcmd.mutation_token = mt;
|
58
|
+
}
|
59
|
+
|
60
|
+
/* Set the options.. */
|
61
|
+
opts.v.v0.persist_to = dctx->persist_to;
|
62
|
+
opts.v.v0.replicate_to = dctx->replicate_to;
|
63
|
+
|
64
|
+
mctx = lcb_endure3_ctxnew(dctx->instance, &opts, &err);
|
65
|
+
if (mctx == NULL) {
|
66
|
+
goto GT_BAIL;
|
67
|
+
}
|
68
|
+
|
69
|
+
lcbdurctx_set_durstore(mctx, 1);
|
70
|
+
err = mctx->addcmd(mctx, (lcb_CMDBASE*)&dcmd);
|
71
|
+
if (err != LCB_SUCCESS) {
|
72
|
+
mctx->fail(mctx);
|
73
|
+
goto GT_BAIL;
|
74
|
+
}
|
75
|
+
lcb_sched_enter(dctx->instance);
|
76
|
+
err = mctx->done(mctx, sresp->cookie);
|
77
|
+
lcb_sched_leave(dctx->instance);
|
78
|
+
|
79
|
+
if (err == LCB_SUCCESS) {
|
80
|
+
/* Everything OK? */
|
81
|
+
free(dctx);
|
82
|
+
return;
|
83
|
+
}
|
84
|
+
|
85
|
+
GT_BAIL:
|
86
|
+
{
|
87
|
+
lcb_RESPENDURE dresp = { 0 };
|
88
|
+
resp.key = sresp->key;
|
89
|
+
resp.nkey = sresp->nkey;
|
90
|
+
resp.cookie = sresp->cookie;
|
91
|
+
resp.rc = err;
|
92
|
+
resp.dur_resp = &dresp;
|
93
|
+
cb = lcb_find_callback(dctx->instance, LCB_CALLBACK_STOREDUR);
|
94
|
+
cb(dctx->instance, LCB_CALLBACK_STOREDUR, (const lcb_RESPBASE*)&resp);
|
95
|
+
free(dctx);
|
96
|
+
}
|
97
|
+
|
98
|
+
(void)pl;
|
99
|
+
}
|
100
|
+
|
101
|
+
static void
|
102
|
+
handle_dur_schedfail(mc_PACKET *pkt)
|
103
|
+
{
|
104
|
+
DURSTORECTX *dctx = (void *)pkt->u_rdata.exdata;
|
105
|
+
free(dctx);
|
106
|
+
}
|
107
|
+
|
108
|
+
mc_REQDATAPROCS storedur_procs = {
|
109
|
+
handle_dur_storecb,
|
110
|
+
handle_dur_schedfail
|
111
|
+
};
|
112
|
+
|
113
|
+
static lcb_size_t
|
114
|
+
get_value_size(mc_PACKET *packet)
|
115
|
+
{
|
116
|
+
if (packet->flags & MCREQ_F_VALUE_IOV) {
|
117
|
+
return packet->u_value.multi.total_length;
|
118
|
+
} else {
|
119
|
+
return packet->u_value.single.size;
|
120
|
+
}
|
121
|
+
}
|
122
|
+
|
123
|
+
static lcb_error_t
|
124
|
+
get_esize_and_opcode(
|
125
|
+
lcb_storage_t ucmd, lcb_uint8_t *opcode, lcb_uint8_t *esize)
|
126
|
+
{
|
127
|
+
if (ucmd == LCB_SET || ucmd == LCB_UPSERT) {
|
128
|
+
*opcode = PROTOCOL_BINARY_CMD_SET;
|
129
|
+
*esize = 8;
|
130
|
+
} else if (ucmd == LCB_ADD) {
|
131
|
+
*opcode = PROTOCOL_BINARY_CMD_ADD;
|
132
|
+
*esize = 8;
|
133
|
+
} else if (ucmd == LCB_REPLACE) {
|
134
|
+
*opcode = PROTOCOL_BINARY_CMD_REPLACE;
|
135
|
+
*esize = 8;
|
136
|
+
} else if (ucmd == LCB_APPEND) {
|
137
|
+
*opcode = PROTOCOL_BINARY_CMD_APPEND;
|
138
|
+
*esize = 0;
|
139
|
+
} else if (ucmd == LCB_PREPEND) {
|
140
|
+
*opcode = PROTOCOL_BINARY_CMD_PREPEND;
|
141
|
+
*esize = 0;
|
142
|
+
} else {
|
143
|
+
return LCB_EINVAL;
|
144
|
+
}
|
145
|
+
return LCB_SUCCESS;
|
146
|
+
}
|
147
|
+
|
148
|
+
|
149
|
+
static int
|
150
|
+
can_compress(lcb_t instance, const mc_PIPELINE *pipeline,
|
151
|
+
const lcb_VALBUF *vbuf, lcb_datatype_t datatype)
|
152
|
+
{
|
153
|
+
mc_SERVER *server = (mc_SERVER *)pipeline;
|
154
|
+
int compressopts = LCBT_SETTING(instance, compressopts);
|
155
|
+
|
156
|
+
if (mcreq_compression_supported() == 0) {
|
157
|
+
return 0;
|
158
|
+
}
|
159
|
+
|
160
|
+
if (vbuf->vtype != LCB_KV_COPY) {
|
161
|
+
return 0;
|
162
|
+
}
|
163
|
+
if ((compressopts & LCB_COMPRESS_OUT) == 0) {
|
164
|
+
return 0;
|
165
|
+
}
|
166
|
+
if (server->compsupport == 0 && (compressopts & LCB_COMPRESS_FORCE) == 0) {
|
167
|
+
return 0;
|
168
|
+
}
|
169
|
+
if (datatype & LCB_VALUE_F_SNAPPYCOMP) {
|
170
|
+
return 0;
|
171
|
+
}
|
172
|
+
return 1;
|
173
|
+
}
|
174
|
+
|
175
|
+
static lcb_error_t
|
176
|
+
do_store3(lcb_t instance, const void *cookie,
|
177
|
+
const lcb_CMDBASE *cmd, int is_durstore)
|
178
|
+
{
|
179
|
+
mc_PIPELINE *pipeline;
|
180
|
+
mc_PACKET *packet;
|
181
|
+
mc_REQDATA *rdata;
|
182
|
+
mc_CMDQUEUE *cq = &instance->cmdq;
|
183
|
+
int hsize;
|
184
|
+
int should_compress = 0;
|
185
|
+
lcb_error_t err;
|
186
|
+
|
187
|
+
lcb_storage_t operation;
|
188
|
+
lcb_U32 flags;
|
189
|
+
const lcb_VALBUF *vbuf;
|
190
|
+
lcb_datatype_t datatype;
|
191
|
+
|
192
|
+
protocol_binary_request_set scmd;
|
193
|
+
protocol_binary_request_header *hdr = &scmd.message.header;
|
194
|
+
|
195
|
+
if (!is_durstore) {
|
196
|
+
const lcb_CMDSTORE *simple_cmd = (const lcb_CMDSTORE *)cmd;
|
197
|
+
operation = simple_cmd->operation;
|
198
|
+
flags = simple_cmd->flags;
|
199
|
+
vbuf = &simple_cmd->value;
|
200
|
+
datatype = simple_cmd->datatype;
|
201
|
+
} else {
|
202
|
+
const lcb_CMDSTOREDUR *durcmd = (const lcb_CMDSTOREDUR *)cmd;
|
203
|
+
operation = durcmd->operation;
|
204
|
+
flags = durcmd->flags;
|
205
|
+
vbuf = &durcmd->value;
|
206
|
+
datatype = durcmd->datatype;
|
207
|
+
}
|
208
|
+
|
209
|
+
if (LCB_KEYBUF_IS_EMPTY(&cmd->key)) {
|
210
|
+
return LCB_EMPTY_KEY;
|
211
|
+
}
|
212
|
+
|
213
|
+
err = get_esize_and_opcode(
|
214
|
+
operation, &hdr->request.opcode, &hdr->request.extlen);
|
215
|
+
if (err != LCB_SUCCESS) {
|
216
|
+
return err;
|
217
|
+
}
|
218
|
+
|
219
|
+
switch (operation) {
|
220
|
+
case LCB_APPEND:
|
221
|
+
case LCB_PREPEND:
|
222
|
+
if (cmd->exptime || flags) {
|
223
|
+
return LCB_OPTIONS_CONFLICT;
|
224
|
+
}
|
225
|
+
break;
|
226
|
+
case LCB_ADD:
|
227
|
+
if (cmd->cas) {
|
228
|
+
return LCB_OPTIONS_CONFLICT;
|
229
|
+
}
|
230
|
+
break;
|
231
|
+
default:
|
232
|
+
break;
|
233
|
+
}
|
234
|
+
|
235
|
+
hsize = hdr->request.extlen + sizeof(*hdr);
|
236
|
+
|
237
|
+
err = mcreq_basic_packet(cq, (const lcb_CMDBASE *)cmd, hdr,
|
238
|
+
hdr->request.extlen, &packet, &pipeline, MCREQ_BASICPACKET_F_FALLBACKOK);
|
239
|
+
|
240
|
+
if (err != LCB_SUCCESS) {
|
241
|
+
return err;
|
242
|
+
}
|
243
|
+
|
244
|
+
should_compress = can_compress(instance, pipeline, vbuf, datatype);
|
245
|
+
if (should_compress) {
|
246
|
+
int rv = mcreq_compress_value(pipeline, packet, &vbuf->u_buf.contig);
|
247
|
+
if (rv != 0) {
|
248
|
+
mcreq_release_packet(pipeline, packet);
|
249
|
+
return LCB_CLIENT_ENOMEM;
|
250
|
+
}
|
251
|
+
} else {
|
252
|
+
mcreq_reserve_value(pipeline, packet, vbuf);
|
253
|
+
}
|
254
|
+
|
255
|
+
if (is_durstore) {
|
256
|
+
int duropts = 0;
|
257
|
+
lcb_U16 persist_u , replicate_u;
|
258
|
+
const lcb_CMDSTOREDUR *dcmd = (const lcb_CMDSTOREDUR *)cmd;
|
259
|
+
DURSTORECTX *dctx = calloc(1, sizeof(*dctx));
|
260
|
+
|
261
|
+
persist_u = dcmd->persist_to;
|
262
|
+
replicate_u = dcmd->replicate_to;
|
263
|
+
if (dcmd->replicate_to == -1 || dcmd->persist_to == -1) {
|
264
|
+
duropts = LCB_DURABILITY_VALIDATE_CAPMAX;
|
265
|
+
}
|
266
|
+
|
267
|
+
err = lcb_durability_validate(instance, &persist_u, &replicate_u, duropts);
|
268
|
+
if (err != LCB_SUCCESS) {
|
269
|
+
mcreq_wipe_packet(pipeline, packet);
|
270
|
+
mcreq_release_packet(pipeline, packet);
|
271
|
+
free(dctx);
|
272
|
+
return err;
|
273
|
+
}
|
274
|
+
|
275
|
+
dctx->instance = instance;
|
276
|
+
dctx->persist_to = persist_u;
|
277
|
+
dctx->replicate_to = replicate_u;
|
278
|
+
packet->u_rdata.exdata = &dctx->base;
|
279
|
+
packet->flags |= MCREQ_F_REQEXT;
|
280
|
+
|
281
|
+
dctx->base.cookie = cookie;
|
282
|
+
dctx->base.procs = &storedur_procs;
|
283
|
+
}
|
284
|
+
|
285
|
+
rdata = MCREQ_PKT_RDATA(packet);
|
286
|
+
rdata->cookie = cookie;
|
287
|
+
rdata->start = gethrtime();
|
288
|
+
|
289
|
+
scmd.message.body.expiration = htonl(cmd->exptime);
|
290
|
+
scmd.message.body.flags = htonl(flags);
|
291
|
+
hdr->request.magic = PROTOCOL_BINARY_REQ;
|
292
|
+
hdr->request.cas = lcb_htonll(cmd->cas);
|
293
|
+
hdr->request.datatype = PROTOCOL_BINARY_RAW_BYTES;
|
294
|
+
|
295
|
+
if (should_compress || (datatype & LCB_VALUE_F_SNAPPYCOMP)) {
|
296
|
+
hdr->request.datatype |= PROTOCOL_BINARY_DATATYPE_COMPRESSED;
|
297
|
+
}
|
298
|
+
if (datatype & LCB_VALUE_F_JSON) {
|
299
|
+
hdr->request.datatype |= PROTOCOL_BINARY_DATATYPE_JSON;
|
300
|
+
}
|
301
|
+
|
302
|
+
hdr->request.opaque = packet->opaque;
|
303
|
+
hdr->request.bodylen = htonl(
|
304
|
+
hdr->request.extlen + ntohs(hdr->request.keylen)
|
305
|
+
+ get_value_size(packet));
|
306
|
+
|
307
|
+
memcpy(SPAN_BUFFER(&packet->kh_span), scmd.bytes, hsize);
|
308
|
+
LCB_SCHED_ADD(instance, pipeline, packet);
|
309
|
+
TRACE_STORE_BEGIN(hdr, (lcb_CMDSTORE* )cmd);
|
310
|
+
return LCB_SUCCESS;
|
311
|
+
}
|
312
|
+
|
313
|
+
LIBCOUCHBASE_API
|
314
|
+
lcb_error_t
|
315
|
+
lcb_store3(lcb_t instance, const void *cookie, const lcb_CMDSTORE *cmd)
|
316
|
+
{
|
317
|
+
return do_store3(instance, cookie, (const lcb_CMDBASE*)cmd, 0);
|
318
|
+
}
|
319
|
+
|
320
|
+
LIBCOUCHBASE_API
|
321
|
+
lcb_error_t
|
322
|
+
lcb_storedur3(lcb_t instance, const void *cookie, const lcb_CMDSTOREDUR *cmd)
|
323
|
+
{
|
324
|
+
return do_store3(instance, cookie, (const lcb_CMDBASE*)cmd, 1);
|
325
|
+
}
|
326
|
+
|
327
|
+
LIBCOUCHBASE_API
|
328
|
+
lcb_error_t
|
329
|
+
lcb_store(lcb_t instance, const void *cookie, lcb_size_t num,
|
330
|
+
const lcb_store_cmd_t * const * items)
|
331
|
+
{
|
332
|
+
unsigned ii;
|
333
|
+
lcb_error_t err = LCB_SUCCESS;
|
334
|
+
|
335
|
+
lcb_sched_enter(instance);
|
336
|
+
for (ii = 0; ii < num; ii++) {
|
337
|
+
const lcb_store_cmd_t *src = items[ii];
|
338
|
+
lcb_CMDSTORE dst;
|
339
|
+
memset(&dst, 0, sizeof(dst));
|
340
|
+
|
341
|
+
dst.key.contig.bytes = src->v.v0.key;
|
342
|
+
dst.key.contig.nbytes = src->v.v0.nkey;
|
343
|
+
dst._hashkey.contig.bytes = src->v.v0.hashkey;
|
344
|
+
dst._hashkey.contig.nbytes = src->v.v0.nhashkey;
|
345
|
+
dst.value.u_buf.contig.bytes = src->v.v0.bytes;
|
346
|
+
dst.value.u_buf.contig.nbytes = src->v.v0.nbytes;
|
347
|
+
dst.operation = src->v.v0.operation;
|
348
|
+
dst.flags = src->v.v0.flags;
|
349
|
+
dst.datatype = src->v.v0.datatype;
|
350
|
+
dst.cas = src->v.v0.cas;
|
351
|
+
dst.exptime = src->v.v0.exptime;
|
352
|
+
err = lcb_store3(instance, cookie, &dst);
|
353
|
+
if (err != LCB_SUCCESS) {
|
354
|
+
lcb_sched_fail(instance);
|
355
|
+
return err;
|
356
|
+
}
|
357
|
+
}
|
358
|
+
lcb_sched_leave(instance);
|
359
|
+
SYNCMODE_INTERCEPT(instance)
|
360
|
+
}
|
@@ -0,0 +1,510 @@
|
|
1
|
+
/* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
|
2
|
+
/*
|
3
|
+
* Copyright 2015 Couchbase, Inc.
|
4
|
+
*
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
* you may not use this file except in compliance with the License.
|
7
|
+
* You may obtain a copy of the License at
|
8
|
+
*
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
*
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
* See the License for the specific language governing permissions and
|
15
|
+
* limitations under the License.
|
16
|
+
*/
|
17
|
+
#include "internal.h"
|
18
|
+
#include <vector>
|
19
|
+
#include <string>
|
20
|
+
#include <include/libcouchbase/subdoc.h>
|
21
|
+
|
22
|
+
static lcb_size_t
|
23
|
+
get_value_size(mc_PACKET *packet)
|
24
|
+
{
|
25
|
+
if (packet->flags & MCREQ_F_HASVALUE) {
|
26
|
+
if (packet->flags & MCREQ_F_VALUE_IOV) {
|
27
|
+
return packet->u_value.multi.total_length;
|
28
|
+
} else {
|
29
|
+
return packet->u_value.single.size;
|
30
|
+
}
|
31
|
+
} else {
|
32
|
+
return 0;
|
33
|
+
}
|
34
|
+
}
|
35
|
+
|
36
|
+
namespace SubdocCmdTraits {
|
37
|
+
enum Options {
|
38
|
+
EMPTY_PATH = 1<<0,
|
39
|
+
ALLOW_EXPIRY = 1<<1,
|
40
|
+
HAS_VALUE = 1<<2,
|
41
|
+
ALLOW_MKDIRP = 1<<3,
|
42
|
+
IS_LOOKUP = 1<<4
|
43
|
+
};
|
44
|
+
|
45
|
+
struct Traits {
|
46
|
+
const unsigned allow_empty_path;
|
47
|
+
const unsigned allow_expiry;
|
48
|
+
const unsigned has_value;
|
49
|
+
const unsigned allow_mkdir_p;
|
50
|
+
const unsigned is_lookup;
|
51
|
+
const uint8_t opcode;
|
52
|
+
|
53
|
+
inline bool valid() const {
|
54
|
+
return opcode != 0;
|
55
|
+
}
|
56
|
+
|
57
|
+
inline unsigned mode() const {
|
58
|
+
return is_lookup ? LCB_SDMULTI_MODE_LOOKUP : LCB_SDMULTI_MODE_MUTATE;
|
59
|
+
}
|
60
|
+
|
61
|
+
inline Traits(uint8_t op, unsigned options) :
|
62
|
+
allow_empty_path(options & EMPTY_PATH),
|
63
|
+
allow_expiry(options & ALLOW_EXPIRY),
|
64
|
+
has_value(options & HAS_VALUE),
|
65
|
+
allow_mkdir_p(options & ALLOW_MKDIRP),
|
66
|
+
is_lookup(options & IS_LOOKUP),
|
67
|
+
opcode(op) {}
|
68
|
+
};
|
69
|
+
|
70
|
+
static const Traits
|
71
|
+
Get(PROTOCOL_BINARY_CMD_SUBDOC_GET, IS_LOOKUP);
|
72
|
+
|
73
|
+
static const Traits
|
74
|
+
Exists(PROTOCOL_BINARY_CMD_SUBDOC_EXISTS, IS_LOOKUP);
|
75
|
+
|
76
|
+
static const Traits
|
77
|
+
GetCount(PROTOCOL_BINARY_CMD_SUBDOC_GET_COUNT, IS_LOOKUP|EMPTY_PATH);
|
78
|
+
|
79
|
+
static const Traits
|
80
|
+
DictAdd(PROTOCOL_BINARY_CMD_SUBDOC_DICT_ADD, ALLOW_EXPIRY|HAS_VALUE);
|
81
|
+
|
82
|
+
static const Traits
|
83
|
+
DictUpsert(PROTOCOL_BINARY_CMD_SUBDOC_DICT_UPSERT,
|
84
|
+
ALLOW_EXPIRY|HAS_VALUE|ALLOW_MKDIRP);
|
85
|
+
|
86
|
+
static const Traits
|
87
|
+
Remove(PROTOCOL_BINARY_CMD_SUBDOC_DELETE, ALLOW_EXPIRY);
|
88
|
+
|
89
|
+
static const Traits
|
90
|
+
ArrayInsert(PROTOCOL_BINARY_CMD_SUBDOC_ARRAY_INSERT,
|
91
|
+
ALLOW_EXPIRY|HAS_VALUE);
|
92
|
+
|
93
|
+
static const Traits
|
94
|
+
Replace(PROTOCOL_BINARY_CMD_SUBDOC_REPLACE, ALLOW_EXPIRY|HAS_VALUE);
|
95
|
+
|
96
|
+
static const Traits
|
97
|
+
ArrayAddFirst(PROTOCOL_BINARY_CMD_SUBDOC_ARRAY_PUSH_FIRST,
|
98
|
+
ALLOW_EXPIRY|HAS_VALUE|EMPTY_PATH|ALLOW_MKDIRP);
|
99
|
+
|
100
|
+
static const Traits
|
101
|
+
ArrayAddLast(PROTOCOL_BINARY_CMD_SUBDOC_ARRAY_PUSH_LAST,
|
102
|
+
ALLOW_EXPIRY|HAS_VALUE|EMPTY_PATH|ALLOW_MKDIRP);
|
103
|
+
|
104
|
+
static const Traits
|
105
|
+
ArrayAddUnique(PROTOCOL_BINARY_CMD_SUBDOC_ARRAY_ADD_UNIQUE,
|
106
|
+
ALLOW_EXPIRY|HAS_VALUE|EMPTY_PATH|ALLOW_MKDIRP);
|
107
|
+
|
108
|
+
static const Traits
|
109
|
+
Counter(PROTOCOL_BINARY_CMD_SUBDOC_COUNTER, ALLOW_EXPIRY|HAS_VALUE|ALLOW_MKDIRP);
|
110
|
+
|
111
|
+
static const Traits
|
112
|
+
Invalid(0, 0);
|
113
|
+
|
114
|
+
const Traits&
|
115
|
+
find(unsigned mode)
|
116
|
+
{
|
117
|
+
switch (mode) {
|
118
|
+
case LCB_SDCMD_REPLACE:
|
119
|
+
return Replace;
|
120
|
+
case LCB_SDCMD_DICT_ADD:
|
121
|
+
return DictAdd;
|
122
|
+
case LCB_SDCMD_DICT_UPSERT:
|
123
|
+
return DictUpsert;
|
124
|
+
case LCB_SDCMD_ARRAY_ADD_FIRST:
|
125
|
+
return ArrayAddFirst;
|
126
|
+
case LCB_SDCMD_ARRAY_ADD_LAST:
|
127
|
+
return ArrayAddLast;
|
128
|
+
case LCB_SDCMD_ARRAY_ADD_UNIQUE:
|
129
|
+
return ArrayAddUnique;
|
130
|
+
case LCB_SDCMD_ARRAY_INSERT:
|
131
|
+
return ArrayInsert;
|
132
|
+
case LCB_SDCMD_GET:
|
133
|
+
return Get;
|
134
|
+
case LCB_SDCMD_EXISTS:
|
135
|
+
return Exists;
|
136
|
+
case LCB_SDCMD_GET_COUNT:
|
137
|
+
return GetCount;
|
138
|
+
case LCB_SDCMD_REMOVE:
|
139
|
+
return Remove;
|
140
|
+
case LCB_SDCMD_COUNTER:
|
141
|
+
return Counter;
|
142
|
+
default:
|
143
|
+
return Invalid;
|
144
|
+
}
|
145
|
+
}
|
146
|
+
}
|
147
|
+
|
148
|
+
static size_t
|
149
|
+
get_valbuf_size(const lcb_VALBUF& vb)
|
150
|
+
{
|
151
|
+
if (vb.vtype == LCB_KV_COPY || vb.vtype == LCB_KV_CONTIG) {
|
152
|
+
return vb.u_buf.contig.nbytes;
|
153
|
+
} else {
|
154
|
+
if (vb.u_buf.multi.total_length) {
|
155
|
+
return vb.u_buf.multi.total_length;
|
156
|
+
} else {
|
157
|
+
size_t tmp = 0;
|
158
|
+
for (size_t ii = 0; ii < vb.u_buf.multi.niov; ++ii) {
|
159
|
+
tmp += vb.u_buf.multi.iov[ii].iov_len;
|
160
|
+
}
|
161
|
+
return tmp;
|
162
|
+
}
|
163
|
+
}
|
164
|
+
}
|
165
|
+
|
166
|
+
struct MultiBuilder {
|
167
|
+
MultiBuilder(const lcb_CMDSUBDOC *cmd_)
|
168
|
+
: cmd(cmd_), payload_size(0), mode(0) {
|
169
|
+
size_t ebufsz = is_lookup() ? cmd->nspecs * 4 : cmd->nspecs * 8;
|
170
|
+
extra_body = new char[ebufsz];
|
171
|
+
bodysz = 0;
|
172
|
+
}
|
173
|
+
|
174
|
+
~MultiBuilder() {
|
175
|
+
if (extra_body != NULL) {
|
176
|
+
delete[] extra_body;
|
177
|
+
}
|
178
|
+
}
|
179
|
+
|
180
|
+
inline MultiBuilder(const MultiBuilder&);
|
181
|
+
|
182
|
+
// IOVs which are fed into lcb_VALBUF for subsequent use
|
183
|
+
const lcb_CMDSUBDOC *cmd;
|
184
|
+
std::vector<lcb_IOV> iovs;
|
185
|
+
char *extra_body;
|
186
|
+
size_t bodysz;
|
187
|
+
|
188
|
+
// Total size of the payload itself
|
189
|
+
size_t payload_size;
|
190
|
+
|
191
|
+
unsigned mode;
|
192
|
+
|
193
|
+
bool is_lookup() const {
|
194
|
+
return mode == LCB_SDMULTI_MODE_LOOKUP;
|
195
|
+
}
|
196
|
+
|
197
|
+
bool is_mutate() const {
|
198
|
+
return mode == LCB_SDMULTI_MODE_MUTATE;
|
199
|
+
}
|
200
|
+
|
201
|
+
void maybe_setmode(const SubdocCmdTraits::Traits& t) {
|
202
|
+
if (mode == 0) {
|
203
|
+
mode = t.mode();
|
204
|
+
}
|
205
|
+
}
|
206
|
+
|
207
|
+
template <typename T> void add_field(T itm, size_t len) {
|
208
|
+
const char *b = reinterpret_cast<const char *>(&itm);
|
209
|
+
memcpy(extra_body + bodysz, b, len);
|
210
|
+
bodysz += len;
|
211
|
+
}
|
212
|
+
|
213
|
+
const char *extra_mark() const {
|
214
|
+
return extra_body + bodysz;
|
215
|
+
}
|
216
|
+
|
217
|
+
void add_extras_iov(const char *last_begin) {
|
218
|
+
const char *p_end = extra_mark();
|
219
|
+
add_iov(last_begin, p_end - last_begin);
|
220
|
+
}
|
221
|
+
|
222
|
+
void add_iov(const void *b, size_t n) {
|
223
|
+
if (!n) {
|
224
|
+
return;
|
225
|
+
}
|
226
|
+
|
227
|
+
lcb_IOV iov;
|
228
|
+
iov.iov_base = const_cast<void*>(b);
|
229
|
+
iov.iov_len = n;
|
230
|
+
iovs.push_back(iov);
|
231
|
+
payload_size += n;
|
232
|
+
}
|
233
|
+
|
234
|
+
void add_iov(const lcb_VALBUF& vb) {
|
235
|
+
if (vb.vtype == LCB_KV_CONTIG || vb.vtype == LCB_KV_COPY) {
|
236
|
+
add_iov(vb.u_buf.contig.bytes, vb.u_buf.contig.nbytes);
|
237
|
+
} else {
|
238
|
+
for (size_t ii = 0; ii < vb.u_buf.contig.nbytes; ++ii) {
|
239
|
+
const lcb_IOV& iov = vb.u_buf.multi.iov[ii];
|
240
|
+
if (!iov.iov_len) {
|
241
|
+
continue; // Skip it
|
242
|
+
}
|
243
|
+
payload_size += iov.iov_len;
|
244
|
+
iovs.push_back(iov);
|
245
|
+
}
|
246
|
+
}
|
247
|
+
}
|
248
|
+
|
249
|
+
inline lcb_error_t add_spec(const lcb_SDSPEC *);
|
250
|
+
};
|
251
|
+
|
252
|
+
lcb_error_t
|
253
|
+
MultiBuilder::add_spec(const lcb_SDSPEC *spec)
|
254
|
+
{
|
255
|
+
const SubdocCmdTraits::Traits& trait = SubdocCmdTraits::find(spec->sdcmd);
|
256
|
+
if (!trait.valid()) {
|
257
|
+
return LCB_UNKNOWN_SDCMD;
|
258
|
+
}
|
259
|
+
maybe_setmode(trait);
|
260
|
+
|
261
|
+
if (trait.mode() != mode) {
|
262
|
+
return LCB_OPTIONS_CONFLICT;
|
263
|
+
}
|
264
|
+
|
265
|
+
const char *p_begin = extra_mark();
|
266
|
+
// opcode
|
267
|
+
add_field(trait.opcode, 1);
|
268
|
+
// flags
|
269
|
+
uint8_t sdflags = 0;
|
270
|
+
if (spec->options & LCB_SDSPEC_F_MKINTERMEDIATES) {
|
271
|
+
sdflags = SUBDOC_FLAG_MKDIR_P;
|
272
|
+
}
|
273
|
+
if (spec->options & LCB_SDSPEC_F_MKDOCUMENT) {
|
274
|
+
sdflags |= SUBDOC_FLAG_MKDOC;
|
275
|
+
}
|
276
|
+
add_field(sdflags, 1);
|
277
|
+
|
278
|
+
uint16_t npath = static_cast<uint16_t>(spec->path.contig.nbytes);
|
279
|
+
if (!npath && !trait.allow_empty_path) {
|
280
|
+
return LCB_EMPTY_PATH;
|
281
|
+
}
|
282
|
+
|
283
|
+
// Path length
|
284
|
+
add_field(static_cast<uint16_t>(htons(npath)), 2);
|
285
|
+
|
286
|
+
uint32_t vsize = 0;
|
287
|
+
if (is_mutate()) {
|
288
|
+
// Mutation needs an additional 'value' spec.
|
289
|
+
vsize = get_valbuf_size(spec->value);
|
290
|
+
add_field(static_cast<uint32_t>(htonl(vsize)), 4);
|
291
|
+
}
|
292
|
+
|
293
|
+
// Finalize the header..
|
294
|
+
add_extras_iov(p_begin);
|
295
|
+
|
296
|
+
// Add the actual path
|
297
|
+
add_iov(spec->path.contig.bytes, spec->path.contig.nbytes);
|
298
|
+
if (vsize) {
|
299
|
+
add_iov(spec->value);
|
300
|
+
}
|
301
|
+
return LCB_SUCCESS;
|
302
|
+
}
|
303
|
+
|
304
|
+
|
305
|
+
static lcb_error_t
|
306
|
+
sd3_single(lcb_t instance, const void *cookie, const lcb_CMDSUBDOC *cmd)
|
307
|
+
{
|
308
|
+
// Find the trait
|
309
|
+
const lcb_SDSPEC *spec = cmd->specs;
|
310
|
+
const SubdocCmdTraits::Traits& traits = SubdocCmdTraits::find(spec->sdcmd);
|
311
|
+
lcb_error_t rc;
|
312
|
+
|
313
|
+
// Any error here is implicitly related to the only spec
|
314
|
+
if (cmd->error_index) {
|
315
|
+
*cmd->error_index = 0;
|
316
|
+
}
|
317
|
+
|
318
|
+
if (!traits.valid()) {
|
319
|
+
return LCB_UNKNOWN_SDCMD;
|
320
|
+
}
|
321
|
+
|
322
|
+
// Determine if the trait matches the mode. Technically we don't care
|
323
|
+
// about this (since it's always a single command) but we do want the
|
324
|
+
// API to remain consistent.
|
325
|
+
if (cmd->multimode != 0 && cmd->multimode != traits.mode()) {
|
326
|
+
return LCB_OPTIONS_CONFLICT;
|
327
|
+
}
|
328
|
+
|
329
|
+
if (LCB_KEYBUF_IS_EMPTY(&cmd->key)) {
|
330
|
+
return LCB_EMPTY_KEY;
|
331
|
+
}
|
332
|
+
if (LCB_KEYBUF_IS_EMPTY(&spec->path) && !traits.allow_empty_path) {
|
333
|
+
return LCB_EMPTY_PATH;
|
334
|
+
}
|
335
|
+
|
336
|
+
lcb_VALBUF valbuf;
|
337
|
+
const lcb_VALBUF *valbuf_p = &valbuf;
|
338
|
+
lcb_IOV tmpiov[2];
|
339
|
+
lcb_FRAGBUF *fbuf = &valbuf.u_buf.multi;
|
340
|
+
|
341
|
+
valbuf.vtype = LCB_KV_IOVCOPY;
|
342
|
+
fbuf->iov = tmpiov;
|
343
|
+
fbuf->niov = 1;
|
344
|
+
fbuf->total_length = 0;
|
345
|
+
tmpiov[0].iov_base = const_cast<void*>(spec->path.contig.bytes);
|
346
|
+
tmpiov[0].iov_len = spec->path.contig.nbytes;
|
347
|
+
|
348
|
+
if (traits.has_value) {
|
349
|
+
if (spec->value.vtype == LCB_KV_COPY) {
|
350
|
+
fbuf->niov = 2;
|
351
|
+
/* Subdoc value is the second IOV */
|
352
|
+
tmpiov[1].iov_base = (void *)spec->value.u_buf.contig.bytes;
|
353
|
+
tmpiov[1].iov_len = spec->value.u_buf.contig.nbytes;
|
354
|
+
} else {
|
355
|
+
/* Assume properly formatted packet */
|
356
|
+
valbuf_p = &spec->value;
|
357
|
+
}
|
358
|
+
}
|
359
|
+
|
360
|
+
uint8_t extlen = 3;
|
361
|
+
uint32_t exptime = 0;
|
362
|
+
if (cmd->exptime) {
|
363
|
+
if (!traits.allow_expiry) {
|
364
|
+
return LCB_OPTIONS_CONFLICT;
|
365
|
+
}
|
366
|
+
exptime = cmd->exptime;
|
367
|
+
extlen = 7;
|
368
|
+
}
|
369
|
+
|
370
|
+
protocol_binary_request_subdocument request;
|
371
|
+
protocol_binary_request_header *hdr = &request.message.header;
|
372
|
+
mc_PACKET *packet;
|
373
|
+
mc_PIPELINE *pipeline;
|
374
|
+
|
375
|
+
rc = mcreq_basic_packet(&instance->cmdq,
|
376
|
+
(const lcb_CMDBASE*)cmd,
|
377
|
+
hdr, extlen, &packet, &pipeline, MCREQ_BASICPACKET_F_FALLBACKOK);
|
378
|
+
|
379
|
+
if (rc != LCB_SUCCESS) {
|
380
|
+
return rc;
|
381
|
+
}
|
382
|
+
|
383
|
+
rc = mcreq_reserve_value(pipeline, packet, valbuf_p);
|
384
|
+
if (rc != LCB_SUCCESS) {
|
385
|
+
mcreq_wipe_packet(pipeline, packet);
|
386
|
+
mcreq_release_packet(pipeline, packet);
|
387
|
+
return rc;
|
388
|
+
}
|
389
|
+
|
390
|
+
MCREQ_PKT_RDATA(packet)->cookie = cookie;
|
391
|
+
MCREQ_PKT_RDATA(packet)->start = gethrtime();
|
392
|
+
|
393
|
+
hdr->request.magic = PROTOCOL_BINARY_REQ;
|
394
|
+
hdr->request.datatype = PROTOCOL_BINARY_RAW_BYTES;
|
395
|
+
hdr->request.extlen = packet->extlen;
|
396
|
+
hdr->request.opaque = packet->opaque;
|
397
|
+
hdr->request.cas = lcb_htonll(cmd->cas);
|
398
|
+
hdr->request.bodylen = htonl(hdr->request.extlen +
|
399
|
+
ntohs(hdr->request.keylen) + get_value_size(packet));
|
400
|
+
|
401
|
+
request.message.extras.pathlen = htons(spec->path.contig.nbytes);
|
402
|
+
request.message.extras.subdoc_flags = 0;
|
403
|
+
|
404
|
+
if (spec->options & LCB_SDSPEC_F_MKINTERMEDIATES) {
|
405
|
+
request.message.extras.subdoc_flags |= SUBDOC_FLAG_MKDIR_P;
|
406
|
+
}
|
407
|
+
if (spec->options & LCB_SDSPEC_F_MKDOCUMENT) {
|
408
|
+
request.message.extras.subdoc_flags |= SUBDOC_FLAG_MKDOC;
|
409
|
+
}
|
410
|
+
|
411
|
+
hdr->request.opcode = traits.opcode;
|
412
|
+
memcpy(SPAN_BUFFER(&packet->kh_span), request.bytes, sizeof request.bytes);
|
413
|
+
if (exptime) {
|
414
|
+
exptime = htonl(exptime);
|
415
|
+
memcpy(SPAN_BUFFER(&packet->kh_span) + sizeof request.bytes, &exptime, 4);
|
416
|
+
}
|
417
|
+
|
418
|
+
LCB_SCHED_ADD(instance, pipeline, packet);
|
419
|
+
return LCB_SUCCESS;
|
420
|
+
}
|
421
|
+
|
422
|
+
LIBCOUCHBASE_API
|
423
|
+
lcb_error_t
|
424
|
+
lcb_subdoc3(lcb_t instance, const void *cookie, const lcb_CMDSUBDOC *cmd)
|
425
|
+
{
|
426
|
+
// First validate the command
|
427
|
+
if (cmd->nspecs == 0) {
|
428
|
+
return LCB_ENO_COMMANDS;
|
429
|
+
}
|
430
|
+
|
431
|
+
if (cmd->nspecs == 1) {
|
432
|
+
return sd3_single(instance, cookie, cmd);
|
433
|
+
}
|
434
|
+
|
435
|
+
uint32_t exp = cmd->exptime;
|
436
|
+
lcb_error_t rc = LCB_SUCCESS;
|
437
|
+
|
438
|
+
MultiBuilder ctx(cmd);
|
439
|
+
if (cmd->error_index) {
|
440
|
+
*cmd->error_index = -1;
|
441
|
+
}
|
442
|
+
|
443
|
+
if (exp && !ctx.is_mutate()) {
|
444
|
+
return LCB_OPTIONS_CONFLICT;
|
445
|
+
}
|
446
|
+
|
447
|
+
for (size_t ii = 0; ii < cmd->nspecs; ++ii) {
|
448
|
+
if (cmd->error_index) {
|
449
|
+
*cmd->error_index = ii;
|
450
|
+
}
|
451
|
+
rc = ctx.add_spec(cmd->specs + ii);
|
452
|
+
if (rc != LCB_SUCCESS) {
|
453
|
+
return rc;
|
454
|
+
}
|
455
|
+
}
|
456
|
+
|
457
|
+
mc_PIPELINE *pl;
|
458
|
+
mc_PACKET *pkt;
|
459
|
+
uint8_t extlen = exp ? 4 : 0;
|
460
|
+
protocol_binary_request_header hdr;
|
461
|
+
|
462
|
+
if (cmd->error_index) {
|
463
|
+
*cmd->error_index = -1;
|
464
|
+
}
|
465
|
+
|
466
|
+
rc = mcreq_basic_packet(
|
467
|
+
&instance->cmdq, reinterpret_cast<const lcb_CMDBASE*>(cmd),
|
468
|
+
&hdr, extlen, &pkt, &pl, MCREQ_BASICPACKET_F_FALLBACKOK);
|
469
|
+
|
470
|
+
if (rc != LCB_SUCCESS) {
|
471
|
+
return rc;
|
472
|
+
}
|
473
|
+
|
474
|
+
lcb_VALBUF vb = { LCB_KV_IOVCOPY };
|
475
|
+
vb.u_buf.multi.iov = &ctx.iovs[0];
|
476
|
+
vb.u_buf.multi.niov = ctx.iovs.size();
|
477
|
+
vb.u_buf.multi.total_length = ctx.payload_size;
|
478
|
+
rc = mcreq_reserve_value(pl, pkt, &vb);
|
479
|
+
|
480
|
+
if (rc != LCB_SUCCESS) {
|
481
|
+
mcreq_wipe_packet(pl, pkt);
|
482
|
+
mcreq_release_packet(pl, pkt);
|
483
|
+
return rc;
|
484
|
+
}
|
485
|
+
|
486
|
+
// Set the header fields.
|
487
|
+
hdr.request.magic = PROTOCOL_BINARY_REQ;
|
488
|
+
if (ctx.is_lookup()) {
|
489
|
+
hdr.request.opcode = PROTOCOL_BINARY_CMD_SUBDOC_MULTI_LOOKUP;
|
490
|
+
} else {
|
491
|
+
hdr.request.opcode = PROTOCOL_BINARY_CMD_SUBDOC_MULTI_MUTATION;
|
492
|
+
}
|
493
|
+
hdr.request.datatype = PROTOCOL_BINARY_RAW_BYTES;
|
494
|
+
hdr.request.extlen = pkt->extlen;
|
495
|
+
hdr.request.opaque = pkt->opaque;
|
496
|
+
hdr.request.cas = lcb_htonll(cmd->cas);
|
497
|
+
hdr.request.bodylen = htonl(hdr.request.extlen +
|
498
|
+
ntohs(hdr.request.keylen) + ctx.payload_size);
|
499
|
+
memcpy(SPAN_BUFFER(&pkt->kh_span), hdr.bytes, sizeof hdr.bytes);
|
500
|
+
if (exp) {
|
501
|
+
exp = htonl(exp);
|
502
|
+
memcpy(SPAN_BUFFER(&pkt->kh_span) + 24, &exp, 4);
|
503
|
+
}
|
504
|
+
|
505
|
+
MCREQ_PKT_RDATA(pkt)->cookie = cookie;
|
506
|
+
MCREQ_PKT_RDATA(pkt)->start = gethrtime();
|
507
|
+
LCB_SCHED_ADD(instance, pl, pkt);
|
508
|
+
return LCB_SUCCESS;
|
509
|
+
}
|
510
|
+
|