Exception reading data with caching turned on #1407
Replies: 2 comments
-
When you set caching on a variable, the entire data array will be read into memory before any index subsets are performed, which is likely not quite what you are wanting. It's really intended for caching things like coordinate variable data, which tend to be accessed multiple times and do not consume lots of space. It can be useful in other situations, as you have found previously, but it's not always appropriate. |
Beta Was this translation helpful? Give feedback.
-
Thanks. That explains a lot. It also points me toward a better way to use the API than depending on the cache. Please feel free to close this discussion if you'd like to do so. Gary |
Beta Was this translation helpful? Give feedback.
-
This may be a new issue.
I am seeing an exception when attempting to read from a large (10.9 GB) NetCDF file that contains a global elevation and bathymetry data set. The exception occurs when the setCaching(true) is employed. I recognize that this method is deprecated, and I also note that it is not necessary for the particular file that I am accessing. But it is included in my code because it has proven absolutely necessary to get decent performance when reading similar data sets with different chunking schemes... For details, see Discussion number 1399.
I am using cdm-core-5.6.0
The exception is
The file I am reading is the GEBCO 2019 global bathymetry set which can be downloaded from The GEBCO Historical downloads. To download it, click on the link marked "Download GEBCO 2021 grid".
The variable I am accessing is
I access it using code as shown below. The code is intended to read data from the file one row at a time. It throws an exception the first time it is called.
I believe that the "elevation" variable is a single-precision float and that the read request size should only be about 4 x 86400 = 345600 bytes. I do not have an explanation for why the read request ends up being 3732480000. But I note that this value corresponds to the number of cells in grid for the variable, with 43200 x 86400 = 3732480000.
Beta Was this translation helpful? Give feedback.
All reactions