/** * Constructor. * * @param startPos starting address of the entire data array. * @param elemSize size of an element in bytes. * @param varShape shape of the entire data array. * @param wantSection the wanted section of data, contains a List of Range objects. * @throws InvalidRangeException if ranges are misformed */ public LayoutRegular(long startPos, int elemSize, int[] varShape, Section wantSection) throws InvalidRangeException { assert startPos >= 0; assert elemSize > 0; this.startPos = startPos; this.elemSize = elemSize; chunker = new IndexChunker(varShape, wantSection); }
public long getTotalNelems() { return chunker.getTotalNelems(); }
public boolean hasNext() { return chunker.hasNext(); }
@Test public void testFull() throws InvalidRangeException { int[] shape = new int[] {123,22,92,12}; Section section = new Section(shape); IndexChunker index = new IndexChunker(shape, section); assert index.getTotalNelems() == section.computeSize(); IndexChunker.Chunk chunk = index.next(); assert chunk.getNelems() == section.computeSize(); assert !index.hasNext(); }
/** * Constructor. * * @param startPos starting address of the entire data array. * @param elemSize size of an element in bytes. * @param recSize size of outer stride in bytes * @param srcShape shape of the entire data array. must have rank > 0 * @param wantSection the wanted section of data * @throws ucar.ma2.InvalidRangeException if ranges are misformed */ public LayoutRegularSegmented(long startPos, int elemSize, long recSize, int[] srcShape, Section wantSection) throws InvalidRangeException { assert startPos > 0; assert elemSize > 0; assert recSize > 0; assert srcShape.length > 0; this.startPos = startPos; this.elemSize = elemSize; this.recSize = recSize; chunker = new IndexChunker(srcShape, wantSection); this.total = chunker.getTotalNelems(); this.innerNelems = (srcShape[0] == 0) ? 0 : Index.computeSize(srcShape) / srcShape[0]; this.done = 0; }
@Test public void testPart() throws InvalidRangeException { int[] full = new int[] {2, 10, 20}; int[] part = new int[] {2, 5, 20}; Section section = new Section(part); IndexChunker index = new IndexChunker(full, section); assert index.getTotalNelems() == section.computeSize(); IndexChunker.Chunk chunk = index.next(); assert chunk.getNelems() == section.computeSize()/2; }
public Chunk next() { IndexChunker.Chunk chunk = chunker.next(); chunk.setSrcPos( startPos + chunk.getSrcElem() * elemSize); return chunk; } }
/** * Constructor. * * @param startPos starting address of the entire data array. * @param elemSize size of an element in bytes. * @param recSize size of outer stride in bytes * @param srcShape shape of the entire data array. must have rank > 0 * @param wantSection the wanted section of data * @throws ucar.ma2.InvalidRangeException if ranges are misformed */ public LayoutRegularSegmented(long startPos, int elemSize, long recSize, int[] srcShape, Section wantSection) throws InvalidRangeException { assert startPos > 0; assert elemSize > 0; assert recSize > 0; assert srcShape.length > 0; this.startPos = startPos; this.elemSize = elemSize; this.recSize = recSize; chunker = new IndexChunker(srcShape, wantSection); this.total = chunker.getTotalNelems(); this.innerNelems = (srcShape[0] == 0) ? 0 : Index.computeSize(srcShape) / srcShape[0]; this.done = 0; }
public Chunk next() { IndexChunker.Chunk chunk = chunker.next(); chunk.setSrcPos( startPos + chunk.getSrcElem() * elemSize); return chunk; } }
/** * Constructor. * * @param startPos starting address of the entire data array. * @param elemSize size of an element in bytes. * @param recSize size of outer stride in bytes * @param srcShape shape of the entire data array. must have rank > 0 * @param wantSection the wanted section of data * @throws ucar.ma2.InvalidRangeException if ranges are misformed */ public LayoutRegularSegmented(long startPos, int elemSize, long recSize, int[] srcShape, Section wantSection) throws InvalidRangeException { assert startPos > 0; assert elemSize > 0; assert recSize > 0; assert srcShape.length > 0; this.startPos = startPos; this.elemSize = elemSize; this.recSize = recSize; chunker = new IndexChunker(srcShape, wantSection); this.total = chunker.getTotalNelems(); this.innerNelems = (srcShape[0] == 0) ? 0 : Index.computeSize(srcShape) / srcShape[0]; this.done = 0; }
public Chunk next() { IndexChunker.Chunk chunk = chunker.next(); chunk.setSrcPos( startPos + chunk.getSrcElem() * elemSize); return chunk; } }
public long getTotalNelems() { return chunker.getTotalNelems(); }
public boolean hasNext() { return chunker.hasNext(); }
/** * Constructor. * * @param startPos starting address of the entire data array. * @param elemSize size of an element in bytes. * @param varShape shape of the entire data array. * @param wantSection the wanted section of data, contains a List of Range objects. * @throws InvalidRangeException if ranges are misformed */ public LayoutRegular(long startPos, int elemSize, int[] varShape, Section wantSection) throws InvalidRangeException { assert startPos >= 0; assert elemSize > 0; this.startPos = startPos; this.elemSize = elemSize; chunker = new IndexChunker(varShape, wantSection); }
chunker = new IndexChunker(srcShape, wantSection); this.total = chunker.getTotalNelems(); this.done = 0; this.elemSize = elemSize;
public Chunk nextOuter() { chunkOuter = chunker.next(); long srcPos = getFilePos( chunkOuter.getSrcElem() * elemSize); chunkOuter.setSrcPos( srcPos); return chunkOuter; }
public long getTotalNelems() { return chunker.getTotalNelems(); }
public boolean hasNext() { return chunker.hasNext(); }
/** * Constructor. * * @param startPos starting address of the entire data array. * @param elemSize size of an element in bytes. * @param varShape shape of the entire data array. * @param wantSection the wanted section of data, contains a List of Range objects. * @throws InvalidRangeException if ranges are misformed */ public LayoutRegular(long startPos, int elemSize, int[] varShape, Section wantSection) throws InvalidRangeException { assert startPos >= 0; assert elemSize > 0; this.startPos = startPos; this.elemSize = elemSize; chunker = new IndexChunker(varShape, wantSection); }