Class HDFCachedGrid

All Implemented Interfaces:
Cloneable, ValueSource

public class HDFCachedGrid extends CachedGrid
The HDF cached grid class is a cached grid that understands how to read variable data from HDF files.
Since:
3.1.0
Author:
Peter Hollemans
  • Field Details

    • DEFAULT_TILE_SIZE

      public static final int DEFAULT_TILE_SIZE
      Default tile size in bytes.
      See Also:
    • DEFAULT_CACHE_SIZE

      public static final int DEFAULT_CACHE_SIZE
      Default cache size in bytes.
      See Also:
  • Constructor Details

    • HDFCachedGrid

      public HDFCachedGrid(Grid grid, HDFReader reader) throws IOException
      Constructs a new read-only HDF cached grid with the specified properties. Unchunked HDF variables will be given the default tile size, otherwise the tile size is determined from the file.
      Parameters:
      grid - the grid to use for attributes.
      reader - the HDF reader data source.
      Throws:
      IOException - if a problem occurred accessing the HDF file.
    • HDFCachedGrid

      public HDFCachedGrid(Grid grid, HDFWriter writer) throws IOException
      Constructs a new read-write HDF cached grid with the specified properties. Unchunked HDF files will be cached using the default tile size, otherwise the tile size is determined from the file.
      Parameters:
      grid - the grid to use for attributes.
      writer - the HDF writer data destination.
      Throws:
      IOException - if a problem occurred accessing the HDF file.
  • Method Details

    • getDataClass

      public Class getDataClass()
      Gets the data class. This method overrides the parent because the data class for an HDF cached grid is not available from the data array when needed in some cases.
      Overrides:
      getDataClass in class DataVariable
      Returns:
      the Java class of the data array.
    • getDataStream

      public Object getDataStream()
      Description copied from class: CachedGrid
      Gets the cache data stream as an object. This is useful for classes that read and write cached grids.
      Specified by:
      getDataStream in class CachedGrid
      Returns:
      the data stream used for reading and writing data.
    • setTileDims

      public void setTileDims(int[] dims)
      Creates a new cache where each tile has the specified dimensions. Only unchunked HDF variables may have the tile dimensions set. For chunked variables, the method has no effect.
      Overrides:
      setTileDims in class CachedGrid
      Parameters:
      dims - the tile dimensions as [rows, columns].
    • readTile

      protected TilingScheme.Tile readTile(TilingScheme.TilePosition pos) throws IOException
      Description copied from class: CachedGrid
      Reads the specified tile.
      Specified by:
      readTile in class CachedGrid
      Parameters:
      pos - the tile position to read.
      Returns:
      the tile at the specified position.
      Throws:
      IOException - if an error occurred reading the tile data.
    • writeTile

      protected void writeTile(TilingScheme.Tile tile) throws IOException
      Description copied from class: CachedGrid
      Writes the specified tile. The implementation of this method must set the tile to be not dirty upon successfully writing it, or throw an error.
      Specified by:
      writeTile in class CachedGrid
      Parameters:
      tile - the tile to write.
      Throws:
      IOException - if an error occurred writing the tile data.