Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add API 630 #232

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/rustdoc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion foundationdb-bindingtester/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@ 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"]
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"
Expand Down
32 changes: 32 additions & 0 deletions foundationdb-bindingtester/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,16 @@ 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 =
Element::Bytes(Bytes(Cow::Borrowed(b"GOT_APPROXIMATE_SIZE")));

use crate::fdb::options::{MutationType, StreamingMode};
use tuple::VersionstampOffset;

fn mutation_from_str(s: &str) -> MutationType {
match s {
"ADD" => MutationType::Add,
Expand Down Expand Up @@ -171,6 +174,7 @@ enum InstrCode {
GetCommittedVersion,
GetApproximateSize,
WaitFuture,
GetEstimatedRangeSize,

TuplePack,
TuplePackWithVersionstamp,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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.
Expand Down
3 changes: 2 additions & 1 deletion foundationdb-gen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@ 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 = []
fdb-5_2 = []
fdb-6_0 = []
fdb-6_1 = []
fdb-6_2 = []
fdb-6_3 = []

[dependencies]
xml-rs = "0.8.0"
2 changes: 2 additions & 0 deletions foundationdb-gen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion foundationdb-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,15 @@ 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 = []
fdb-5_2 = []
fdb-6_0 = []
fdb-6_1 = []
fdb-6_2 = []
fdb-6_3 = []

[dependencies]

Expand Down
6 changes: 6 additions & 0 deletions foundationdb-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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...
Expand Down
Loading