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();
}
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());
}
}
}
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();
}
}
}
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();
}
}
}
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);
}
Aggregations