use of org.apache.fluo.api.client.Transaction in project incubator-rya by apache.
the class DeleteFluoPcj method deletePcj.
/**
* Deletes all metadata and {@link BindingSet}s associated with a Rya
* Precomputed Join Index from the Fluo application that is incrementally
* updating it.
*
* @param client - Connects to the Fluo application that is updating the PCJ
* Index. (not null)
* @param pcjId - The PCJ ID for the query that will removed from the Fluo
* application. (not null)
* @throws UnsupportedQueryException - thrown when Fluo app is unable to read FluoQuery associated
* with given pcjId.
*/
public void deletePcj(final FluoClient client, final String pcjId) throws UnsupportedQueryException {
requireNonNull(client);
requireNonNull(pcjId);
final Transaction tx = client.newTransaction();
// Delete the query's metadata. This halts input.
final List<String> nodeIds = getNodeIds(tx, pcjId);
deleteMetadata(tx, nodeIds, pcjId);
// Delete the binding sets associated with the query's nodes.
for (final String nodeId : nodeIds) {
deleteData(client, nodeId);
}
}
use of org.apache.fluo.api.client.Transaction in project incubator-rya by apache.
the class DeleteFluoPcj method deleteMetadata.
/**
* Deletes metadata for all nodeIds associated with a given queryId in a
* single transaction. Prevents additional BindingSets from being created as
* new triples are added.
*
* @param tx - Transaction of a given Fluo table. (not null)
* @param nodeIds - Nodes whose metatdata will be deleted. (not null)
* @param pcjId - The PCJ ID of the query whose will be deleted. (not null)
*/
private void deleteMetadata(final Transaction tx, final List<String> nodeIds, final String pcjId) {
requireNonNull(tx);
requireNonNull(nodeIds);
requireNonNull(pcjId);
try (final Transaction typeTx = tx) {
Set<String> spNodeIds = new HashSet<>();
// remove metadata associated with each nodeId and store statement pattern nodeIds
for (final String nodeId : nodeIds) {
final NodeType type = NodeType.fromNodeId(nodeId).get();
if (type == NodeType.STATEMENT_PATTERN) {
spNodeIds.add(nodeId);
}
deleteMetadataColumns(typeTx, nodeId, type.getMetaDataColumns());
}
// Use stored statement pattern nodeIds to update list of stored statement pattern nodeIds
// in Fluo table
StatementPatternIdManager.removeStatementPatternIds(typeTx, spNodeIds);
typeTx.commit();
}
}
use of org.apache.fluo.api.client.Transaction in project incubator-rya by apache.
the class InsertTriples method insert.
/**
* Insert a batch of RyaStatements into Fluo.
*
* @param fluo - A connection to the Fluo table that will be updated. (not null)
* @param triples - The triples to insert. (not null)
*/
public void insert(final FluoClient fluo, final Collection<RyaStatement> triples) {
checkNotNull(fluo);
checkNotNull(triples);
try (Transaction tx = fluo.newTransaction()) {
for (final RyaStatement triple : triples) {
Optional<byte[]> visibility = Optional.fromNullable(triple.getColumnVisibility());
try {
tx.set(spoFormat(triple), FluoQueryColumns.TRIPLES, Bytes.of(visibility.or(new byte[0])));
} catch (final TripleRowResolverException e) {
log.error("Could not convert a Triple into the SPO format: " + triple);
}
}
tx.commit();
}
}
Aggregations