Skip to content

use stream instead of fs.readdir() #1471

Closed

Description

@ORESoftware

I have this question on SO:
https://stackoverflow.com/questions/52131509/read-large-directory-with-nodejs

say we have a directory of 10,000,000 items or whatever. Instead of reading all paths into memory, it would be nice to be able to read the directory about 15,000 items concurrently.

Does Node.js offer a way to do that? Even with Unix child processes, still not sure how to do this.

Activity

  1. gireeshpunathil commented on May 9, 2019

    @gireeshpunathil
    Member

    @ORESoftware -

    the underlying capability that provides us the data is readdir / getdents, and as long as those provide us the data in one shot, whether we stream it or not is immaterial, as the data is already in memory.

    In general terms, what this would mean is, where we don't have control over the volume of data that we receive from a source, making a streamified version do not make meaning?

  2. gireeshpunathil commented on May 9, 2019

    @gireeshpunathil
    Member

    on a different note, if child processes use shell commands and stream data to parent, it would be sub-optimal IMO, as we are just forcing the data to be streamed, but:

    • the entire data is held by child at some point in time
    • latency in getting the data to the parent
  3. richardlau commented on May 9, 2019

    @richardlau
    Member

    I think you're after nodejs/node#583 which AFAIK hasn't yet been implemented on the Node.js side. Possibly https://www.npmjs.com/package/fs-readdir-stream (from one of the comments in the issue)?

  4. gireeshpunathil commented on Jun 24, 2019

    @gireeshpunathil
    Member
  5. gireeshpunathil commented on Jul 15, 2019

    @gireeshpunathil
    Member

    inactive, closing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions