use of org.apache.rya.api.persist.query.BatchRyaQuery in project incubator-rya by apache.
the class AccumuloRyaQueryEngine method batchQuery.
@Override
public CloseableIteration<RyaStatement, RyaDAOException> batchQuery(Collection<RyaStatement> stmts, AccumuloRdfConfiguration conf) throws RyaDAOException {
if (conf == null) {
conf = configuration;
}
BatchRyaQuery batchRyaQuery = BatchRyaQuery.builder(stmts).load(conf).build();
CloseableIterable<RyaStatement> results = query(batchRyaQuery);
return new CloseableIterableIteration<RyaStatement, RyaDAOException>(results);
}
use of org.apache.rya.api.persist.query.BatchRyaQuery in project incubator-rya by apache.
the class CreateFluoPcj method importHistoricResultsIntoFluo.
private void importHistoricResultsIntoFluo(FluoClient fluo, FluoQuery fluoQuery, Connector accumulo, String ryaInstance) throws RyaDAOException {
// Reuse the same set object while performing batch inserts.
final Set<RyaStatement> queryBatch = new HashSet<>();
// historic matches into Fluo.
for (final StatementPatternMetadata patternMetadata : fluoQuery.getStatementPatternMetadata()) {
// Get an iterator over all of the binding sets that match the
// statement pattern.
final StatementPattern pattern = FluoStringConverter.toStatementPattern(patternMetadata.getStatementPattern());
queryBatch.add(spToRyaStatement(pattern));
}
// Create AccumuloRyaQueryEngine to query for historic results
final AccumuloRdfConfiguration conf = new AccumuloRdfConfiguration();
conf.setTablePrefix(ryaInstance);
conf.setAuths(getAuths(accumulo));
try (final AccumuloRyaQueryEngine queryEngine = new AccumuloRyaQueryEngine(accumulo, conf);
CloseableIterable<RyaStatement> queryIterable = queryEngine.query(new BatchRyaQuery(queryBatch))) {
final Set<RyaStatement> triplesBatch = new HashSet<>();
// Insert batches of the binding sets into Fluo.
for (final RyaStatement ryaStatement : queryIterable) {
if (triplesBatch.size() == spInsertBatchSize) {
writeBatch(fluo, triplesBatch);
triplesBatch.clear();
}
triplesBatch.add(ryaStatement);
}
if (!triplesBatch.isEmpty()) {
writeBatch(fluo, triplesBatch);
triplesBatch.clear();
}
} catch (final IOException e) {
log.warn("Ignoring IOException thrown while closing the AccumuloRyaQueryEngine used by CreatePCJ.", e);
}
}
Aggregations