Package lupos.datastructures.items

Examples of lupos.datastructures.items.Item


        final Collection<TriplePattern> otp = this.collectTriplePatternOfChildren(child);
        if(otp.size()>0){
          final Construct c2 = new Construct();
          c2.setTemplates(otp);
          final Node childchild=child.jjtGetChild(0);
          Item item=null;
          if (childchild instanceof ASTQuotedURIRef) {
            try {
              item=LiteralFactory.createURILiteralWithoutLazyLiteral("<"+ childchild.toString() + ">");
            } catch (final Exception e) {
              System.err.println(e);
View Full Code Here


  protected void createMultipleOccurence(final ASTTripleSet tripleSet, final OperatorConnection connection, final Item graphConstraint) {
    if(USE_CLOSURE_AND_PATHLENGTHZERO_OPERATORS){
      try{
        Variable subject;
        Variable object;
        Item realSubject = null;
        Item realObject = null;
        boolean subjectIsALiteral = false;
        boolean objectIsALiteral = false;
        Item itm = getItem(tripleSet.jjtGetChild(0));
        if (!itm.isVariable()){
          subject = this.getVariable(getItem(tripleSet.jjtGetChild(0)).toString(), getItem(tripleSet.jjtGetChild(2)).toString(), "interimSubject");
          realSubject = itm;
          subjectIsALiteral = true;
        } else {
          subject = (Variable) itm;
        }
        final Node subjectNode = tripleSet.jjtGetChild(0);

        itm = getItem(tripleSet.jjtGetChild(2));
        if (!itm.isVariable()){
          object = this.getVariable(getItem(tripleSet.jjtGetChild(0)).toString(), getItem(tripleSet.jjtGetChild(2)).toString(), "interimObject");
          realObject = itm;
          objectIsALiteral = true;
        } else {
          object = (Variable) itm;
        }
        final Node objectNode = tripleSet.jjtGetChild(2);


        final Node predicateNode = tripleSet.jjtGetChild(1);
        final BasicOperator startingOperator = predicateNode.accept(this, connection, graphConstraint, subject, object, subjectNode, objectNode);

        if(!subjectIsALiteral && !objectIsALiteral){
          startingOperator.addSucceedingOperator(connection.getOperatorIDTuple());
        }
        else
          if(subjectIsALiteral && !objectIsALiteral){
            final Filter filter = new Filter("(" + subject + " = " + realSubject +")");
            final Projection projection = new Projection();
            projection.addProjectionElement(object);
            if(graphConstraint!=null && graphConstraint.isVariable() && !graphConstraint.equals(getItem(subjectNode)) && !graphConstraint.equals(getItem(objectNode))) {
              projection.addProjectionElement((Variable)graphConstraint);
            }

            filter.addSucceedingOperator(new OperatorIDTuple(projection,0));
            projection.addSucceedingOperator(connection.getOperatorIDTuple());
            startingOperator.addSucceedingOperator(new OperatorIDTuple(filter,0));

          }
          else
            if(!subjectIsALiteral && objectIsALiteral){
              final Filter filter = new Filter("(" + object + " = " + realObject + ")");
              final Projection projection = new Projection();
              projection.addProjectionElement(subject);
              if(graphConstraint!=null && graphConstraint.isVariable() && !graphConstraint.equals(getItem(subjectNode)) && !graphConstraint.equals(getItem(objectNode))) {
                projection.addProjectionElement((Variable)graphConstraint);
              }

              filter.addSucceedingOperator(new OperatorIDTuple(projection,0));
              projection.addSucceedingOperator(connection.getOperatorIDTuple());
              startingOperator.addSucceedingOperator(new OperatorIDTuple(filter,0));

            }
            else
              if(subjectIsALiteral && objectIsALiteral){
                final Filter firstFilter = new Filter("(" + object + " = " + realObject + ")");
                final Filter secondFilter = new Filter("(" + subject + " = " + realSubject + ")");
                final Projection firstProjection = new Projection();
                firstProjection.addProjectionElement(subject);
                if(graphConstraint!=null && graphConstraint.isVariable() && !graphConstraint.equals(getItem(subjectNode)) && !graphConstraint.equals(getItem(objectNode))) {
                  firstProjection.addProjectionElement((Variable)graphConstraint);
                }
                final Projection secondProjection = new Projection();
                secondProjection.addProjectionElement(object);
                if(graphConstraint!=null && graphConstraint.isVariable() && !graphConstraint.equals(getItem(subjectNode)) && !graphConstraint.equals(getItem(objectNode))) {
                  secondProjection.addProjectionElement((Variable)graphConstraint);
                }

                firstFilter.addSucceedingOperator(new OperatorIDTuple(firstProjection,0));
                firstProjection.addSucceedingOperator(new OperatorIDTuple(secondFilter, 0));
                secondFilter.addSucceedingOperator(new OperatorIDTuple(secondProjection,0));
                secondProjection.addSucceedingOperator(connection.getOperatorIDTuple());
                startingOperator.addSucceedingOperator(new OperatorIDTuple(firstFilter,0));
              }
      }
      catch( final Exception e){
        e.printStackTrace();
        System.out.println(e);
      }
    } else {
      // alternative way to evaluate (...)?, (...)* and (...)+ without using the Closure and PathLengthZero operators!
      try{
        Variable subject;
        Variable object;
        Item realSubject = null;
        Item realObject = null;
        boolean subjectIsALiteral = false;
        boolean objectIsALiteral = false;
        Item itm = getItem(tripleSet.jjtGetChild(0));
        if (!itm.isVariable()){
          subject = this.getVariable(getItem(tripleSet.jjtGetChild(0)).toString(), getItem(tripleSet.jjtGetChild(2)).toString(), "interimSubject");
          realSubject = itm;
          subjectIsALiteral = true;
        } else {
          subject = (Variable) itm;
        }
        final Node subjectNode = tripleSet.jjtGetChild(0);
        itm = getItem(tripleSet.jjtGetChild(2));
        if (!itm.isVariable()){
          object = this.getVariable(getItem(tripleSet.jjtGetChild(0)).toString(), getItem(tripleSet.jjtGetChild(2)).toString(), "interimObject");
          realObject = itm;
          objectIsALiteral = true;
        } else {
          object = (Variable) itm;
View Full Code Here

    }
  }

  private Set<Literal> getSetOfLiterals(final Node node){
    Set<Literal> allowedLiterals = null;
    final Item item = getItem(node);
    if(!item.isVariable()){
      allowedLiterals = new HashSet<Literal>();
      allowedLiterals.add((Literal) item);
    }
    return allowedLiterals;
  }
View Full Code Here

  protected boolean isGeneratedFromIndexScanOperator(final Bindings bindingsToCheck){
    for(final TriplePattern tp: this.basicIndex.getTriplePattern()){
      final Literal[] literals = new Literal[3];
      for(int i=0; i<3; i++){
        final Item item = tp.getPos(i);
        if(item.isVariable()){
          final Variable var = (Variable) item;
          final Literal literal = bindingsToCheck.get(var);
          if(literal == null){
            return false;
          }
View Full Code Here

    final Collection<TriplePattern> bindPattern = new ArrayList<TriplePattern>();
    for (final TriplePattern tp : pattern) {
      final TriplePattern newPat = new TriplePattern();
      int i = 0;
      for (final Item item : tp.getItems()) {
        Item toSet = null;
        if (item.isVariable() && bind.getVariableSet().contains(item))
          toSet = item.getLiteral(bind);
        else
          toSet = item;
        newPat.setPos(toSet, i++);
View Full Code Here

  protected void processIndexScan(final QueryResult result, final Bindings bind) {
    final Item[] newItems = new Item[this.predicatePattern.getPatternItems()
        .size()];
    int i = 0;
    for (final Item item : this.predicatePattern.getPatternItems()) {
      Item toSet = null;
      if (item.isVariable() && bind.getVariableSet().contains(item)) {
        toSet = item.getLiteral(bind);
      } else {
        toSet = item;
      }
View Full Code Here

      }

      @Override
      public Item next() {
        if(this.next!=null){
          final Item zNext = this.next;
          this.next = null;
          return zNext;
        }
        return this.iterator.next();
      }
View Full Code Here

  }

  private static boolean isMatching(final TriplePattern tp, final Item[] generateItems){
    boolean flag=true;
    for(int i=0; i<3; i++){
      final Item a = generateItems[i];
      final Item b = tp.getPos(i);
      if(!a.isVariable() && !b.isVariable() && !a.equals(b)){
        flag=false;
        break;
      }
    }
    return flag;
View Full Code Here

TOP

Related Classes of lupos.datastructures.items.Item

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.