Пример #1
0
 @Override
 public boolean equals(Object that) {
   if (this == that) {
     return true;
   } else if (that instanceof OrRule<?>) {
     final OrRule<?> other = OrRule.class.cast(that);
     return left.equals(other.left) && right.equals(other.right);
   } else {
     return false;
   }
 }
Пример #2
0
 /**
  * applyRulesDebugByteArray.
  *
  * @param op a {@link lupos.engine.operators.BasicOperator} object.
  * @param mapStartNodes a {@link java.util.Map} object.
  * @param rules an array of {@link lupos.optimizations.logical.rules.Rule} objects.
  * @param untilRule a {@link lupos.optimizations.logical.rules.Rule} object.
  * @param prefixInstance a {@link lupos.rdf.Prefix} object.
  * @return a {@link java.util.List} object.
  */
 public List<DebugContainer<BasicOperatorByteArray>> applyRulesDebugByteArray(
     final BasicOperator op,
     final Map<Class<? extends BasicOperator>, Set<BasicOperator>> mapStartNodes,
     final Rule[] rules,
     final Rule untilRule,
     final Prefix prefixInstance) {
   final List<DebugContainer<BasicOperatorByteArray>> debug =
       new LinkedList<DebugContainer<BasicOperatorByteArray>>();
   for (final Rule r : rules) {
     if (untilRule != null && r.equals(untilRule)) break;
     while (r.applyDebug(op, mapStartNodes)) {
       debug.add(
           new DebugContainer<BasicOperatorByteArray>(
               r.getName(),
               r.getDescription(),
               BasicOperatorByteArray.getBasicOperatorByteArray(op.deepClone(), prefixInstance)));
       // mapStartNodes = RuleEngine.createStartNodeMap(op);
       if (checkNodeMap) {
         // check if all nodes of the operatorgraph are in the
         // map:
         op.visit(
             new SimpleOperatorGraphVisitor() {
               public Object visit(final BasicOperator basicOperator) {
                 if (!checkIfInNodeMap(basicOperator, mapStartNodes))
                   System.err.println(
                       "The following node is not in mapStartNodes:" + basicOperator);
                 return null;
               }
             });
         // check if all nodes of the map are in the
         // operatorgraph:
         for (final Map.Entry<Class<? extends BasicOperator>, Set<BasicOperator>> entry :
             mapStartNodes.entrySet()) {
           for (final BasicOperator bo : entry.getValue()) {
             final FindInOperatorGraph findInOperatorGraph = new FindInOperatorGraph(bo);
             op.visit(findInOperatorGraph);
             if (!findInOperatorGraph.getFlag())
               System.err.println(
                   "The following node for class "
                       + entry.getKey()
                       + " is not in the operatorgraph:"
                       + bo);
           }
         }
       }
       Rule[] rulesToApply = r.getRulesToApply(this);
       if (rulesToApply == null) rulesToApply = this.rules;
       debug.addAll(applyRulesDebugByteArray(op, mapStartNodes, rulesToApply, r, prefixInstance));
     }
   }
   return debug;
 }
Пример #3
0
 /**
  * applyRules.
  *
  * @param op a {@link lupos.engine.operators.BasicOperator} object.
  * @param mapStartNodes a {@link java.util.Map} object.
  * @param rules an array of {@link lupos.optimizations.logical.rules.Rule} objects.
  * @param untilRule a {@link lupos.optimizations.logical.rules.Rule} object.
  */
 public void applyRules(
     final BasicOperator op,
     final Map<Class<? extends BasicOperator>, Set<BasicOperator>> mapStartNodes,
     final Rule[] rules,
     final Rule untilRule) {
   for (final Rule r : rules) {
     if (untilRule != null && r.equals(untilRule)) break;
     while (r.apply(op, mapStartNodes)) {
       Rule[] rulesToApply = r.getRulesToApply(this);
       if (rulesToApply == null) rulesToApply = this.rules;
       applyRules(op, mapStartNodes, rulesToApply, r);
     }
   }
 }