Package lupos.engine.operators.tripleoperator

Examples of lupos.engine.operators.tripleoperator.TriplePattern


      subOperator.addSucceedingOperator(construct);
      construct.addPrecedingOperator(subOperator);
      final List<TriplePattern> patterns = new ArrayList<TriplePattern>();
      for (final Uniterm term : obj.getHead().getPredicates()) {
        if (((RulePredicate) term).isTriple()) {
          final TriplePattern pattern = this.unitermToTriplePattern(term);
          patterns.add(pattern);
        }
      }
      construct.setTemplates(patterns);
      // Fuer jedes Triplepattern in Construct ein Generate fuer Inferenz erstellen
      // wird, falls es keinen Consumer gibt, spaeter wieder entfernt
      for (final TriplePattern pattern : construct.getTemplates()) {
        final Generate generateTriplesOp = new Generate(pattern.getItems());
        generateTriplesOp.addPrecedingOperator(subOperator);
        subOperator.addSucceedingOperator(new OperatorIDTuple(generateTriplesOp, subOperator.getSucceedingOperators().size()));
        generateTriplesOp.addPrecedingOperator(subOperator);
        // TripleProduzenten registrieren
        this.add(this.tripleProducer, new KeyTriplePattern(pattern), generateTriplesOp);
View Full Code Here


      this.add(this.tripleConsumer, new KeyPredicatePattern(predPat), predPat);
      return predPat;
    }
    // Normale TripleBearbeitung
    // 1. TriplePattern erstellen
    final TriplePattern pattern = (TriplePattern) zpattern;

    // 2. Index erstellen, noch ohne succeding operator
    final BasicOperator index = this.indexScanCreator.createIndexScanAndConnectWithRoot(null, new ArrayList<TriplePattern>(Arrays.asList(pattern)), null);
    index.setPrecedingOperator(this.indexScanCreator.getRoot());

    // 3. Pr�fen ob Triple-Pr�dikat an anderer Stelle erzeugt wird
    final KeyTriplePattern keyPattern = new KeyTriplePattern(pattern);
    boolean flag = false;

    final HashSet<KeyTriplePattern> possibleMatchingKeysOfProducers = new LinkedHashSet<KeyTriplePattern>();

    for(final KEY mainkey: this.tripleProducer.keySet()){
      if(mainkey instanceof KeyTriplePattern){
        final KeyTriplePattern mainkeyTP = (KeyTriplePattern) mainkey;
        if(keyPattern.mayConsume(mainkeyTP)){
          possibleMatchingKeysOfProducers.add(mainkeyTP);
          flag = true;
        }
      }
    }
    if (flag) {
      // index -> (union -> distinct) <- triplepattern : return union
//      Distinct distinct = new Distinct();
      final Union union = new Union();
//      union.setSucceedingOperator(new OperatorIDTuple(distinct, 0));
      index.setSucceedingOperator(new OperatorIDTuple(union, 0));
      union.addPrecedingOperator(index);
//      distinct.setSucceedingOperator((OperatorIDTuple) arg);
      pattern.setSucceedingOperator(new OperatorIDTuple(union, 1));
      union.addPrecedingOperator(pattern);
      for(final KeyTriplePattern keyTP: possibleMatchingKeysOfProducers){
        this.add(this.tripleConsumer, keyTP, pattern);
      }
//      return distinct;
View Full Code Here

    super();
  }

  @Override
  protected void init() {
    final TriplePattern tp = new TriplePattern();
    final ReplaceVar repVar = new ReplaceVar();

    tp.setSucceedingOperator(new OperatorIDTuple(repVar, 0));
    repVar.setPrecedingOperator(tp);

    subGraphMap = new HashMap<BasicOperator, String>();
    subGraphMap.put(tp, "tp");
    subGraphMap.put(repVar, "repVar");
View Full Code Here

    // operator?
    for (final BasicOperator bo : repVar.getPrecedingOperators()) {
      if (!(bo instanceof TriplePattern))
        return false;
      else {
        final TriplePattern tp = (TriplePattern) bo;
        if (tp.getSucceedingOperators().size() > 1)
          return false;
        for (final Variable v : tp.getVariables()) {
          int found = 0;
          for (final Variable v2 : repVar
              .getSubstitutionsVariableRight()) {
            if (v2.equals(v)) {
              found++;
View Full Code Here

    for (final OperatorIDTuple oidt : repVar.getSucceedingOperators())
      oidt.getOperator().removePrecedingOperator(repVar);

    for (final BasicOperator bo : repVar.getPrecedingOperators()) {
      final TriplePattern tp = (TriplePattern) bo; // this has been
      // checked in
      // checkPrecondition
      // Already checked in checkPrecondition: All variables in tp can be
      // replaced!
      for (final Variable v : tp.getVariables()) {
        final Variable rv = repVar.getReplacement(v);
        tp.replace(v, rv);
      }
      final List<OperatorIDTuple> list = new LinkedList<OperatorIDTuple>();
      list.addAll(repVar.getSucceedingOperators());
      tp.setSucceedingOperators(list);
      for (final OperatorIDTuple oidt : repVar.getSucceedingOperators())
        oidt.getOperator().addPrecedingOperator(tp);
    }

    // rootOperator.deleteParents();
View Full Code Here

    for (int i = 0; i < generates.size(); i++) {
      System.out.println("Connects Generate number " + i);
      final Generate generate = generates.get(i);
      final LinkedList<OperatorIDTuple> possiblePats = new LinkedList<OperatorIDTuple>();

      TriplePattern pat;
      for (int a = 0; a < pats.size(); a++) {
        pat = (TriplePattern) pats.get(a).getOperator();
        if (matchPossible(generate.getValueOrVariable(), pat.getItems())) {
          possiblePats.add(new OperatorIDTuple(pat, 0));
          pat.addPrecedingOperator(generate);
        }
      }
      if (possiblePats.size() > 0) {
        try {
          Thread.sleep(50);
        } catch (final InterruptedException e) {
          System.err.println(e);
          e.printStackTrace();
        }
        System.out.println(generate.toString() + "----"
            + possiblePats.toString());
        generate.setSucceedingOperators(possiblePats);
        for (int p = 0; p < possiblePats.size(); p++) {
          pat = (TriplePattern) possiblePats.get(p).getOperator();
          pat.addPrecedingOperator(generate);
        }
      } else {
        generate
            .setSucceedingOperators(new LinkedList<OperatorIDTuple>());
      }
View Full Code Here

              }
            } else {
              items[i] = currentItem;
            }
          }
          tps_new.add(new TriplePattern(items));         
        }
        BasicIndexScanOptional.this.indexScanOperator.setTriplePatterns(tps_new);
        if(BasicIndexScanOptional.this.indexScanOperator instanceof RDF3XIndexScan){
          ((RDF3XIndexScan)BasicIndexScanOptional.this.indexScanOperator).setCollationOrder((Collection<Variable>)null);
        }
View Full Code Here

          if (indicesC != null && indicesC.size() > 1) {
            // deal with special case: several default graphs!
            if (this.triplePatterns.size() != 1) {
              System.err.println("Can only process one triple pattern!");
            }
            final TriplePattern tp = this.triplePatterns.iterator()
                .next();
            final Triple key = getKey(tp, null);
            final Triple keyMinimum = this.getKeyMinimum(tp, null);
            final Triple keyMaximum = this.getKeyMaximum(tp, null);
View Full Code Here

  public QueryResult join(final Indices indices, final Bindings bindings) {
    final SixIndices sixIndices = (SixIndices) indices;
    if (this.triplePatterns.size() != 1) {
      System.err.println("Can only process one triple pattern!");
    }
    final TriplePattern tp = this.triplePatterns.iterator().next();
    final Triple key = getKey(tp, bindings);
    final Triple keyMinimum = this.getKeyMinimum(tp, bindings);
    final Triple keyMaximum = this.getKeyMaximum(tp, bindings);
    final Iterator<Triple> it = this.getIterator(sixIndices, key, keyMinimum,
        keyMaximum);

    if (!it.hasNext()) {
      return null;
    }

    return QueryResult.createInstance(it, tp, this.collationOrder, tp
        .getBloomFilters() != null);
  }
View Full Code Here

  private void optimizeJoinOrderAccordingToMostRestrictionsForMergeJoin() {
    final Collection<TriplePattern> remainingTP = new LinkedList<TriplePattern>();
    remainingTP.addAll(this.triplePatterns);
    final Collection<TriplePattern> newTriplePattern = new LinkedList<TriplePattern>();
    while (remainingTP.size() > 1) {
      TriplePattern best1 = null;
      TriplePattern best2 = null;
      int minOpenPositions = 4;
      for (final TriplePattern tp1 : remainingTP) {
        for (final TriplePattern tp2 : remainingTP) {
          if (!tp1.equals(tp2)) {
            final HashSet<String> v = tp1.getVariableNames();
View Full Code Here

TOP

Related Classes of lupos.engine.operators.tripleoperator.TriplePattern

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.