Skip to content

Commit

Permalink
update test
Browse files Browse the repository at this point in the history
  • Loading branch information
wangxiaoying committed Apr 22, 2024
1 parent 835e4d1 commit 59699a5
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ aaa2 conn="POSTGRES_URL":
cd connectorx-python && PYO3_PYTHON=$HOME/.pyenv/versions/3.8.12/bin/python3.8 PYTHONPATH=$HOME/.pyenv/versions/conn/lib/python3.8/site-packages LD_LIBRARY_PATH=$HOME/.pyenv/versions/3.8.12/lib/ cargo run --no-default-features --features aaa --example test_aaa

aaa conn="POSTGRES_URL":
cd connectorx-python && PYO3_PYTHON=$HOME/.pyenv/versions/3.12.2/bin/python3.12 PYTHONPATH=$HOME/.pyenv/versions/conn/lib/python3.12/site-packages LD_LIBRARY_PATH=$HOME/.pyenv/versions/3.12.2/lib/ cargo run --no-default-features --features aaa --example test_aaa
cd connectorx-python && PYO3_PYTHON=$HOME/.pyenv/versions/3.12.2/bin/python3.12 PYTHONPATH=$HOME/.pyenv/versions/conn12/lib/python3.12/site-packages LD_LIBRARY_PATH=$HOME/.pyenv/versions/3.12.2/lib/ cargo run --no-default-features --features aaa --example test_aaa

aaa-d conn="POSTGRES_URL":
cd connectorx-python && RUST_BACKTRACE=1 PYO3_PYTHON=$HOME/.pyenv/versions/3.12.2/bin/python3.12 PYTHONPATH=$HOME/.pyenv/versions/conn/lib/python3.12/site-packages LD_LIBRARY_PATH=$HOME/.pyenv/versions/3.12.2/lib/ rust-lldb target/debug/examples/test_aaa
cd connectorx-python && RUST_BACKTRACE=1 PYO3_PYTHON=$HOME/.pyenv/versions/3.12.2/bin/python3.12 PYTHONPATH=$HOME/.pyenv/versions/conn12/lib/python3.12/site-packages LD_LIBRARY_PATH=$HOME/.pyenv/versions/3.12.2/lib/ rust-lldb target/debug/examples/test_aaa

# benches
flame-tpch conn="POSTGRES_URL":
Expand Down
4 changes: 2 additions & 2 deletions connectorx-python/examples/test_aaa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ fn main() {
"pandas",
None,
Some(vec![
String::from("select test_int from test_table where test_int > 3"),
// String::from("select test_int, test_str from test_table where test_int <= 3"),
String::from("select test_int, test_str from test_table where test_int = 1"),
String::from("select test_int, test_str from test_table where test_int = 0"),
]),
None,
)
Expand Down
14 changes: 12 additions & 2 deletions connectorx-python/src/pandas/pystring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ unsafe impl Element for PyString {
}
}

#[derive(Clone, Copy)]
#[derive(Clone, Copy, Debug)]
pub enum StringInfo {
ASCII(usize), // len of the string, not byte length
UCS1(usize),
Expand Down Expand Up @@ -50,7 +50,17 @@ impl StringInfo {
pub fn pystring(&self, py: Python) -> PyString {
let objptr = unsafe {
match self {
StringInfo::ASCII(len) => ffi::PyUnicode_New(*len as ffi::Py_ssize_t, 0x7F),
StringInfo::ASCII(len) => {
// let size = std::mem::size_of::<PyASCIIObject>() + (len + 1) * 1;
// println!(
// "len: {}, {}, size: {}",
// len,
// (*len as ffi::Py_ssize_t),
// size
// );
// let tmp = ffi::PyObject_Malloc(size);
ffi::PyUnicode_New(*len as ffi::Py_ssize_t, 0x7F)
}
StringInfo::UCS1(len) => ffi::PyUnicode_New(*len as ffi::Py_ssize_t, 0xFF),
StringInfo::UCS2(len) => ffi::PyUnicode_New(*len as ffi::Py_ssize_t, 0xFFFF),
StringInfo::UCS4(len) => ffi::PyUnicode_New(*len as ffi::Py_ssize_t, 0x10FFFF),
Expand Down

0 comments on commit 59699a5

Please sign in to comment.