use of org.apache.rya.api.client.Install in project incubator-rya by apache.
the class MongoCreatePCJIT method createPCJ.
@Test
public void createPCJ() throws Exception {
final MongoConnectionDetails connectionDetails = getConnectionDetails();
final RyaClient ryaClient = MongoRyaClientFactory.build(connectionDetails, getMongoClient());
// Initialize the commands that will be used by this test.
final CreatePCJ createPCJ = ryaClient.getCreatePCJ();
final Install installRya = ryaClient.getInstall();
final InstallConfiguration installConf = InstallConfiguration.builder().setEnablePcjIndex(true).build();
installRya.install(conf.getRyaInstanceName(), installConf);
System.out.println(getMongoClient().getDatabase(conf.getRyaInstanceName()).getCollection("instance_details").find().first().toJson());
// Create a PCJ.
final String sparql = "SELECT ?x " + "WHERE { " + "?x <http://talksTo> <http://Eve>. " + "?x <http://worksAt> <http://TacoJoint>." + "}";
final String pcjId = createPCJ.createPCJ(conf.getRyaInstanceName(), sparql);
// Verify the RyaDetails were updated to include the new PCJ.
final Optional<RyaDetails> ryaDetails = ryaClient.getGetInstanceDetails().getDetails(conf.getRyaInstanceName());
final ImmutableMap<String, PCJDetails> details = ryaDetails.get().getPCJIndexDetails().getPCJDetails();
final PCJDetails pcjDetails = details.get(pcjId);
assertEquals(pcjId, pcjDetails.getId());
assertFalse(pcjDetails.getLastUpdateTime().isPresent());
try (final PrecomputedJoinStorage pcjStorage = new MongoPcjStorage(getMongoClient(), conf.getRyaInstanceName())) {
final PcjMetadata pcjMetadata = pcjStorage.getPcjMetadata(pcjId);
// confirm that the pcj was added to the pcj store.
assertEquals(sparql, pcjMetadata.getSparql());
assertEquals(0L, pcjMetadata.getCardinality());
}
}
use of org.apache.rya.api.client.Install in project incubator-rya by apache.
the class MongoInstallIT method install.
@Test
public void install() throws DuplicateInstanceNameException, RyaClientException {
// Install an instance of Rya.
final String ryaInstance = conf.getMongoDBName();
// Setup the connection details that were used for the embedded Mongo DB instance we are testing with.
final MongoConnectionDetails connectionDetails = getConnectionDetails();
// Check that the instance does not exist.
final InstanceExists instanceExists = new MongoInstanceExists(getMongoClient());
assertFalse(instanceExists.exists(ryaInstance));
// Install an instance of Rya with all the valid options turned on.
final InstallConfiguration installConfig = InstallConfiguration.builder().setEnableTableHashPrefix(true).setEnableFreeTextIndex(true).setEnableTemporalIndex(true).build();
final RyaClient ryaClient = MongoRyaClientFactory.build(connectionDetails, getMongoClient());
final Install install = ryaClient.getInstall();
install.install(ryaInstance, installConfig);
// Check that the instance exists.
assertTrue(instanceExists.exists(ryaInstance));
// Show that the expected collections were created within the database.
final List<String> expected = Arrays.asList(INSTANCE_DETAILS_COLLECTION_NAME, "rya_triples");
int count = 0;
final List<String> found = new ArrayList<>();
for (final String collection : getMongoClient().getDatabase(conf.getMongoDBName()).listCollectionNames()) {
count += expected.contains(collection) ? 1 : 0;
found.add(collection);
}
assertTrue("Tables missing from:" + expected + " actual:" + found, expected.size() == count);
assertTrue("Instance should exist.", instanceExists.exists(ryaInstance));
}
Aggregations