コード例 #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
  public void generate(int nconstraints) throws Exception {
    StringBuilder constraint = new StringBuilder();
    for (int i = 0; i < nconstraints; i++) {
      // Parse the DDS to produce a ServerDDS object
      ServerDDS sdds = new ServerDDS(new test_ServerFactory());

      StringBufferInputStream teststream = new StringBufferInputStream(testDDS);
      if (!sdds.parse(teststream)) throw new ParseException("Cannot parse DDS");
      collectnodes(sdds);
      constraint.setLength(0);
      genconstraint(constraint);
      System.out.println(constraint.toString());
    }
  }
コード例 #3
0
 void genvalueset(StringBuilder buf, BaseType lhsvar) {
   // Decide if this will be a multi-valued rhs
   boolean issingleton = (random.nextDouble() >= NVALUESPROB);
   if (issingleton) {
     genvalue(buf, lhsvar, false);
   } else {
     // Determine the number of of elements in the rhs set (> 1)
     int setsize = random.nextInt(MAXRHSSIZE) + 1; // 1..MAXRHSSIZE
     while (setsize < 2) setsize = random.nextInt(MAXRHSSIZE) + 1; // 1..MAXRHSSIZE
     buf.append("{");
     for (int i = 0; i < setsize; i++) {
       if (i > 0) buf.append(",");
       genvalue(buf, lhsvar, false);
     }
     buf.append("}");
   }
 }
コード例 #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
 void genvalue(StringBuilder buf, BaseType lhsvar, boolean forceconstant) {
   // decide if the rhs is going to be a var or a constant
   boolean isvar = (random.nextDouble() < VARRHSPROB);
   if (isvar && !forceconstant) {
     BaseType rhsvar = findmatchingvar(lhsvar);
     if (rhsvar != null) gendimpoint(getPath(rhsvar), buf);
     else genvalue(buf, lhsvar, true); // replace with a constant
   } else { // use a constant
     String rhs = valuefor(lhsvar);
     while (rhs == null) rhs = valuefor(lhsvar);
     buf.append(rhs);
   }
 }
コード例 #6
0
 void genselection(BaseType lhsvar, StringBuilder buf) {
   gendimpoint(getPath(lhsvar), buf);
   String operator = opset[random.nextInt(opset.length)];
   buf.append(operator);
   genvalueset(buf, lhsvar);
 }