1 2 Previous Next 16 Replies Latest reply on Apr 29, 2016 9:36 AM by ruben.navarro

    Latest support for Apache Jena 2.11.1 (aka Jena Adapter) available on OTN and MOS

    alwu-Oracle

      The latest support for Apache Jena (formerly known as Jena Adapter) is available on both OTN and MOS.

       

      • To download from OTN, go to the this page (Oracle Semantic Technologies Downloads) and select the download link "Download Release 12.1.0.2 of Oracle Database Support for Apache Jena and Fuseki, and Protege Desktop"

       

      • To download from MOS, login to support.oracle.com, enter "22959933" in the text box under "Enter search terms" and it should bring you to a page with a link "Support for Apache Jena: FETCH CLAUSE CAUSING LONG DELAY GETTING RESULTS". Follow that link and you should be able to download the release kit (a .zip file).

       

      ---------------------------------------------------------------

      README for Oracle Spatial and Graph RDF Semantic Graph support for Apache Jena (formerly known as Jena Adapter)

      on Oracle Database Release 12c (12.1.0.1, 12.1.0.2 or newer)

       

      This major release of support for Apache Jena version 2.11.1 introduces two new features: optimized support of SPARQL 1.1 query syntax and smart router for small to medium size RDF/OWL datasets. Optimized support of SPARQL 1.1 query syntax moves the complete SPARQL 1.1 query into Oracle Database and executes it as a single SQL query. It enhances query performance by up to 10x by reducing the communications overhead of SPARQL 1.1 queries. This feature is transparent to applications and end users.  Queries with SPARQL 1.0 syntax have no change in execution flow.

       

      Smart router is a feature designed for small to medium size RDF/OWL datasets that can fit in memory. It improves the performance of complex SPARQL queries by up to 50x by storing a copy of the graph data in memory and switching, at run time, between in-memory execution and in-database execution, depending upon the relative progress of both execution paths.

       

      To enable smart router with either Joseki or Fuseki, use the predicate "oracle:hybridGraphs". An example snippet to be used in a Fuseki configuration is shown below. Modify the example to include your database connection, model name, sqlReadDOP (degree of parallelism used to populate the in-memory dataset), and maximum number of quads (triples) permitted for the in-memory dataset.

       

      <#oracle> rdf:type oracle:Dataset;

          oracle:connection

          [ a oracle:OracleConnection ;

            oracle:jdbcURL "jdbc:oracle:thin:@<host>:<port>:<sid>" ;

            oracle:User "*****" ;

            oracle:Password "*****"

          ];

          oracle:hybridGraphs [ oracle:firstModel "my_graph" ;

                                oracle:populateWithDBData "true";

                                oracle:sqlReadDOP  4;

                                oracle:maxQuadsAllowed 1800000 ] .

       

      An example configuration snippet to turn on smart router in Joseki is as follows.

       

      <#oracle> rdf:type oracle:Dataset;

          joseki:poolSize     2 ;         ## Number of concurrent connections allowed to this dataset.

          oracle:connection

          [ a oracle:OracleConnection ;

            oracle:dataSourceName "OracleSemDS"

          ];

          oracle:hybridGraphs [ oracle:firstModel "my_graph" ;

                                oracle:populateWithDBData "true";

                                oracle:sqlReadDOP  4;

                                oracle:maxQuadsAllowed 1800000 ] .

       

      Smart router is not recommended for a dataset graph that does not entirely fit in memory or for a graph undergoing frequent changes. These dataset graphs should continue use "oracle:allGraphs".

       

      In addition to the two features described above, this release also improves the S2S (SPARQL to SQL) feature. S2S now supports RDB2RDF view model and answers SPARQL queries referencing non-existent named graph URIs correctly.

       

       

       

      --

      -- Mandatory Configuration Step in the DB --

      --

      * If you run support for Apache Jena and connect to Oracle Database as a user,for example the user "SCOTT", please use SQL*Plus and login as SCOTT and remove one existing procedure and 3 helper functions. They will be re-created automatically next time support for Apache Jena is executed.

       

      * sqlplus scott/<password>

         drop PROCEDURE ORACLE_ORARDF_S2SSVRNG;

         drop function  ORACLE_ORARDF_S2SUSRNG;

         drop function  ORACLE_ORARDF_S2SUSRNGL;

         drop function  ORACLE_ORARDF_S2SLG;

      -- End of configuration

       

      NOTE: this release requires Oracle Database Release 12c or newer. It does not support Oracle Database 11g. For applications that depend on release 11.2.0.x, please continue using the previous version of support for Apache Jena.

       

      Message was edited by: alwu-Oracle

        • 1. Re: Latest support for Apache Jena 2.11.1 (aka Jena Adapter) available on MOS
          ruben.navarro

          Hi!

           

          I tried this new Jena adaptor (I was using the one released on October 2015) and I found following problems:

          - COUNT aggregates are returned with type xsd:decimal. As stated by the SPARQL 1.1 algebra, it should actually be an xsd:integer (https://www.w3.org/TR/sparql11-query/#defn_aggCount)

          - ORDER BY clauses seem to be completely ignored

           

          QueryExecution are build as follows (just in case I'm missing something):

           

           

          Oracle oracle = new Oracle((OracleConnection) dataSource.getConnection());
          
           GraphOracleSem graph = this.graphOracleSem(oracle);
           DatasetGraphOracleSem dataset = DatasetGraphOracleSem.createFrom(graph);
          
          // don't need the GraphOracleSem anymore, release resources
           graph.close();
           Dataset ds = DatasetFactory.create(dataset);
          
           QueryExecution qe = QueryExecutionFactory.create(sparqlQueryRequest.getQuery(), ds);
          
          
          • 2. Re: Latest support for Apache Jena 2.11.1 (aka Jena Adapter) available on MOS
            alwu-Oracle

            Thanks for the feedback. It is by design (for performance and uniformity) that COUNT aggregates return xsd:decimal. It is a small deviation from the SPEC but hopefully does not cause a real trouble for application development.

             

            Regarding ORDER BY being ignored, it sounds quite strange. Can you please send a test case to alan dot wu at oracle dot com?

             

            Zhe Wu

            • 3. Re: Re: Latest support for Apache Jena 2.11.1 (aka Jena Adapter) available on MOS
              ruben.navarro

              Hi Alan!

               

              Here a test case for the ORDER BY problem:

               

              package com.eccenca.test;
              
              import com.hp.hpl.jena.query.Dataset;
              import com.hp.hpl.jena.query.DatasetFactory;
              import com.hp.hpl.jena.query.QueryExecutionFactory;
              import com.hp.hpl.jena.query.QueryFactory;
              import com.hp.hpl.jena.query.ResultSet;
              import com.hp.hpl.jena.sparql.modify.GraphStoreBasic;
              import com.hp.hpl.jena.update.UpdateExecutionFactory;
              import com.hp.hpl.jena.update.UpdateFactory;
              
              import oracle.jdbc.OracleConnection;
              import oracle.jdbc.pool.OracleDataSource;
              import oracle.spatial.rdf.client.jena.DatasetGraphOracleSem;
              import oracle.spatial.rdf.client.jena.GraphOracleSem;
              import oracle.spatial.rdf.client.jena.Oracle;
              import oracle.ucp.jdbc.PoolDataSource;
              import oracle.ucp.jdbc.PoolDataSourceFactory;
              
              import java.sql.SQLException;
              
              /**
               * @author Ruben Navarro Piris
               */
              public class OracleOrderByTest {
              
                public static void main(String[] args) throws SQLException {
              
                 // connection pool configuration
                 PoolDataSource dataSource = PoolDataSourceFactory.getPoolDataSource();
                dataSource.setConnectionFactoryClassName(OracleDataSource.class.getCanonicalName());
                dataSource.setURL("jdbc:oracle:thin:@(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(PORT = 1521)(HOST = docker.local))(CONNECT_DATA = (SERVICE_NAME = orcl)))");
                dataSource.setUser("c##rdfusr");
                dataSource.setPassword("rdfusr");
              
                insertData(dataSource);
              
                selectAndPrint(dataSource, false);
                selectAndPrint(dataSource, true);
                }
              
                private static void insertData(PoolDataSource dataSource) throws SQLException {
                 // dataset connection
                 OracleConnection connection = (OracleConnection) dataSource.getConnection();
                connection.setAutoCommit(false);
                Oracle oracle = new Oracle(connection);
                 try {
                GraphOracleSem graph = new GraphOracleSem(oracle, "MODEL");
                DatasetGraphOracleSem dataset = DatasetGraphOracleSem.createFrom(graph);
              
                 // - don't need the GraphOracleSem anymore, release resources
                 graph.close();
                Dataset ds = DatasetFactory.create(dataset);
              
                 // insert data
                 UpdateExecutionFactory.create(UpdateFactory.create("INSERT DATA { GRAPH <urn:g2> {<urn:2> <urn:2> <urn:2> . <urn:22> <urn:22> <urn:22> . } }"), new GraphStoreBasic(ds)).execute();
                UpdateExecutionFactory.create(UpdateFactory.create("INSERT DATA { GRAPH <urn:g4> {<urn:4> <urn:4> <urn:4> . <urn:44> <urn:44> <urn:44> } }"), new GraphStoreBasic(ds)).execute();
                UpdateExecutionFactory.create(UpdateFactory.create("INSERT DATA { GRAPH <urn:g3> {<urn:3> <urn:3> <urn:3> . <urn:33> <urn:33> <urn:33> } }"), new GraphStoreBasic(ds)).execute();
                UpdateExecutionFactory.create(UpdateFactory.create("INSERT DATA { GRAPH <urn:g1> {<urn:1> <urn:1> <urn:1> . <urn:11> <urn:11> <urn:11> } }"), new GraphStoreBasic(ds)).execute();
                connection.commit();
                } catch (SQLException | RuntimeException e) {
                connection.rollback();
                 throw e;
                } finally {
                oracle.dispose();
                }
                }
              
                private static void selectAndPrint(PoolDataSource dataSource, boolean distinct) throws SQLException {
              
                 // dataset connection
                 OracleConnection connection = (OracleConnection) dataSource.getConnection();
                connection.setAutoCommit(false);
                Oracle oracle = new Oracle(connection);
                 try {
                GraphOracleSem graph = new GraphOracleSem(oracle, "MODEL");
                DatasetGraphOracleSem dataset = DatasetGraphOracleSem.createFrom(graph);
              
                 // - don't need the GraphOracleSem anymore, release resources
                 graph.close();
                Dataset ds = DatasetFactory.create(dataset);
              
                 // select
                 ResultSet rs;
              
                rs = QueryExecutionFactory.create(QueryFactory.create(
                 "SELECT " + (distinct ? "DISTINCT" : "") + " ?g " +
                 "FROM <urn:g1> " +
                 "FROM <urn:g4> " +
                 "FROM <urn:g2> " +
                 "FROM <urn:g3> " +
                 "FROM NAMED <urn:g1> " +
                 "FROM NAMED <urn:g4> " +
                 "FROM NAMED <urn:g2> " +
                 "FROM NAMED <urn:g3> " +
                 "{ GRAPH ?g {?s ?p ?o}} ORDER BY ?g"), ds).execSelect();
                System.out.println("### RESULTS; use distinct=" + distinct);
                 while (rs.hasNext()) {
                System.out.println("# Row: " + rs.next());
                }
                } finally {
                oracle.dispose();
                }
                }
              
              }
              

               

              And here the output that I got:

               

              ### RESULTS; use distinct=false
              # Row: ( ?g = <urn:g2> )
              # Row: ( ?g = <urn:g2> )
              # Row: ( ?g = <urn:g4> )
              # Row: ( ?g = <urn:g4> )
              # Row: ( ?g = <urn:g3> )
              # Row: ( ?g = <urn:g3> )
              # Row: ( ?g = <urn:g1> )
              # Row: ( ?g = <urn:g1> )
              
              
              ### RESULTS; use distinct=true
              # Row: ( ?g = <urn:g3> )
              # Row: ( ?g = <urn:g1> )
              # Row: ( ?g = <urn:g2> )
              # Row: ( ?g = <urn:g4> )
              
              • 4. Re: Re: Latest support for Apache Jena 2.11.1 (aka Jena Adapter) available on MOS
                ruben.navarro

                Regarding the COUNT problem, it is problematic in the sense that an overhead is necessary on the client side in order to achieve full SPARQL 1.1 compliance, since the query should be analysed (looking for variables resulting from COUNT aggregates) & convert the result for each row while iterating.

                I can imagine that this logic is easier to integrate in the Oracle Jena adapter and less error prone than on client  side.

                 

                Since this worked correctly on previous version, I consider it a functional regression, which should at least be corrected with an optional parameter (the default behaviour could stay as it is right now, if the parameter is active, COUNT results are returned as xsd:integer).

                • 5. Re: Latest support for Apache Jena 2.11.1 (aka Jena Adapter) available on OTN and MOS
                  alwu-Oracle

                  Thanks for the test case.

                   

                  Can you please change the query as follows and see if it makes a difference?

                   

                        String query = " SELECT ?g " +

                                            "FROM <urn:g1> " +

                                            "FROM <urn:g4> " +

                                            "FROM <urn:g2> " +

                                            "FROM <urn:g3> " +

                                            "FROM NAMED <urn:g1> " +

                                            "FROM NAMED <urn:g4> " +

                                            "FROM NAMED <urn:g2> " +

                                            "FROM NAMED <urn:g3> " +

                                            " { select " + (distinct ? "DISTINCT" : "") + " ?g "+

                        "{ GRAPH ?g {?s ?p ?o}} } ORDER BY ?g";

                   

                  The difference is that DISTINCT is now in an inner query and ORDER BY is pushed out a bit.

                   

                  Zhe Wu

                  • 6. Re: Latest support for Apache Jena 2.11.1 (aka Jena Adapter) available on OTN and MOS
                    ruben.navarro

                    The adapted query returned the expected results. Should I open a service support task for this matter or is a patch already planed/in progress?

                     

                    Thanks in advance!

                    • 7. Re: Latest support for Apache Jena 2.11.1 (aka Jena Adapter) available on OTN and MOS
                      3180035

                      Hi,

                      If I download the RDF semantic graph support version 12.1.0.2 where are the Oracle .class files in jar folder ?(compared to 12.1.0.1) ? Apache Jena Support for Oracle 12c

                      • 9. Re: Latest support for Apache Jena 2.11.1 (aka Jena Adapter) available on OTN and MOS
                        alwu-Oracle

                        Is this what you are looking for?

                         

                        % jar tvf jar/sdordfclient_12c.jar |grep Oracle.class

                        20656 Tue Feb 02 17:03:02 EST 2016 oracle/spatial/rdf/client/jena/Oracle.class

                         

                        Thanks,

                         

                        Zhe

                        • 10. Re: Latest support for Apache Jena 2.11.1 (aka Jena Adapter) available on OTN and MOS
                          ruben.navarro

                          Hi Zhe!

                           

                          For reason, I cannot open a standard service request (only a "Contact us SR"), there seems to be some mix up in the MOS rights we got granted. Is it possible for you to add it yourself?

                          Is there any update on this problem? If so, aprox. when will a fix be published?

                           

                          Thanks in advance!

                           

                          Ruben

                          • 11. Re: Latest support for Apache Jena 2.11.1 (aka Jena Adapter) available on OTN and MOS
                            alwu-Oracle

                            Hi Ruben,

                             

                            I doubt I can.

                             

                            However, to download the latest Jena Adapter (support for Apache Jena) from MOS, login to support.oracle.com, enter "22959933" in the text box under "Enter search terms" and it should bring you to a page with a link "Support for Apache Jena: FETCH CLAUSE CAUSING LONG DELAY GETTING RESULTS". Follow that link and you should be able to download the release kit (a .zip file).

                             

                            Thanks,

                             

                            Zhe

                            • 12. Re: Latest support for Apache Jena 2.11.1 (aka Jena Adapter) available on OTN and MOS
                              ruben.navarro

                              Hi Zhe!

                               

                              Thanks for the reply. I actually meant that with this new release (which I installed and tested) the mentioned ORDER BY problem is still there. Just wanted to know if it was already fixed/planed internally, if not I'll write down an SR once I get access to that feature in MOS.

                               

                              Cheers!

                               

                              Ruben

                              • 13. Re: Latest support for Apache Jena 2.11.1 (aka Jena Adapter) available on OTN and MOS
                                alwu-Oracle

                                Hi Ruben,

                                 

                                I see. I thought you were referring to a different issue. Sorry for the confusion. Yes the fix has been done internally.

                                 

                                Thanks,

                                 

                                Zhe Wu

                                • 14. Re: Latest support for Apache Jena 2.11.1 (aka Jena Adapter) available on OTN and MOS
                                  alwu-Oracle

                                  Hi Ruben,

                                   

                                  Just to be sure we are on the same page. What is size of the sdordfclient_12.jar you are using?

                                   

                                  1,161,752 sdordfclient_12c.jar

                                   

                                  Thanks,


                                  Zhe Wu

                                  1 2 Previous Next