Search in sources :

Example 1 with BatchDeleter

use of org.apache.accumulo.core.client.BatchDeleter in project accumulo by apache.

the class TabletStateChangeIteratorIT method removeLocation.

private void removeLocation(String table, String tableNameToModify) throws TableNotFoundException, MutationsRejectedException {
    Table.ID tableIdToModify = Table.ID.of(getConnector().tableOperations().tableIdMap().get(tableNameToModify));
    BatchDeleter deleter = getConnector().createBatchDeleter(table, Authorizations.EMPTY, 1, new BatchWriterConfig());
    deleter.setRanges(Collections.singleton(new KeyExtent(tableIdToModify, null, null).toMetadataRange()));
    deleter.fetchColumnFamily(MetadataSchema.TabletsSection.CurrentLocationColumnFamily.NAME);
    deleter.delete();
    deleter.close();
}
Also used : BatchDeleter(org.apache.accumulo.core.client.BatchDeleter) MetadataTable(org.apache.accumulo.core.metadata.MetadataTable) Table(org.apache.accumulo.core.client.impl.Table) BatchWriterConfig(org.apache.accumulo.core.client.BatchWriterConfig) KeyExtent(org.apache.accumulo.core.data.impl.KeyExtent)

Example 2 with BatchDeleter

use of org.apache.accumulo.core.client.BatchDeleter in project incubator-rya by apache.

the class AccumuloPeriodicQueryResultStorage method deletePeriodicQueryResults.

@Override
public void deletePeriodicQueryResults(final String queryId, final long binId) throws PeriodicQueryStorageException {
    final String tableName = tableNameFactory.makeTableName(ryaInstance, queryId);
    BatchDeleter deleter = null;
    try {
        final Text prefix = getRowPrefix(binId);
        deleter = accumuloConn.createBatchDeleter(tableName, auths, 1, new BatchWriterConfig());
        deleter.setRanges(Collections.singleton(Range.prefix(prefix)));
        deleter.delete();
    } catch (final Exception e) {
        throw new PeriodicQueryStorageException(e.getMessage());
    } finally {
        try {
            if (deleter != null) {
                deleter.close();
            }
        } catch (final Exception e) {
            throw new PeriodicQueryStorageException(e.getMessage());
        }
    }
}
Also used : BatchDeleter(org.apache.accumulo.core.client.BatchDeleter) PeriodicQueryStorageException(org.apache.rya.indexing.pcj.storage.PeriodicQueryStorageException) BatchWriterConfig(org.apache.accumulo.core.client.BatchWriterConfig) Text(org.apache.hadoop.io.Text) PeriodicQueryStorageException(org.apache.rya.indexing.pcj.storage.PeriodicQueryStorageException) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) MalformedQueryException(org.openrdf.query.MalformedQueryException) BindingSetConversionException(org.apache.rya.indexing.pcj.storage.accumulo.BindingSetConverter.BindingSetConversionException) AccumuloException(org.apache.accumulo.core.client.AccumuloException)

Example 3 with BatchDeleter

use of org.apache.accumulo.core.client.BatchDeleter in project incubator-rya by apache.

the class AccumuloRyaDAO method dropGraph.

@Override
public void dropGraph(final AccumuloRdfConfiguration conf, final RyaURI... graphs) throws RyaDAOException {
    BatchDeleter bd_spo = null;
    BatchDeleter bd_po = null;
    BatchDeleter bd_osp = null;
    try {
        bd_spo = createBatchDeleter(tableLayoutStrategy.getSpo(), conf.getAuthorizations());
        bd_po = createBatchDeleter(tableLayoutStrategy.getPo(), conf.getAuthorizations());
        bd_osp = createBatchDeleter(tableLayoutStrategy.getOsp(), conf.getAuthorizations());
        bd_spo.setRanges(Collections.singleton(new Range()));
        bd_po.setRanges(Collections.singleton(new Range()));
        bd_osp.setRanges(Collections.singleton(new Range()));
        for (final RyaURI graph : graphs) {
            bd_spo.fetchColumnFamily(new Text(graph.getData()));
            bd_po.fetchColumnFamily(new Text(graph.getData()));
            bd_osp.fetchColumnFamily(new Text(graph.getData()));
        }
        bd_spo.delete();
        bd_po.delete();
        bd_osp.delete();
    // TODO indexers do not support delete-UnsupportedOperation Exception will be thrown
    // for (AccumuloIndex index : secondaryIndexers) {
    // index.dropGraph(graphs);
    // }
    } catch (final Exception e) {
        throw new RyaDAOException(e);
    } finally {
        if (bd_spo != null) {
            bd_spo.close();
        }
        if (bd_po != null) {
            bd_po.close();
        }
        if (bd_osp != null) {
            bd_osp.close();
        }
    }
}
Also used : RyaURI(org.apache.rya.api.domain.RyaURI) BatchDeleter(org.apache.accumulo.core.client.BatchDeleter) RyaDAOException(org.apache.rya.api.persist.RyaDAOException) Text(org.apache.hadoop.io.Text) Range(org.apache.accumulo.core.data.Range) TableNotFoundException(org.apache.accumulo.core.client.TableNotFoundException) MutationsRejectedException(org.apache.accumulo.core.client.MutationsRejectedException) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) IOException(java.io.IOException) AccumuloException(org.apache.accumulo.core.client.AccumuloException) RyaDAOException(org.apache.rya.api.persist.RyaDAOException)

Example 4 with BatchDeleter

use of org.apache.accumulo.core.client.BatchDeleter in project incubator-rya by apache.

the class AccumuloRyaDAO method purge.

private void purge(final String tableName, final String[] auths) throws TableNotFoundException, MutationsRejectedException {
    if (tableExists(tableName)) {
        logger.info("Purging accumulo table: " + tableName);
        final BatchDeleter batchDeleter = createBatchDeleter(tableName, new Authorizations(auths));
        try {
            batchDeleter.setRanges(Collections.singleton(new Range()));
            batchDeleter.delete();
        } finally {
            batchDeleter.close();
        }
    }
}
Also used : BatchDeleter(org.apache.accumulo.core.client.BatchDeleter) Authorizations(org.apache.accumulo.core.security.Authorizations) Range(org.apache.accumulo.core.data.Range)

Example 5 with BatchDeleter

use of org.apache.accumulo.core.client.BatchDeleter in project accumulo by apache.

the class MockConnectorTest method testDeletewithBatchDeleter.

@Test
public void testDeletewithBatchDeleter() throws Exception {
    Connector c = new MockConnector("root", new MockInstance());
    // make sure we are using a clean table
    if (c.tableOperations().exists("test"))
        c.tableOperations().delete("test");
    c.tableOperations().create("test");
    BatchDeleter deleter = c.createBatchDeleter("test", Authorizations.EMPTY, 2, new BatchWriterConfig());
    // first make sure it deletes fine when its empty
    deleter.setRanges(Collections.singletonList(new Range(("r1"))));
    deleter.delete();
    this.checkRemaining(c, "test", 0);
    // test deleting just one row
    BatchWriter writer = c.createBatchWriter("test", new BatchWriterConfig());
    Mutation m = new Mutation("r1");
    m.put("fam", "qual", "value");
    writer.addMutation(m);
    // make sure the write goes through
    writer.flush();
    writer.close();
    deleter.setRanges(Collections.singletonList(new Range(("r1"))));
    deleter.delete();
    this.checkRemaining(c, "test", 0);
    // test multi row deletes
    writer = c.createBatchWriter("test", new BatchWriterConfig());
    m = new Mutation("r1");
    m.put("fam", "qual", "value");
    writer.addMutation(m);
    Mutation m2 = new Mutation("r2");
    m2.put("fam", "qual", "value");
    writer.addMutation(m2);
    // make sure the write goes through
    writer.flush();
    writer.close();
    deleter.setRanges(Collections.singletonList(new Range(("r1"))));
    deleter.delete();
    checkRemaining(c, "test", 1);
}
Also used : Connector(org.apache.accumulo.core.client.Connector) BatchDeleter(org.apache.accumulo.core.client.BatchDeleter) BatchWriterConfig(org.apache.accumulo.core.client.BatchWriterConfig) MultiTableBatchWriter(org.apache.accumulo.core.client.MultiTableBatchWriter) BatchWriter(org.apache.accumulo.core.client.BatchWriter) Mutation(org.apache.accumulo.core.data.Mutation) Range(org.apache.accumulo.core.data.Range) Test(org.junit.Test)

Aggregations

BatchDeleter (org.apache.accumulo.core.client.BatchDeleter)6 BatchWriterConfig (org.apache.accumulo.core.client.BatchWriterConfig)4 Range (org.apache.accumulo.core.data.Range)4 Text (org.apache.hadoop.io.Text)3 AccumuloException (org.apache.accumulo.core.client.AccumuloException)2 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)2 BatchWriter (org.apache.accumulo.core.client.BatchWriter)2 Connector (org.apache.accumulo.core.client.Connector)2 Table (org.apache.accumulo.core.client.impl.Table)2 Mutation (org.apache.accumulo.core.data.Mutation)2 KeyExtent (org.apache.accumulo.core.data.impl.KeyExtent)2 MetadataTable (org.apache.accumulo.core.metadata.MetadataTable)2 Test (org.junit.Test)2 IOException (java.io.IOException)1 Collection (java.util.Collection)1 MultiTableBatchWriter (org.apache.accumulo.core.client.MultiTableBatchWriter)1 MutationsRejectedException (org.apache.accumulo.core.client.MutationsRejectedException)1 TableNotFoundException (org.apache.accumulo.core.client.TableNotFoundException)1 Value (org.apache.accumulo.core.data.Value)1 Authorizations (org.apache.accumulo.core.security.Authorizations)1