Skip to content
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

Add support for saving the index produced with a full GRIB scan at open. #20

Closed
alexamici opened this Issue Oct 8, 2018 · 2 comments

Comments

Projects
None yet
2 participants
@alexamici
Copy link
Collaborator

alexamici commented Oct 8, 2018

At the moment every time a GRIB file is opened cfgrib needs to scan all the messages in the file to build the index that is then used to compute the values of the coordinates and build the hypercube representation of the variables.

Worse, when opening a GRIB file with the convenience function open_datasets the index is discarded every time the recursive call fails and the expensive file scan is done again.

Proposed implementation requirements for the feature are:

  • save the index to disk with path + .idx immediately after computation
    • a pickle of the in-memory structure is the simplest implementation
    • shall not fail if the index cannot be written (file can be on a read only filesystem)
  • when opening a file search for the path + .idx index file, test that it is in sync with the GRIB file and load it
    • timestamp ordering is enough for now
    • do not fail if the index is corrupt
  • use locking to avoid concurrent writes or reads and write
    • concurrents reads must be ok
@iainrussell

This comment has been minimized.

Copy link
Member

iainrussell commented Oct 9, 2018

I think it's worth mentioning that it probably should not fail if it cannot write the index file - the GRIB file could be in a read-only directory, in which case it would not be possible to write the index to the same place.

@alexamici

This comment has been minimized.

Copy link
Collaborator Author

alexamici commented Oct 22, 2018

The implementation is still wasteful and very fragile, but the index is saved to and read from disk.

@alexamici alexamici closed this in 46cd93c Oct 28, 2018

alexamici added a commit that referenced this issue Oct 28, 2018

@alexamici alexamici changed the title Add support for saving the index produced with a full GIRB scan at open. Add support for saving the index produced with a full GRIB scan at open. Nov 12, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.