Skip to content

Commit

Permalink
Remove feature flag requirement for GetData on () (#334)
Browse files Browse the repository at this point in the history
Currently, the GetData trait implementation for unit type `()` is in
arrow_get_data.rs. This makes the trait impl blocked behind either the
`default-engine` or `sync-engine` flags. This PR moves the GetData trait
implementation to engine_data.rs to make it available without the flags
so that it can be used by other engines.

Closes: #315
  • Loading branch information
OussamaSaoudi-db authored Sep 11, 2024
1 parent 2547322 commit ed1919a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
21 changes: 0 additions & 21 deletions kernel/src/engine/arrow_get_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,24 +77,3 @@ impl<'a> GetData<'a> for MapArray {
}
}
}

macro_rules! impl_null_get {
( $(($name: ident, $typ: ty)), * ) => {
$(
fn $name(&'a self, _row_index: usize, _field_name: &str) -> DeltaResult<Option<$typ>> {
Ok(None)
}
)*
};
}

impl<'a> GetData<'a> for () {
impl_null_get!(
(get_bool, bool),
(get_int, i32),
(get_long, i64),
(get_str, &'a str),
(get_list, ListItem<'a>),
(get_map, MapItem<'a>)
);
}
21 changes: 21 additions & 0 deletions kernel/src/engine_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,27 @@ pub trait GetData<'a> {
);
}

macro_rules! impl_null_get {
( $(($name: ident, $typ: ty)), * ) => {
$(
fn $name(&'a self, _row_index: usize, _field_name: &str) -> DeltaResult<Option<$typ>> {
Ok(None)
}
)*
};
}

impl<'a> GetData<'a> for () {
impl_null_get!(
(get_bool, bool),
(get_int, i32),
(get_long, i64),
(get_str, &'a str),
(get_list, ListItem<'a>),
(get_map, MapItem<'a>)
);
}

// This is a convenience wrapper over `GetData` to allow code like:
// `let name: Option<String> = getters[1].get_opt(row_index, "metadata.name")?;`
pub(crate) trait TypedGetData<'a, T> {
Expand Down

0 comments on commit ed1919a

Please sign in to comment.