This example uses analyze method in the OracleGraphNoSql class to generate data sampling from a graph. In this example, data sampling is generated in a proportion sampPercentage: sampFactor with respect to all triples stored in the default graph.
import org.openjena.riot.Lang;
import oracle.rdf.kv.client.jena.*;
public class Example16
{
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 a DatasetGraphNoSql object to manage the dataset in the
// Oracle NoSQL Database
OracleGraphNoSql graph = new OracleGraphNoSql(conn);
DatasetGraphNoSql datasetGraph = DatasetGraphNoSql.createFrom(graph);
// Clear dataset and close it as it is needed just to clear the
// dataset
datasetGraph.clearRepository();
datasetGraph.close();
// Load data from file into the Oracle NoSQL Database
DatasetGraphNoSql.load("family.rdf", Lang.RDFXML, conn,
"http://example.com");
// Analyze the default graph and gnerate sampling data
long sizeSamp = graph.analyze(iSampRate);
System.out.println("sampling size is " + sizeSamp);
graph.close();
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 Example15 <store_name> \ <host_name> <host_port> 0.005 sampling size is 5