public StructureDataIterator getStructureDataIterator(Cursor cursor, int bufferSize) throws IOException { int recnum = cursor.getParentRecnum(); try { Section section = new Section().appendRange(recnum, recnum); int count = 1; while (count++ < struct.getRank()) // handles multidim case section.appendRange(null); ArrayStructure data = (ArrayStructure) struct.read(section); // read all the data for a fixed outer index return data.getStructureDataIterator(); } catch (InvalidRangeException e) { throw new IllegalStateException(e); } }
public StructureDataIterator getStructureDataIterator(Cursor cursor, int bufferSize) throws IOException { int recnum = cursor.getParentRecnum(); try { Section section = new Section().appendRange(recnum, recnum); int count = 1; while (count++ < struct.getRank()) // handles multidim case section.appendRange(null); ArrayStructure data = (ArrayStructure) struct.read(section); // read all the data for a fixed outer index return data.getStructureDataIterator(); } catch (InvalidRangeException e) { throw new IllegalStateException(e); } }
@Override public StructureDataIterator getStructureDataIterator(Cursor cursor) throws IOException { int recnum = cursor.getParentRecnum(); try { Section section = new Section().appendRange(recnum, recnum); int count = 1; while (count++ < struct.getRank()) // handles multidim case section.appendRange(null); ArrayStructure data = (ArrayStructure) struct.read(section); // read all the data for a fixed outer index return data.getStructureDataIterator(); } catch (InvalidRangeException e) { throw new IllegalStateException(e); } }
public void testDatasetAddRecordAfter() throws InvalidRangeException, IOException { NetcdfDataset nc = NetcdfDataset.openDataset(TestDir.cdmLocalTestDataDir + "testWriteRecord.nc"); assert (Boolean) nc.sendIospMessage(NetcdfFile.IOSP_MESSAGE_ADD_RECORD_STRUCTURE); // record variable Variable record = nc.findVariable("record"); assert record instanceof StructureDS; StructureDS rs = (StructureDS) record; assert rs.getRank() == 1; assert rs.getDimension(0).getLength() == 2; /* Read a record */ Array rsValues = rs.read("1:1:2"); assert (rsValues instanceof ArrayStructure); assert rsValues.getRank() == 1; assert rsValues.getShape()[0] == 1; StructureData sdata = (StructureData) rsValues.getObject(rsValues.getIndex()); Array gdata = sdata.getArray("time"); assert gdata instanceof ArrayInt.D0 : gdata.getClass().getName(); ArrayInt.D0 tdata = (ArrayInt.D0) gdata; int t = tdata.get(); assert t == 18; int t2 = sdata.getScalarInt("time"); assert t2 == 18; /* Read the times: unlimited dimension */ Variable time = rs.findVariable("time"); Array timeValues = time.read(); assert (timeValues instanceof ArrayInt.D0); ArrayInt.D0 ta = (ArrayInt.D0) timeValues; assert (ta.get() == 6) : ta.get(); nc.close(); }
assert record instanceof StructureDS; StructureDS rs = (StructureDS) record; assert rs.getRank() == 1; assert rs.getDimension(0).getLength() == 2;