-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* apply scalar function patch Co-authored-by: Matthew Gapp <[email protected]> * fix tests * format --------- Co-authored-by: Matthew Gapp <[email protected]>
- Loading branch information
1 parent
1e29fc1
commit 58a6ad4
Showing
16 changed files
with
1,343 additions
and
100 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 { | ||
Check warning on line 9 in crates/duckdb/src/types/string.rs
|
||
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.