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

Infinty for different data types #55

Open
jerry40 opened this issue Sep 30, 2020 · 4 comments
Open

Infinty for different data types #55

jerry40 opened this issue Sep 30, 2020 · 4 comments

Comments

@jerry40
Copy link

jerry40 commented Sep 30, 2020

Hi!

I'm struggling with this task: sometimes I need to send timestamp as infinity (0Wp). Is it possible? Perhaps typed could take Infinity or some parameter that means "I want to deserialize it as null/inf etc... on kdb side"?

Thanks!

@michaelwittig
Copy link
Owner

From looking at the code I don't think that it is possible at the moment.

The only workaround would be to send the whole command as a string:

con.k("something[1;0Wp]", function(err, res) { ... });

@jerry40
Copy link
Author

jerry40 commented Sep 30, 2020

Unfortunately I need this for .u.upd command, I create a javascript array with timestamps. I can send nulls but can't send infinity.
But in theory can we have 2 additional states/flags (+Inf/-Inf) for typed data? I think it can be checked at deserialization moment and every type can turn the inf value into correct 0W value before sending it to kdb.

@michaelwittig
Copy link
Owner

For writing, we use the JavaScript Date type which does not support the idea of infinity. So you are in a bad position.

You can switch from Date to Number (then with nano second precission) with the nanos2date flag but only when reading.

To solve this issue, you would need to make a change to support writing of a JavaScript Number (in nano seconds) as a timestamp: https://github.com/michaelwittig/node-q/blob/master/lib/c.js#L703 and you would need to allow to pass a Number into the typed api https://github.com/michaelwittig/node-q/blob/master/lib/typed.js#L158

@jerry40
Copy link
Author

jerry40 commented Sep 30, 2020

Interesting, I'll try this idea, thanks!

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

No branches or pull requests

2 participants