use of org.apache.rya.accumulo.AccumuloRyaDAO in project incubator-rya by apache.
the class KafkaRyaSubGraphExportIT method loadRyaStatements.
protected String loadRyaStatements(final String sparql, final Collection<RyaStatement> statements) throws Exception {
requireNonNull(sparql);
requireNonNull(statements);
FluoClient client = null;
try {
CreateFluoPcj createPcj = new CreateFluoPcj();
client = new FluoClientImpl(super.getFluoConfiguration());
String id = createPcj.createPcj(sparql, client).getQueryId();
AccumuloRyaDAO dao = getRyaDAO();
dao.add(statements.iterator());
// Wait for the Fluo application to finish computing the end result.
super.getMiniFluo().waitForObservers();
// FluoITHelper.printFluoTable(client);
return id;
} finally {
if (client != null) {
client.close();
}
}
}
use of org.apache.rya.accumulo.AccumuloRyaDAO in project incubator-rya by apache.
the class AccumuloInstanceDriver method setUpDao.
/**
* Sets up the {@link AccumuloRyaDAO}.
* @throws Exception
*/
public void setUpDao() throws Exception {
// Setup dao
log.info("Creating " + driverName + " DAO");
dao = new AccumuloRyaDAO();
dao.setConnector(connector);
dao.setConf(config);
// Flush the tables before initializing the DAO
for (final String tableName : tableList) {
connector.tableOperations().flush(tableName, null, null, false);
}
dao.init();
}
use of org.apache.rya.accumulo.AccumuloRyaDAO in project incubator-rya by apache.
the class AccumuloRyaUtils method setupDao.
/**
* Sets up a {@link AccumuloRyaDAO} with the specified connector and config.
* @param connector the {@link Connector}.
* @param accumuloRdfConfiguration the {@link AccumuloRdfConfiguration}.
* @return the {@link AccumuloRyaDAO}.
*/
public static AccumuloRyaDAO setupDao(final Connector connector, final AccumuloRdfConfiguration accumuloRdfConfiguration) {
final AccumuloRyaDAO accumuloRyaDao = new AccumuloRyaDAO();
accumuloRyaDao.setConnector(connector);
accumuloRyaDao.setConf(accumuloRdfConfiguration);
try {
accumuloRyaDao.init();
} catch (final RyaDAOException e) {
log.error("Error initializing DAO", e);
}
return accumuloRyaDao;
}
use of org.apache.rya.accumulo.AccumuloRyaDAO in project incubator-rya by apache.
the class HistoricStreamingVisibilityIT method historicResults.
/**
* Ensure historic matches are included in the result.
*/
@Test
public void historicResults() throws Exception {
// A query that finds people who talk to Eve and work at Chipotle.
final String sparql = "SELECT ?x " + "WHERE { " + "?x <http://talksTo> <http://Eve>. " + "?x <http://worksAt> <http://Chipotle>." + "}";
final Connector accumuloConn = super.getAccumuloConnector();
accumuloConn.securityOperations().changeUserAuthorizations(getUsername(), new Authorizations("U", "V", "W"));
final AccumuloRyaDAO dao = new AccumuloRyaDAO();
dao.setConnector(accumuloConn);
dao.setConf(makeConfig());
dao.init();
// Triples that are loaded into Rya before the PCJ is created.
final ValueFactory vf = new ValueFactoryImpl();
final Set<RyaStatement> historicTriples = Sets.newHashSet(makeRyaStatement(vf.createStatement(vf.createURI("http://Alice"), vf.createURI("http://talksTo"), vf.createURI("http://Eve")), "U"), makeRyaStatement(vf.createStatement(vf.createURI("http://Bob"), vf.createURI("http://talksTo"), vf.createURI("http://Eve")), "V"), makeRyaStatement(vf.createStatement(vf.createURI("http://Charlie"), vf.createURI("http://talksTo"), vf.createURI("http://Eve")), "W"), makeRyaStatement(vf.createStatement(vf.createURI("http://Eve"), vf.createURI("http://helps"), vf.createURI("http://Kevin")), "U"), makeRyaStatement(vf.createStatement(vf.createURI("http://Bob"), vf.createURI("http://worksAt"), vf.createURI("http://Chipotle")), "W"), makeRyaStatement(vf.createStatement(vf.createURI("http://Charlie"), vf.createURI("http://worksAt"), vf.createURI("http://Chipotle")), "V"), makeRyaStatement(vf.createStatement(vf.createURI("http://Eve"), vf.createURI("http://worksAt"), vf.createURI("http://Chipotle")), "U"), makeRyaStatement(vf.createStatement(vf.createURI("http://David"), vf.createURI("http://worksAt"), vf.createURI("http://Chipotle")), "V"));
dao.add(historicTriples.iterator());
dao.flush();
// The expected results of the SPARQL query once the PCJ has been computed.
final Set<BindingSet> expected = new HashSet<>();
MapBindingSet bs = new MapBindingSet();
bs.addBinding("x", vf.createURI("http://Bob"));
expected.add(bs);
bs = new MapBindingSet();
bs.addBinding("x", vf.createURI("http://Charlie"));
expected.add(bs);
// Create the PCJ table.
final PrecomputedJoinStorage pcjStorage = new AccumuloPcjStorage(accumuloConn, getRyaInstanceName());
final String pcjId = pcjStorage.createPcj(sparql);
try (FluoClient fluoClient = FluoFactory.newClient(super.getFluoConfiguration())) {
new CreateFluoPcj().withRyaIntegration(pcjId, pcjStorage, fluoClient, accumuloConn, getRyaInstanceName());
}
// Verify the end results of the query match the expected results.
super.getMiniFluo().waitForObservers();
final Set<BindingSet> results = Sets.newHashSet(pcjStorage.listResults(pcjId));
Assert.assertEquals(expected, results);
}
use of org.apache.rya.accumulo.AccumuloRyaDAO in project incubator-rya by apache.
the class StatementPatternStorageTest method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
connector = new MockInstance(instance).getConnector(user, pwd.getBytes());
connector.tableOperations().create(tablePrefix + RdfCloudTripleStoreConstants.TBL_SPO_SUFFIX);
connector.tableOperations().create(tablePrefix + RdfCloudTripleStoreConstants.TBL_PO_SUFFIX);
connector.tableOperations().create(tablePrefix + RdfCloudTripleStoreConstants.TBL_OSP_SUFFIX);
connector.tableOperations().create(tablePrefix + RdfCloudTripleStoreConstants.TBL_NS_SUFFIX);
SecurityOperations secOps = connector.securityOperations();
secOps.createUser(user, pwd.getBytes(), auths);
secOps.grantTablePermission(user, tablePrefix + RdfCloudTripleStoreConstants.TBL_SPO_SUFFIX, TablePermission.READ);
secOps.grantTablePermission(user, tablePrefix + RdfCloudTripleStoreConstants.TBL_PO_SUFFIX, TablePermission.READ);
secOps.grantTablePermission(user, tablePrefix + RdfCloudTripleStoreConstants.TBL_OSP_SUFFIX, TablePermission.READ);
secOps.grantTablePermission(user, tablePrefix + RdfCloudTripleStoreConstants.TBL_NS_SUFFIX, TablePermission.READ);
conf = new AccumuloRdfConfiguration();
ryaDAO = new AccumuloRyaDAO();
ryaDAO.setConnector(connector);
conf.setTablePrefix(tablePrefix);
ryaDAO.setConf(conf);
ryaDAO.init();
}
Aggregations