Search in sources :

Example 1 with DeleteFluoPcj

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

the class CreateDeleteIT method deletePCJ.

@Test
public void deletePCJ() 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>." + "}";
    // Triples that are loaded into Rya before the PCJ is created.
    final ValueFactory vf = new ValueFactoryImpl();
    final Set<Statement> statements = Sets.newHashSet(vf.createStatement(vf.createURI("http://Alice"), vf.createURI("http://talksTo"), vf.createURI("http://Eve")), vf.createStatement(vf.createURI("http://Bob"), vf.createURI("http://talksTo"), vf.createURI("http://Eve")), vf.createStatement(vf.createURI("http://Charlie"), vf.createURI("http://talksTo"), vf.createURI("http://Eve")), vf.createStatement(vf.createURI("http://Eve"), vf.createURI("http://helps"), vf.createURI("http://Kevin")), vf.createStatement(vf.createURI("http://Bob"), vf.createURI("http://worksAt"), vf.createURI("http://Chipotle")), vf.createStatement(vf.createURI("http://Charlie"), vf.createURI("http://worksAt"), vf.createURI("http://Chipotle")), vf.createStatement(vf.createURI("http://Eve"), vf.createURI("http://worksAt"), vf.createURI("http://Chipotle")), vf.createStatement(vf.createURI("http://David"), vf.createURI("http://worksAt"), vf.createURI("http://Chipotle")));
    // Create the PCJ in Fluo and load the statements into Rya.
    final String pcjId = loadData(sparql, statements);
    try (FluoClient fluoClient = FluoFactory.newClient(getFluoConfiguration())) {
        // Ensure the data was loaded.
        final List<Bytes> rows = getFluoTableEntries(fluoClient);
        assertEquals(19, rows.size());
        // Delete the PCJ from the Fluo application.
        new DeleteFluoPcj(1).deletePcj(fluoClient, pcjId);
        getMiniFluo().waitForObservers();
        // Ensure all data related to the query has been removed.
        final List<Bytes> empty_rows = getFluoTableEntries(fluoClient);
        assertEquals(1, empty_rows.size());
    }
}
Also used : Bytes(org.apache.fluo.api.data.Bytes) FluoClient(org.apache.fluo.api.client.FluoClient) Statement(org.openrdf.model.Statement) ValueFactoryImpl(org.openrdf.model.impl.ValueFactoryImpl) DeleteFluoPcj(org.apache.rya.indexing.pcj.fluo.api.DeleteFluoPcj) ValueFactory(org.openrdf.model.ValueFactory) Test(org.junit.Test)

Example 2 with DeleteFluoPcj

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

the class CreateDeleteIT method deleteAggregation.

@Test
public void deleteAggregation() throws Exception {
    // A query that finds the maximum price for an item within the inventory.
    final String sparql = "SELECT (max(?price) as ?maxPrice) { " + "?item <urn:price> ?price . " + "}";
    // Create the Statements that will be loaded into Rya.
    final ValueFactory vf = new ValueFactoryImpl();
    final Collection<Statement> statements = Sets.newHashSet(vf.createStatement(vf.createURI("urn:apple"), vf.createURI("urn:price"), vf.createLiteral(2.50)), vf.createStatement(vf.createURI("urn:gum"), vf.createURI("urn:price"), vf.createLiteral(0.99)), vf.createStatement(vf.createURI("urn:sandwich"), vf.createURI("urn:price"), vf.createLiteral(4.99)));
    // Create the PCJ in Fluo and load the statements into Rya.
    final String pcjId = loadData(sparql, statements);
    try (FluoClient fluoClient = FluoFactory.newClient(getFluoConfiguration())) {
        // Ensure the data was loaded.
        final List<Bytes> rows = getFluoTableEntries(fluoClient);
        assertEquals(11, rows.size());
        // Delete the PCJ from the Fluo application.
        new DeleteFluoPcj(1).deletePcj(fluoClient, pcjId);
        getMiniFluo().waitForObservers();
        // Ensure all data related to the query has been removed.
        final List<Bytes> empty_rows = getFluoTableEntries(fluoClient);
        assertEquals(1, empty_rows.size());
    }
}
Also used : Bytes(org.apache.fluo.api.data.Bytes) FluoClient(org.apache.fluo.api.client.FluoClient) Statement(org.openrdf.model.Statement) ValueFactoryImpl(org.openrdf.model.impl.ValueFactoryImpl) DeleteFluoPcj(org.apache.rya.indexing.pcj.fluo.api.DeleteFluoPcj) ValueFactory(org.openrdf.model.ValueFactory) Test(org.junit.Test)

Example 3 with DeleteFluoPcj

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

the class AccumuloDeletePCJ method stopUpdatingPCJ.

private void stopUpdatingPCJ(final String fluoAppName, final String pcjId) {
    requireNonNull(fluoAppName);
    requireNonNull(pcjId);
    // Connect to the Fluo application that is updating this instance's PCJs.
    final AccumuloConnectionDetails cd = super.getAccumuloConnectionDetails();
    try (final FluoClient fluoClient = new FluoClientFactory().connect(cd.getUsername(), new String(cd.getUserPass()), cd.getInstanceName(), cd.getZookeepers(), fluoAppName)) {
        // Delete the PCJ from the Fluo App.
        try {
            new DeleteFluoPcj(1000).deletePcj(fluoClient, pcjId);
        } catch (Exception e) {
            log.warn("PcjId corresponds to an invalid PCJ. The query cannot be deleted.");
        }
    }
}
Also used : FluoClient(org.apache.fluo.api.client.FluoClient) DeleteFluoPcj(org.apache.rya.indexing.pcj.fluo.api.DeleteFluoPcj) PCJStorageException(org.apache.rya.indexing.pcj.storage.PrecomputedJoinStorage.PCJStorageException) RyaClientException(org.apache.rya.api.client.RyaClientException) InstanceDoesNotExistException(org.apache.rya.api.client.InstanceDoesNotExistException)

Aggregations

FluoClient (org.apache.fluo.api.client.FluoClient)3 DeleteFluoPcj (org.apache.rya.indexing.pcj.fluo.api.DeleteFluoPcj)3 Bytes (org.apache.fluo.api.data.Bytes)2 Test (org.junit.Test)2 Statement (org.openrdf.model.Statement)2 ValueFactory (org.openrdf.model.ValueFactory)2 ValueFactoryImpl (org.openrdf.model.impl.ValueFactoryImpl)2 InstanceDoesNotExistException (org.apache.rya.api.client.InstanceDoesNotExistException)1 RyaClientException (org.apache.rya.api.client.RyaClientException)1 PCJStorageException (org.apache.rya.indexing.pcj.storage.PrecomputedJoinStorage.PCJStorageException)1