-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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-15060: [JS] Add LargeUtf8 type #35780
Merged
Merged
Changes from 36 commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
a3ef0ce
GH-15060: [JS] Add LargeUtf8 type
domoritz 3b2c851
Switch back to int types
domoritz 9562d08
Adding more largeUtf8 stuff
domoritz 775370a
Fix remaining type issues
domoritz 46ef804
Update comment
domoritz e11b078
Fix
domoritz 3e91639
Correct and refine types
domoritz 564a3e8
More refined types
domoritz b73a1f4
Move ArrayCtor type
domoritz 3f9359b
Change default offset to Int32Array
domoritz 263ce42
Test large utf8 builder
domoritz 95410d0
Fix support for bigints and add missing visitors
domoritz 0853353
Fix data generation
domoritz 7e14e1e
Disable test auto run
domoritz 5790d14
Fix index of for largeUTF8
domoritz 200e5e5
Fix offset math with bigint
domoritz 7bf5426
Update type names
domoritz 059572a
Merge branch 'main' into dom/large-utf8
domoritz 0357214
More updates
domoritz ad9cfd5
revert change and fix comment
domoritz b3cd5b2
Get rid of toNumber
domoritz 8b2b443
Remove unused get method
domoritz aaa137c
Skip js test for now
domoritz 4dbca13
remove unused import
domoritz 22bad7f
Support serialization to JSON and back for large utf8
domoritz 28795dc
Pre es2020 compat
domoritz 282c30b
Remove offset from buffer
domoritz a79f5ca
Update enum.ts
domoritz f1042a5
I think this is the right buffer builder.
domoritz e66d5ae
Add types to builder flush method
domoritz b05f38d
Correct offset buffer type
domoritz dae4775
Revert "I think this is the right buffer builder."
domoritz 6949b6c
Better rounding method
domoritz d2f7b0b
bring back ceil
domoritz d63ef0c
style: format
domoritz 806800b
update status
domoritz 1da7ef6
Simpify vector assembler
domoritz 6117916
Separate code paths for utf and large utf
domoritz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Licensed to the Apache Software Foundation (ASF) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The ASF licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
import { LargeUtf8 } from '../type.js'; | ||
import { encodeUtf8 } from '../util/utf8.js'; | ||
import { BufferBuilder } from './buffer.js'; | ||
import { VariableWidthBuilder, BuilderOptions } from '../builder.js'; | ||
|
||
/** @ignore */ | ||
export class LargeUtf8Builder<TNull = any> extends VariableWidthBuilder<LargeUtf8, TNull> { | ||
constructor(opts: BuilderOptions<LargeUtf8, TNull>) { | ||
super(opts); | ||
this._values = new BufferBuilder(new Uint8Array(0)); | ||
} | ||
public get byteLength(): number { | ||
let size = this._pendingLength + (this.length * 4); | ||
this._offsets && (size += this._offsets.byteLength); | ||
this._values && (size += this._values.byteLength); | ||
this._nulls && (size += this._nulls.byteLength); | ||
return size; | ||
} | ||
public setValue(index: number, value: string) { | ||
return super.setValue(index, encodeUtf8(value) as any); | ||
} | ||
// @ts-ignore | ||
// TODO: move to largeBinaryBuilder when implemented | ||
// protected _flushPending(pending: Map<number, Uint8Array | undefined>, pendingLength: number): void { } | ||
protected _flushPending(pending: Map<number, Uint8Array | undefined>, pendingLength: number) { | ||
const offsets = this._offsets; | ||
const data = this._values.reserve(pendingLength).buffer; | ||
let offset = 0; | ||
for (const [index, value] of pending) { | ||
if (value === undefined) { | ||
offsets.set(index, BigInt(0)); | ||
} else { | ||
const length = value.length; | ||
data.set(value, offset); | ||
offsets.set(index, BigInt(length)); | ||
offset += length; | ||
} | ||
} | ||
} | ||
} | ||
|
||
// (LargeUtf8Builder.prototype as any)._flushPending = (LargeBinaryBuilder.prototype as any)._flushPending; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you skip 19 on purpose?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We haven't implemented it so I'm skipping it for now.