use of org.apache.rya.indexing.pcj.fluo.app.batch.SpanBatchDeleteInformation in project incubator-rya by apache.
the class FluoBinPruner method pruneBindingSetBin.
/**
* This method deletes BindingSets in the specified bin from the BindingSet
* Column of the indicated Fluo nodeId
*
* @param id
* - Fluo nodeId
* @param bin
* - bin id
*/
@Override
public void pruneBindingSetBin(final NodeBin nodeBin) {
final String id = nodeBin.getNodeId();
final long bin = nodeBin.getBin();
try (Transaction tx = client.newTransaction()) {
final Optional<NodeType> type = NodeType.fromNodeId(id);
if (!type.isPresent()) {
log.trace("Unable to determine NodeType from id: " + id);
throw new RuntimeException();
}
final Column batchInfoColumn = type.get().getResultColumn();
final Bytes batchInfoSpanPrefix = BindingHashShardingFunction.getShardedScanPrefix(id, vf.createLiteral(bin));
final SpanBatchDeleteInformation batchInfo = SpanBatchDeleteInformation.builder().setColumn(batchInfoColumn).setSpan(Span.prefix(batchInfoSpanPrefix)).build();
BatchInformationDAO.addBatch(tx, id, batchInfo);
tx.commit();
}
}
use of org.apache.rya.indexing.pcj.fluo.app.batch.SpanBatchDeleteInformation in project incubator-rya by apache.
the class DeleteFluoPcj method deleteData.
/**
* Deletes all results (BindingSets or Statements) associated with the specified nodeId.
*
* @param nodeId - nodeId whose {@link BindingSet}s will be deleted. (not null)
* @param client - Used to delete the data. (not null)
*/
private void deleteData(final FluoClient client, final String nodeId) {
requireNonNull(client);
requireNonNull(nodeId);
final NodeType type = NodeType.fromNodeId(nodeId).get();
Transaction tx = client.newTransaction();
Bytes prefixBytes = Bytes.of(type.getNodeTypePrefix());
SpanBatchDeleteInformation batch = SpanBatchDeleteInformation.builder().setColumn(type.getResultColumn()).setSpan(Span.prefix(prefixBytes)).setBatchSize(batchSize).setNodeId(Optional.of(nodeId)).build();
BatchInformationDAO.addBatch(tx, nodeId, batch);
tx.commit();
}
use of org.apache.rya.indexing.pcj.fluo.app.batch.SpanBatchDeleteInformation in project incubator-rya by apache.
the class BatchInformationSerializerTest method testSpanBatchInformationSerialization.
@Test
public void testSpanBatchInformationSerialization() {
SpanBatchDeleteInformation batch = SpanBatchDeleteInformation.builder().setBatchSize(1000).setColumn(FluoQueryColumns.PERIODIC_QUERY_BINDING_SET).setSpan(Span.prefix(Bytes.of("prefix"))).build();
System.out.println(batch);
byte[] batchBytes = BatchInformationSerializer.toBytes(batch);
Optional<BatchInformation> decodedBatch = BatchInformationSerializer.fromBytes(batchBytes);
System.out.println(decodedBatch);
assertEquals(batch, decodedBatch.get());
}
Aggregations