com.bigdata.samples
Class SampleCode

java.lang.Object
  extended by com.bigdata.samples.SampleCode
Direct Known Subclasses:
LoadNamedGraphs, TestNamedGraphs

public class SampleCode
extends Object

Demonstrate how to use bigdata. You are free to use this code for whatever purpose without restriction.

Author:
mikep

Field Summary
protected static org.apache.log4j.Logger log
          Do you have log4j set up correctly? Bigdata turns its logging level way down by default (WARN).
 
Constructor Summary
SampleCode()
           
 
Method Summary
protected  void compare(TupleQueryResult result, Collection<BindingSet> answer)
           
protected  BindingSet createBindingSet(Binding... bindings)
           
 void doLUBMTest(String lubmResource)
          Run a simple LUBM load and query benchmark.
 void doU1()
           
 void doU10()
           
 void executeConstructQuery(Repository repo, String query, QueryLanguage ql)
          Execute a "construct" query.
 boolean executeFreeTextQuery(Repository repo)
          Demonstrate execution of a free-text query.
 void executeHistoricalQuery(Repository repo)
          Demonstrate execution of historical query using a read-only transaction.
 boolean executeProvenanceQuery(Repository repo)
          Demonstrate execution of statement level provenance.
 void executeSelectQuery(Repository repo, String query, QueryLanguage ql)
          Execute a "select" query.
 Reader getReader(Class c, String resource)
           
 Properties loadProperties(String resource)
          Load a Properties object from a file.
 void loadSomeData(Repository repo)
          Add a statement to a repository.
 void loadSomeDataFromADocument(Repository repo, String resource, String baseURL)
          Load a document into a repository.
static void main(String[] args)
          Are you running with the -server JVM option? You should be.
 void readSomeData(Repository repo, URI uri)
          Read some statements from a repository.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static final org.apache.log4j.Logger log
Do you have log4j set up correctly? Bigdata turns its logging level way down by default (WARN). You should not be seeing INFO or DEBUG log statements from bigdata - if you are, then this will severely impact performance.

Constructor Detail

SampleCode

public SampleCode()
Method Detail

loadProperties

public Properties loadProperties(String resource)
                          throws Exception
Load a Properties object from a file.

Parameters:
resource -
Returns:
Throws:
Exception

loadSomeData

public void loadSomeData(Repository repo)
                  throws Exception
Add a statement to a repository.

Parameters:
repo -
Throws:
Exception

loadSomeDataFromADocument

public void loadSomeDataFromADocument(Repository repo,
                                      String resource,
                                      String baseURL)
                               throws Exception
Load a document into a repository.

Parameters:
repo -
resource -
baseURL -
Throws:
Exception

readSomeData

public void readSomeData(Repository repo,
                         URI uri)
                  throws Exception
Read some statements from a repository.

Parameters:
repo -
uri -
Throws:
Exception

executeSelectQuery

public void executeSelectQuery(Repository repo,
                               String query,
                               QueryLanguage ql)
                        throws Exception
Execute a "select" query.

Parameters:
repo -
query -
ql -
Throws:
Exception

executeConstructQuery

public void executeConstructQuery(Repository repo,
                                  String query,
                                  QueryLanguage ql)
                           throws Exception
Execute a "construct" query.

Parameters:
repo -
query -
ql -
Throws:
Exception

executeFreeTextQuery

public boolean executeFreeTextQuery(Repository repo)
                             throws Exception
Demonstrate execution of a free-text query.

Parameters:
repo -
Throws:
Exception

executeProvenanceQuery

public boolean executeProvenanceQuery(Repository repo)
                               throws Exception
Demonstrate execution of statement level provenance.

Parameters:
repo -
Throws:
Exception

executeHistoricalQuery

public void executeHistoricalQuery(Repository repo)
                            throws Exception
Demonstrate execution of historical query using a read-only transaction.

Note: Bigdata preserves historical commit points until their release age expires. This behavior is controlled by the deployment mode (RW, WORM, or cluster) and by AbstractTransactionService.Options#MIN_RELEASE_AGE. Except for the WORM deployment mode, you MUST guard a historical commit point on which you want to read using a read-lock. The read-lock itself is just a read-only connection. It can be obtained for any historical commit point that you want to "pin" and can be released once you are no longer need to "pin" that commit point.

The read-lock is not required for the WORM deployment because it never releases historical commit points.

Parameters:
repo -
Throws:
Exception

doLUBMTest

public void doLUBMTest(String lubmResource)
                throws Exception
Run a simple LUBM load and query benchmark.

Parameters:
lubmResource - the ZIP file containing the LUBM data files
filter - helps filter out non-data files in the ZIP file
Throws:
Exception

doU10

public void doU10()
           throws Exception
Throws:
Exception

doU1

public void doU1()
          throws Exception
Throws:
Exception

getReader

public Reader getReader(Class c,
                        String resource)

main

public static void main(String[] args)
Are you running with the -server JVM option? You should be. Also, try increasing heap size with -Xmx512m or even -Xmx1024m if you have enough RAM.

Parameters:
args -

createBindingSet

protected BindingSet createBindingSet(Binding... bindings)

compare

protected void compare(TupleQueryResult result,
                       Collection<BindingSet> answer)
                throws QueryEvaluationException
Throws:
QueryEvaluationException


Copyright © 2006-2011 SYSTAP, LLC. All Rights Reserved.