-
Notifications
You must be signed in to change notification settings - Fork 1
upgrade hightable to 0.13.1 #180
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
Merged
Merged
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
a2ba20f
upgrade hightable to 0.13.0 + adapt style. Note that more is needed (…
severo 0e1e2c1
implement multi column sort
severo a1b58ce
use the same stringify function
severo 5646996
export Cells, not Row
severo 74e2245
import the built hightable CSS
severo 5275ccf
stringify bigint
severo 7ddf178
only fetch the values for the column, without transposing to objects
severo 580803a
rename variable 'classes' to 'styles'
severo 14173d4
upgrade to hightable 0.13.1 and use its exported stringify function
severo 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,65 @@ | ||
| import { ColumnData, ParquetReadOptions, parquetRead } from 'hyparquet' | ||
|
|
||
| type GetColumnOptions = Omit<ParquetReadOptions, 'columns' | 'rowStart' | 'rowEnd' | 'onChunk' | 'onComplete'> & {column: string} | ||
|
|
||
| export async function getParquetColumn({ metadata, file, column, compressors }: GetColumnOptions): Promise<unknown[]> { | ||
| const numRows = Number(metadata?.num_rows) | ||
| if (isNaN(numRows)) { | ||
| throw new Error('metadata.num_rows is undefined') | ||
| } | ||
| if (numRows === 0) { | ||
| return [] | ||
| } | ||
| const lastError: {error?: Error} = {} | ||
| const values: unknown[] = Array(numRows).fill(undefined) | ||
| const ranges: [number, number][] = [] | ||
| function onChunk({ columnName, columnData, rowStart, rowEnd }: ColumnData) { | ||
| if (columnName !== column) { | ||
| lastError.error = new Error(`unexpected column name ${columnName}`) | ||
| } | ||
| for (let i = rowStart; i < rowEnd; i++) { | ||
| values[i] = columnData[i - rowStart] | ||
| } | ||
| ranges.push([rowStart, rowEnd]) | ||
| } | ||
|
|
||
| // this awaits all the promises. When it returns, all the data should have already been sent using onChunk | ||
| await parquetRead({ metadata, file, columns: [column], compressors, onChunk }) | ||
|
|
||
| // Do some checks before returning the data | ||
|
|
||
| // check for errors | ||
| if (lastError.error !== undefined) { | ||
| throw lastError.error | ||
| } | ||
|
|
||
| // check for missing data (should be faster than checking for undefined values in the array) | ||
| const sortedRanges = ranges.sort((a, b) => a[0] - b[0]) | ||
| for (let i = 0; i < sortedRanges.length - 1; i++) { | ||
| const range = sortedRanges[i] | ||
| const nextRange = sortedRanges[i + 1] | ||
| if (!range || !nextRange) { | ||
| throw new Error('The ranges should not be undefined') | ||
| } | ||
| if (range[1] !== nextRange[0]) { | ||
| throw new Error(`missing data between rows ${range[1]} and ${nextRange[0]}`) | ||
| } | ||
| } | ||
| const firstRange = sortedRanges[0] | ||
| if (!firstRange) { | ||
| throw new Error('The first range should not be undefined') | ||
| } | ||
| if (firstRange[0] !== 0) { | ||
| throw new Error(`missing data before row ${firstRange[0]}`) | ||
| } | ||
| const lastRange = sortedRanges[sortedRanges.length - 1] | ||
| if (!lastRange) { | ||
| throw new Error('The last range should not be undefined') | ||
| } | ||
| if (lastRange[1] !== numRows) { | ||
| throw new Error(`missing data after row ${lastRange[1]}`) | ||
| } | ||
|
|
||
| // return the values | ||
| return values | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Uh oh!
There was an error while loading. Please reload this page.