Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mocha failure #21

Open
krasic opened this issue Jan 6, 2020 · 7 comments
Open

mocha failure #21

krasic opened this issue Jan 6, 2020 · 7 comments

Comments

@krasic
Copy link

krasic commented Jan 6, 2020

Hi. I am trying to change parquetjs to support 64 bit integers using bigint-buffer. The change seems straightforward and works in client code I have. However, I want to update parquetjs tests to reflect my change, and when I try to run their test I see this failure:

`$ npm test

parquetjs@0.8.0 test /home/***/parquetjs
mocha

ParquetCodec::PLAIN
✓ should encode BOOLEAN values
✓ should decode BOOLEAN values
✓ should encode INT32 values
✓ should decode INT32 values
node: ../src/bigint-buffer.c:132: fromBigInt: Assertion status == napi_ok' failed. Aborted (core dumped)
I gather this is something related to native modules, but I'm a n00b in that regard. Any ideas?

@no2chem
Copy link
Owner

no2chem commented Jan 6, 2020

Thanks for reporting this. Do you have a fork with the changes you've made? I could take a look into it.

@krasic
Copy link
Author

krasic commented Jan 6, 2020

PR here: Use bigint for int64

@no2chem
Copy link
Owner

no2chem commented Jan 7, 2020

Hm, I see the issue.

Your call to toBufferLE passes a number instead of a bigint:
https://github.com/ZJONSSON/parquetjs/pull/37/files#diff-b67720d607909e3cae702d746c5bf6f0R53

bigint-buffer doesn't know how to handle numbers so it errors out.
moreover, you're passing an array of numbers, so it really doesn't know how to handle this.

There's two fixes needed for this:

one is that we need to handle numbers as well as bigints.
second, is that we need to be able to write into a buffer you've allocated. This would eliminate the need for copy and allow you to iterate over the entire array, resulting in multiple n-api transitions.

I'd be happy to look into this, though I'm not sure if I can give you an ETA.

@no2chem
Copy link
Owner

no2chem commented Jan 7, 2020

@krasic - also, I'm interested in what you're trying to do with parquet. if you're looking for performance, it would seem that implementing native bindings would be useful, though I don't know if that's compatible with parquetjs's goals.

@no2chem
Copy link
Owner

no2chem commented Jan 7, 2020

@krasic sorry for the spam, but one more thing: it looks like node 12 has now implemented Buffer.writeBigInt64BE|LE, which probably implements all the functionality you need.
https://nodejs.org/api/buffer.html#buffer_buf_writebigint64be_value_offset

It does seem like the underlying implementation is in javascript though,
https://github.com/nodejs/node/blob/e71a0f4d5faa4ad77887fbb3fff0ddb7bca6942e/lib/internal/buffer.js#L590

So it'll be interesting to benchmark to see what the performance difference is.

@krasic
Copy link
Author

krasic commented Jan 7, 2020 via email

@krasic
Copy link
Author

krasic commented Jan 7, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants