Library Version 12.1.3.0

Example16b. Generate Data sampling for the dataset in the Oracle NoSQL Database
Prev | Chapter 8. Quick Start for the RDF Graph Feature | Next

## Example16b. Generate Data sampling for the dataset in the Oracle NoSQL Database

This uses analyze method in the `OracleDatasetGraphNoSql` class to generate data sampling from the dataset. In this example, data sampling is generated using a sampling rate with respect to all triples/quads stored in the dataset.

    import org.openjena.riot.Lang;
    import oracle.rdf.kv.client.jena.*;

    public class Example16b
    {

      public static void main(String[] args) throws Exception
      {

    String szStoreName  = args[0];
    String szHostName   = args[1];
    String szHostPort   = args[2];
    double iSampRate = Double.parseDouble(args[3]);

    // Create Oracle NoSQL connection
    OracleNoSqlConnection conn
           = OracleNoSqlConnection.createInstance(szStoreName,
                                                  szHostName,
                                                  szHostPort);

    // Create an Oracle DatasetGraphNoSql object to manage
    // the dataset in the Oracle NoSQL Database
    OracleGraphNoSql graph = new OracleGraphNoSql(conn);
    DatasetGraphNoSql datasetGraph = DatasetGraphNoSql.createFrom(graph);

    // Close graph as it is no longer needed
    graph.close();

    // Clear dataset and close it as it is needed just to clear the
    // dataset
    datasetGraph.clearRepository();

    // Load data from file into the Oracle NoSQL Database
    DatasetGraphNoSql.load("family.rdf", Lang.RDFXML, conn,
                               "http://example.com");

    // Analyze the default graph and generate sampling data
    long sizeSamp = datasetGraph.analyze(iSampRate);

    System.out.println("sampling size is " + sizeSamp);

    // Close connection
    conn.dispose();
      }
    }

The following are the commands to compile and run this example, as well as the expected output of the java command.

    javac -classpath ./:./jena-core-2.7.4.jar:./jena-arq-2.9.4.jar: \
    ./sdordfnosqlclient.jar:./kvclient.jar:./xercesImpl-2.10.0.jar: \
    ./slf4j-api-1.6.4.jar:./slf4j-log4j12-1.6.4.jar:./log4j/1.2.16.jar: \
    ./jena-iri-0.9.4.jar:./xml-apis-1.4.01.jar Example16.java

    javac -classpath ./:./jena-core-2.7.4.jar:./jena-arq-2.9.4.jar: \
    ./sdordfnosqlclient.jar:./kvclient.jar:./xercesImpl-2.10.0.jar: \
    ./slf4j-api-1.6.4.jar:./slf4j-log4j12-1.6.4.jar:./log4j/1.2.16.jar: \
    ./jena-iri-0.9.4.jar:./xml-apis-1.4.01.jar Example16b <store_name>\
    <host_name> <host_port> 0.005

    sampling size is 5

Prev | Up | Next
Generate Data sampling for a graph in the Oracle NoSQL Database | Home | Build an Ontology Model using Jena OntModel APIs