Esempio n. 1
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;
 }
 @Override
 public List<DebugContainer<BasicOperatorByteArray>> physicalOptimizationDebugByteArray(
     final Prefix prefixInstance) {
   this.physicalOptimization();
   final LinkedList<DebugContainer<BasicOperatorByteArray>> debug =
       new LinkedList<DebugContainer<BasicOperatorByteArray>>();
   debug.add(
       new DebugContainer<BasicOperatorByteArray>(
           "After physical optimization...",
           "physicaloptimizationRule",
           BasicOperatorByteArray.getBasicOperatorByteArray(
               this.rootNode.deepClone(), prefixInstance)));
   return debug;
 }