예제 #1
0
 public void sequence(DapSequence seq) throws DapException {
   List<DapVariable> fields = seq.getFields();
   Odometer odom = null;
   if (seq.getRank() == 0) { // scalar
     odom = new ScalarOdometer();
   } else { // dimensioned
     List<Slice> slices = ce.getConstrainedSlices(seq);
     odom = Odometer.factory(slices, seq.getDimensions(), false);
   }
   try {
     while (odom.hasNext()) {
       // Decide how many rows for this sequence
       int nrows = (rowcount == 0 ? this.values.nextCount(MAXROWS) : rowcount);
       writer.writeObject(DapType.INT64, (long) nrows);
       for (int i = 0; i < nrows; i++) {
         for (int j = 0; j < fields.size(); j++) {
           DapVariable field = fields.get(j);
           variable(field);
         }
       }
       odom.next();
     }
   } catch (IOException ioe) {
     throw new DapException(ioe);
   }
 }
예제 #2
0
 public void atomicVariable(DapAtomicVariable dapvar) throws DapException {
   DapType basetype = dapvar.getBaseType();
   Odometer odom = null;
   if (dapvar.getRank() == 0) { // scalar
     odom = new ScalarOdometer();
   } else { // dimensioned
     // get the slices from the constraint
     List<Slice> slices = ce.getConstrainedSlices(dapvar);
     // Create an odometer from the slices
     odom = Odometer.factory(slices, dapvar.getDimensions(), false);
   }
   while (odom.hasNext()) {
     Object value = values.nextValue(basetype);
     if (DEBUG) {
       System.err.printf("generate: %s = %s\n", dapvar.getFQN(), value);
       System.err.flush();
     }
     try {
       assert (writer != null);
       writer.writeObject(basetype, value);
     } catch (IOException ioe) {
       throw new DapException(ioe);
     }
     odom.next();
   }
 }
예제 #3
0
 public void structure(DapStructure struct) throws DapException {
   List<DapVariable> fields = struct.getFields();
   Odometer odom = null;
   if (struct.getRank() == 0) { // scalar
     odom = new ScalarOdometer();
   } else { // dimensioned
     List<Slice> slices = ce.getConstrainedSlices(struct);
     odom = Odometer.factory(slices, struct.getDimensions(), false);
   }
   while (odom.hasNext()) {
     // generate a value for each field recursively
     for (int i = 0; i < fields.size(); i++) {
       DapVariable field = fields.get(i);
       variable(field);
     }
     odom.next();
   }
 }