Package ucar.nc2.iosp

Interface Layout

  • All Known Subinterfaces:
    LayoutBB
    All Known Implementing Classes:
    H5tiledLayout, H5tiledLayout, H5tiledLayoutBB, H5tiledLayoutBB, LayoutBBTiled, LayoutRegular, LayoutRegularSegmented, LayoutSegmented, LayoutTiled, ZarrLayoutBB

    public interface Layout
    Iterator to read/write subsets of a multidimensional array, finding the contiguous chunks. The iteration is monotonic in both src and dest positions.

    Example for Integers:

      int[] read( Layout index, int[] src) {
        int[] dest = new int[index.getTotalNelems()];
        while (index.hasNext()) {
          Layout.Chunk chunk = index.next();
          System.arraycopy(src, chunk.getSrcElem(), dest, chunk.getDestElem(), chunk.getNelems());
        }
        return dest;
      }
    
      int[] read( Layout index, RandomAccessFile raf) {
        int[] dest = new int[index.getTotalNelems()];
        while (index.hasNext()) {
          Layout.Chunk chunk = index.next();
          raf.seek( chunk.getSrcPos());
          raf.readInt(dest, chunk.getDestElem(), chunk.getNelems());
        }
        return dest;
      }
    
       // note src and dest misnamed
        void write( Layout index, int[] src, RandomAccessFile raf) {
          while (index.hasNext()) {
            Layout.Chunk chunk = index.next();
            raf.seek ( chunk.getSrcPos());
            for (int k=0; k
    Since:
    Jan 2, 2008
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Interface Description
      static interface  Layout.Chunk
      A chunk of data that is contiguous in both the source and destination.
    • Method Detail

      • getTotalNelems

        long getTotalNelems()
        Get total number of elements in the wanted subset.
        Returns:
        total number of elements in the wanted subset.
      • getElemSize

        int getElemSize()
        Get size of each element in bytes.
        Returns:
        size of each element in bytes.
      • hasNext

        boolean hasNext()
        Is there more to do
        Returns:
        true if theres more to do
      • next

        Layout.Chunk next()
        Get the next chunk
        Returns:
        next chunk, or null if !hasNext()