-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fs2.createWriteStreamAsNDJSON Which are also optimized (~20% faster read). Remove less useful (aka "never used") ndjson helpers, because fs2.* is more convenient now. Remove `binary-split` dependency, vendor/adopt its code, optimize for `\n` splitting (versus generic variable length splitting).
- Loading branch information
1 parent
fd53324
commit cfc70cc
Showing
17 changed files
with
273 additions
and
324 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
yarn tsn ndjsonParseSpeed | ||
*/ | ||
|
||
import { | ||
_pipeline, | ||
fs2, | ||
requireEnvKeys, | ||
runScript, | ||
transformLogProgress, | ||
transformMap, | ||
} from '../src' | ||
|
||
const { SNAPSHOTS_DIR, SNAPSHOT_ID } = requireEnvKeys('SNAPSHOTS_DIR', 'SNAPSHOT_ID') | ||
|
||
runScript(async () => { | ||
const filePath = `${SNAPSHOTS_DIR}/${SNAPSHOT_ID}` | ||
const outputFilePath = `${SNAPSHOTS_DIR}/${SNAPSHOT_ID}_out.ndjson.gz` | ||
console.log({ filePath, outputFilePath }) | ||
let keys = 0 | ||
|
||
await _pipeline([ | ||
fs2.createReadStreamAsNDJSON(filePath).take(10_000), | ||
transformMap<any, any>(async fu => { | ||
keys += Object.keys(fu || {}).length // just to do some work | ||
return fu | ||
}), | ||
transformLogProgress({ logEvery: 1000, extra: () => ({ keys }) }), | ||
// writableVoid(), | ||
fs2.createWriteStreamAsNDJSON(outputFilePath), | ||
]) | ||
}) |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
Oops, something went wrong.