private ucar . ma2 . Array readRecordDataSubset ( ucar . nc2 . Structure s , Section section ) throws java . io . IOException { Range recordRange = section . getRange ( 0 ) ; int nrecords = recordRange . length ( ) ; // create the ArrayStructureMA StructureMembers members = s . makeStructureMembers ( ) ; for ( StructureMembers . Member m : members . getMembers ( ) ) { Variable v2 = s . findVariable ( m . getName ( ) ) ; N3header . Vinfo vinfo = ( N3header . Vinfo ) v2 . getSPobject ( ) ; m . setDataParam ( ( int ) ( vinfo . begin - header . recStart ) ) ; // offset from start of record // construct the full shape int rank = m . getShape ( ) . length ; int [ ] fullShape = new int [ rank + 1 ] ; fullShape [ 0 ] = nrecords ; // the first dimension System . arraycopy ( m . getShape ( ) , 0 , fullShape , 1 , rank ) ; // the remaining dimensions Array data = Array . factory ( m . getDataType ( ) , fullShape ) ; m . setDataArray ( data ) ; m . setDataObject ( data . getIndexIterator ( ) ) ; } //LOOK this is all wrong - why using recsize ??? return null ; /* members.setStructureSize(recsize); ArrayStructureMA structureArray = new ArrayStructureMA(members, new int[]{nrecords}); // note dependency on raf; should probably defer to subclass // loop over records byte[] record = new byte[ recsize]; ByteBuffer bb = ByteBuffer.wrap(record); for (int recnum = recordRange.first(); recnum <= recordRange.last(); recnum += recordRange.stride()) { if (debugRecord) System.out.println(" readRecordDataSubset recno= " + recnum); // read one record raf.seek(recStart + recnum * recsize); // where the record starts if (recnum != numrecs - 1) raf.readFully(record, 0, recsize); else raf.read(record, 0, recsize); // "wart" allows file to be one byte short. since its always padding, we allow // transfer desired variable(s) to result array(s) for (StructureMembers.Member m : members.getMembers()) { IndexIterator dataIter = (IndexIterator) m.getDataObject(); IospHelper.copyFromByteBuffer(bb, m, dataIter); } } return structureArray; */ }
Read data from record structure that has been subsetted . Read one record at at time put requested variable into ArrayStructureMA .