示例#1
0
 void gendimrange(List<BaseType> path, StringBuilder buf) {
   for (int i = 0; i < path.size(); i++) {
     BaseType bt = path.get(i);
     int rank = 0;
     if (bt.getParent() instanceof DArray) rank = ((DArray) (bt.getParent())).numDimensions();
     if (i > 0) buf.append('.');
     buf.append(bt.getEncodedName());
     for (int j = 0; j < rank; j++) {
       String dimprojection = dimrangeset[random.nextInt(dimrangeset.length)];
       buf.append(dimprojection);
     }
   }
 }
示例#2
0
 long computeArraySize(SDArray da) throws Exception {
   assert (da.getContainerVar() instanceof DPrimitive);
   BaseType base = da.getPrimitiveVector().getTemplate();
   DataType dtype = DODSNetcdfFile.convertToNCType(base);
   int elemSize = dtype.getSize();
   int n = da.numDimensions();
   List<Range> ranges = new ArrayList<Range>(n);
   long size = 0;
   for (int i = 0; i < n; i++) {
     ranges.add(new Range(da.getStart(i), da.getStop(i), da.getStride(i)));
     Section s = new Section(ranges);
     size += s.computeSize() * elemSize;
   }
   return size;
 }
示例#3
0
 BaseType findmatchingvar(BaseType var) {
   assert (isprimitive(var));
   BaseType match = null;
   for (BaseType bt : leaves) {
     if (bt == var) continue;
     if (sametype(bt, var)) {
       // make sure that this var does not cause conflict
       if (selections.contains(bt)) continue;
       if (projections.contains(bt)) continue;
       if (valuelist.contains(bt)) continue;
       BaseType parent = containsParent(bt, projections);
       if (parent != null) continue;
       match = bt;
       valuelist.add(bt);
     }
   }
   return match;
 }
示例#4
0
 void genconstraint(StringBuilder buf) {
   int nprojections = random.nextInt(NPROJECTIONS);
   int nselections = random.nextInt(NSELECTIONS);
   if (nprojections + nselections == 0) nprojections++; // guarantee non-null constraint
   projections = new ArrayList<BaseType>();
   // generate candidate projection list
   while (projections.size() < nprojections) {
     BaseType node = choose(allnodes);
     // check for conflicts
     if (projections.contains(node)) continue; // no duplicates
     if (containsChild(node, projections)) continue; // child => !parent
     BaseType parent = containsParent(node, projections);
     if (parent != null) projections.remove(parent); // parent && child => !parent
     projections.add(node);
   }
   projections = sort(projections); // sort
   for (int i = 0; i < projections.size(); i++) {
     BaseType node = projections.get(i);
     if (i > 0) buf.append(",");
     genprojection(node, buf);
   }
   selections = new ArrayList<BaseType>();
   valuelist = new ArrayList<BaseType>();
   // generate candidate selection list
   while (selections.size() < nselections) {
     BaseType node = choose(leaves);
     if (selections.contains(node)) continue; // no duplicates
     // conflict avoidance
     if (projections.contains(node)) continue; // no duplicates with projection list
     if (containsChild(node, projections)) continue; // child => !parent wrt projection list
     BaseType parent = containsParent(node, projections);
     if (parent != null) continue; // project parent && select child => remove child
     selections.add(node);
   }
   for (int i = 0; i < nselections; i++) {
     BaseType node = selections.get(i);
     buf.append("&");
     genselection(node, buf);
   }
 }
示例#5
0
 BaseType choose(List<BaseType> nodeset) {
   // choose a random DDS node from a given nodeset
   int choice = random.nextInt(nodeset.size()); // 0..|nodeset|-1
   return nodeset.get(choice);
 }