-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add scalar support with arrow types and overloading
- Loading branch information
1 parent
2bd811e
commit aebc114
Showing
16 changed files
with
1,330 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
use libduckdb_sys::{duckdb_string_t, duckdb_string_t_data, duckdb_string_t_length}; | ||
|
||
/// Wrapper for underlying duck string type with a lifetime bound to a &mut duckdb_string_t | ||
pub struct DuckString<'a> { | ||
ptr: &'a mut duckdb_string_t, | ||
} | ||
|
||
impl<'a> DuckString<'a> { | ||
pub(crate) fn new(ptr: &'a mut duckdb_string_t) -> Self { | ||
DuckString { ptr } | ||
} | ||
} | ||
|
||
impl<'a> DuckString<'a> { | ||
/// convert duckdb_string_t to a copy on write string | ||
pub fn as_str(&mut self) -> std::borrow::Cow<'a, str> { | ||
String::from_utf8_lossy(self.as_bytes()) | ||
} | ||
|
||
/// convert duckdb_string_t to a byte slice | ||
pub fn as_bytes(&mut self) -> &'a [u8] { | ||
unsafe { | ||
let len = duckdb_string_t_length(*self.ptr); | ||
let c_ptr = duckdb_string_t_data(self.ptr); | ||
std::slice::from_raw_parts(c_ptr as *const u8, len as usize) | ||
} | ||
} | ||
} |
Oops, something went wrong.