Package javolution.util

Examples of javolution.util.FastList$Node


  @Override
  public Object evaluate(final ASTFunctionCall node, final Bindings b, final Map<Node, Object> d) throws TypeErrorException, NotBoundException {
    final Literal name = LazyLiteral.getLiteral(node.jjtGetChild(0));
    final ExternalFunction externalFunction = EvaluationVisitorImplementation.externalFunctions.get(name);
    if(externalFunction!=null){
      final Node child1 = node.jjtGetChild(1);
      final int number = child1.jjtGetNumChildren();
      final Object[] args = new Object[number];
      for(int i=0; i<number; i++){
        args[i] = child1.jjtGetChild(i).accept(this, b, d);
      }
      return externalFunction.evaluate(args);
    }
    if (name.toString().startsWith("<http://www.w3.org/2001/XMLSchema#")) {
      return Helper.cast(name.toString(), this.resultOfChildZero(node.jjtGetChild(1), b, d));
View Full Code Here


      final Map<Node, Object> d) throws NotBoundException, TypeErrorException {
    if (node.jjtGetNumChildren() == 0) {
      return "";
    }
    // jump over ASTExpressionList!
    final Node child0 = node.jjtGetChild(0);
    if (child0 instanceof ASTNIL || child0.jjtGetNumChildren() == 0) {
      return "";
    }
    Object result = Helper.unlazy(child0.jjtGetChild(0).accept(this, b, d));
    if (Helper.isNumeric(result)) {
      return null;
    }
    for (int i = 1; i < child0.jjtGetNumChildren(); i++) {

      final Object child = Helper.unlazy(child0.jjtGetChild(i).accept(this, b, d));

      if (Helper.isNumeric(child)) {
        return null;
      }
View Full Code Here

      return !this.handleInAndNotIn(node, b, d);
  }

  protected boolean handleInAndNotIn(final Node node, final Bindings b, final Map<Node, Object> d) throws NotBoundException, TypeErrorException {
    final Object arg1 = Helper.unlazy(this.resultOfChildZero(node, b, d));
    final Node child1 = node.jjtGetChild(1);
    for(int i=0; i<child1.jjtGetNumChildren(); i++) {
      final Object arg2 = Helper.unlazy(child1.jjtGetChild(i).accept(this, b, d));
      if(Helper.equals(arg1, arg2)) {
        return true;
      }
    }
    return false;
View Full Code Here

    }
  }

  @Override
  public Object evaluate(final ASTCoalesceFuncNode node, final Bindings b, final Map<Node, Object> d) throws NotBoundException, TypeErrorException {
    final Node child0 = node.jjtGetChild(0);
    for(int i=0; i<child0.jjtGetNumChildren(); i++){
      try {
        return Helper.unlazy(child0.jjtGetChild(i).accept(this, b, d));
      } catch(final Error e){
        // ignore...
      } catch(final Exception e){
        // ignore...
      }
View Full Code Here

  public void visit(final ASTWindow node, final OperatorConnection connection, final Item graphConstraint) {
    ASTType.TYPE dot = ASTType.TYPE.TRIPLES;
    int slidingNumber = 10;
    Literal iri = null;
    for (int i = 0; i < node.jjtGetNumChildren(); i++) {
      final Node n = node.jjtGetChild(i);
      if (n instanceof ASTType) {
        dot = ((ASTType) n).getType();
        slidingNumber = ((ASTType) n).getValue();
        if(dot == ASTType.TYPE.INSTANCESDURATION || dot == ASTType.TYPE.INSTANCESNUMBER){
          iri = ((ASTQuotedURIRef)n.jjtGetChild(0)).getLiteral(true);
        }
      }
    }
    final Window window;
    switch(dot){
      default:
      case TRIPLES:
        window = new WindowTriples(slidingNumber);
        break;
      case DURATION:
        window = new WindowDuration(slidingNumber);
        break;
      case INSTANCESNUMBER:
        window = new WindowInstancesNumber(slidingNumber, iri);
        break;
      case INSTANCESDURATION:
        window = new WindowInstancesDuration(slidingNumber, iri);
        break;
    }
    if (this.indexScanCreator_Stream.getStream() == null) {
      System.out.println("Query uses Window operations, but did not define a stream, asssuming STREAM INTERMEDIATERESULT TRIPLES 1");
      final CollectResult cr = new CollectResult(false);
      this.result.addApplication(cr);
      this.indexScanCreator_Stream.setStream(new StreamTriples(cr, 1));
    }
    this.indexScanCreator_Stream.getStream().addSucceedingOperator(new OperatorIDTuple(window, 0));
    final PatternMatcher currentPatternMatcher = new PatternMatcher();
    window.addSucceedingOperator(new OperatorIDTuple(currentPatternMatcher, 0));
    final PatternMatcher oldPatternMatcher = this.indexScanCreator_Stream.getCurrentPatternMatcher();
    this.indexScanCreator_Stream.setCurrentPatternMatcher(currentPatternMatcher);
    for (int i = 0; i < node.jjtGetNumChildren(); i++) {
      final Node n = node.jjtGetChild(i);
      if (!(n instanceof ASTType)) {
        n.accept(this, connection, graphConstraint);
      }
    }
    this.indexScanCreator_Stream.setCurrentPatternMatcher(oldPatternMatcher);
  }
View Full Code Here

        this.visit((ASTStream)node.jjtGetChild(i));
      }
    }

    int index;
    final Node child0 = node.jjtGetChild(0);
    if(child0 instanceof ASTConstructTemplate){
      this.setGraphConstraints(child0, connection);
      index=1;
    } else {
      index=0;
      for (int i = index; i < node.jjtGetNumChildren(); i++) {
        final Node childi = node.jjtGetChild(i);
        if(childi instanceof ASTGroupConstraint) {
          this.setGraphConstraints(childi, connection);
        }
      }
    }
    for (int i = index; i < node.jjtGetNumChildren(); i++) {
      final Node childi = node.jjtGetChild(i);
      if(childi instanceof ASTGroupConstraint) {
        childi.accept(this, connection, null);
      } else {
        if(!(childi instanceof ASTStream)){
          childi.accept(this, connection);
        }
      }
    }
  }
View Full Code Here

      final Construct c = new Construct();
      c.setTemplates(operators);
      graphConstructs.add(new Tuple<Construct, Item>(c, null));
    }
    for(int i=0; i<node.jjtGetNumChildren();i++){
      final Node child = node.jjtGetChild(i);
      if(child instanceof ASTGraphConstraint){
        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);
            }
          } else if(childchild instanceof ASTVar){
            item = new Variable(((ASTVar)childchild).getName());
View Full Code Here

  }

  public Collection<TriplePattern> collectTriplePatternOfChildren(final Node node){
    final Collection<TriplePattern> resultantTriplePatterns = new LinkedList<TriplePattern>();
    for(int i=0; i<node.jjtGetNumChildren(); i++){
      final Node child = node.jjtGetChild(i);
      if(child instanceof ASTTripleSet){
        resultantTriplePatterns.add(this.getTriplePattern((ASTTripleSet)child));
      }
    }
    return resultantTriplePatterns;
View Full Code Here

  public TriplePattern getTriplePattern(final ASTTripleSet node) {
    final Item[] item = { null, null, null };

    for (int i = 0; i < 3; i++) {
      final Node n = node.jjtGetChild(i);
      if(n instanceof ASTObjectList){
        item[i] = getItem(n.jjtGetChild(0));
      } else {
        item[i] = getItem(n);
      }
    }
    final TriplePattern tpe = new TriplePattern(item[0], item[1], item[2]);
View Full Code Here

          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;
        }
        final Node objectNode = tripleSet.jjtGetChild(2);
        final ReplaceVar replaceVar = new ReplaceVar();
        replaceVar.addSubstitution(object, subject);
        final Variable variable = this.getVariable(subject.toString(), object.toString(), "interimVariable");
        replaceVar.addSubstitution(variable, object);
        if(graphConstraint!=null && graphConstraint.isVariable() && !graphConstraint.equals(getItem(subjectNode)) && !graphConstraint.equals(getItem(objectNode))) {
View Full Code Here

TOP

Related Classes of javolution.util.FastList$Node

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.