1 Reply Latest reply on Jun 24, 2016 5:01 PM by 2622171

    Smart router in Jena API

    3259770

      Hi,

       

      I would like to use the smart router feature in the new Apache Jena Adapter version. The announcement describes how to turn it on in joseki/fuseki, but is it possible to use it just with Jena APIs.

       

      Is a javadoc for the Jena adapter available somewhere, or Java sources?

       

      Best regards,

      Michal

        • 1. Re: Smart router in Jena API
          2622171

          Hello Michal,

           

          It is possible indeed. To use the smart router using just Support for Apache Jena (previously known as Jena Adapter) APIs you will need a DatasetGraph for third party evaluation (Apache Jena's In Memory) and a DatasetGraphOracleHybrid for Oracle DB evaluation and smart router management:

           

          // A common graph with a DB Connection

          GraphOracleSem graph = new GraphOracleSem(oracleConnection, modelName);

          // Basic graph for third party (in memory) evaluation

          DatasetGraph dsg = DatasetGraphFactory.createMem();

          // Hybrid dataset

          DatasetGraphOraleSem dsgHybrid = DatasetGraphOracleHybrid.createFrom(

                               graph,

                               dsg,

                               true,    // Boolean value. Whether populate third

                                        // party dsg or not when created

                               2,       // Integer value. Dop for SQL reading

                               1000000  // Long value. Max number of quads allowed

                                        // in memory

                               );

          // A wrapped dataset on which you can work

          Dataset myDataset = DatasetImpl.wrap(datasetHybrid);


          // Now you can use your dataset as always and the smart router will be

          // switching, at run time, between in-memory execution and in-database

          // execution.

          String query = "SELECT ?s ?p ?o WHERE {?s ?p ?o}";

          QueryExecution qexec = QueryExecutionFactory.create(query, myDataset);

          try {

              ResultSet results = qexec.execSelect();

              ResultSetFormatter.output(System.out, results, ResultsFormat.FMT_RDF_NT);

          }

          finally {

              qexec.close();

              graph.close();

              myDataset.close();

              oracleConnection.dispose();

          }

           

          The javadoc directory is included in the same Support for Apache Jena package kit.

           

          If you have an additional question, let us know.

           

           

          Miriam Mecate