Search in sources :

Example 1 with SpanBatchDeleteInformation

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();
    }
}
Also used : Bytes(org.apache.fluo.api.data.Bytes) Transaction(org.apache.fluo.api.client.Transaction) Column(org.apache.fluo.api.data.Column) NodeType(org.apache.rya.indexing.pcj.fluo.app.NodeType) SpanBatchDeleteInformation(org.apache.rya.indexing.pcj.fluo.app.batch.SpanBatchDeleteInformation)

Example 2 with SpanBatchDeleteInformation

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();
}
Also used : Bytes(org.apache.fluo.api.data.Bytes) Transaction(org.apache.fluo.api.client.Transaction) NodeType(org.apache.rya.indexing.pcj.fluo.app.NodeType) SpanBatchDeleteInformation(org.apache.rya.indexing.pcj.fluo.app.batch.SpanBatchDeleteInformation)

Example 3 with SpanBatchDeleteInformation

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());
}
Also used : JoinBatchInformation(org.apache.rya.indexing.pcj.fluo.app.batch.JoinBatchInformation) BatchInformation(org.apache.rya.indexing.pcj.fluo.app.batch.BatchInformation) SpanBatchDeleteInformation(org.apache.rya.indexing.pcj.fluo.app.batch.SpanBatchDeleteInformation) Test(org.junit.Test)

Aggregations

SpanBatchDeleteInformation (org.apache.rya.indexing.pcj.fluo.app.batch.SpanBatchDeleteInformation)3 Transaction (org.apache.fluo.api.client.Transaction)2 Bytes (org.apache.fluo.api.data.Bytes)2 NodeType (org.apache.rya.indexing.pcj.fluo.app.NodeType)2 Column (org.apache.fluo.api.data.Column)1 BatchInformation (org.apache.rya.indexing.pcj.fluo.app.batch.BatchInformation)1 JoinBatchInformation (org.apache.rya.indexing.pcj.fluo.app.batch.JoinBatchInformation)1 Test (org.junit.Test)1