Package lupos.datastructures.items.literal

Examples of lupos.datastructures.items.literal.URILiteral


  public Object evaluate(Bindings binding, Object optionalResult) {
    return evaluate(binding, optionalResult, null);
  }

  public Object evaluate(Bindings binding, Object optionalResult, Multimap<IExpression, IExpression> equalities) {
    final URILiteral name = (URILiteral) ((Constant) termName).getLiteral();
    // Definiert?
    if (!RIFBuiltinFactory.isDefined(name))
      throw new RIFException("Builtin " + name.toString()
          + " not defined!");
    // Bindung notwendig?
    // if (!doBind
    // && !(Sets
    // .intersection(getVariables(), binding.getVariableSet())
View Full Code Here


      LazyLiteral.setHm(new StringIntegerMapJava(simap));

      final StringArray ismap = new StringArray();
      LazyLiteral.setV(ismap);

      final URILiteral defaultGraph = new StringURILiteral("<http://localhost/default>");
      // just for inserting it into the codemap:
      defaultGraph.createThisLiteralNew();

      final Indices indices = new SixIndices(defaultGraph, true);

      // write out index info
View Full Code Here

            .getV(), CodeMapURILiteral.getHm(), in);
      }
    }
    int number = InputHelper.readLuposInt(in);
    for (int i = 0; i < number; i++) {
      final URILiteral uri = (URILiteral) LiteralFactory.readLuposLiteral(in);
      final Indices indices = this.indicesFactory.createIndices(uri);
      indices.readIndexInfo(in);
      this.defaultGraphData.put(uri, indices);
    }
    number = InputHelper.readLuposInt(in);
    for (int i = 0; i < number; i++) {
      final URILiteral uri = (URILiteral) LiteralFactory.readLuposLiteral(in);
      final Indices indices = this.indicesFactory.createIndices(uri);
      indices.readIndexInfo(in);
      this.namedGraphData.put(uri, indices);
    }
  }
View Full Code Here

  @SuppressWarnings("unchecked")
  public static void _main(final QueryEvaluator evaluator,
      final String datafile, final String queryfile) {
    try {
      final URILiteral rdfURL = LiteralFactory
          .createURILiteralWithoutLazyLiteral("<file:" + datafile
              + ">");
      final Collection<URILiteral> defaultGraphs = new LinkedList<URILiteral>();
      final Collection<URILiteral> namedGraphs = new LinkedList<URILiteral>();
      defaultGraphs.add(rdfURL);

      Collection<String> queryFiles;
      if (evaluator.multiplequeries) {
        queryFiles = FileHelper.readFileToCollection(queryfile);
      } else {
        queryFiles = new LinkedList<String>();
        queryFiles.add(queryfile);
      }

      // dataset is given from command line
      if (evaluator.dataset.compareTo("") != 0) {
        // copy RDF name in dataset to the static variable dataset
        final BufferedReader br = new BufferedReader(new FileReader(
            evaluator.dataset));
        while (br.ready()) {
          String rdf = br.readLine();
          // System.out.println(rdf);

          while (br.ready() && (rdf.length() > 0)
              && rdf.substring(0, 1).compareTo("*") == 0) {
            rdf = br.readLine();
            // System.out.println(query);
          }

          if ((rdf.length() > 0)
              && (rdf.substring(0, 1).compareTo("*") != 0)) {
            final String[] s = rdf.split(" ");
            if (s.length > 0) {
              boolean defaultGraph;
              String url;
              if (s.length == 1) {
                defaultGraph = true;
                url = s[0];
              } else {
                url = s[1];
                if (s[0].compareTo("named") == 0
                    || s[0].compareTo("named:") == 0)
                  defaultGraph = false;
                else
                  defaultGraph = true;
              }
              final URILiteral rdfURL2 = LiteralFactory
                  .createURILiteralWithoutLazyLiteral("<file:"
                      + url + ">");

              if (defaultGraph)
                defaultGraphs.add(rdfURL2);
              else
                namedGraphs.add(rdfURL2);
            }
          }

        }
      }

      if (evaluator.compare != compareEvaluator.NONE) {
        String[] argsCompareEngine = evaluator.compareoptions
            .split("[\b]|[\t]|[\f]|[\n]|[\r]| ");
        for (int i = 0; i < argsCompareEngine.length; i++) {
          if (argsCompareEngine[i].compareTo("--compare") == 0
              || argsCompareEngine[i]
                  .compareTo("--compareoptions") == 0
              || argsCompareEngine[i].compareTo("--times") == 0) {
            System.out.println("The option " + argsCompareEngine[i]
                + " must not be nested in a compare option!");
            return;
          }
        }

        String compareDataFile = datafile;

        Collection<URILiteral> compareDefaultGraphs = defaultGraphs;
        Collection<URILiteral> compareNamedGraphs = namedGraphs;
        // final Collection<String> compareQueryFiles = queryFiles;
        if (!argsCompareEngine[0].startsWith("--")) {
          compareDataFile = argsCompareEngine[0];
          final URILiteral compareRdfURL = LiteralFactory
              .createURILiteralWithoutLazyLiteral("<file:"
                  + compareDataFile + ">");
          compareDefaultGraphs = new LinkedList<URILiteral>();
          compareNamedGraphs = new LinkedList<URILiteral>();
          compareDefaultGraphs.add(compareRdfURL);
View Full Code Here

              for (final String name : this.root.namedGraphs) {

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

                final Bindings graphConstraintBindings = this.bindingsFactory.createInstance();
                final URILiteral rdfName = indices.getRdfName();
                graphConstraintBindings.add(graphConstraint, rdfName);
                if (queryResult == null) {
                  queryResult = QueryResult.createInstance(new AddConstantBindingIterator(graphConstraint, rdfName, this.join(indices,
                      graphConstraintBindings).oneTimeIterator()));
                } else {
View Full Code Here

    this.getArgs().set("sortduringindexconstruction", Dataset.SORT.STRINGSEARCHTREE);
    this.getArgs().set("loadindexinfo", true);
    this.init();

    // load indices!
    final URILiteral rdfURL = LiteralFactory.createStringURILiteral("<file:" + datafile + ">");
    final LinkedList<URILiteral> defaultGraphs = new LinkedList<URILiteral>();
    defaultGraphs.add(rdfURL);
    log.info("Load indices...");
    this.prepareInputData(defaultGraphs, new LinkedList<URILiteral>());
    log.debug("Indices loaded with {} in the codemap and {} triples in the evaluation indices! ",
View Full Code Here

                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(
                      (SixIndices) indices, zkey, pos);
                  if (intermediateMax != null
                      && (max == null || max
                          .compareToNotNecessarilySPARQLSpecificationConform(intermediateMax) < 0)) {
                    max = intermediateMax;
                  }
                }
              }
            }
          }

          // if the graph constraint is an URILiteral fetch the
          // matching indices object
          // but do not bind anything
          else {
            for (final Indices indices : indicesC) {

              final URILiteral rdfName = indices.getRdfName();
              if (namedGraphs.contains(rdfName)) {
                final Literal intermediateMax = this.getMaxLiteral(
                    (SixIndices) indices, key, pos);
                if (intermediateMax != null
                    && (max == null || max
View Full Code Here

                  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,
                        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);
                    }
                  }
                }
              }
            }

            // if the graph constraint is an URILiteral fetch the
            // matching indices object
            // but do not bind anything
            else {
              final Triple keyMinimum = this.getKey(tp, null, minima);
              final Triple keyMaximum = this.getKey(tp, null, maxima);
              for (final Indices indices : indicesC) {

                final URILiteral rdfName = indices.getRdfName();
                if (namedGraphs.contains(rdfName)) {
                  final VarBucket vb = this.getVarBucket(v, tp,
                      key, keyMinimum, keyMaximum,
                      (SixIndices) indices);
                  if (vb != null) {
View Full Code Here

            ((ParallelIterator<Bindings>)this.it).close();
          }
        }

        private Iterator<Bindings> getNextIteratorQueryResult(){
          final URILiteral endpointURI = this.nextEndpoint();
          if(endpointURI==null){
            return null;
          }
          final String uri = endpointURI.getString();
          try {
            return FederatedQueryWithSucceedingJoin.addEndpointVariable((Variable)endpoint, endpointURI, Client.submitQuery(uri, fQuery, bindingsFactory)).oneTimeIterator();
          } catch (final IOException e) {
            System.err.println(e);
            e.printStackTrace();
          }
          return null;
        }

        private URILiteral nextEndpoint(){
          while(this.it.hasNext()){
            final Bindings service = this.it.next();
            Literal endpointURI = service.get((Variable) endpoint);
            if (endpointURI instanceof LazyLiteral) {
              endpointURI = ((LazyLiteral) endpointURI).getLiteral();
            }
            if (endpointURI instanceof URILiteral) {
              final URILiteral result = (URILiteral) endpointURI;
              if(!this.alreadyAskedEndpoints.contains(result)){ // do not ask endpoints several times!
                this.alreadyAskedEndpoints.add(result);
                return result;
              }
            } else {
View Full Code Here

      evaluation.enableButtons();
    } else { // evaluate query...
      try {
        try {
          final QueryEvaluator<Node> evaluator = evaluation.getEvaluator();
          final URILiteral rdfURL = LiteralFactory.createStringURILiteral("<inlinedata:" + this.data + ">");
          this.defaultGraphs = new LinkedList<URILiteral>();
          this.defaultGraphs.add(rdfURL);

          if (mode == EvaluationMode.DEMO
              || mode == EvaluationMode.TIMES) {
View Full Code Here

TOP

Related Classes of lupos.datastructures.items.literal.URILiteral

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.