Skip to content

Enhance List and Map expression return type interpretation #154

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

Open
wants to merge 1 commit into
base: v2
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
21 changes: 16 additions & 5 deletions aerospike-core/src/expressions/lists.rs
Original file line number Diff line number Diff line change
Expand Up @@ -698,10 +698,21 @@ fn add_write(
}

#[doc(hidden)]
const fn get_value_type(return_type: i64) -> ExpType {
if (return_type & !(ListReturnType::Inverted as i64)) == ListReturnType::Values as i64 {
ExpType::LIST
} else {
ExpType::INT
fn get_value_type(return_type: i64) -> ExpType {
let t = return_type & !(ListReturnType::Inverted as i64);

match t {
t if t == ListReturnType::Index as i64
|| t == ListReturnType::ReverseIndex as i64
|| t == ListReturnType::Rank as i64
|| t == ListReturnType::ReverseRank as i64 => ExpType::LIST,

t if t == ListReturnType::Count as i64 => ExpType::INT,

t if t == ListReturnType::Values as i64 => ExpType::LIST,

t if t == ListReturnType::Exists as i64 => ExpType::BOOL,

_ => panic!("Invalid ListReturnType: {}", return_type)
}
}
27 changes: 20 additions & 7 deletions aerospike-core/src/expressions/maps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -846,13 +846,26 @@ fn add_write(
}

#[doc(hidden)]
const fn get_value_type(return_type: i64) -> ExpType {
fn get_value_type(return_type: i64) -> ExpType {
let t = return_type & !(MapReturnType::Inverted as i64);
if t == MapReturnType::Key as i64 || t == MapReturnType::Value as i64 {
ExpType::LIST
} else if t == MapReturnType::KeyValue as i64 {
ExpType::MAP
} else {
ExpType::INT

match t {
t if t == MapReturnType::Index as i64
|| t == MapReturnType::ReverseIndex as i64
|| t == MapReturnType::Rank as i64
|| t == MapReturnType::ReverseRank as i64 => ExpType::LIST,

t if t == MapReturnType::Count as i64 => ExpType::INT,

t if t == MapReturnType::Key as i64
|| t == MapReturnType::Value as i64 => ExpType::LIST,

t if t == MapReturnType::KeyValue as i64
|| t == MapReturnType::OrderedMap as i64
|| t == MapReturnType::UnorderedMap as i64 => ExpType::MAP,

t if t == MapReturnType::Exists as i64 => ExpType::BOOL,

_ => panic!("Invalid MapReturnType: {}", return_type)
}
}