Java Code Examples for com.bigdata.rdf.model.BigdataStatement#isInferred()

The following examples show how to use com.bigdata.rdf.model.BigdataStatement#isInferred() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LoadPdb.java    From database with GNU General Public License v2.0 5 votes vote down vote up
public static void readSomeData(Repository repo) throws Exception {

		RepositoryConnection cxn = repo.getConnection();
		int counter = 0;
		try {

			RepositoryResult<Statement> stmts = cxn.getStatements(null, null, null, true /*
																						* include
																						* inferred
																						*/);
			while (stmts.hasNext()) {
				Statement stmt = stmts.next();
				Resource s = stmt.getSubject();
				URI p = stmt.getPredicate();
				Value o = stmt.getObject();
				// do something with the statement
				LOG.info(stmt);

				// cast to BigdataStatement to get at additional information
				BigdataStatement bdStmt = (BigdataStatement) stmt;
				if (bdStmt.isExplicit()) {
					// do one thing
				} else if (bdStmt.isInferred()) {
					// do another thing
				} else { // bdStmt.isAxiom()
					// do something else
				}
				LOG.info(bdStmt.getStatementType());
				counter++;
			}

		} finally {
			// close the repository connection
			cxn.close();

			LOG.info("Number of Triples: " + counter);
		}

	}
 
Example 2
Source File: SampleCode.java    From database with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Read some statements from a repository.
 * 
 * @param repo
 * @param uri
 * @throws Exception
 */
public void readSomeData(Repository repo, URI uri) throws Exception {
    
    /*
     * With MVCC, you read from a historical state to avoid blocking and
     * being blocked by writers.  BigdataSailRepository.getQueryConnection
     * gives you a view of the repository at the last commit point.
     */
    RepositoryConnection cxn;
    if (repo instanceof BigdataSailRepository) { 
        cxn = ((BigdataSailRepository) repo).getReadOnlyConnection();
    } else {
        cxn = repo.getConnection();
    }
    
    try {
        
        RepositoryResult<Statement> stmts = 
            cxn.getStatements(uri, null, null, true /* include inferred */);
        while (stmts.hasNext()) {
            Statement stmt = stmts.next();
            Resource s = stmt.getSubject();
            URI p = stmt.getPredicate();
            Value o = stmt.getObject();
            // do something with the statement
            log.info(stmt);
            
            // cast to BigdataStatement to get at additional information
            BigdataStatement bdStmt = (BigdataStatement) stmt;
            if (bdStmt.isExplicit()) {
                // do one thing
            } else if (bdStmt.isInferred()) {
                // do another thing
            } else { // bdStmt.isAxiom()
                // do something else
            }
            log.info(bdStmt.getStatementType());
        }
        
    } finally {
        // close the repository connection
        cxn.close();
    }
    
}