Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the CSV row fetching logic to improve performance by allowing row number estimates in different random ranges to overlap. Previously, the system would reassign row numbers across all ranges to prevent overlap, which was slower. Now, row numbers are only reassigned when bytes are contiguous and ranges are merged. The changes also introduce a "prefix rows" fetching strategy to handle partial rows when starting from estimated byte positions.
Key changes:
- Modified
CSVCache.store()to require afirstRowparameter for creating new ranges - Refactored
getNextMissingRow()to return separatefirstByteToFetchandfirstByteToStorevalues along with expectedfirstRow - Reduced default chunk size from 500KB to 100KB for finer-grained fetching when estimating positions
Reviewed Changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/cache.ts | Added firstRow parameter to store() method; refactored getNextMissingRow() to support prefix fetching with separate fetch/store byte positions |
| src/dataframe.ts | Refactored fetch loop to use new getNextMissingRow() API; added prefix row fetching; changed event emission to per-row instead of per-fetch; reduced default chunk size to 100KB |
| test/cache.test.ts | Updated all store() calls to include required firstRow parameter; updated getNextMissingRow() test expectations for new return structure; removed test for row number estimation across ranges |
| test/dataframe.test.ts | Added extra row to test data; updated expected values to reflect new fetching behavior with prefix rows |
| src/Welcome.tsx | Added new example dataset (19th-century novelists) for testing with large files |
| package.json | Updated dependencies: csv-range to 0.0.10, vitest/coverage to 4.0.12, eslint plugins to latest versions, vite to 7.2.4 |
| package-lock.json | Updated lockfile to match package.json dependency changes |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
We now allow the estimated row numbers in different random row ranges to overlap. We only reassign them when the bytes are contiguous and we merge two ranges.
The consequence is that the response is a lot faster.