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

hashmap for quick var and dim retrieval -- nc3 files #238

Merged
merged 8 commits into from
Apr 4, 2016
Merged

hashmap for quick var and dim retrieval -- nc3 files #238

merged 8 commits into from
Apr 4, 2016

Conversation

gsjaardema
Copy link
Contributor

Added a hashmap that hashes the var/dim name and returns the var/dim id which can then be used for O(1) lookup of the actual var/dim object for nc3 files. This eliminates walking a doubly-linked list with strcmp calls that was previously needed to retrieve a var/dim when given a name.

Removed the old hash stored in the var/dim which was used to eliminate many strcmp calls.

Results in significant speedup for files with large numbers of vars and dims; prototype for applying a similar concept to nc4 and possibly nc5 (pnetcdf-based) files.

The var struct has a 'dim' field which was not being used
Instead, the dimids field would always search for the dim
with the matching dimid.  For db with large numbers of dims,
this could be a significant time sync.

Modified code to always set var-dim[i] when var->dimids[i] was
set (if the dim existed at that point).  Then use the var->dim
field instead of var->dimids and search whenever requested.

All var->dim accesses are protected by asserts that verify
non-null and that the var->dim[]->dimid == var->dimids[].
@WardF
Copy link
Member

WardF commented Apr 4, 2016

Looks good; managing merge now, thanks very much @gsjaardema !

@gsjaardema
Copy link
Contributor Author

Thanks. I am working on a similar patch for nc4 files...

@WardF WardF merged commit 27b1a87 into Unidata:master Apr 4, 2016
WardF added a commit that referenced this pull request Apr 4, 2016
@gsjaardema gsjaardema deleted the nc3-var-dim-hash branch April 4, 2016 19:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants