Package lupos.datastructures.items

Examples of lupos.datastructures.items.Variable


        // graph is used)
        if (graphConstraintItem != null) {

          if (graphConstraintItem instanceof Variable) {

            final Variable graphConstraint = (Variable) graphConstraintItem;

            // check if named graphs were provided at query time
            if (this.root.namedGraphs != null
                && this.root.namedGraphs.size() > 0) {
View Full Code Here


  protected static String getKey(final TriplePattern tp) {
    final HashMap<Variable, Variable> alreadyUsedVariables = new HashMap<Variable, Variable>();
    String key = "";
    for (int i = 0; i < 3; i++) {
      if (tp.getPos(i).isVariable()) {
        Variable v = alreadyUsedVariables.get(tp.getPos(i));
        if (v == null) {
          v = new Variable("" + alreadyUsedVariables.size());
          alreadyUsedVariables.put((Variable) tp.getPos(i), v);
        }
        key += v.toString();
      } else {
        if (tp.getPos(i) instanceof LazyLiteralOriginalContent) {
          key += "\""
              + ((LazyLiteralOriginalContent) tp.getPos(i))
                  .getCodeOriginalContent() + "\"";
View Full Code Here

    if(filter.getPrecedingOperators().size()>1)
      return false;
   
    do {
   
      Variable v=add.getVar();
      Literal l=add.getLiteral();
     
      lupos.sparql1_1.Node n = filter.getNodePointer();
      if (n.jjtGetNumChildren() > 0) {
        n = n.jjtGetChild(0);
        if (n instanceof lupos.sparql1_1.ASTEqualsNode) {
          lupos.sparql1_1.Node left = n.jjtGetChild(0);
          lupos.sparql1_1.Node right = n.jjtGetChild(1);
          if (right instanceof lupos.sparql1_1.ASTVar) {
            final lupos.sparql1_1.Node tmp = left;
            left = right;
            right = tmp;
          }
          if (left instanceof lupos.sparql1_1.ASTVar) {
            final String varname = ((lupos.sparql1_1.ASTVar) left)
                .getName();
            Variable var = new Variable(varname);
            VariableInInferenceRule varInference = new VariableInInferenceRule(varname);
 
            if (right instanceof lupos.sparql1_1.ASTQName
                || right instanceof lupos.sparql1_1.ASTQuotedURIRef
                || right instanceof lupos.sparql1_1.ASTFloatingPoint
                || right instanceof lupos.sparql1_1.ASTInteger
                || right instanceof lupos.sparql1_1.ASTStringLiteral
                || right instanceof lupos.sparql1_1.ASTDoubleCircumflex) {
              Literal constant = LazyLiteral.getLiteral(right);
             
              if(var.equals(v) || varInference.equals(v)){
                if(!l.equals(constant))
                  return true;
              }
             
            } else return false;
View Full Code Here

        .getSubstitutionsVariableRight();
    final LinkedList<Variable> rep2VarsRight = rep2
        .getSubstitutionsVariableRight();
    final LinkedList<Variable> rep2VarsLeft = rep2
        .getSubstitutionsVariableLeft();
    Variable var;
    int index = -1;
    for (int i = 0; i < rep2VarsRight.size(); i++) {
      var = rep2VarsRight.get(i);
      index = rep1VarsLeft.indexOf(var);
      // No transitivity
View Full Code Here

        if (rightNode instanceof lupos.sparql1_1.ASTVar
            && leftNode instanceof lupos.sparql1_1.ASTVar) {

          // both variables must be the same ones as in the 2 Add
          // operators...
          final Variable leftFilterVar = new Variable(
              ((lupos.sparql1_1.ASTVar) leftNode).getName());
          final Variable rightFilterVar = new Variable(
              ((lupos.sparql1_1.ASTVar) rightNode).getName());
          if ((add1.getVar().equalsNormalOrVariableInInferenceRule(
              leftFilterVar) && add2.getVar()
              .equalsNormalOrVariableInInferenceRule(
                  rightFilterVar))
View Full Code Here

        }
        final Bindings bnew = Projection.this.bindingsFactory.createInstance();

        final Iterator<Variable> it = Projection.this.s.iterator();
        while (it.hasNext()) {
          final Variable elem = it.next();
          bnew.add(elem, bind1.get(elem));
        }
        bnew.addAllTriples(bind1);
        bnew.addAllPresortingNumbers(bind1);
        return bnew;
View Full Code Here

        // graph is used)
        if (graphConstraintItem != null) {

          if (graphConstraintItem instanceof Variable) {

            final Variable graphConstraint = (Variable) graphConstraintItem;

            // check if named graphs were provided at query time
            if (this.root.namedGraphs != null
                && this.root.namedGraphs.size() > 0) {

              // Convert the named graphs' names into URILiterals
              // to be applicable
              // later on
              for (final String name : this.root.namedGraphs) {

                final Indices indices = this.root.dataset
                    .getNamedGraphIndices(LiteralFactory
                        .createURILiteralWithoutLazyLiteral(name));

                final URILiteral rdfName = indices.getRdfName();
                if (namedGraphs.contains(rdfName)) {
                  final TriplePattern ztp = new TriplePattern(
                      graphConstraint
                          .equals(tp.getPos(0)) ? rdfName
                          : tp.getPos(0),
                      graphConstraint
                          .equals(tp.getPos(1)) ? rdfName
                          : tp.getPos(1),
                      graphConstraint
                          .equals(tp.getPos(2)) ? rdfName
                          : tp.getPos(2));
                  final Triple zkey = getKey(ztp, null);
                  final Literal intermediateMax = this.getMaxLiteral(
                      (SixIndices) indices, zkey, pos);
                  if (intermediateMax != null
                      && (max == null || max
                          .compareToNotNecessarilySPARQLSpecificationConform(intermediateMax) < 0)) {
                    max = intermediateMax;
                  }
                }

              }

            }

            // otherwise there might have been named graphs added
            // during the evaluation
            else {

              // get all indices of named graphs and bind them to
              // the graph constraint
              final Collection<Indices> dataSetIndices = this.root.dataset
                  .getNamedGraphIndices();
              if (dataSetIndices != null) {

                for (final Indices indices : dataSetIndices) {
                  final TriplePattern ztp = new TriplePattern(
                      graphConstraint
                          .equals(tp.getPos(0)) ? indices
                          .getRdfName()
                          : tp.getPos(0),
                      graphConstraint
                          .equals(tp.getPos(1)) ? indices
                          .getRdfName()
                          : tp.getPos(1),
                      graphConstraint
                          .equals(tp.getPos(2)) ? indices
                          .getRdfName()
                          : tp.getPos(2));
                  final Triple zkey = getKey(ztp, null);
                  final Literal intermediateMax = this.getMaxLiteral(
View Full Code Here

        .getSubstitutionsVariableRight();
    final LinkedList<Variable> repLitLeft = repLit
        .getSubstitutionsLiteralLeft();
    final LinkedList<Literal> repLitRight = repLit
        .getSubstitutionsLiteralRight();
    Variable var;
    int index = -1;
    for (int i = 0; i < repVarRight.size(); i++) {
      var = repVarRight.get(i);
      index = repLitLeft.indexOf(var);
      // (x,<a>),(y,x) => (x,<a>),(y,<a>)
      if (index > -1) {
        final Variable var2 = repVarLeft.get(i);
        repVar_new.removeSubstitution(var2, var);
        repLit_new.addSubstitution(var2, repLitRight.get(index));
      }
    }
View Full Code Here

          // graph is used)
          if (graphConstraintItem != null) {

            if (graphConstraintItem instanceof Variable) {

              final Variable graphConstraint = (Variable) graphConstraintItem;

              // check if named graphs were provided at query time
              if (this.root.namedGraphs != null
                  && this.root.namedGraphs.size() > 0) {

                // Convert the named graphs' names into
                // URILiterals
                // to be applicable
                // later on
                for (final String name : this.root.namedGraphs) {

                  final Indices indices = this.root.dataset
                      .getNamedGraphIndices(LiteralFactory
                          .createURILiteralWithoutLazyLiteral(name));

                  final URILiteral rdfName = indices
                      .getRdfName();
                  if (namedGraphs.contains(rdfName)) {
                    final TriplePattern ztp = new TriplePattern(
                        graphConstraint.equals(tp
                            .getPos(0)) ? rdfName
                            : tp.getPos(0),
                        graphConstraint.equals(tp
                            .getPos(1)) ? rdfName
                            : tp.getPos(1),
                        graphConstraint.equals(tp
                            .getPos(2)) ? rdfName
                            : tp.getPos(2));
                    final Triple zkey = getKey(ztp, null);
                    final Triple keyMinimum = this.getKey(ztp,
                        null, minima);
                    final Triple keyMaximum = this.getKey(ztp,
                        null, maxima);

                    final VarBucket vb = this.getVarBucket(v,
                        ztp, zkey, keyMinimum,
                        keyMaximum,
                        (SixIndices) indices);
                    if (vb != null) {
                      final VarBucket previous_vb = result
                          .get(v);
                      if (previous_vb != null) {
                        vb.add(previous_vb);
                      }
                      vb.minimum = (minima == null) ? null
                          : minima.get(v);
                      vb.maximum = (maxima == null) ? null
                          : maxima.get(v);
                      result.put(v, vb);
                    }
                  }

                }

              }

              // otherwise there might have been named graphs
              // added
              // during the evaluation
              else {

                // get all indices of named graphs and bind them
                // to
                // the graph constraint
                final Collection<Indices> dataSetIndices = this.root.dataset
                    .getNamedGraphIndices();
                if (dataSetIndices != null) {

                  for (final Indices indices : dataSetIndices) {
                    final TriplePattern ztp = new TriplePattern(
                        graphConstraint.equals(tp
                            .getPos(0)) ? indices
                            .getRdfName() : tp
                            .getPos(0),
                        graphConstraint.equals(tp
                            .getPos(1)) ? indices
                            .getRdfName() : tp
                            .getPos(1),
                        graphConstraint.equals(tp
                            .getPos(2)) ? indices
                            .getRdfName() : tp
                            .getPos(2));
                    final Triple zkey = getKey(ztp, null);
                    final Triple keyMinimum = this.getKey(ztp,
View Full Code Here

      vars.retainAll(joinPartners);
      if(vars.size()>0) {
        final Map<Variable, Tuple<Literal, Literal>> localExtrema = indexScan.getMinMax(tp, vars);
        if(localExtrema!=null){
          for(final Entry<Variable, Tuple<Literal, Literal>> entry: localExtrema.entrySet()){
            final Variable var = entry.getKey();
            final Literal min = minima.get(var);
            final Literal otherMin = entry.getValue().getFirst();
            if(min==null || min.compareToNotNecessarilySPARQLSpecificationConform(otherMin)>0) {
              minima.put(var, otherMin);
            }
View Full Code Here

TOP

Related Classes of lupos.datastructures.items.Variable

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.