コード例 #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
 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;
 }
コード例 #3
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);
   }
 }
コード例 #4
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);
 }