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

GH-40959: [JS] Store Timestamps in 64 bits #40960

Merged
merged 19 commits into from
Apr 16, 2024
Merged

Conversation

domoritz
Copy link
Member

@domoritz domoritz commented Apr 2, 2024

Merge after #40892.

This pull request also changes Dates to return timestamps instead of Date instances (similar to Timestamps and for the same reason.

js/src/type.ts Show resolved Hide resolved
js/src/type.ts Show resolved Hide resolved
js/src/type.ts Show resolved Hide resolved
}
});
return data;
}

function createTimestamp(length: number, nullBitmap: Uint8Array, multiple: number, values: (number | null)[] = []) {
const mult = 86400 * multiple;
const data = new Int32Array(length * 2).fill(0);
const data = new BigInt64Array(length).fill(0n);
const data32 = createDate32(length, nullBitmap, values);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit weird, don't you want to create timestamp data that does not represent whole days?

Copy link
Member Author

@domoritz domoritz Apr 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. I rewrote the timestamp generation logic to generate meaningful timestamps.

@@ -32,22 +32,14 @@ const randnulls = <T, TNull = null>(values: T[], n: TNull = <any>null) => values
export const randomBytes = (length: number) => fillRandom(Uint8Array, length);

export const stringsNoNulls = (length = 20) => Array.from({ length }, (_) => randomString(1 + (Math.trunc(Math.random() * 19))));
export const timestamp32sNoNulls = (length = 20, now = Math.trunc(Date.now() / 86400000)) =>
export const timestampNoNulls = (length = 20, now = Math.trunc(Date.now() / 86400000)) =>
Array.from({ length }, (_) => (Math.trunc(now + (rand() * 10000 * (rand() > 0.5 ? -1 : 1)))) * 86400000);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given the scale of rand() * 10000 compared to now, this will never produce timestamps with a negative value, right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. I changed it to use 100000 which gives us negative numbers as well.

@domoritz domoritz added this to the 16.0.0 milestone Apr 12, 2024
@raulcd raulcd removed this from the 16.0.0 milestone Apr 16, 2024
@github-actions github-actions bot removed the awaiting committer review Awaiting committer review label Apr 16, 2024
@github-actions github-actions bot added the awaiting changes Awaiting changes label Apr 16, 2024
@domoritz domoritz requested a review from pitrou April 16, 2024 17:31
@github-actions github-actions bot added awaiting change review Awaiting change review and removed awaiting changes Awaiting changes labels Apr 16, 2024
@domoritz domoritz merged commit 18876b2 into apache:main Apr 16, 2024
10 of 11 checks passed
@domoritz domoritz deleted the dom/64-bits branch April 16, 2024 21:01
Copy link

After merging your PR, Conbench analyzed the 7 benchmarking runs that have been run so far on merge-commit 18876b2.

There were 2 benchmark results indicating a performance regression:

The full Conbench report has more details. It also includes information about 1 possible false positive for unstable benchmarks that are known to sometimes produce them.

domoritz added a commit to domoritz/arrow that referenced this pull request Apr 17, 2024
Merge after apache#40892.

This pull request also changes Dates to return timestamps instead of
Date instances (similar to Timestamps and for the same reason.

* GitHub Issue: apache#40959
@domoritz domoritz removed the awaiting change review Awaiting change review label Apr 18, 2024
raulcd pushed a commit that referenced this pull request Apr 29, 2024
Merge after #40892.

This pull request also changes Dates to return timestamps instead of
Date instances (similar to Timestamps and for the same reason.

* GitHub Issue: #40959
tolleybot pushed a commit to tmct/arrow that referenced this pull request May 2, 2024
Merge after apache#40892.

This pull request also changes Dates to return timestamps instead of
Date instances (similar to Timestamps and for the same reason.

* GitHub Issue: apache#40959
tolleybot pushed a commit to tmct/arrow that referenced this pull request May 4, 2024
Merge after apache#40892.

This pull request also changes Dates to return timestamps instead of
Date instances (similar to Timestamps and for the same reason.

* GitHub Issue: apache#40959
rok pushed a commit to tmct/arrow that referenced this pull request May 8, 2024
Merge after apache#40892.

This pull request also changes Dates to return timestamps instead of
Date instances (similar to Timestamps and for the same reason.

* GitHub Issue: apache#40959
rok pushed a commit to tmct/arrow that referenced this pull request May 8, 2024
Merge after apache#40892.

This pull request also changes Dates to return timestamps instead of
Date instances (similar to Timestamps and for the same reason.

* GitHub Issue: apache#40959
Fil added a commit to observablehq/framework that referenced this pull request May 21, 2024
Fil added a commit to observablehq/framework that referenced this pull request May 21, 2024
* adopt and document the new apache-arrow date encoding

ref. apache/arrow#40960

* copy edit

---------

Co-authored-by: Mike Bostock <mbostock@gmail.com>
vibhatha pushed a commit to vibhatha/arrow that referenced this pull request May 25, 2024
Merge after apache#40892.

This pull request also changes Dates to return timestamps instead of
Date instances (similar to Timestamps and for the same reason.

* GitHub Issue: apache#40959
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants