Class ChunkingIndex


  • public class ChunkingIndex
    extends Object
    An index that computes chunk shapes. It is intended to be used to compute the origins and shapes for a series of contiguous writes to a multidimensional array. It writes the first n elements (n < maxChunkElems), then the next, etc. Contributed by cwardgar@usgs.gov 4/12/2010 TODO this assumes strides are always 1 TODO can we use nc2.write.IndexChunker?
    • Constructor Detail

      • ChunkingIndex

        public ChunkingIndex​(int[] shape)
    • Method Detail

      • currentCounter

        public int[] currentCounter()
        Get the current counter.
      • currentElement

        public long currentElement()
        Get the current element's index into the 1D backing array.
      • size

        public long size()
      • incr

        public long incr()
        Increment the current element by 1.
        Returns:
        currentElement()
      • setCurrentCounter

        public void setCurrentCounter​(long currElement)
        Set the current counter from the 1D "current element" currElement = offset + stride[0]*current[0] + ...
        Parameters:
        currElement - set to this value
      • computeChunkShape

        public int[] computeChunkShape​(long maxChunkElems)
        Computes the shape of the largest possible contiguous chunk, starting at currentCounter() and with numElems <= maxChunkElems.
        Parameters:
        maxChunkElems - the maximum number of elements in the chunk shape. The actual element count of the shape returned is likely to be different, and can be found with Arrays.computeSize(int[]).
        Returns:
        the shape of the largest possible contiguous chunk.