diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 15174b58..bcbf0761 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,6 +23,8 @@ jobs: - name: Install FoundationDB uses: Clikengo/foundationdb-actions-install@v1 + with: + version: "6.3.15" - name: Install Clang if: matrix.os == 'windows-latest' @@ -63,6 +65,12 @@ jobs: command: test args: --manifest-path foundationdb/Cargo.toml --features num-bigint --tests + - name: Test 6.3 + uses: actions-rs/cargo@v1 + with: + command: test + args: --manifest-path foundationdb/Cargo.toml --no-default-features --features fdb-6_3 --tests + - name: Test 6.2 uses: actions-rs/cargo@v1 with: @@ -115,6 +123,8 @@ jobs: - name: Install FoundationDB uses: Clikengo/foundationdb-actions-install@v1 + with: + version: "6.3.15" - name: Install Rust toolchain uses: actions-rs/toolchain@v1 @@ -143,6 +153,8 @@ jobs: - name: Install FoundationDB uses: Clikengo/foundationdb-actions-install@v1 + with: + version: "6.3.15" - uses: actions-rs/toolchain@v1 with: @@ -175,6 +187,8 @@ jobs: - name: Install FoundationDB uses: Clikengo/foundationdb-actions-install@v1 + with: + version: "6.3.15" - uses: actions-rs/toolchain@v1 with: diff --git a/.github/workflows/rustdoc.yml b/.github/workflows/rustdoc.yml index ec3b1223..05803aa6 100644 --- a/.github/workflows/rustdoc.yml +++ b/.github/workflows/rustdoc.yml @@ -16,6 +16,8 @@ jobs: - name: Install FoundationDB uses: Clikengo/foundationdb-actions-install@v1 + with: + version: "6.3.15" - name: Install Rust toolchain uses: actions-rs/toolchain@v1 diff --git a/foundationdb-bindingtester/Cargo.toml b/foundationdb-bindingtester/Cargo.toml index 2144faa2..e83a6b4a 100644 --- a/foundationdb-bindingtester/Cargo.toml +++ b/foundationdb-bindingtester/Cargo.toml @@ -20,7 +20,7 @@ categories = ["database"] license = "MIT/Apache-2.0" [features] -default = ["fdb-6_2"] +default = ["fdb-6_3"] # Use the locally embedded foundationdb fdb_c.h and fdb.options files embedded-fdb-include = ["foundationdb/embedded-fdb-include"] fdb-5_1 = ["foundationdb/fdb-5_1"] @@ -28,6 +28,7 @@ fdb-5_2 = ["foundationdb/fdb-5_2"] fdb-6_0 = ["foundationdb/fdb-6_0"] fdb-6_1 = ["foundationdb/fdb-6_1"] fdb-6_2 = ["foundationdb/fdb-6_2"] +fdb-6_3 = ["foundationdb/fdb-6_3"] [dependencies] env_logger = "0.7.1" diff --git a/foundationdb-bindingtester/src/main.rs b/foundationdb-bindingtester/src/main.rs index 69f38e03..3e61325c 100644 --- a/foundationdb-bindingtester/src/main.rs +++ b/foundationdb-bindingtester/src/main.rs @@ -27,6 +27,8 @@ static GOT_COMMITTED_VERSION: Element = static ERROR_NONE: Element = Element::Bytes(Bytes(Cow::Borrowed(b"ERROR: NONE"))); static ERROR_MULTIPLE: Element = Element::Bytes(Bytes(Cow::Borrowed(b"ERROR: MULTIPLE"))); static OK: Element = Element::Bytes(Bytes(Cow::Borrowed(b"OK"))); +static ESTIMATE_RANGE_RESPONSE: Element = + Element::Bytes(Bytes(Cow::Borrowed(b"GOT_ESTIMATED_RANGE_SIZE"))); #[cfg(feature = "fdb-6_2")] static GOT_APPROXIMATE_SIZE: Element = @@ -34,6 +36,7 @@ static GOT_APPROXIMATE_SIZE: Element = use crate::fdb::options::{MutationType, StreamingMode}; use tuple::VersionstampOffset; + fn mutation_from_str(s: &str) -> MutationType { match s { "ADD" => MutationType::Add, @@ -171,6 +174,7 @@ enum InstrCode { GetCommittedVersion, GetApproximateSize, WaitFuture, + GetEstimatedRangeSize, TuplePack, TuplePackWithVersionstamp, @@ -247,6 +251,7 @@ impl Instr { "GET_COMMITTED_VERSION" => GetCommittedVersion, "GET_APPROXIMATE_SIZE" => GetApproximateSize, "WAIT_FUTURE" => WaitFuture, + "GET_ESTIMATED_RANGE_SIZE" => GetEstimatedRangeSize, "TUPLE_PACK" => TuplePack, "TUPLE_PACK_WITH_VERSIONSTAMP" => TuplePackWithVersionstamp, @@ -1230,6 +1235,33 @@ impl StackMachine { let item = self.pop().await; self.stack.push(item); } + + // Pops the top two items off of the stack as BEGIN_KEY and END_KEY to + // construct a key range. Then call the `getEstimatedRangeSize` API of + // the language binding. Make sure the API returns without error. Finally + // push the string "GOT_ESTIMATED_RANGE_SIZE" onto the stack. + GetEstimatedRangeSize => { + debug!("get estimated range size"); + #[cfg(feature = "fdb-6_3")] + { + let begin = self.pop_bytes().await; + let end = self.pop_bytes().await; + + if let Ok(estimate) = trx + .as_mut() + .get_estimated_range_size_bytes(&begin, &end) + .await + { + debug!("got an estimate of {} bytes", estimate); + self.push(number, ESTIMATE_RANGE_RESPONSE.clone().into_owned()); + } + } + #[cfg(not(feature = "fdb-6_3"))] + { + unimplemented!("get_estimated_range_size requires fdb630+"); + } + } + // Pops the top item off of the stack as N. Pops the next N items off of the // stack and packs them as the tuple [item0,item1,...,itemN], and then pushes // this single packed value onto the stack. diff --git a/foundationdb-gen/Cargo.toml b/foundationdb-gen/Cargo.toml index 415827c2..79225ce2 100644 --- a/foundationdb-gen/Cargo.toml +++ b/foundationdb-gen/Cargo.toml @@ -26,7 +26,7 @@ features = ["embedded-fdb-include"] codecov = { repository = "Clikengo/foundationdb-rs", branch = "master", service = "github" } [features] -default = ["fdb-6_2"] +default = ["fdb-6_3"] # Use the locally embedded foundationdb fdb.options file embedded-fdb-include = [] fdb-5_1 = [] @@ -34,6 +34,7 @@ fdb-5_2 = [] fdb-6_0 = [] fdb-6_1 = [] fdb-6_2 = [] +fdb-6_3 = [] [dependencies] xml-rs = "0.8.0" diff --git a/foundationdb-gen/src/lib.rs b/foundationdb-gen/src/lib.rs index 94635047..f12ad18e 100644 --- a/foundationdb-gen/src/lib.rs +++ b/foundationdb-gen/src/lib.rs @@ -366,6 +366,8 @@ const OPTIONS_DATA: &[u8] = include_bytes!("../include/600/fdb.options"); const OPTIONS_DATA: &[u8] = include_bytes!("../include/610/fdb.options"); #[cfg(all(feature = "embedded-fdb-include", feature = "fdb-6_2"))] const OPTIONS_DATA: &[u8] = include_bytes!("../include/620/fdb.options"); +#[cfg(all(feature = "embedded-fdb-include", feature = "fdb-6_3"))] +const OPTIONS_DATA: &[u8] = include_bytes!("../include/630/fdb.options"); pub fn emit(w: &mut impl fmt::Write) -> fmt::Result { let mut reader = OPTIONS_DATA; diff --git a/foundationdb-sys/Cargo.toml b/foundationdb-sys/Cargo.toml index 6e727f10..cf110d61 100644 --- a/foundationdb-sys/Cargo.toml +++ b/foundationdb-sys/Cargo.toml @@ -27,7 +27,7 @@ features = ["embedded-fdb-include"] codecov = { repository = "Clikengo/foundationdb-rs", branch = "master", service = "github" } [features] -default = ["fdb-6_2"] +default = ["fdb-6_3"] # Use the locally embedded foundationdb fdb_c.h file embedded-fdb-include = [] fdb-5_1 = [] @@ -35,6 +35,7 @@ fdb-5_2 = [] fdb-6_0 = [] fdb-6_1 = [] fdb-6_2 = [] +fdb-6_3 = [] [dependencies] diff --git a/foundationdb-sys/build.rs b/foundationdb-sys/build.rs index 16a1deb0..1db821b6 100644 --- a/foundationdb-sys/build.rs +++ b/foundationdb-sys/build.rs @@ -24,6 +24,8 @@ const INCLUDE_PATH: &str = "-I./include/600"; const INCLUDE_PATH: &str = "-I./include/610"; #[cfg(all(feature = "embedded-fdb-include", feature = "fdb-6_2"))] const INCLUDE_PATH: &str = "-I./include/620"; +#[cfg(all(feature = "embedded-fdb-include", feature = "fdb-6_3"))] +const INCLUDE_PATH: &str = "-I./include/630"; fn main() { // Link against fdb_c. @@ -63,6 +65,10 @@ fn main() { { api_version = 620; } + #[cfg(feature = "fdb-6_3")] + { + api_version = 630; + } // Sigh, bindgen only takes a String for its header path, but that's UTF-8 while // PathBuf is OS-native... diff --git a/foundationdb-sys/include/630/fdb_c.h b/foundationdb-sys/include/630/fdb_c.h new file mode 100644 index 00000000..30177d96 --- /dev/null +++ b/foundationdb-sys/include/630/fdb_c.h @@ -0,0 +1,374 @@ +/* + * fdb_c.h + * + * This source file is part of the FoundationDB open source project + * + * Copyright 2013-2018 Apple Inc. and the FoundationDB project authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef FDB_C_H +#define FDB_C_H +#pragma once + +#ifndef DLLEXPORT +#define DLLEXPORT +#endif + +#if !defined(FDB_API_VERSION) +#error You must #define FDB_API_VERSION prior to including fdb_c.h (current version is 630) +#elif FDB_API_VERSION < 13 +#error API version no longer supported (upgrade to 13) +#elif FDB_API_VERSION > 630 +#error Requested API version requires a newer version of this header +#endif + +#if FDB_API_VERSION >= 23 && !defined(WARN_UNUSED_RESULT) +#ifdef __GNUG__ +#define WARN_UNUSED_RESULT __attribute__((warn_unused_result)) +#else +#define WARN_UNUSED_RESULT +#endif +#else +#define WARN_UNUSED_RESULT +#endif + +// With default settings, gcc will not warn about unprototyped functions being called, so it +// is easy to erroneously call a function which is not available at FDB_API_VERSION and then +// get an error only at runtime. These macros ensure a compile error in such cases, and +// attempt to make the compile error slightly informative. +#define This_FoundationDB_API_function_is_removed_at_this_FDB_API_VERSION() \ + { == == = } +#define FDB_REMOVED_FUNCTION This_FoundationDB_API_function_is_removed_at_this_FDB_API_VERSION(0) + +#include + +#include "fdb_c_options.g.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Pointers to these opaque types represent objects in the FDB API */ +typedef struct FDB_future FDBFuture; +typedef struct FDB_database FDBDatabase; +typedef struct FDB_transaction FDBTransaction; + +typedef int fdb_error_t; +typedef int fdb_bool_t; + +DLLEXPORT const char* fdb_get_error(fdb_error_t code); + +DLLEXPORT fdb_bool_t fdb_error_predicate(int predicate_test, fdb_error_t code); + +#define /* fdb_error_t */ fdb_select_api_version(v) fdb_select_api_version_impl(v, FDB_API_VERSION) + +DLLEXPORT WARN_UNUSED_RESULT fdb_error_t fdb_network_set_option(FDBNetworkOption option, + uint8_t const* value, + int value_length); + +#if FDB_API_VERSION >= 14 +DLLEXPORT WARN_UNUSED_RESULT fdb_error_t fdb_setup_network(); +#endif + +DLLEXPORT WARN_UNUSED_RESULT fdb_error_t fdb_run_network(); + +DLLEXPORT WARN_UNUSED_RESULT fdb_error_t fdb_stop_network(); + +DLLEXPORT WARN_UNUSED_RESULT fdb_error_t fdb_add_network_thread_completion_hook(void (*hook)(void*), + void* hook_parameter); + +#pragma pack(push, 4) +#if FDB_API_VERSION >= 630 +typedef struct keyvalue { + const uint8_t* key; + int key_length; + const uint8_t* value; + int value_length; +} FDBKeyValue; +#else +typedef struct keyvalue { + const void* key; + int key_length; + const void* value; + int value_length; +} FDBKeyValue; +#endif +#pragma pack(pop) + +DLLEXPORT void fdb_future_cancel(FDBFuture* f); + +DLLEXPORT void fdb_future_release_memory(FDBFuture* f); + +DLLEXPORT void fdb_future_destroy(FDBFuture* f); + +DLLEXPORT WARN_UNUSED_RESULT fdb_error_t fdb_future_block_until_ready(FDBFuture* f); + +DLLEXPORT fdb_bool_t fdb_future_is_ready(FDBFuture* f); + +typedef void (*FDBCallback)(FDBFuture* future, void* callback_parameter); + +DLLEXPORT WARN_UNUSED_RESULT fdb_error_t fdb_future_set_callback(FDBFuture* f, + FDBCallback callback, + void* callback_parameter); + +#if FDB_API_VERSION >= 23 +DLLEXPORT WARN_UNUSED_RESULT fdb_error_t fdb_future_get_error(FDBFuture* f); +#endif + +DLLEXPORT WARN_UNUSED_RESULT fdb_error_t fdb_future_get_int64(FDBFuture* f, int64_t* out); + +DLLEXPORT WARN_UNUSED_RESULT fdb_error_t fdb_future_get_key(FDBFuture* f, uint8_t const** out_key, int* out_key_length); + +DLLEXPORT WARN_UNUSED_RESULT fdb_error_t fdb_future_get_value(FDBFuture* f, + fdb_bool_t* out_present, + uint8_t const** out_value, + int* out_value_length); + +#if FDB_API_VERSION >= 14 +DLLEXPORT WARN_UNUSED_RESULT fdb_error_t fdb_future_get_keyvalue_array(FDBFuture* f, + FDBKeyValue const** out_kv, + int* out_count, + fdb_bool_t* out_more); +#endif + +DLLEXPORT WARN_UNUSED_RESULT fdb_error_t fdb_future_get_string_array(FDBFuture* f, + const char*** out_strings, + int* out_count); + +DLLEXPORT WARN_UNUSED_RESULT fdb_error_t fdb_create_database(const char* cluster_file_path, FDBDatabase** out_database); + +DLLEXPORT void fdb_database_destroy(FDBDatabase* d); + +DLLEXPORT WARN_UNUSED_RESULT fdb_error_t fdb_database_set_option(FDBDatabase* d, + FDBDatabaseOption option, + uint8_t const* value, + int value_length); + +DLLEXPORT WARN_UNUSED_RESULT fdb_error_t fdb_database_create_transaction(FDBDatabase* d, + FDBTransaction** out_transaction); + +DLLEXPORT void fdb_transaction_destroy(FDBTransaction* tr); + +DLLEXPORT void fdb_transaction_cancel(FDBTransaction* tr); + +#if FDB_API_VERSION >= 14 +DLLEXPORT WARN_UNUSED_RESULT fdb_error_t fdb_transaction_set_option(FDBTransaction* tr, + FDBTransactionOption option, + uint8_t const* value, + int value_length); +#endif + +DLLEXPORT void fdb_transaction_set_read_version(FDBTransaction* tr, int64_t version); + +DLLEXPORT WARN_UNUSED_RESULT FDBFuture* fdb_transaction_get_read_version(FDBTransaction* tr); + +#if FDB_API_VERSION >= 14 +DLLEXPORT WARN_UNUSED_RESULT FDBFuture* fdb_transaction_get(FDBTransaction* tr, + uint8_t const* key_name, + int key_name_length, + fdb_bool_t snapshot); +#endif + +#if FDB_API_VERSION >= 14 +DLLEXPORT WARN_UNUSED_RESULT FDBFuture* fdb_transaction_get_key(FDBTransaction* tr, + uint8_t const* key_name, + int key_name_length, + fdb_bool_t or_equal, + int offset, + fdb_bool_t snapshot); +#endif + +DLLEXPORT WARN_UNUSED_RESULT FDBFuture* fdb_transaction_get_addresses_for_key(FDBTransaction* tr, + uint8_t const* key_name, + int key_name_length); + +#if FDB_API_VERSION >= 14 +DLLEXPORT WARN_UNUSED_RESULT FDBFuture* fdb_transaction_get_range(FDBTransaction* tr, + uint8_t const* begin_key_name, + int begin_key_name_length, + fdb_bool_t begin_or_equal, + int begin_offset, + uint8_t const* end_key_name, + int end_key_name_length, + fdb_bool_t end_or_equal, + int end_offset, + int limit, + int target_bytes, + FDBStreamingMode mode, + int iteration, + fdb_bool_t snapshot, + fdb_bool_t reverse); +#endif + +DLLEXPORT void fdb_transaction_set(FDBTransaction* tr, + uint8_t const* key_name, + int key_name_length, + uint8_t const* value, + int value_length); + +DLLEXPORT void fdb_transaction_atomic_op(FDBTransaction* tr, + uint8_t const* key_name, + int key_name_length, + uint8_t const* param, + int param_length, + FDBMutationType operation_type); + +DLLEXPORT void fdb_transaction_clear(FDBTransaction* tr, uint8_t const* key_name, int key_name_length); + +DLLEXPORT void fdb_transaction_clear_range(FDBTransaction* tr, + uint8_t const* begin_key_name, + int begin_key_name_length, + uint8_t const* end_key_name, + int end_key_name_length); + +DLLEXPORT WARN_UNUSED_RESULT FDBFuture* fdb_transaction_watch(FDBTransaction* tr, + uint8_t const* key_name, + int key_name_length); + +DLLEXPORT WARN_UNUSED_RESULT FDBFuture* fdb_transaction_commit(FDBTransaction* tr); + +DLLEXPORT WARN_UNUSED_RESULT fdb_error_t fdb_transaction_get_committed_version(FDBTransaction* tr, + int64_t* out_version); + +// This function intentionally returns an FDBFuture instead of an integer directly, +// so that calling this API can see the effect of previous mutations on the transaction. +// Specifically, mutations are applied asynchronously by the main thread. In order to +// see them, this call has to be serviced by the main thread too. +DLLEXPORT WARN_UNUSED_RESULT FDBFuture* fdb_transaction_get_approximate_size(FDBTransaction* tr); + +DLLEXPORT WARN_UNUSED_RESULT FDBFuture* fdb_transaction_get_versionstamp(FDBTransaction* tr); + +DLLEXPORT WARN_UNUSED_RESULT FDBFuture* fdb_transaction_on_error(FDBTransaction* tr, fdb_error_t error); + +DLLEXPORT void fdb_transaction_reset(FDBTransaction* tr); + +DLLEXPORT WARN_UNUSED_RESULT fdb_error_t fdb_transaction_add_conflict_range(FDBTransaction* tr, + uint8_t const* begin_key_name, + int begin_key_name_length, + uint8_t const* end_key_name, + int end_key_name_length, + FDBConflictRangeType type); + +DLLEXPORT WARN_UNUSED_RESULT FDBFuture* fdb_transaction_get_estimated_range_size_bytes(FDBTransaction* tr, + uint8_t const* begin_key_name, + int begin_key_name_length, + uint8_t const* end_key_name, + int end_key_name_length); + +#define FDB_KEYSEL_LAST_LESS_THAN(k, l) k, l, 0, 0 +#define FDB_KEYSEL_LAST_LESS_OR_EQUAL(k, l) k, l, 1, 0 +#define FDB_KEYSEL_FIRST_GREATER_THAN(k, l) k, l, 1, 1 +#define FDB_KEYSEL_FIRST_GREATER_OR_EQUAL(k, l) k, l, 0, 1 + +DLLEXPORT WARN_UNUSED_RESULT fdb_error_t fdb_select_api_version_impl(int runtime_version, int header_version); + +DLLEXPORT int fdb_get_max_api_version(); +DLLEXPORT const char* fdb_get_client_version(); + +/* LEGACY API VERSIONS */ + +#if FDB_API_VERSION < 620 +DLLEXPORT WARN_UNUSED_RESULT fdb_error_t fdb_future_get_version(FDBFuture* f, int64_t* out_version); +#else +#define fdb_future_get_version(f, ov) FDB_REMOVED_FUNCTION +#endif + +#if FDB_API_VERSION < 610 || defined FDB_INCLUDE_LEGACY_TYPES +typedef struct FDB_cluster FDBCluster; + +typedef enum { + // This option is only a placeholder for C compatibility and should not be used + FDB_CLUSTER_OPTION_DUMMY_DO_NOT_USE = -1 +} FDBClusterOption; +#endif + +#if FDB_API_VERSION < 610 +DLLEXPORT WARN_UNUSED_RESULT fdb_error_t fdb_future_get_cluster(FDBFuture* f, FDBCluster** out_cluster); + +DLLEXPORT WARN_UNUSED_RESULT fdb_error_t fdb_future_get_database(FDBFuture* f, FDBDatabase** out_database); + +DLLEXPORT WARN_UNUSED_RESULT FDBFuture* fdb_create_cluster(const char* cluster_file_path); + +DLLEXPORT void fdb_cluster_destroy(FDBCluster* c); + +DLLEXPORT WARN_UNUSED_RESULT fdb_error_t fdb_cluster_set_option(FDBCluster* c, + FDBClusterOption option, + uint8_t const* value, + int value_length); + +DLLEXPORT WARN_UNUSED_RESULT FDBFuture* fdb_cluster_create_database(FDBCluster* c, + uint8_t const* db_name, + int db_name_length); +#else +#define fdb_future_get_cluster(f, oc) FDB_REMOVED_FUNCTION +#define fdb_future_get_database(f, od) FDB_REMOVED_FUNCTION +#define fdb_create_cluster(cfp) FDB_REMOVED_FUNCTION +#define fdb_cluster_destroy(c) FDB_REMOVED_FUNCTION +#define fdb_cluster_set_option(c, o, v, vl) FDB_REMOVED_FUNCTION +#define fdb_cluster_create_database(c, dn, dnl) FDB_REMOVED_FUNCTION +#endif + +#if FDB_API_VERSION < 23 +DLLEXPORT WARN_UNUSED_RESULT fdb_error_t fdb_future_get_error(FDBFuture* f, const char** out_description /* = NULL */); + +DLLEXPORT fdb_bool_t fdb_future_is_error(FDBFuture* f); +#else +#define fdb_future_is_error(x) FDB_REMOVED_FUNCTION +#endif + +#if FDB_API_VERSION < 14 +DLLEXPORT WARN_UNUSED_RESULT fdb_error_t fdb_future_get_keyvalue_array(FDBFuture* f, + FDBKeyValue const** out_kv, + int* out_count); + +DLLEXPORT WARN_UNUSED_RESULT FDBFuture* fdb_transaction_get(FDBTransaction* tr, + uint8_t const* key_name, + int key_name_length); + +DLLEXPORT WARN_UNUSED_RESULT FDBFuture* fdb_transaction_get_key(FDBTransaction* tr, + uint8_t const* key_name, + int key_name_length, + fdb_bool_t or_equal, + int offset); + +DLLEXPORT WARN_UNUSED_RESULT fdb_error_t fdb_setup_network(const char* local_address); + +DLLEXPORT void fdb_transaction_set_option(FDBTransaction* tr, FDBTransactionOption option); + +DLLEXPORT WARN_UNUSED_RESULT FDBFuture* fdb_transaction_get_range(FDBTransaction* tr, + uint8_t const* begin_key_name, + int begin_key_name_length, + uint8_t const* end_key_name, + int end_key_name_length, + int limit); + +DLLEXPORT WARN_UNUSED_RESULT FDBFuture* fdb_transaction_get_range_selector(FDBTransaction* tr, + uint8_t const* begin_key_name, + int begin_key_name_length, + fdb_bool_t begin_or_equal, + int begin_offset, + uint8_t const* end_key_name, + int end_key_name_length, + fdb_bool_t end_or_equal, + int end_offset, + int limit); +#else +#define fdb_transaction_get_range_selector(tr, bkn, bknl, boe, bo, ekn, eknl, eoe, eo, lim) FDB_REMOVED_FUNCTION +#endif + +#ifdef __cplusplus +} +#endif +#endif diff --git a/foundationdb-sys/include/630/fdb_c_options.g.h b/foundationdb-sys/include/630/fdb_c_options.g.h new file mode 100644 index 00000000..93524d86 --- /dev/null +++ b/foundationdb-sys/include/630/fdb_c_options.g.h @@ -0,0 +1,457 @@ +#ifndef FDB_C_OPTIONS_G_H +#define FDB_C_OPTIONS_G_H +#pragma once + +/* + * FoundationDB C API + * + * This source file is part of the FoundationDB open source project + * + * Copyright 2013-2018 Apple Inc. and the FoundationDB project authors + * + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * Do not include this file directly. + */ + +typedef enum { + // Deprecated + // Parameter: (String) IP:PORT + FDB_NET_OPTION_LOCAL_ADDRESS=10, + + // Deprecated + // Parameter: (String) path to cluster file + FDB_NET_OPTION_CLUSTER_FILE=20, + + // Enables trace output to a file in a directory of the clients choosing + // Parameter: (String) path to output directory (or NULL for current working directory) + FDB_NET_OPTION_TRACE_ENABLE=30, + + // Sets the maximum size in bytes of a single trace output file. This value should be in the range ``[0, INT64_MAX]``. If the value is set to 0, there is no limit on individual file size. The default is a maximum size of 10,485,760 bytes. + // Parameter: (Int) max size of a single trace output file + FDB_NET_OPTION_TRACE_ROLL_SIZE=31, + + // Sets the maximum size of all the trace output files put together. This value should be in the range ``[0, INT64_MAX]``. If the value is set to 0, there is no limit on the total size of the files. The default is a maximum size of 104,857,600 bytes. If the default roll size is used, this means that a maximum of 10 trace files will be written at a time. + // Parameter: (Int) max total size of trace files + FDB_NET_OPTION_TRACE_MAX_LOGS_SIZE=32, + + // Sets the 'LogGroup' attribute with the specified value for all events in the trace output files. The default log group is 'default'. + // Parameter: (String) value of the LogGroup attribute + FDB_NET_OPTION_TRACE_LOG_GROUP=33, + + // Select the format of the log files. xml (the default) and json are supported. + // Parameter: (String) Format of trace files + FDB_NET_OPTION_TRACE_FORMAT=34, + + // Select clock source for trace files. now (the default) or realtime are supported. + // Parameter: (String) Trace clock source + FDB_NET_OPTION_TRACE_CLOCK_SOURCE=35, + + // Once provided, this string will be used to replace the port/PID in the log file names. + // Parameter: (String) The identifier that will be part of all trace file names + FDB_NET_OPTION_TRACE_FILE_IDENTIFIER=36, + + // Set internal tuning or debugging knobs + // Parameter: (String) knob_name=knob_value + FDB_NET_OPTION_KNOB=40, + + // Deprecated + // Parameter: (String) file path or linker-resolved name + FDB_NET_OPTION_TLS_PLUGIN=41, + + // Set the certificate chain + // Parameter: (Bytes) certificates + FDB_NET_OPTION_TLS_CERT_BYTES=42, + + // Set the file from which to load the certificate chain + // Parameter: (String) file path + FDB_NET_OPTION_TLS_CERT_PATH=43, + + // Set the private key corresponding to your own certificate + // Parameter: (Bytes) key + FDB_NET_OPTION_TLS_KEY_BYTES=45, + + // Set the file from which to load the private key corresponding to your own certificate + // Parameter: (String) file path + FDB_NET_OPTION_TLS_KEY_PATH=46, + + // Set the peer certificate field verification criteria + // Parameter: (Bytes) verification pattern + FDB_NET_OPTION_TLS_VERIFY_PEERS=47, + + // + // Parameter: Option takes no parameter + FDB_NET_OPTION_BUGGIFY_ENABLE=48, + + // + // Parameter: Option takes no parameter + FDB_NET_OPTION_BUGGIFY_DISABLE=49, + + // Set the probability of a BUGGIFY section being active for the current execution. Only applies to code paths first traversed AFTER this option is changed. + // Parameter: (Int) probability expressed as a percentage between 0 and 100 + FDB_NET_OPTION_BUGGIFY_SECTION_ACTIVATED_PROBABILITY=50, + + // Set the probability of an active BUGGIFY section being fired + // Parameter: (Int) probability expressed as a percentage between 0 and 100 + FDB_NET_OPTION_BUGGIFY_SECTION_FIRED_PROBABILITY=51, + + // Set the ca bundle + // Parameter: (Bytes) ca bundle + FDB_NET_OPTION_TLS_CA_BYTES=52, + + // Set the file from which to load the certificate authority bundle + // Parameter: (String) file path + FDB_NET_OPTION_TLS_CA_PATH=53, + + // Set the passphrase for encrypted private key. Password should be set before setting the key for the password to be used. + // Parameter: (String) key passphrase + FDB_NET_OPTION_TLS_PASSWORD=54, + + // Disables the multi-version client API and instead uses the local client directly. Must be set before setting up the network. + // Parameter: Option takes no parameter + FDB_NET_OPTION_DISABLE_MULTI_VERSION_CLIENT_API=60, + + // If set, callbacks from external client libraries can be called from threads created by the FoundationDB client library. Otherwise, callbacks will be called from either the thread used to add the callback or the network thread. Setting this option can improve performance when connected using an external client, but may not be safe to use in all environments. Must be set before setting up the network. WARNING: This feature is considered experimental at this time. + // Parameter: Option takes no parameter + FDB_NET_OPTION_CALLBACKS_ON_EXTERNAL_THREADS=61, + + // Adds an external client library for use by the multi-version client API. Must be set before setting up the network. + // Parameter: (String) path to client library + FDB_NET_OPTION_EXTERNAL_CLIENT_LIBRARY=62, + + // Searches the specified path for dynamic libraries and adds them to the list of client libraries for use by the multi-version client API. Must be set before setting up the network. + // Parameter: (String) path to directory containing client libraries + FDB_NET_OPTION_EXTERNAL_CLIENT_DIRECTORY=63, + + // Prevents connections through the local client, allowing only connections through externally loaded client libraries. + // Parameter: Option takes no parameter + FDB_NET_OPTION_DISABLE_LOCAL_CLIENT=64, + + // Spawns multiple worker threads for each version of the client that is loaded. Setting this to a number greater than one implies disable_local_client. + // Parameter: (Int) Number of client threads to be spawned. Each cluster will be serviced by a single client thread. + FDB_NET_OPTION_CLIENT_THREADS_PER_VERSION=65, + + // Disables logging of client statistics, such as sampled transaction activity. + // Parameter: Option takes no parameter + FDB_NET_OPTION_DISABLE_CLIENT_STATISTICS_LOGGING=70, + + // Deprecated + // Parameter: Option takes no parameter + FDB_NET_OPTION_ENABLE_SLOW_TASK_PROFILING=71, + + // Enables debugging feature to perform run loop profiling. Requires trace logging to be enabled. WARNING: this feature is not recommended for use in production. + // Parameter: Option takes no parameter + FDB_NET_OPTION_ENABLE_RUN_LOOP_PROFILING=71, + + // Enable client buggify - will make requests randomly fail (intended for client testing) + // Parameter: Option takes no parameter + FDB_NET_OPTION_CLIENT_BUGGIFY_ENABLE=80, + + // Disable client buggify + // Parameter: Option takes no parameter + FDB_NET_OPTION_CLIENT_BUGGIFY_DISABLE=81, + + // Set the probability of a CLIENT_BUGGIFY section being active for the current execution. + // Parameter: (Int) probability expressed as a percentage between 0 and 100 + FDB_NET_OPTION_CLIENT_BUGGIFY_SECTION_ACTIVATED_PROBABILITY=82, + + // Set the probability of an active CLIENT_BUGGIFY section being fired. A section will only fire if it was activated + // Parameter: (Int) probability expressed as a percentage between 0 and 100 + FDB_NET_OPTION_CLIENT_BUGGIFY_SECTION_FIRED_PROBABILITY=83 +} FDBNetworkOption; + +typedef enum { + // Set the size of the client location cache. Raising this value can boost performance in very large databases where clients access data in a near-random pattern. Defaults to 100000. + // Parameter: (Int) Max location cache entries + FDB_DB_OPTION_LOCATION_CACHE_SIZE=10, + + // Set the maximum number of watches allowed to be outstanding on a database connection. Increasing this number could result in increased resource usage. Reducing this number will not cancel any outstanding watches. Defaults to 10000 and cannot be larger than 1000000. + // Parameter: (Int) Max outstanding watches + FDB_DB_OPTION_MAX_WATCHES=20, + + // Specify the machine ID that was passed to fdbserver processes running on the same machine as this client, for better location-aware load balancing. + // Parameter: (String) Hexadecimal ID + FDB_DB_OPTION_MACHINE_ID=21, + + // Specify the datacenter ID that was passed to fdbserver processes running in the same datacenter as this client, for better location-aware load balancing. + // Parameter: (String) Hexadecimal ID + FDB_DB_OPTION_DATACENTER_ID=22, + + // Snapshot read operations will see the results of writes done in the same transaction. This is the default behavior. + // Parameter: Option takes no parameter + FDB_DB_OPTION_SNAPSHOT_RYW_ENABLE=26, + + // Snapshot read operations will not see the results of writes done in the same transaction. This was the default behavior prior to API version 300. + // Parameter: Option takes no parameter + FDB_DB_OPTION_SNAPSHOT_RYW_DISABLE=27, + + // Sets the maximum escaped length of key and value fields to be logged to the trace file via the LOG_TRANSACTION option. This sets the ``transaction_logging_max_field_length`` option of each transaction created by this database. See the transaction option description for more information. + // Parameter: (Int) Maximum length of escaped key and value fields. + FDB_DB_OPTION_TRANSACTION_LOGGING_MAX_FIELD_LENGTH=405, + + // Set a timeout in milliseconds which, when elapsed, will cause each transaction automatically to be cancelled. This sets the ``timeout`` option of each transaction created by this database. See the transaction option description for more information. Using this option requires that the API version is 610 or higher. + // Parameter: (Int) value in milliseconds of timeout + FDB_DB_OPTION_TRANSACTION_TIMEOUT=500, + + // Set a maximum number of retries after which additional calls to ``onError`` will throw the most recently seen error code. This sets the ``retry_limit`` option of each transaction created by this database. See the transaction option description for more information. + // Parameter: (Int) number of times to retry + FDB_DB_OPTION_TRANSACTION_RETRY_LIMIT=501, + + // Set the maximum amount of backoff delay incurred in the call to ``onError`` if the error is retryable. This sets the ``max_retry_delay`` option of each transaction created by this database. See the transaction option description for more information. + // Parameter: (Int) value in milliseconds of maximum delay + FDB_DB_OPTION_TRANSACTION_MAX_RETRY_DELAY=502, + + // Set the maximum transaction size in bytes. This sets the ``size_limit`` option on each transaction created by this database. See the transaction option description for more information. + // Parameter: (Int) value in bytes + FDB_DB_OPTION_TRANSACTION_SIZE_LIMIT=503, + + // The read version will be committed, and usually will be the latest committed, but might not be the latest committed in the event of a simultaneous fault and misbehaving clock. + // Parameter: Option takes no parameter + FDB_DB_OPTION_TRANSACTION_CAUSAL_READ_RISKY=504, + + // Addresses returned by get_addresses_for_key include the port when enabled. As of api version 630, this option is enabled by default and setting this has no effect. + // Parameter: Option takes no parameter + FDB_DB_OPTION_TRANSACTION_INCLUDE_PORT_IN_ADDRESS=505 +} FDBDatabaseOption; + +typedef enum { + // The transaction, if not self-conflicting, may be committed a second time after commit succeeds, in the event of a fault + // Parameter: Option takes no parameter + FDB_TR_OPTION_CAUSAL_WRITE_RISKY=10, + + // The read version will be committed, and usually will be the latest committed, but might not be the latest committed in the event of a simultaneous fault and misbehaving clock. + // Parameter: Option takes no parameter + FDB_TR_OPTION_CAUSAL_READ_RISKY=20, + + // + // Parameter: Option takes no parameter + FDB_TR_OPTION_CAUSAL_READ_DISABLE=21, + + // Addresses returned by get_addresses_for_key include the port when enabled. As of api version 630, this option is enabled by default and setting this has no effect. + // Parameter: Option takes no parameter + FDB_TR_OPTION_INCLUDE_PORT_IN_ADDRESS=23, + + // The next write performed on this transaction will not generate a write conflict range. As a result, other transactions which read the key(s) being modified by the next write will not conflict with this transaction. Care needs to be taken when using this option on a transaction that is shared between multiple threads. When setting this option, write conflict ranges will be disabled on the next write operation, regardless of what thread it is on. + // Parameter: Option takes no parameter + FDB_TR_OPTION_NEXT_WRITE_NO_WRITE_CONFLICT_RANGE=30, + + // Reads performed by a transaction will not see any prior mutations that occured in that transaction, instead seeing the value which was in the database at the transaction's read version. This option may provide a small performance benefit for the client, but also disables a number of client-side optimizations which are beneficial for transactions which tend to read and write the same keys within a single transaction. + // Parameter: Option takes no parameter + FDB_TR_OPTION_READ_YOUR_WRITES_DISABLE=51, + + // Deprecated + // Parameter: Option takes no parameter + FDB_TR_OPTION_READ_AHEAD_DISABLE=52, + + // + // Parameter: Option takes no parameter + FDB_TR_OPTION_DURABILITY_DATACENTER=110, + + // + // Parameter: Option takes no parameter + FDB_TR_OPTION_DURABILITY_RISKY=120, + + // Deprecated + // Parameter: Option takes no parameter + FDB_TR_OPTION_DURABILITY_DEV_NULL_IS_WEB_SCALE=130, + + // Specifies that this transaction should be treated as highest priority and that lower priority transactions should block behind this one. Use is discouraged outside of low-level tools + // Parameter: Option takes no parameter + FDB_TR_OPTION_PRIORITY_SYSTEM_IMMEDIATE=200, + + // Specifies that this transaction should be treated as low priority and that default priority transactions will be processed first. Batch priority transactions will also be throttled at load levels smaller than for other types of transactions and may be fully cut off in the event of machine failures. Useful for doing batch work simultaneously with latency-sensitive work + // Parameter: Option takes no parameter + FDB_TR_OPTION_PRIORITY_BATCH=201, + + // This is a write-only transaction which sets the initial configuration. This option is designed for use by database system tools only. + // Parameter: Option takes no parameter + FDB_TR_OPTION_INITIALIZE_NEW_DATABASE=300, + + // Allows this transaction to read and modify system keys (those that start with the byte 0xFF) + // Parameter: Option takes no parameter + FDB_TR_OPTION_ACCESS_SYSTEM_KEYS=301, + + // Allows this transaction to read system keys (those that start with the byte 0xFF) + // Parameter: Option takes no parameter + FDB_TR_OPTION_READ_SYSTEM_KEYS=302, + + // + // Parameter: (String) Optional transaction name + FDB_TR_OPTION_DEBUG_RETRY_LOGGING=401, + + // Deprecated + // Parameter: (String) String identifier to be used in the logs when tracing this transaction. The identifier must not exceed 100 characters. + FDB_TR_OPTION_TRANSACTION_LOGGING_ENABLE=402, + + // Sets a client provided identifier for the transaction that will be used in scenarios like tracing or profiling. Client trace logging or transaction profiling must be separately enabled. + // Parameter: (String) String identifier to be used when tracing or profiling this transaction. The identifier must not exceed 100 characters. + FDB_TR_OPTION_DEBUG_TRANSACTION_IDENTIFIER=403, + + // Enables tracing for this transaction and logs results to the client trace logs. The DEBUG_TRANSACTION_IDENTIFIER option must be set before using this option, and client trace logging must be enabled to get log output. + // Parameter: Option takes no parameter + FDB_TR_OPTION_LOG_TRANSACTION=404, + + // Sets the maximum escaped length of key and value fields to be logged to the trace file via the LOG_TRANSACTION option, after which the field will be truncated. A negative value disables truncation. + // Parameter: (Int) Maximum length of escaped key and value fields. + FDB_TR_OPTION_TRANSACTION_LOGGING_MAX_FIELD_LENGTH=405, + + // Sets an identifier for server tracing of this transaction. When committed, this identifier triggers logging when each part of the transaction authority encounters it, which is helpful in diagnosing slowness in misbehaving clusters. The identifier is randomly generated. When there is also a debug_transaction_identifier, both IDs are logged together. + // Parameter: Option takes no parameter + FDB_TR_OPTION_SERVER_REQUEST_TRACING=406, + + // Set a timeout in milliseconds which, when elapsed, will cause the transaction automatically to be cancelled. Valid parameter values are ``[0, INT_MAX]``. If set to 0, will disable all timeouts. All pending and any future uses of the transaction will throw an exception. The transaction can be used again after it is reset. Prior to API version 610, like all other transaction options, the timeout must be reset after a call to ``onError``. If the API version is 610 or greater, the timeout is not reset after an ``onError`` call. This allows the user to specify a longer timeout on specific transactions than the default timeout specified through the ``transaction_timeout`` database option without the shorter database timeout cancelling transactions that encounter a retryable error. Note that at all API versions, it is safe and legal to set the timeout each time the transaction begins, so most code written assuming the older behavior can be upgraded to the newer behavior without requiring any modification, and the caller is not required to implement special logic in retry loops to only conditionally set this option. + // Parameter: (Int) value in milliseconds of timeout + FDB_TR_OPTION_TIMEOUT=500, + + // Set a maximum number of retries after which additional calls to ``onError`` will throw the most recently seen error code. Valid parameter values are ``[-1, INT_MAX]``. If set to -1, will disable the retry limit. Prior to API version 610, like all other transaction options, the retry limit must be reset after a call to ``onError``. If the API version is 610 or greater, the retry limit is not reset after an ``onError`` call. Note that at all API versions, it is safe and legal to set the retry limit each time the transaction begins, so most code written assuming the older behavior can be upgraded to the newer behavior without requiring any modification, and the caller is not required to implement special logic in retry loops to only conditionally set this option. + // Parameter: (Int) number of times to retry + FDB_TR_OPTION_RETRY_LIMIT=501, + + // Set the maximum amount of backoff delay incurred in the call to ``onError`` if the error is retryable. Defaults to 1000 ms. Valid parameter values are ``[0, INT_MAX]``. If the maximum retry delay is less than the current retry delay of the transaction, then the current retry delay will be clamped to the maximum retry delay. Prior to API version 610, like all other transaction options, the maximum retry delay must be reset after a call to ``onError``. If the API version is 610 or greater, the retry limit is not reset after an ``onError`` call. Note that at all API versions, it is safe and legal to set the maximum retry delay each time the transaction begins, so most code written assuming the older behavior can be upgraded to the newer behavior without requiring any modification, and the caller is not required to implement special logic in retry loops to only conditionally set this option. + // Parameter: (Int) value in milliseconds of maximum delay + FDB_TR_OPTION_MAX_RETRY_DELAY=502, + + // Set the transaction size limit in bytes. The size is calculated by combining the sizes of all keys and values written or mutated, all key ranges cleared, and all read and write conflict ranges. (In other words, it includes the total size of all data included in the request to the cluster to commit the transaction.) Large transactions can cause performance problems on FoundationDB clusters, so setting this limit to a smaller value than the default can help prevent the client from accidentally degrading the cluster's performance. This value must be at least 32 and cannot be set to higher than 10,000,000, the default transaction size limit. + // Parameter: (Int) value in bytes + FDB_TR_OPTION_SIZE_LIMIT=503, + + // Snapshot read operations will see the results of writes done in the same transaction. This is the default behavior. + // Parameter: Option takes no parameter + FDB_TR_OPTION_SNAPSHOT_RYW_ENABLE=600, + + // Snapshot read operations will not see the results of writes done in the same transaction. This was the default behavior prior to API version 300. + // Parameter: Option takes no parameter + FDB_TR_OPTION_SNAPSHOT_RYW_DISABLE=601, + + // The transaction can read and write to locked databases, and is responsible for checking that it took the lock. + // Parameter: Option takes no parameter + FDB_TR_OPTION_LOCK_AWARE=700, + + // By default, operations that are performed on a transaction while it is being committed will not only fail themselves, but they will attempt to fail other in-flight operations (such as the commit) as well. This behavior is intended to help developers discover situations where operations could be unintentionally executed after the transaction has been reset. Setting this option removes that protection, causing only the offending operation to fail. + // Parameter: Option takes no parameter + FDB_TR_OPTION_USED_DURING_COMMIT_PROTECTION_DISABLE=701, + + // The transaction can read from locked databases. + // Parameter: Option takes no parameter + FDB_TR_OPTION_READ_LOCK_AWARE=702, + + // This option should only be used by tools which change the database configuration. + // Parameter: Option takes no parameter + FDB_TR_OPTION_USE_PROVISIONAL_PROXIES=711, + + // The transaction can retrieve keys that are conflicting with other transactions. + // Parameter: Option takes no parameter + FDB_TR_OPTION_REPORT_CONFLICTING_KEYS=712, + + // By default, the special key space will only allow users to read from exactly one module (a subspace in the special key space). Use this option to allow reading from zero or more modules. Users who set this option should be prepared for new modules, which may have different behaviors than the modules they're currently reading. For example, a new module might block or return an error. + // Parameter: Option takes no parameter + FDB_TR_OPTION_SPECIAL_KEY_SPACE_RELAXED=713, + + // Adds a tag to the transaction that can be used to apply manual targeted throttling. At most 5 tags can be set on a transaction. + // Parameter: (String) String identifier used to associated this transaction with a throttling group. Must not exceed 16 characters. + FDB_TR_OPTION_TAG=800, + + // Adds a tag to the transaction that can be used to apply manual or automatic targeted throttling. At most 5 tags can be set on a transaction. + // Parameter: (String) String identifier used to associated this transaction with a throttling group. Must not exceed 16 characters. + FDB_TR_OPTION_AUTO_THROTTLE_TAG=801 +} FDBTransactionOption; + +typedef enum { + // Client intends to consume the entire range and would like it all transferred as early as possible. + FDB_STREAMING_MODE_WANT_ALL=-2, + + // The default. The client doesn't know how much of the range it is likely to used and wants different performance concerns to be balanced. Only a small portion of data is transferred to the client initially (in order to minimize costs if the client doesn't read the entire range), and as the caller iterates over more items in the range larger batches will be transferred in order to minimize latency. After enough iterations, the iterator mode will eventually reach the same byte limit as ``WANT_ALL`` + FDB_STREAMING_MODE_ITERATOR=-1, + + // Infrequently used. The client has passed a specific row limit and wants that many rows delivered in a single batch. Because of iterator operation in client drivers make request batches transparent to the user, consider ``WANT_ALL`` StreamingMode instead. A row limit must be specified if this mode is used. + FDB_STREAMING_MODE_EXACT=0, + + // Infrequently used. Transfer data in batches small enough to not be much more expensive than reading individual rows, to minimize cost if iteration stops early. + FDB_STREAMING_MODE_SMALL=1, + + // Infrequently used. Transfer data in batches sized in between small and large. + FDB_STREAMING_MODE_MEDIUM=2, + + // Infrequently used. Transfer data in batches large enough to be, in a high-concurrency environment, nearly as efficient as possible. If the client stops iteration early, some disk and network bandwidth may be wasted. The batch size may still be too small to allow a single client to get high throughput from the database, so if that is what you need consider the SERIAL StreamingMode. + FDB_STREAMING_MODE_LARGE=3, + + // Transfer data in batches large enough that an individual client can get reasonable read bandwidth from the database. If the client stops iteration early, considerable disk and network bandwidth may be wasted. + FDB_STREAMING_MODE_SERIAL=4 +} FDBStreamingMode; + +typedef enum { + // Performs an addition of little-endian integers. If the existing value in the database is not present or shorter than ``param``, it is first extended to the length of ``param`` with zero bytes. If ``param`` is shorter than the existing value in the database, the existing value is truncated to match the length of ``param``. The integers to be added must be stored in a little-endian representation. They can be signed in two's complement representation or unsigned. You can add to an integer at a known offset in the value by prepending the appropriate number of zero bytes to ``param`` and padding with zero bytes to match the length of the value. However, this offset technique requires that you know the addition will not cause the integer field within the value to overflow. + FDB_MUTATION_TYPE_ADD=2, + + // Deprecated + FDB_MUTATION_TYPE_AND=6, + + // Performs a bitwise ``and`` operation. If the existing value in the database is not present, then ``param`` is stored in the database. If the existing value in the database is shorter than ``param``, it is first extended to the length of ``param`` with zero bytes. If ``param`` is shorter than the existing value in the database, the existing value is truncated to match the length of ``param``. + FDB_MUTATION_TYPE_BIT_AND=6, + + // Deprecated + FDB_MUTATION_TYPE_OR=7, + + // Performs a bitwise ``or`` operation. If the existing value in the database is not present or shorter than ``param``, it is first extended to the length of ``param`` with zero bytes. If ``param`` is shorter than the existing value in the database, the existing value is truncated to match the length of ``param``. + FDB_MUTATION_TYPE_BIT_OR=7, + + // Deprecated + FDB_MUTATION_TYPE_XOR=8, + + // Performs a bitwise ``xor`` operation. If the existing value in the database is not present or shorter than ``param``, it is first extended to the length of ``param`` with zero bytes. If ``param`` is shorter than the existing value in the database, the existing value is truncated to match the length of ``param``. + FDB_MUTATION_TYPE_BIT_XOR=8, + + // Appends ``param`` to the end of the existing value already in the database at the given key (or creates the key and sets the value to ``param`` if the key is empty). This will only append the value if the final concatenated value size is less than or equal to the maximum value size (i.e., if it fits). WARNING: No error is surfaced back to the user if the final value is too large because the mutation will not be applied until after the transaction has been committed. Therefore, it is only safe to use this mutation type if one can guarantee that one will keep the total value size under the maximum size. + FDB_MUTATION_TYPE_APPEND_IF_FITS=9, + + // Performs a little-endian comparison of byte strings. If the existing value in the database is not present or shorter than ``param``, it is first extended to the length of ``param`` with zero bytes. If ``param`` is shorter than the existing value in the database, the existing value is truncated to match the length of ``param``. The larger of the two values is then stored in the database. + FDB_MUTATION_TYPE_MAX=12, + + // Performs a little-endian comparison of byte strings. If the existing value in the database is not present, then ``param`` is stored in the database. If the existing value in the database is shorter than ``param``, it is first extended to the length of ``param`` with zero bytes. If ``param`` is shorter than the existing value in the database, the existing value is truncated to match the length of ``param``. The smaller of the two values is then stored in the database. + FDB_MUTATION_TYPE_MIN=13, + + // Transforms ``key`` using a versionstamp for the transaction. Sets the transformed key in the database to ``param``. The key is transformed by removing the final four bytes from the key and reading those as a little-Endian 32-bit integer to get a position ``pos``. The 10 bytes of the key from ``pos`` to ``pos + 10`` are replaced with the versionstamp of the transaction used. The first byte of the key is position 0. A versionstamp is a 10 byte, unique, monotonically (but not sequentially) increasing value for each committed transaction. The first 8 bytes are the committed version of the database (serialized in big-Endian order). The last 2 bytes are monotonic in the serialization order for transactions. WARNING: At this time, versionstamps are compatible with the Tuple layer only in the Java, Python, and Go bindings. Also, note that prior to API version 520, the offset was computed from only the final two bytes rather than the final four bytes. + FDB_MUTATION_TYPE_SET_VERSIONSTAMPED_KEY=14, + + // Transforms ``param`` using a versionstamp for the transaction. Sets the ``key`` given to the transformed ``param``. The parameter is transformed by removing the final four bytes from ``param`` and reading those as a little-Endian 32-bit integer to get a position ``pos``. The 10 bytes of the parameter from ``pos`` to ``pos + 10`` are replaced with the versionstamp of the transaction used. The first byte of the parameter is position 0. A versionstamp is a 10 byte, unique, monotonically (but not sequentially) increasing value for each committed transaction. The first 8 bytes are the committed version of the database (serialized in big-Endian order). The last 2 bytes are monotonic in the serialization order for transactions. WARNING: At this time, versionstamps are compatible with the Tuple layer only in the Java, Python, and Go bindings. Also, note that prior to API version 520, the versionstamp was always placed at the beginning of the parameter rather than computing an offset. + FDB_MUTATION_TYPE_SET_VERSIONSTAMPED_VALUE=15, + + // Performs lexicographic comparison of byte strings. If the existing value in the database is not present, then ``param`` is stored. Otherwise the smaller of the two values is then stored in the database. + FDB_MUTATION_TYPE_BYTE_MIN=16, + + // Performs lexicographic comparison of byte strings. If the existing value in the database is not present, then ``param`` is stored. Otherwise the larger of the two values is then stored in the database. + FDB_MUTATION_TYPE_BYTE_MAX=17, + + // Performs an atomic ``compare and clear`` operation. If the existing value in the database is equal to the given value, then given key is cleared. + FDB_MUTATION_TYPE_COMPARE_AND_CLEAR=20 +} FDBMutationType; + +typedef enum { + // Used to add a read conflict range + FDB_CONFLICT_RANGE_TYPE_READ=0, + + // Used to add a write conflict range + FDB_CONFLICT_RANGE_TYPE_WRITE=1 +} FDBConflictRangeType; + +typedef enum { + // Returns ``true`` if the error indicates the operations in the transactions should be retried because of transient error. + FDB_ERROR_PREDICATE_RETRYABLE=50000, + + // Returns ``true`` if the error indicates the transaction may have succeeded, though not in a way the system can verify. + FDB_ERROR_PREDICATE_MAYBE_COMMITTED=50001, + + // Returns ``true`` if the error indicates the transaction has not committed, though in a way that can be retried. + FDB_ERROR_PREDICATE_RETRYABLE_NOT_COMMITTED=50002 +} FDBErrorPredicate; + +#endif diff --git a/foundationdb-sys/include/630/version.txt b/foundationdb-sys/include/630/version.txt new file mode 100644 index 00000000..8bbf9a8d --- /dev/null +++ b/foundationdb-sys/include/630/version.txt @@ -0,0 +1 @@ +6.3.16 \ No newline at end of file diff --git a/foundationdb/Cargo.toml b/foundationdb/Cargo.toml index a244ca0c..078cd670 100644 --- a/foundationdb/Cargo.toml +++ b/foundationdb/Cargo.toml @@ -26,7 +26,7 @@ features = ["embedded-fdb-include"] codecov = { repository = "Clikengo/foundationdb-rs", branch = "master", service = "github" } [features] -default = ["fdb-6_2", "uuid"] +default = ["fdb-6_3", "uuid"] # Use the locally embedded foundationdb fdb_c.h and fdb.options files embedded-fdb-include = [ "foundationdb-sys/embedded-fdb-include", @@ -37,6 +37,7 @@ fdb-5_2 = ["foundationdb-sys/fdb-5_2", "foundationdb-gen/fdb-5_2"] fdb-6_0 = ["foundationdb-sys/fdb-6_0", "foundationdb-gen/fdb-6_0"] fdb-6_1 = ["foundationdb-sys/fdb-6_1", "foundationdb-gen/fdb-6_1"] fdb-6_2 = ["foundationdb-sys/fdb-6_2", "foundationdb-gen/fdb-6_2"] +fdb-6_3 = ["foundationdb-sys/fdb-6_3", "foundationdb-gen/fdb-6_3"] [build-dependencies] foundationdb-gen = { version = "0.5.1", path = "../foundationdb-gen", default-features = false } diff --git a/foundationdb/src/future.rs b/foundationdb/src/future.rs index 80a0827f..85292069 100644 --- a/foundationdb/src/future.rs +++ b/foundationdb/src/future.rs @@ -478,11 +478,11 @@ impl TryFrom for i64 { fn try_from(f: FdbFutureHandle) -> FdbResult { let mut version: i64 = 0; error::eval(unsafe { - #[cfg(feature = "fdb-6_2")] + #[cfg(any(feature = "fdb-6_2", feature = "fdb-6_3"))] { fdb_sys::fdb_future_get_int64(f.as_ptr(), &mut version) } - #[cfg(not(feature = "fdb-6_2"))] + #[cfg(not(any(feature = "fdb-6_2", feature = "fdb-6_3")))] { fdb_sys::fdb_future_get_version(f.as_ptr(), &mut version) } diff --git a/foundationdb/src/transaction.rs b/foundationdb/src/transaction.rs index b5c1ac9f..3bb60309 100644 --- a/foundationdb/src/transaction.rs +++ b/foundationdb/src/transaction.rs @@ -596,6 +596,24 @@ impl Transaction { } } + /// Get the estimated byte size of the key range based on the byte sample collected by FDB + #[cfg(feature = "fdb-6_3")] + pub fn get_estimated_range_size_bytes( + &self, + begin: &[u8], + end: &[u8], + ) -> impl Future> + Send + Sync + Unpin { + FdbFuture::::new(unsafe { + fdb_sys::fdb_transaction_get_estimated_range_size_bytes( + self.inner.as_ptr(), + begin.as_ptr(), + fdb_len(begin.len(), "begin"), + end.as_ptr(), + fdb_len(end.len(), "end"), + ) + }) + } + /// Attempts to commit the sets and clears previously applied to the database snapshot /// represented by transaction to the actual database. /// diff --git a/foundationdb/tests/range.rs b/foundationdb/tests/range.rs index 884ddafe..edcc92dc 100644 --- a/foundationdb/tests/range.rs +++ b/foundationdb/tests/range.rs @@ -18,6 +18,8 @@ fn test_range() { futures::executor::block_on(test_get_range_async()).expect("failed to run"); futures::executor::block_on(test_range_option_async()).expect("failed to run"); futures::executor::block_on(test_get_ranges_async()).expect("failed to run"); + #[cfg(feature = "fdb-6_3")] + futures::executor::block_on(test_get_estimate_range()).expect("failed to run"); } async fn test_get_range_async() -> FdbResult<()> { @@ -203,3 +205,31 @@ async fn test_range_option_async() -> FdbResult<()> { Ok(()) } +async fn test_get_estimate_range() -> FdbResult<()> { + const N: usize = 10000; + + let db = common::database().await?; + let trx = db.create_trx()?; + let key_begin = "test-rangeoption-"; + let key_end = "test-rangeoption."; + let k = |i: u32| format!("{}-{:010}", key_begin, i); + + eprintln!("clearing..."); + trx.clear_range(key_begin.as_bytes(), key_end.as_bytes()); + + eprintln!("inserting..."); + for i in 0..10000 { + let value = common::random_str(10); + trx.set(k(i).as_bytes(), value.as_bytes()); + } + trx.commit().await?; + + let trx = db.create_trx()?; + let estimate = trx + .get_estimated_range_size_bytes(key_begin.as_bytes(), key_end.as_bytes()) + .await?; + eprintln!("get an estimate of {} bytes", estimate); + assert!(estimate > 0); + + Ok(()) +} diff --git a/scripts/run_bindingtester.sh b/scripts/run_bindingtester.sh index 04a02c01..09595ab5 100755 --- a/scripts/run_bindingtester.sh +++ b/scripts/run_bindingtester.sh @@ -22,9 +22,9 @@ esac cd ${fdb_builddir:?} ## Get foundationdb source - git clone --depth 1 https://github.com/apple/foundationdb.git -b release-6.1 + git clone --depth 1 https://github.com/apple/foundationdb.git -b release-6.3 cd foundationdb - git checkout release-6.1 + git checkout release-6.3 ## need the python api bindings make fdb_python @@ -33,6 +33,6 @@ esac echo "testers['rust'] = Tester('rust', '${bindingtester}', 2040, 23, MAX_API_VERSION, types=ALL_TYPES) " >> ./bindings/bindingtester/known_testers.py ./bindings/bindingtester/bindingtester.py --test-name scripted rust - ./bindings/bindingtester/bindingtester.py --num-ops 1000 --api-version 610 --test-name api --compare python rust - ./bindings/bindingtester/bindingtester.py --num-ops 1000 --api-version 610 --test-name api --concurrency 5 rust + ./bindings/bindingtester/bindingtester.py --num-ops 1000 --api-version 630 --test-name api --compare python rust + ./bindings/bindingtester/bindingtester.py --num-ops 1000 --api-version 630 --test-name api --concurrency 5 rust )