本文整理汇总了Java中org.openrdf.sail.Sail类的典型用法代码示例。如果您正苦于以下问题:Java Sail类的具体用法?Java Sail怎么用?Java Sail使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Sail类属于org.openrdf.sail包,在下文中一共展示了Sail类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: installRyaInstance
import org.openrdf.sail.Sail; //导入依赖的package包/类
private void installRyaInstance() throws Exception {
final MiniAccumuloCluster cluster = super.getMiniAccumuloCluster();
final String instanceName = cluster.getInstanceName();
final String zookeepers = cluster.getZooKeepers();
// Install the Rya instance to the mini accumulo cluster.
final RyaClient ryaClient = AccumuloRyaClientFactory.build(
new AccumuloConnectionDetails(ACCUMULO_USER, ACCUMULO_PASSWORD.toCharArray(), instanceName, zookeepers),
super.getAccumuloConnector());
ryaClient.getInstall().install(RYA_INSTANCE_NAME,
InstallConfiguration.builder().setEnableTableHashPrefix(false).setEnableFreeTextIndex(false)
.setEnableEntityCentricIndex(false).setEnableGeoIndex(false).setEnableTemporalIndex(false).setEnablePcjIndex(true)
.setFluoPcjAppName(super.getFluoConfiguration().getApplicationName()).build());
// Connect to the Rya instance that was just installed.
final AccumuloRdfConfiguration conf = makeConfig(instanceName, zookeepers);
final Sail sail = RyaSailFactory.getInstance(conf);
dao = RyaSailFactory.getAccumuloDAOWithUpdatedConfig(conf);
ryaSailRepo = new RyaSailRepository(sail);
}
示例2: connectToRya
import org.openrdf.sail.Sail; //导入依赖的package包/类
private Sail connectToRya(final String ryaInstanceName) throws RyaClientException {
try {
final AccumuloConnectionDetails connectionDetails = super.getAccumuloConnectionDetails();
final AccumuloRdfConfiguration ryaConf = new AccumuloRdfConfiguration();
ryaConf.setTablePrefix(ryaInstanceName);
ryaConf.set(ConfigUtils.CLOUDBASE_USER, connectionDetails.getUsername());
ryaConf.set(ConfigUtils.CLOUDBASE_PASSWORD, new String(connectionDetails.getUserPass()));
ryaConf.set(ConfigUtils.CLOUDBASE_ZOOKEEPERS, connectionDetails.getZookeepers());
ryaConf.set(ConfigUtils.CLOUDBASE_INSTANCE, connectionDetails.getInstanceName());
// Turn PCJs off so that we will only scan the core Rya tables while building the PCJ results.
ryaConf.set(ConfigUtils.USE_PCJ, "false");
return RyaSailFactory.getInstance(ryaConf);
} catch (SailException | AccumuloException | AccumuloSecurityException | RyaDAOException | InferenceEngineException e) {
throw new RyaClientException("Could not connect to the Rya instance named '" + ryaInstanceName + "'.", e);
}
}
示例3: ensureInEntityStore_Test
import org.openrdf.sail.Sail; //导入依赖的package包/类
@Test
public void ensureInEntityStore_Test() throws Exception {
final Sail sail = RyaSailFactory.getInstance(conf);
SailRepositoryConnection conn = new SailRepository(sail).getConnection();
conn.begin();
try(MongoEntityIndexer indexer = new MongoEntityIndexer()) {
indexer.setConf(conf);
indexer.init();
setupTypes(indexer);
addStatements(conn);
final EntityStorage entities = indexer.getEntityStorage();
final RyaURI subject = new RyaURI("urn:alice");
final Optional<Entity> alice = entities.get(subject);
assertTrue(alice.isPresent());
} finally {
conn.close();
}
}
示例4: near_invalidDistance
import org.openrdf.sail.Sail; //导入依赖的package包/类
@Test(expected = MalformedQueryException.class)
public void near_invalidDistance() throws Exception {
final Sail sail = GeoRyaSailFactory.getInstance(conf);
final SailRepositoryConnection conn = new SailRepository(sail).getConnection();
try {
populateRya(conn);
//Only captial
final String query =
"PREFIX geo: <http://www.opengis.net/ont/geosparql#>\n"
+ "PREFIX geof: <http://www.opengis.net/def/function/geosparql/>\n"
+ "SELECT * \n" //
+ "WHERE { \n"
+ " <urn:geo> geo:asWKT ?point .\n"
+ " FILTER(geof:sfNear(?point, \"POINT(38.8895 77.0353)\"^^geo:wktLiteral, distance))"
+ "}";
conn.prepareTupleQuery(QueryLanguage.SPARQL, query).evaluate();
} finally {
conn.close();
sail.shutDown();
}
}
示例5: near_negativeDistance
import org.openrdf.sail.Sail; //导入依赖的package包/类
@Test(expected = IllegalArgumentException.class)
public void near_negativeDistance() throws Exception {
final Sail sail = GeoRyaSailFactory.getInstance(conf);
final SailRepositoryConnection conn = new SailRepository(sail).getConnection();
try {
populateRya(conn);
//Only captial
final String query =
"PREFIX geo: <http://www.opengis.net/ont/geosparql#>\n"
+ "PREFIX geof: <http://www.opengis.net/def/function/geosparql/>\n"
+ "SELECT * \n" //
+ "WHERE { \n"
+ " <urn:geo> geo:asWKT ?point .\n"
+ " FILTER(geof:sfNear(?point, \"POINT(38.8895 77.0353)\"^^geo:wktLiteral, -100))"
+ "}";
final TupleQueryResult rez = conn.prepareTupleQuery(QueryLanguage.SPARQL, query).evaluate();
while(rez.hasNext()) {
rez.next();
}
} finally {
conn.close();
sail.shutDown();
}
}
示例6: tooManyArgumentsTest
import org.openrdf.sail.Sail; //导入依赖的package包/类
@Test(expected = QueryEvaluationException.class)
public void tooManyArgumentsTest() throws Exception {
final Sail sail = GeoRyaSailFactory.getInstance(conf);
final SailRepositoryConnection conn = new SailRepository(sail).getConnection();
try {
populateRya(conn);
// Only captial
final String query =
"PREFIX geo: <http://www.opengis.net/ont/geosparql#>\n"
+ "PREFIX geof: <http://www.opengis.net/def/function/geosparql/>\n"
+ "SELECT * \n" //
+ "WHERE { \n" + " <urn:geo> geo:asWKT ?point .\n"
+ " FILTER(geof:sfNear(?point, \"POINT(38.8895 77.0353)\"^^geo:wktLiteral, 100, 1000, 10))"
+ "}";
conn.prepareTupleQuery(QueryLanguage.SPARQL, query).evaluate();
} finally {
conn.close();
sail.shutDown();
}
}
示例7: ensureInEventStore_Test
import org.openrdf.sail.Sail; //导入依赖的package包/类
@Test
public void ensureInEventStore_Test() throws Exception {
final Sail sail = GeoRyaSailFactory.getInstance(conf);
final SailRepository repo = new SailRepository(sail);
try(final MongoGeoTemporalIndexer indexer = new MongoGeoTemporalIndexer()) {
indexer.setConf(conf);
indexer.init();
addStatements(repo.getConnection());
final EventStorage events = indexer.getEventStorage();
final RyaURI subject = new RyaURI("urn:event1");
final Optional<Event> event = events.get(subject);
assertTrue(event.isPresent());
} finally {
sail.shutDown();
}
}
示例8: getSail
import org.openrdf.sail.Sail; //导入依赖的package包/类
@Override
public synchronized Sail getSail() throws SailException {
if (repository == null) {
try {
virtuoso = new VirtuosoRepository("jdbc:virtuoso://localhost:1111", "dba", "dba", true);
repository = new RepositorySail(virtuoso);
// Needed for inferencing...
URL schema = Thread.currentThread().getContextClassLoader().getResource("/org/waag/ah/rdf/schema/artsholland.rdf");
RepositoryConnection connection = virtuoso.getConnection();
connection.add(schema, null, RDFFormat.RDFXML);
virtuoso.createRuleSet("artsholland", "http://purl.org/artsholland/1.0/");
connection.close();
} catch (Exception e) {
throw new SailException(e);
}
}
return repository;
}
示例9: getSail
import org.openrdf.sail.Sail; //导入依赖的package包/类
@Override
public synchronized Sail getSail() throws SailException {
if (sail == null) {
try {
config = PlatformConfigHelper.getConfig();
Properties properties = ConfigurationConverter.getProperties(loadProperties());
// BigdataSailRepository repository = new BigdataSailRepository(new com.bigdata.rdf.sail.BigdataSail(properties));
// repo = new BigdataSail(repository);
sail = new SimpleTypeInferencingSail(
// new SmartSailWrapper(
new BigdataSail(properties));
// sail.setPipelineTypes(Arrays.asList(
// "getReadOnlyConnection",
// "getReadWriteConnection",
// "getUnisolatedConnection"));
} catch (Exception e) {
throw new SailException(e);
}
}
return sail;
}
示例10: GenerateRdf
import org.openrdf.sail.Sail; //导入依赖的package包/类
public GenerateRdf(String currentNameSpace, String outputFileName) throws RepositoryException {
rand = new Random(System.currentTimeMillis());
if (!outputFileName.contains(".rdf")) {
outputFileName += ".rdf";
}
java.io.File outFile = new java.io.File("tmp/" + outputFileName.replace(".rdf", "")+ UUID.randomUUID());
Sail sailInMemory = new MemoryStore(outFile);
sr = new SailRepository(sailInMemory);
sr.initialize();
src = sr.getConnection();
vf = sr.getValueFactory();
try {
currentNamespaceUri = vf.createURI(currentNameSpace);
_currentNamespace = currentNameSpace;
} catch (IllegalArgumentException ex) {
Logger.getLogger(App.class.getName()).warning("The uri was invalid. Using the default one: " + DEFAULT_NAMESPACE);
currentNamespaceUri = vf.createURI(DEFAULT_NAMESPACE);
_currentNamespace = DEFAULT_NAMESPACE;
}
this.outputFileName = outputFileName;
}
示例11: getSail
import org.openrdf.sail.Sail; //导入依赖的package包/类
public Sail getSail(SailImplConfig config)
throws SailConfigException
{
if (!SAIL_TYPE.equals(config.getType())) {
throw new SailConfigException("Invalid Sail type: " + config.getType());
}
BEDFileStore memoryStore = new BEDFileStore();
if (config instanceof BEDFileConfig) {
BEDFileConfig memConfig = (BEDFileConfig)config;
memoryStore.setBedFile(new File(memConfig.getFile()));
}
return memoryStore;
}
示例12: RepositoryRegistry
import org.openrdf.sail.Sail; //导入依赖的package包/类
/**
* Initializes Sesame repository for Neo4j based on Blueprints
* implementation.
*
* @param database Neo4j database service
* @throws RepositoryException if there was a problem initializing the
* Sesame repository
*/
private RepositoryRegistry(GraphDatabaseService database)
throws RepositoryException {
initRio();
Graph graph = new Neo4j2Graph(database);
String patterns = SPARQLExtensionProps.getProperty("query.patterns");
Sail sail = new GraphSail((KeyIndexableGraph) graph, patterns);
this.rep = new SailRepository(sail);
rep.initialize();
}
示例13: createRc
import org.openrdf.sail.Sail; //导入依赖的package包/类
@Override
protected final void createRc( Properties p ) {
if ( null != rc ) {
// we've already have our rc created, so there's nothing to do here
return;
}
Security.getSecurity().associateUser( this, new LocalUserImpl() );
MemoryStore memstore = ( p.containsKey( MEMSTORE_DIR )
? new MemoryStore( new File( p.getProperty( MEMSTORE_DIR ) ) )
: new MemoryStore() );
if ( p.containsKey( SYNC_DELAY ) ) {
memstore.setSyncDelay( Long.parseLong( p.getProperty( SYNC_DELAY ) ) );
}
Sail sail = ( p.containsKey( INFER )
? new ForwardChainingRDFSInferencer( memstore )
: memstore );
Repository repo = new SailRepository( sail );
try {
repo.initialize();
rc = repo.getConnection();
}
catch ( Exception e ) {
try {
repo.shutDown();
}
catch ( Exception ex ) {
log.error( ex, ex );
}
}
setRepositoryConnection( rc, true );
}
示例14: createRepository
import org.openrdf.sail.Sail; //导入依赖的package包/类
private ObjectRepository createRepository() throws Exception {
Sail sail = new MemoryStore();
sail = new AuditingSail(sail);
Repository repo = new OptimisticRepository(sail);
repo.initialize();
ObjectRepositoryFactory factory = new ObjectRepositoryFactory();
return factory.createRepository(config, repo);
}
示例15: testCollect
import org.openrdf.sail.Sail; //导入依赖的package包/类
@Test
public void testCollect() throws ProvenanceCollectionException, RepositoryException, MalformedQueryException, QueryEvaluationException {
Sail ms = new MemoryStore();
SailRepository repo = new SailRepository(ms);
repo.initialize();
TriplestoreProvenanceCollector coll = new TriplestoreProvenanceCollector(repo, "fakeUser", "SPARQL");
coll.recordQuery("fakeQuery");
String queryString = "SELECT ?x ?y WHERE { ?x ?p ?y } ";
TupleQuery tupleQuery = repo.getConnection().prepareTupleQuery(QueryLanguage.SPARQL, queryString);
TupleQueryResult result = tupleQuery.evaluate();
// TODO not asserting on the results.
assertTrue(result.hasNext());
}