use of org.apache.rya.accumulo.AccumuloRyaDAO in project incubator-rya by apache.
the class StatementPatternEvalTest method init.
@Before
public void init() throws Exception {
conf = getConf();
Instance mock = new MockInstance("instance");
Connector conn = mock.getConnector("root", new PasswordToken(""));
dao = new AccumuloRyaDAO();
dao.setConnector(conn);
dao.init();
eval = new ParallelEvaluationStrategyImpl(new StoreTripleSource(conf, dao), null, null, conf);
}
use of org.apache.rya.accumulo.AccumuloRyaDAO in project incubator-rya by apache.
the class StatementPatternStorage method addInferredRanges.
protected void addInferredRanges(String tablePrefix, Job job) throws IOException {
logger.info("Adding inferences to statement pattern[subject:" + subject_value + ", predicate:" + predicate_value + ", object:" + object_value + "]");
// inference engine
AccumuloRyaDAO ryaDAO = new AccumuloRyaDAO();
InferenceEngine inferenceEngine = new InferenceEngine();
try {
AccumuloRdfConfiguration rdfConf = new AccumuloRdfConfiguration(job.getConfiguration());
rdfConf.setTablePrefix(tablePrefix);
ryaDAO.setConf(rdfConf);
try {
if (!mock) {
ryaDAO.setConnector(new ZooKeeperInstance(inst, zookeepers).getConnector(user, userP.getBytes(StandardCharsets.UTF_8)));
} else {
ryaDAO.setConnector(new MockInstance(inst).getConnector(user, userP.getBytes(StandardCharsets.UTF_8)));
}
} catch (Exception e) {
throw new IOException(e);
}
ryaDAO.init();
inferenceEngine.setConf(rdfConf);
inferenceEngine.setRyaDAO(ryaDAO);
inferenceEngine.setSchedule(false);
inferenceEngine.init();
// is it subclassof or subpropertyof
if (RDF.TYPE.equals(predicate_value)) {
// try subclassof
Collection<URI> parents = inferenceEngine.findParents(inferenceEngine.getSubClassOfGraph(), (URI) object_value);
if (parents != null && parents.size() > 0) {
// add all relationships
for (URI parent : parents) {
Map.Entry<TABLE_LAYOUT, Range> temp = createRange(subject_value, predicate_value, parent);
Range range = temp.getValue();
if (logger.isDebugEnabled()) {
logger.debug("Found subClassOf relationship [type:" + object_value + " is subClassOf:" + parent + "]");
}
addRange(range);
}
}
} else if (predicate_value != null) {
// subpropertyof check
Set<URI> parents = inferenceEngine.findParents(inferenceEngine.getSubPropertyOfGraph(), (URI) predicate_value);
for (URI parent : parents) {
Map.Entry<TABLE_LAYOUT, Range> temp = createRange(subject_value, parent, object_value);
Range range = temp.getValue();
if (logger.isDebugEnabled()) {
logger.debug("Found subPropertyOf relationship [type:" + predicate_value + " is subPropertyOf:" + parent + "]");
}
addRange(range);
}
}
} catch (Exception e) {
logger.error("Exception in adding inferred ranges", e);
throw new IOException(e);
} finally {
if (inferenceEngine != null) {
try {
inferenceEngine.destroy();
} catch (InferenceEngineException e) {
logger.error("Exception closing InferenceEngine", e);
}
}
if (ryaDAO != null) {
try {
ryaDAO.destroy();
} catch (RyaDAOException e) {
logger.error("Exception closing ryadao", e);
}
}
}
}
use of org.apache.rya.accumulo.AccumuloRyaDAO in project incubator-rya by apache.
the class TextOutputExample method setUpRya.
static void setUpRya() throws AccumuloException, AccumuloSecurityException, RyaDAOException {
MockInstance mock = new MockInstance(INSTANCE_NAME);
Connector conn = mock.getConnector(USERNAME, new PasswordToken(USERP));
AccumuloRyaDAO dao = new AccumuloRyaDAO();
dao.setConnector(conn);
AccumuloRdfConfiguration conf = new AccumuloRdfConfiguration();
conf.setTablePrefix(PREFIX);
dao.setConf(conf);
dao.init();
String ns = "http://example.com/";
dao.add(new RyaStatement(new RyaURI(ns + "s1"), new RyaURI(ns + "p1"), new RyaURI(ns + "o1")));
dao.add(new RyaStatement(new RyaURI(ns + "s1"), new RyaURI(ns + "p2"), new RyaURI(ns + "o2")));
dao.add(new RyaStatement(new RyaURI(ns + "s2"), new RyaURI(ns + "p1"), new RyaURI(ns + "o3"), new RyaURI(ns + "g1")));
dao.add(new RyaStatement(new RyaURI(ns + "s3"), new RyaURI(ns + "p3"), new RyaURI(ns + "o3"), new RyaURI(ns + "g2")));
dao.destroy();
}
use of org.apache.rya.accumulo.AccumuloRyaDAO in project incubator-rya by apache.
the class GraphXEdgeInputFormatTest method init.
@Before
public void init() throws Exception {
instance = new MockInstance(GraphXEdgeInputFormatTest.class.getName() + ".mock_instance");
Connector connector = instance.getConnector(username, password);
connector.tableOperations().create(table);
AccumuloRdfConfiguration conf = new AccumuloRdfConfiguration();
conf.setTablePrefix("rya_");
conf.setDisplayQueryPlan(false);
apiImpl = new AccumuloRyaDAO();
apiImpl.setConf(conf);
apiImpl.setConnector(connector);
apiImpl.init();
}
use of org.apache.rya.accumulo.AccumuloRyaDAO in project incubator-rya by apache.
the class AccumuloRdfCountToolTest method setUp.
@Before
public void setUp() throws Exception {
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);
connector.tableOperations().create(tablePrefix + RdfCloudTripleStoreConstants.TBL_EVAL_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);
secOps.grantTablePermission(user, tablePrefix + RdfCloudTripleStoreConstants.TBL_EVAL_SUFFIX, TablePermission.READ);
secOps.grantTablePermission(user, tablePrefix + RdfCloudTripleStoreConstants.TBL_EVAL_SUFFIX, TablePermission.WRITE);
dao = new AccumuloRyaDAO();
dao.setConnector(connector);
conf.setTablePrefix(tablePrefix);
dao.setConf(conf);
dao.init();
}
Aggregations