use of org.apache.rya.accumulo.AccumuloRdfConfiguration 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.AccumuloRdfConfiguration 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.AccumuloRdfConfiguration 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.AccumuloRdfConfiguration in project incubator-rya by apache.
the class RdfFileInputToolTest method testNTriplesInput.
@Test
public void testNTriplesInput() throws Exception {
RdfFileInputTool.main(new String[] { "-Dac.mock=true", "-Dac.instance=" + instance, "-Dac.username=" + user, "-Dac.pwd=" + pwd, "-Dac.auth=" + auths.toString(), "-Dac.cv=" + auths.toString(), "-Drdf.tablePrefix=" + tablePrefix, "-Drdf.format=" + RDFFormat.NTRIPLES.getName(), "src/test/resources/test.ntriples" });
RyaStatement rs = new RyaStatement(new RyaURI("urn:lubm:rdfts#GraduateStudent01"), new RyaURI("urn:lubm:rdfts#hasFriend"), new RyaURI("urn:lubm:rdfts#GraduateStudent02"));
rs.setColumnVisibility(auths.toString().getBytes());
AccumuloRdfConfiguration conf = new AccumuloRdfConfiguration();
conf.setTablePrefix(tablePrefix);
conf.setAuths(auths.toString());
TestUtils.verify(connector, conf, rs);
}
use of org.apache.rya.accumulo.AccumuloRdfConfiguration in project incubator-rya by apache.
the class QueryBenchmarkRunIT method setup.
@BeforeClass
public static void setup() throws Exception {
// Squash loud logs.
Logger.getLogger(ClientCnxn.class).setLevel(Level.ERROR);
// Setup the Mini Accumulo Cluster.
final File miniDataDir = com.google.common.io.Files.createTempDir();
final MiniAccumuloConfig cfg = new MiniAccumuloConfig(miniDataDir, ACCUMULO_PASSWORD);
cluster = new MiniAccumuloCluster(cfg);
cluster.start();
// Create a Rya Client connected to the Mini Accumulo Cluster.
final AccumuloConnectionDetails connDetails = new AccumuloConnectionDetails(ACCUMULO_USER, ACCUMULO_PASSWORD.toCharArray(), cluster.getInstanceName(), cluster.getZooKeepers());
final Connector connector = cluster.getConnector(ACCUMULO_USER, ACCUMULO_PASSWORD);
final RyaClient ryaClient = AccumuloRyaClientFactory.build(connDetails, connector);
// Install an instance of Rya on the mini cluster.
installRya(ryaClient);
// Get a Sail object that is backed by the Rya store that is on the mini cluster.
final AccumuloRdfConfiguration ryaConf = new AccumuloRdfConfiguration();
ryaConf.setTablePrefix(RYA_INSTANCE_NAME);
ryaConf.set(ConfigUtils.CLOUDBASE_USER, ACCUMULO_USER);
ryaConf.set(ConfigUtils.CLOUDBASE_PASSWORD, ACCUMULO_PASSWORD);
ryaConf.set(ConfigUtils.CLOUDBASE_ZOOKEEPERS, cluster.getZooKeepers());
ryaConf.set(ConfigUtils.CLOUDBASE_INSTANCE, cluster.getInstanceName());
ryaConf.set(ConfigUtils.USE_PCJ, "true");
ryaConf.set(ConfigUtils.PCJ_STORAGE_TYPE, PrecomputedJoinStorageType.ACCUMULO.toString());
ryaConf.set(ConfigUtils.PCJ_UPDATER_TYPE, PrecomputedJoinUpdaterType.NO_UPDATE.toString());
sail = RyaSailFactory.getInstance(ryaConf);
// Load some data into the cluster that will match the query we're testing against.
loadTestStatements();
// Add a PCJ to the application that summarizes the query.
createTestPCJ(ryaClient);
}
Aggregations