Skip to content

Commit

Permalink
fix: toArray with multiple chunks (#243)
Browse files Browse the repository at this point in the history
closes #242
  • Loading branch information
universalmind303 authored Jul 11, 2024
1 parent 67285ed commit d020e02
Show file tree
Hide file tree
Showing 6 changed files with 1,345 additions and 1,319 deletions.
874 changes: 0 additions & 874 deletions .yarn/releases/yarn-3.6.1.cjs

This file was deleted.

894 changes: 894 additions & 0 deletions .yarn/releases/yarn-4.3.1.cjs

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
compressionLevel: mixed

enableGlobalCache: false

nodeLinker: node-modules
yarnPath: .yarn/releases/yarn-3.6.1.cjs

yarnPath: .yarn/releases/yarn-4.3.1.cjs
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"typedoc": "^0.26.3",
"typescript": "5.5.3"
},
"packageManager": "yarn@3.6.1",
"packageManager": "yarn@4.3.1",
"workspaces": [
"benches"
]
Expand Down
5 changes: 4 additions & 1 deletion src/conversion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ impl ToSeries for JsUnknown {

impl ToNapiValue for Wrap<&Series> {
unsafe fn to_napi_value(napi_env: sys::napi_env, val: Self) -> napi::Result<sys::napi_value> {
let s = val.0;
let s = val.0.rechunk();
let len = s.len();
let dtype = s.dtype();
let env = Env::from_raw(napi_env);
Expand All @@ -79,8 +79,10 @@ impl ToNapiValue for Wrap<&Series> {
DataType::Struct(_) => {
let ca = s.struct_().map_err(JsPolarsErr::from)?;
let df: DataFrame = ca.clone().into();

let (height, _) = df.shape();
let mut rows = env.create_array(height as u32)?;

for idx in 0..height {
let mut row = env.create_object()?;
for col in df.get_columns() {
Expand All @@ -94,6 +96,7 @@ impl ToNapiValue for Wrap<&Series> {
}
_ => {
let mut arr = env.create_array(len as u32)?;

for (idx, val) in s.iter().enumerate() {
arr.set(idx as u32, Wrap(val))?;
}
Expand Down
Loading

0 comments on commit d020e02

Please sign in to comment.