Search in sources :

Example 1 with ListQueryIds

use of org.apache.rya.indexing.pcj.fluo.api.ListQueryIds in project incubator-rya by apache.

the class AccumuloDeletePCJIT method deletePCJ.

@Test
public void deletePCJ() throws InstanceDoesNotExistException, RyaClientException, PCJStorageException, RepositoryException {
    // Initialize the commands that will be used by this test.
    final CreatePCJ createPCJ = new AccumuloCreatePCJ(createConnectionDetails(), accumuloConn);
    // Create a PCJ.
    final String sparql = "SELECT ?x " + "WHERE { " + "?x <http://talksTo> <http://Eve>. " + "?x <http://worksAt> <http://TacoJoint>." + "}";
    final String pcjId = createPCJ.createPCJ(getRyaInstanceName(), sparql);
    // Verify a Query ID was added for the query within the Fluo app.
    List<String> fluoQueryIds = new ListQueryIds().listQueryIds(fluoClient);
    assertEquals(1, fluoQueryIds.size());
    // Insert some statements into Rya.
    final ValueFactory vf = ryaRepo.getValueFactory();
    ryaConn.add(vf.createURI("http://Alice"), vf.createURI("http://talksTo"), vf.createURI("http://Eve"));
    ryaConn.add(vf.createURI("http://Bob"), vf.createURI("http://talksTo"), vf.createURI("http://Eve"));
    ryaConn.add(vf.createURI("http://Charlie"), vf.createURI("http://talksTo"), vf.createURI("http://Eve"));
    ryaConn.add(vf.createURI("http://Eve"), vf.createURI("http://helps"), vf.createURI("http://Kevin"));
    ryaConn.add(vf.createURI("http://Bob"), vf.createURI("http://worksAt"), vf.createURI("http://TacoJoint"));
    ryaConn.add(vf.createURI("http://Charlie"), vf.createURI("http://worksAt"), vf.createURI("http://TacoJoint"));
    ryaConn.add(vf.createURI("http://Eve"), vf.createURI("http://worksAt"), vf.createURI("http://TacoJoint"));
    ryaConn.add(vf.createURI("http://David"), vf.createURI("http://worksAt"), vf.createURI("http://TacoJoint"));
    // Verify the correct results were exported.
    fluo.waitForObservers();
    try (final PrecomputedJoinStorage pcjStorage = new AccumuloPcjStorage(accumuloConn, getRyaInstanceName())) {
        final Set<BindingSet> results = Sets.newHashSet(pcjStorage.listResults(pcjId));
        final MapBindingSet bob = new MapBindingSet();
        bob.addBinding("x", vf.createURI("http://Bob"));
        final MapBindingSet charlie = new MapBindingSet();
        charlie.addBinding("x", vf.createURI("http://Charlie"));
        final Set<BindingSet> expected = Sets.<BindingSet>newHashSet(bob, charlie);
        assertEquals(expected, results);
        // Delete the PCJ.
        final DeletePCJ deletePCJ = new AccumuloDeletePCJ(createConnectionDetails(), accumuloConn);
        deletePCJ.deletePCJ(getRyaInstanceName(), pcjId);
        // Ensure the PCJ's metadata has been removed from the storage.
        assertTrue(pcjStorage.listPcjs().isEmpty());
        // Ensure the PCJ has been removed from the Fluo application.
        fluo.waitForObservers();
        // Verify a Query ID was added for the query within the Fluo app.
        fluoQueryIds = new ListQueryIds().listQueryIds(fluoClient);
        assertEquals(0, fluoQueryIds.size());
    }
}
Also used : MapBindingSet(org.openrdf.query.impl.MapBindingSet) BindingSet(org.openrdf.query.BindingSet) AccumuloPcjStorage(org.apache.rya.indexing.pcj.storage.accumulo.AccumuloPcjStorage) CreatePCJ(org.apache.rya.api.client.CreatePCJ) ValueFactory(org.openrdf.model.ValueFactory) ListQueryIds(org.apache.rya.indexing.pcj.fluo.api.ListQueryIds) PrecomputedJoinStorage(org.apache.rya.indexing.pcj.storage.PrecomputedJoinStorage) MapBindingSet(org.openrdf.query.impl.MapBindingSet) DeletePCJ(org.apache.rya.api.client.DeletePCJ) Test(org.junit.Test)

Example 2 with ListQueryIds

use of org.apache.rya.indexing.pcj.fluo.api.ListQueryIds in project incubator-rya by apache.

the class AccumuloDeletePCJIT method dropAndDestroyPCJ.

@Test
public void dropAndDestroyPCJ() throws InstanceDoesNotExistException, RyaClientException, PCJStorageException, RepositoryException, AccumuloException, AccumuloSecurityException, RyaDAOException {
    // Initialize the commands that will be used by this test.
    final CreatePCJ createPCJ = new AccumuloCreatePCJ(createConnectionDetails(), accumuloConn);
    // Create a PCJ.
    final String sparql1 = "SELECT ?x " + "WHERE { " + "?x <http://worksAt> <http://TacoJoint>." + "}";
    final String pcjId1 = createPCJ.createPCJ(getRyaInstanceName(), sparql1);
    // Create a PCJ.
    final String sparql2 = "SELECT ?x " + "WHERE { " + "?x <http://talksTo> <http://Eve>. " + "}";
    final String pcjId2 = createPCJ.createPCJ(getRyaInstanceName(), sparql2);
    // Verify a Query ID was added for the query within the Fluo app.
    List<String> fluoQueryIds = new ListQueryIds().listQueryIds(fluoClient);
    assertEquals(2, fluoQueryIds.size());
    // Insert some statements into Rya.
    final ValueFactory vf = ryaRepo.getValueFactory();
    ryaConn.add(vf.createURI("http://Alice"), vf.createURI("http://talksTo"), vf.createURI("http://Eve"));
    ryaConn.add(vf.createURI("http://Bob"), vf.createURI("http://talksTo"), vf.createURI("http://Eve"));
    ryaConn.add(vf.createURI("http://Charlie"), vf.createURI("http://talksTo"), vf.createURI("http://Eve"));
    ryaConn.add(vf.createURI("http://Eve"), vf.createURI("http://helps"), vf.createURI("http://Kevin"));
    ryaConn.add(vf.createURI("http://Bob"), vf.createURI("http://worksAt"), vf.createURI("http://TacoJoint"));
    ryaConn.add(vf.createURI("http://Charlie"), vf.createURI("http://worksAt"), vf.createURI("http://TacoJoint"));
    ryaConn.add(vf.createURI("http://Eve"), vf.createURI("http://worksAt"), vf.createURI("http://TacoJoint"));
    ryaConn.add(vf.createURI("http://David"), vf.createURI("http://worksAt"), vf.createURI("http://TacoJoint"));
    // Verify the correct results were exported.
    fluo.waitForObservers();
    try (final PrecomputedJoinStorage pcjStorage = new AccumuloPcjStorage(accumuloConn, getRyaInstanceName())) {
        assertEquals("the PCJ's metadata was added the storage.", 2, pcjStorage.listPcjs().size());
        // Delete all PCJ's.
        AccumuloRyaDAO dao = RyaSailFactory.getAccumuloDAOWithUpdatedConfig(conf);
        dao.dropAndDestroy();
        // Ensure the PCJ's metadata has been removed from the storage.
        assertTrue("the PCJ's metadata has been removed from the storage.", pcjStorage.listPcjs().isEmpty());
        // Ensure the PCJ has been removed from the Fluo application.
        fluo.waitForObservers();
    // Verify Query IDs were deleted for the query within the Fluo app.
    // TODO this fails, shows expected 0, but was 2.
    // fluoQueryIds = new ListQueryIds().listQueryIds(fluoClient);
    // assertEquals("Verify Query IDs were deleted for the query within the Fluo app.", 0, fluoQueryIds.size());
    }
}
Also used : AccumuloRyaDAO(org.apache.rya.accumulo.AccumuloRyaDAO) ListQueryIds(org.apache.rya.indexing.pcj.fluo.api.ListQueryIds) AccumuloPcjStorage(org.apache.rya.indexing.pcj.storage.accumulo.AccumuloPcjStorage) PrecomputedJoinStorage(org.apache.rya.indexing.pcj.storage.PrecomputedJoinStorage) CreatePCJ(org.apache.rya.api.client.CreatePCJ) ValueFactory(org.openrdf.model.ValueFactory) Test(org.junit.Test)

Example 3 with ListQueryIds

use of org.apache.rya.indexing.pcj.fluo.api.ListQueryIds in project incubator-rya by apache.

the class AccumuloCreatePCJIT method createPCJ.

@Test
public void createPCJ() throws Exception {
    AccumuloConnectionDetails connectionDetails = createConnectionDetails();
    // Initialize the commands that will be used by this test.
    final CreatePCJ createPCJ = new AccumuloCreatePCJ(connectionDetails, accumuloConn);
    // Create a PCJ.
    final String sparql = "SELECT ?x " + "WHERE { " + "?x <http://talksTo> <http://Eve>. " + "?x <http://worksAt> <http://TacoJoint>." + "}";
    final String pcjId = createPCJ.createPCJ(getRyaInstanceName(), sparql);
    // Verify the RyaDetails were updated to include the new PCJ.
    final Optional<RyaDetails> ryaDetails = new AccumuloGetInstanceDetails(connectionDetails, accumuloConn).getDetails(getRyaInstanceName());
    final PCJDetails pcjDetails = ryaDetails.get().getPCJIndexDetails().getPCJDetails().get(pcjId);
    assertEquals(pcjId, pcjDetails.getId());
    assertFalse(pcjDetails.getLastUpdateTime().isPresent());
    assertEquals(PCJUpdateStrategy.INCREMENTAL, pcjDetails.getUpdateStrategy().get());
    try (final PrecomputedJoinStorage pcjStorage = new AccumuloPcjStorage(accumuloConn, getRyaInstanceName())) {
        final PcjMetadata pcjMetadata = pcjStorage.getPcjMetadata(pcjId);
        assertEquals(sparql, pcjMetadata.getSparql());
        assertEquals(0L, pcjMetadata.getCardinality());
        // Verify a Query ID was added for the query within the Fluo app.
        final List<String> fluoQueryIds = new ListQueryIds().listQueryIds(fluoClient);
        assertEquals(1, fluoQueryIds.size());
        // Insert some statements into Rya.
        final ValueFactory vf = ryaRepo.getValueFactory();
        ryaConn.add(vf.createURI("http://Alice"), vf.createURI("http://talksTo"), vf.createURI("http://Eve"));
        ryaConn.add(vf.createURI("http://Bob"), vf.createURI("http://talksTo"), vf.createURI("http://Eve"));
        ryaConn.add(vf.createURI("http://Charlie"), vf.createURI("http://talksTo"), vf.createURI("http://Eve"));
        ryaConn.add(vf.createURI("http://Eve"), vf.createURI("http://helps"), vf.createURI("http://Kevin"));
        ryaConn.add(vf.createURI("http://Bob"), vf.createURI("http://worksAt"), vf.createURI("http://TacoJoint"));
        ryaConn.add(vf.createURI("http://Charlie"), vf.createURI("http://worksAt"), vf.createURI("http://TacoJoint"));
        ryaConn.add(vf.createURI("http://Eve"), vf.createURI("http://worksAt"), vf.createURI("http://TacoJoint"));
        ryaConn.add(vf.createURI("http://David"), vf.createURI("http://worksAt"), vf.createURI("http://TacoJoint"));
        // Verify the correct results were exported.
        fluo.waitForObservers();
        final Set<BindingSet> results = Sets.newHashSet(pcjStorage.listResults(pcjId));
        final MapBindingSet bob = new MapBindingSet();
        bob.addBinding("x", vf.createURI("http://Bob"));
        final MapBindingSet charlie = new MapBindingSet();
        charlie.addBinding("x", vf.createURI("http://Charlie"));
        final Set<BindingSet> expected = Sets.<BindingSet>newHashSet(bob, charlie);
        assertEquals(expected, results);
    }
}
Also used : MapBindingSet(org.openrdf.query.impl.MapBindingSet) BindingSet(org.openrdf.query.BindingSet) AccumuloPcjStorage(org.apache.rya.indexing.pcj.storage.accumulo.AccumuloPcjStorage) CreatePCJ(org.apache.rya.api.client.CreatePCJ) RyaDetails(org.apache.rya.api.instance.RyaDetails) ValueFactory(org.openrdf.model.ValueFactory) PCJDetails(org.apache.rya.api.instance.RyaDetails.PCJIndexDetails.PCJDetails) ListQueryIds(org.apache.rya.indexing.pcj.fluo.api.ListQueryIds) PrecomputedJoinStorage(org.apache.rya.indexing.pcj.storage.PrecomputedJoinStorage) PcjMetadata(org.apache.rya.indexing.pcj.storage.PcjMetadata) MapBindingSet(org.openrdf.query.impl.MapBindingSet) Test(org.junit.Test)

Aggregations

CreatePCJ (org.apache.rya.api.client.CreatePCJ)3 ListQueryIds (org.apache.rya.indexing.pcj.fluo.api.ListQueryIds)3 PrecomputedJoinStorage (org.apache.rya.indexing.pcj.storage.PrecomputedJoinStorage)3 AccumuloPcjStorage (org.apache.rya.indexing.pcj.storage.accumulo.AccumuloPcjStorage)3 Test (org.junit.Test)3 ValueFactory (org.openrdf.model.ValueFactory)3 BindingSet (org.openrdf.query.BindingSet)2 MapBindingSet (org.openrdf.query.impl.MapBindingSet)2 AccumuloRyaDAO (org.apache.rya.accumulo.AccumuloRyaDAO)1 DeletePCJ (org.apache.rya.api.client.DeletePCJ)1 RyaDetails (org.apache.rya.api.instance.RyaDetails)1 PCJDetails (org.apache.rya.api.instance.RyaDetails.PCJIndexDetails.PCJDetails)1 PcjMetadata (org.apache.rya.indexing.pcj.storage.PcjMetadata)1