com.bigdata.rdf.sail.BigdataSailRepository Java Examples

The following examples show how to use com.bigdata.rdf.sail.BigdataSailRepository. 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 6 votes vote down vote up
public static void main(String[] args) throws Exception {
		File file = new File("tmp-1Y26.jnl");

		Properties properties = new Properties();
		properties.setProperty(BigdataSail.Options.FILE, file.getAbsolutePath());

		BigdataSail sail = new BigdataSail(properties);
		Repository repo = new BigdataSailRepository(sail);
		repo.initialize();

        if(false) {
        sail.getDatabase().getDataLoader().loadData(
                "contrib/src/problems/alex/1Y26.rdf",
                new File("contrib/src/problems/alex/1Y26.rdf").toURI()
                        .toString(), RDFFormat.RDFXML);
        sail.getDatabase().commit();
        }
        
//		loadSomeDataFromADocument(repo, "contrib/src/problems/alex/1Y26.rdf");
		// readSomeData(repo);
		executeSelectQuery(repo, "SELECT * WHERE { ?s ?p ?o }");
	}
 
Example #2
Source File: Utils.java    From blazegraph-samples with GNU General Public License v2.0 6 votes vote down vote up
public static TupleQueryResult executeSelectQuery(Repository repo, String query,
		QueryLanguage ql) throws OpenRDFException  {

	RepositoryConnection cxn;
	if (repo instanceof BigdataSailRepository) {
		cxn = ((BigdataSailRepository) repo).getReadOnlyConnection();
	} else {
		cxn = repo.getConnection();
	}

	try {

		final TupleQuery tupleQuery = cxn.prepareTupleQuery(ql, query);
		tupleQuery.setIncludeInferred(true /* includeInferred */);
		return tupleQuery.evaluate();
		
	} finally {
		// close the repository connection
		cxn.close();
	}
}
 
Example #3
Source File: SampleBlazegraphSesameEmbedded.java    From blazegraph-samples with GNU General Public License v2.0 6 votes vote down vote up
public static TupleQueryResult executeSelectQuery(final Repository repo, final String query,
		final QueryLanguage ql) throws OpenRDFException  {

	RepositoryConnection cxn;
	if (repo instanceof BigdataSailRepository) {
		cxn = ((BigdataSailRepository) repo).getReadOnlyConnection();
	} else {
		cxn = repo.getConnection();
	}

	try {

		final TupleQuery tupleQuery = cxn.prepareTupleQuery(ql, query);
		tupleQuery.setIncludeInferred(true /* includeInferred */);
		return tupleQuery.evaluate();
		
	} finally {
		// close the repository connection
		cxn.close();
	}
}
 
Example #4
Source File: TripleStoreBlazegraph.java    From powsybl-core with Mozilla Public License 2.0 6 votes vote down vote up
public TripleStoreBlazegraph() {
    final Properties props = new Properties();
    props.put(Options.BUFFER_MODE, "MemStore");
    props.put(AbstractTripleStore.Options.QUADS_MODE, "true");
    props.put(BigdataSail.Options.TRUTH_MAINTENANCE, "false");

    // Quiet
    System.getProperties().setProperty("com.bigdata.Banner.quiet", "true");
    System.getProperties().setProperty("com.bigdata.util.config.LogUtil.quiet", "true");

    BigdataSail sail = new BigdataSail(props); // instantiate a sail
    repo = new BigdataSailRepository(sail); // create a Sesame repository

    try {
        repo.initialize();
    } catch (RepositoryException x) {
        LOG.error("Repository could not be created {}", x.getMessage());
    }
}
 
Example #5
Source File: BigdataRepositoryFactory.java    From database with GNU General Public License v2.0 6 votes vote down vote up
public Repository getRepository(final RepositoryImplConfig config)
	throws RepositoryConfigException {

	if (!TYPE.equals(config.getType())) {
		throw new RepositoryConfigException(
                   "Invalid type: " + config.getType());
	}
	
	if (!(config instanceof BigdataRepositoryConfig)) {
		throw new RepositoryConfigException(
                   "Invalid type: " + config.getClass());
	}
	
       try {
           
		final BigdataRepositoryConfig bigdataConfig = (BigdataRepositoryConfig)config;
		final Properties properties = bigdataConfig.getProperties();
   		final BigdataSail sail = new BigdataSail(properties);
   		return new BigdataSailRepository(sail);
           
       } catch (Exception ex) {
           throw new RepositoryConfigException(ex);
       }
       
}
 
Example #6
Source File: BigdataSparqlTest.java    From database with GNU General Public License v2.0 6 votes vote down vote up
@Override
    protected Repository newRepository() throws RepositoryException {

        if (true) {
            final Properties props = getProperties();
            
            if (cannotInlineTests.contains(testURI)){
            	// The test can not be run using XSD inlining.
                props.setProperty(Options.INLINE_XSD_DATATYPE_LITERALS, "false");
            	props.setProperty(Options.INLINE_DATE_TIMES, "false");
            }
            
            if(unicodeStrengthIdentical.contains(testURI)) {
            	// Force identical Unicode comparisons.
            	props.setProperty(Options.COLLATOR, CollatorEnum.JDK.toString());
            	props.setProperty(Options.STRENGTH, StrengthEnum.Identical.toString());
            }
            
            final BigdataSail sail = new BigdataSail(props);
//            return new DatasetRepository(new BigdataSailRepository(sail));
            return new BigdataSailRepository(sail);
        } else {
            return new DatasetRepository(new SailRepository(new MemoryStore()));
        }
    }
 
Example #7
Source File: BlazeGraphEmbedded.java    From tinkerpop3 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Open a BlazeGraphEmbedded (unisolated) instance wrapping the provided
 * SAIL repository and using the supplied configuration.
 * 
 * @return
 *          an open and initialized repository
 * @param config
 *          additional configuration
 * @return
 *          instance
 */
public static BlazeGraphEmbedded open(final BigdataSailRepository repo,
        final Configuration config) {
    Objects.requireNonNull(repo);
    if (!repo.getDatabase().isStatementIdentifiers()) {
        throw new IllegalArgumentException("BlazeGraph/TP3 requires statement identifiers.");
    }
    
    /*
     * Grab the last commit time and also check for clock skew.
     */
    final long lastCommitTime = lastCommitTime(repo);
    config.setProperty(BlazeGraph.Options.LIST_INDEX_FLOOR, lastCommitTime);

    return new BlazeGraphEmbedded(repo, config);
}
 
Example #8
Source File: BigdataArbitraryLengthPathTest.java    From database with GNU General Public License v2.0 5 votes vote down vote up
protected SailRepository newRepository() throws RepositoryException {

        if (true) {
            final Properties props = getProperties();
            
//            if (cannotInlineTests.contains(testURI)){
//                // The test can not be run using XSD inlining.
//                props.setProperty(Options.INLINE_XSD_DATATYPE_LITERALS, "false");
//                props.setProperty(Options.INLINE_DATE_TIMES, "false");
//            }
//            
//            if(unicodeStrengthIdentical.contains(testURI)) {
//                // Force identical Unicode comparisons.
//                props.setProperty(Options.COLLATOR, CollatorEnum.JDK.toString());
//                props.setProperty(Options.STRENGTH, StrengthEnum.Identical.toString());
//            }
            
            final BigdataSail sail = new BigdataSail(props);
            return new BigdataSailRepository(sail);
        } else {
            /*
             * Run against openrdf.
             */
            SailRepository repo = new SailRepository(new MemoryStore());

            return repo;
        }
    }
 
Example #9
Source File: BigdataConnectionTest.java    From database with GNU General Public License v2.0 5 votes vote down vote up
/**
     * Overridden to destroy the backend database and its files on the disk.
     */
    @Override
    public void tearDown() throws Exception
    {

        final IIndexManager backend = testRepository == null ? null
                : ((BigdataSailRepository) testRepository).getSail()
                        .getIndexManager();

        /*
         * Note: The code in the block below was taken verbatim from
         * super.testDown() in order to explore a tear down issue in testOpen().
         */
        super.tearDown();
//        {
//            
//            testCon2.close();
//            testCon2 = null;
//
//            testCon.close();
//            testCon = null;
//
//            testRepository.shutDown();
//            testRepository = null;
//
//            vf = null;
//
//        }

        if (backend != null) {
            if(log.isInfoEnabled() && backend instanceof Journal)
                log.info(QueryEngineFactory.getInstance().getExistingQueryController((Journal)backend).getCounters());
            backend.destroy();
        }

    }
 
Example #10
Source File: BigdataComplexSparqlQueryTest.java    From database with GNU General Public License v2.0 5 votes vote down vote up
@Override
    protected Repository newRepository() throws RepositoryException {

        final Properties props = getProperties();
        
        final BigdataSail sail = new BigdataSail(props);
        
        backend = sail.getIndexManager();

        return new BigdataSailRepository(sail);

//        if (true) {
//            final Properties props = getProperties();
//            
//            if (cannotInlineTests.contains(testURI)){
//                // The test can not be run using XSD inlining.
//                props.setProperty(Options.INLINE_XSD_DATATYPE_LITERALS, "false");
//                props.setProperty(Options.INLINE_DATE_TIMES, "false");
//            }
//            
//            if(unicodeStrengthIdentical.contains(testURI)) {
//                // Force identical Unicode comparisons.
//                props.setProperty(Options.COLLATOR, CollatorEnum.JDK.toString());
//                props.setProperty(Options.STRENGTH, StrengthEnum.Identical.toString());
//            }
//            
//            final BigdataSail sail = new BigdataSail(props);
//            return new DatasetRepository(new BigdataSailRepository(sail));
//        } else {
//            return new DatasetRepository(new SailRepository(new MemoryStore()));
//        }

    }
 
Example #11
Source File: BigdataSPARQLUpdateConformanceTest.java    From database with GNU General Public License v2.0 5 votes vote down vote up
@Override
    protected BigdataSailRepository newRepository() throws RepositoryException {

//        if (true) {
            final Properties props = getProperties();
            
//            if (cannotInlineTests.contains(testURI)){
//                // The test can not be run using XSD inlining.
//                props.setProperty(Options.INLINE_XSD_DATATYPE_LITERALS, "false");
//                props.setProperty(Options.INLINE_DATE_TIMES, "false");
//            }
//            
//            if(unicodeStrengthIdentical.contains(testURI)) {
//                // Force identical Unicode comparisons.
//                props.setProperty(Options.COLLATOR, CollatorEnum.JDK.toString());
//                props.setProperty(Options.STRENGTH, StrengthEnum.Identical.toString());
//            }
            
            final BigdataSail sail = new BigdataSail(props);
//            return new ContextAwareRepository(new BigdataSailRepository(sail));
            return new BigdataSailRepository(sail);
//        } else {
//            /*
//             * Run against openrdf.
//             */
//            SailRepository repo = new SailRepository(new MemoryStore());
//
//            return new ContextAwareRepository(repo);
//        }
    }
 
Example #12
Source File: BigdataSPARQLUpdateTest.java    From database with GNU General Public License v2.0 5 votes vote down vote up
@Override
    protected Repository newRepository() throws RepositoryException {

        final Properties props = getProperties();
        
        final BigdataSail sail = new BigdataSail(props);
        
        backend = sail.getIndexManager();

        return new BigdataSailRepository(sail);

//        if (true) {
//            final Properties props = getProperties();
//            
//            if (cannotInlineTests.contains(testURI)){
//                // The test can not be run using XSD inlining.
//                props.setProperty(Options.INLINE_XSD_DATATYPE_LITERALS, "false");
//                props.setProperty(Options.INLINE_DATE_TIMES, "false");
//            }
//            
//            if(unicodeStrengthIdentical.contains(testURI)) {
//                // Force identical Unicode comparisons.
//                props.setProperty(Options.COLLATOR, CollatorEnum.JDK.toString());
//                props.setProperty(Options.STRENGTH, StrengthEnum.Identical.toString());
//            }
//            
//            final BigdataSail sail = new BigdataSail(props);
//            return new DatasetRepository(new BigdataSailRepository(sail));
//        } else {
//            return new DatasetRepository(new SailRepository(new MemoryStore()));
//        }

    }
 
Example #13
Source File: SPARQLUpdateTestv2.java    From database with GNU General Public License v2.0 5 votes vote down vote up
protected Repository newRepository() throws RepositoryException {

        final Properties props = getProperties();
        
        final BigdataSail sail = new BigdataSail(props);
        
        backend = sail.getIndexManager();

        return new BigdataSailRepository(sail);

//        if (true) {
//            final Properties props = getProperties();
//            
//            if (cannotInlineTests.contains(testURI)){
//                // The test can not be run using XSD inlining.
//                props.setProperty(Options.INLINE_XSD_DATATYPE_LITERALS, "false");
//                props.setProperty(Options.INLINE_DATE_TIMES, "false");
//            }
//            
//            if(unicodeStrengthIdentical.contains(testURI)) {
//                // Force identical Unicode comparisons.
//                props.setProperty(Options.COLLATOR, CollatorEnum.JDK.toString());
//                props.setProperty(Options.STRENGTH, StrengthEnum.Identical.toString());
//            }
//            
//            final BigdataSail sail = new BigdataSail(props);
//            return new DatasetRepository(new BigdataSailRepository(sail));
//        } else {
//            return new DatasetRepository(new SailRepository(new MemoryStore()));
//        }

    }
 
Example #14
Source File: LocalGOMTestCase.java    From database with GNU General Public License v2.0 5 votes vote down vote up
protected void setUp() throws Exception {

        // instantiate a sail and a Sesame repository
        m_sail = new BigdataSail(getProperties());
        m_repo = new BigdataSailRepository(m_sail);
        m_repo.initialize();
        m_vf = m_sail.getValueFactory();
        // Note: This uses a mock endpoint URL.
        om = new ObjectManager("http://localhost"
                + BigdataStatics.getContextPath() + "/sparql", m_repo);

    }
 
Example #15
Source File: BigdataGraphEmbedded.java    From database with GNU General Public License v2.0 5 votes vote down vote up
/**
    * Create a Blueprints wrapper around a {@link BigdataSailRepository} 
    * instance with a non-standard {@link BlueprintsValueFactory} implementation.
    */
public BigdataGraphEmbedded(final BigdataSailRepository repo, 
		final BlueprintsValueFactory factory, final Properties props) {
    super(factory, props);
    
    this.repo = (BigdataSailRepository) repo;
       this.autocommitOnShutdown = Boolean.valueOf(
               props.getProperty(Options.AUTO_COMMIT_ON_SHUTDOWN, 
                   Boolean.toString(Options.DEFAULT_AUTO_COMMIT_ON_SHUTDOWN)));
}
 
Example #16
Source File: BigdataFederationSparqlTest.java    From database with GNU General Public License v2.0 5 votes vote down vote up
protected BigdataSailRepositoryConnection getQueryConnection(Repository dataRep)
			throws Exception {
		// return dataRep.getConnection();
		final BigdataSailRepositoryConnection con = new BigdataSailRepositoryConnection(new BigdataSailRepository(
				_sail), _sail.getReadOnlyConnection());
//		System.err.println(_sail.getDatabase().dumpStore());
		return con;
	}
 
Example #17
Source File: SampleCode.java    From database with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Execute a "construct" query.
 * 
 * @param repo
 * @param query
 * @param ql
 * @throws Exception
 */
public void executeConstructQuery(Repository repo, String query, 
    QueryLanguage ql) 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 {

        // silly construct queries, can't guarantee distinct results
        final Set<Statement> results = new LinkedHashSet<Statement>();
        final GraphQuery graphQuery = cxn.prepareGraphQuery(ql, query);
        graphQuery.setIncludeInferred(true /* includeInferred */);
        graphQuery.evaluate(new StatementCollector(results));
        // do something with the results
        for (Statement stmt : results) {
            log.info(stmt);
        }

    } finally {
        // close the repository connection
        cxn.close();
    }
    
}
 
Example #18
Source File: TestRollbacks.java    From database with GNU General Public License v2.0 5 votes vote down vote up
private void doTest(final int maxCounter) throws InterruptedException, Exception {

        /*
         * Note: Each run needs to be in a distinct namespace since we otherwise
         * can have side-effects through the BigdataValueFactoryImpl for a given
         * namespace.
         */
        
        final Properties properties = new Properties(getProperties());
        
        properties.setProperty(BigdataSail.Options.NAMESPACE,
                "kb" + runCount.incrementAndGet());
        
        final BigdataSail sail = getSail(properties);
        
        try {
        	// Note: Modified to use the BigdataSailRepository rather than the base SailRepository class.
            final BigdataSailRepository repo = new BigdataSailRepository(sail);
            repo.initialize();
            runConcurrentStuff(repo,maxCounter);
        } finally {
			final IIndexManager db = sail.getIndexManager();
			try {
				if (sail.isOpen()) {
					try {
						sail.shutDown();
					} catch (Throwable t) {
						log.error(t, t);
					}
				}
			} finally {
				db.destroy();
			}
        }
    }
 
Example #19
Source File: SampleCode.java    From database with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Execute a "select" query.
 * 
 * @param repo
 * @param query
 * @param ql
 * @throws Exception
 */
public void executeSelectQuery(Repository repo, String query, 
    QueryLanguage ql) 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 {

        final TupleQuery tupleQuery = cxn.prepareTupleQuery(ql, query);
        tupleQuery.setIncludeInferred(true /* includeInferred */);
        TupleQueryResult result = tupleQuery.evaluate();
        // do something with the results
        while (result.hasNext()) {
            BindingSet bindingSet = result.next();
            log.info(bindingSet);
        }
        
    } finally {
        // close the repository connection
        cxn.close();
    }
    
}
 
Example #20
Source File: SampleCode.java    From database with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Demonstrate execution of a free-text query.
 * 
 * @param repo
 * @throws Exception
 */
public boolean executeFreeTextQuery(Repository repo) throws Exception {
    if (((BigdataSailRepository) repo).getDatabase().getLexiconRelation()
            .getSearchEngine() == null) {
        /*
         * Only if the free text index exists.
         */
        return false;
    }
    RepositoryConnection cxn = repo.getConnection();
    cxn.setAutoCommit(false);
    try {
        cxn.add(new URIImpl("http://www.bigdata.com/A"), RDFS.LABEL,
                new LiteralImpl("Yellow Rose"));
        cxn.add(new URIImpl("http://www.bigdata.com/B"), RDFS.LABEL,
                new LiteralImpl("Red Rose"));
        cxn.add(new URIImpl("http://www.bigdata.com/C"), RDFS.LABEL,
                new LiteralImpl("Old Yellow House"));
        cxn.add(new URIImpl("http://www.bigdata.com/D"), RDFS.LABEL,
                new LiteralImpl("Loud Yell"));
        cxn.commit();
    } catch (Exception ex) {
        cxn.rollback();
        throw ex;
    } finally {
        // close the repository connection
        cxn.close();
    }
    
    String query = "select ?x where { ?x <"+BDS.SEARCH+"> \"Yell\" . }";
    executeSelectQuery(repo, query, QueryLanguage.SPARQL);
    // will match A, C, and D
    return true;
}
 
Example #21
Source File: BasicRepositoryProvider.java    From tinkerpop3 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Open and initialize a BigdataSailRepository using the supplied config
 * properties.  You must specify a journal file in the properties.
 * 
 * @param props
 *          config properties
 * @return
 *          an open and initialized repository
 */
public static BigdataSailRepository open(final Properties props) {
    if (props.getProperty(Journal.Options.FILE) == null) {
        throw new IllegalArgumentException();
    }
    
    final BigdataSail sail = new BigdataSail(props);
    final BigdataSailRepository repo = new BigdataSailRepository(sail);
    Code.wrapThrow(() -> repo.initialize());
    return repo;
}
 
Example #22
Source File: TestRepositoryProvider.java    From tinkerpop3 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Open with default configuration and a tmp journal file, overriding the
 * default config as specified.
 * 
 * @return
 *          an open and initialized Blaze repository
 */
public static BigdataSailRepository open(final Map<String,String> overrides) {
    final Properties props = getProperties(tmpJournal());
    overrides.entrySet().forEach(e -> {
        if (e.getValue() != null) {
            props.setProperty(e.getKey(), e.getValue());
        } else {
            props.remove(e.getKey());
        }
    });
    return open(props);
}
 
Example #23
Source File: SampleCode.java    From tinkerpop3 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Open a BlazeGraph instance backed by the supplied journal file.
 */
public static BlazeGraphEmbedded open(final File file) {
    /*
     * A journal file is the persistence mechanism for an embedded 
     * Blazegraph instance.
     */
    final String journal = file.getAbsolutePath();
    
    /*
     * BasicRepositoryProvider will create a Blazegraph repository using the
     * specified journal file with a reasonable default configuration set
     * for the Tinkerpop3 API. This will also open a previously created
     * repository if the specified journal already exists.
     * 
     * ("Bigdata" is the legacy product name for Blazegraph).
     * 
     * See BasicRepositoryProvider for more details on the default SAIL 
     * configuration.
     */
    final BigdataSailRepository repo = BasicRepositoryProvider.open(journal);
    
    /*
     * Open a BlazeGraphEmbedded instance with no additional configuration.
     * See BlazeGraphEmbedded.Options for additional configuration options.
     */
    final BlazeGraphEmbedded graph = BlazeGraphEmbedded.open(repo);
    return graph;
}
 
Example #24
Source File: SampleCode.java    From tinkerpop3 with GNU General Public License v2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
    /*
     * TestRepositoryProvider extends BasicRepositoryProvider to create a 
     * temp journal file for the lifespan of the individual test method.  
     * You'll want to create your own BasicRepositoryProvider for your
     * application (or just use BasicRepositoryProvider out of the box).
     */
    final BigdataSailRepository repo = TestRepositoryProvider.open();
    /*
     * Open a BlazeGraphEmbedded instance with no additional configuration.
     * See BlazeGraphEmbedded.Options for additional configuration options.
     */
    this.graph = BlazeGraphEmbedded.open(repo);
}
 
Example #25
Source File: EmbeddedBlazeGraphProvider.java    From tinkerpop3 with GNU General Public License v2.0 5 votes vote down vote up
private static synchronized BigdataSailRepository getRepository(final String name) {
    final String journal;
    if (repos.containsKey(name)) {
        journal = repos.get(name);
    } else {
        repos.put(name, journal = TestRepositoryProvider.tmpJournal());
    }
    return TestRepositoryProvider.open(journal);
}
 
Example #26
Source File: BlazeGraphReadOnly.java    From tinkerpop3 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Never publicly instantiated - only by another {@link BlazeGraphEmbedded} 
 * instance.
 */
BlazeGraphReadOnly(final BigdataSailRepository repo,
        final BigdataSailRepositoryConnection cxn,
        final Configuration config) {
    super(repo, config);
    
    this.cxn = cxn;
}
 
Example #27
Source File: SampleBlazegraphSesameEmbedded.java    From blazegraph-samples with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws IOException, OpenRDFException {

		// load journal properties from resources
		final Properties props = loadProperties("/blazegraph.properties");

		// instantiate a sail
		final BigdataSail sail = new BigdataSail(props);
		final Repository repo = new BigdataSailRepository(sail);

		try{
			repo.initialize();
			
			/*
			 * Load data from resources 
			 * src/main/resources/data.n3
			 */
	
			loadDataFromResources(repo, "/data.n3", "");
			
			final String query = "select * {<http://blazegraph.com/blazegraph> ?p ?o}";
			final TupleQueryResult result = executeSelectQuery(repo, query, QueryLanguage.SPARQL);
			
			try {
				while(result.hasNext()){
					
					final BindingSet bs = result.next();
					log.info(bs);
					
				}
			} finally {
				result.close();
			}
		} finally {
			repo.shutDown();
		}
	}
 
Example #28
Source File: SampleBlazegraphCustomFunctionEmbedded.java    From blazegraph-samples with GNU General Public License v2.0 5 votes vote down vote up
public static Repository createRepository(){
	
	final Properties props = new Properties();
	props.put(Options.BUFFER_MODE, BufferMode.DiskRW); 
	props.put(Options.FILE, journalFile); 
	final BigdataSail sail = new BigdataSail(props);
	final Repository repo = new BigdataSailRepository(sail);
	return repo;
	
}
 
Example #29
Source File: EmbeddedBlazeGraphProvider.java    From tinkerpop3 with GNU General Public License v2.0 4 votes vote down vote up
public static BlazeGraphEmbedded open(final Configuration config) {
    final String name = config.getString(Options.REPOSITORY_NAME);
    final BigdataSailRepository repo = getRepository(name);
    return BlazeGraphEmbedded.open(repo, config);
}
 
Example #30
Source File: BlazeGraphFactory.java    From tinkerpop3 with GNU General Public License v2.0 4 votes vote down vote up
public static final BlazeGraphEmbedded open(final String journal) {
    final BigdataSailRepository repo = BasicRepositoryProvider.open(journal);
    return BlazeGraphEmbedded.open(repo);
}