use of org.apache.rya.accumulo.experimental.AccumuloIndexer in project incubator-rya by apache.
the class AccumuloRyaDAO method delete.
@Override
public void delete(final Iterator<RyaStatement> statements, final AccumuloRdfConfiguration conf) throws RyaDAOException {
try {
while (statements.hasNext()) {
final RyaStatement stmt = statements.next();
// query first
final CloseableIteration<RyaStatement, RyaDAOException> query = this.queryEngine.query(stmt, conf);
while (query.hasNext()) {
deleteSingleRyaStatement(query.next());
}
for (final AccumuloIndexer index : secondaryIndexers) {
index.deleteStatement(stmt);
}
}
if (flushEachUpdate.get()) {
mt_bw.flush();
}
} catch (final Exception e) {
throw new RyaDAOException(e);
}
}
use of org.apache.rya.accumulo.experimental.AccumuloIndexer in project incubator-rya by apache.
the class AccumuloRyaDAO method commit.
protected void commit(final Iterator<RyaStatement> commitStatements) throws RyaDAOException {
try {
// TODO: Should have a lock here in case we are adding and committing at the same time
while (commitStatements.hasNext()) {
final RyaStatement stmt = commitStatements.next();
final Map<TABLE_LAYOUT, Collection<Mutation>> mutationMap = ryaTableMutationsFactory.serialize(stmt);
final Collection<Mutation> spo = mutationMap.get(TABLE_LAYOUT.SPO);
final Collection<Mutation> po = mutationMap.get(TABLE_LAYOUT.PO);
final Collection<Mutation> osp = mutationMap.get(TABLE_LAYOUT.OSP);
bw_spo.addMutations(spo);
bw_po.addMutations(po);
bw_osp.addMutations(osp);
for (final AccumuloIndexer index : secondaryIndexers) {
index.storeStatement(stmt);
}
}
if (flushEachUpdate.get()) {
mt_bw.flush();
}
} catch (final Exception e) {
throw new RyaDAOException(e);
}
}
use of org.apache.rya.accumulo.experimental.AccumuloIndexer in project incubator-rya by apache.
the class AccumuloRyaDAO method destroy.
@Override
public void destroy() throws RyaDAOException {
if (!isInitialized.get()) {
return;
}
// TODO: write lock
try {
isInitialized.set(false);
mt_bw.flush();
mt_bw.close();
} catch (final Exception e) {
throw new RyaDAOException(e);
}
for (final AccumuloIndexer indexer : this.secondaryIndexers) {
try {
indexer.destroy();
} catch (final Exception e) {
logger.warn("Failed to destroy indexer", e);
}
}
}
use of org.apache.rya.accumulo.experimental.AccumuloIndexer in project incubator-rya by apache.
the class AccumuloRyaDAO method purge.
@Override
public void purge(final RdfCloudTripleStoreConfiguration configuration) {
for (final String tableName : getTables()) {
try {
purge(tableName, configuration.getAuths());
compact(tableName);
} catch (final TableNotFoundException e) {
logger.error(e.getMessage());
} catch (final MutationsRejectedException e) {
logger.error(e.getMessage());
}
}
for (final AccumuloIndexer indexer : this.secondaryIndexers) {
try {
indexer.purge(configuration);
} catch (final Exception e) {
logger.error("Failed to purge indexer", e);
}
}
}
use of org.apache.rya.accumulo.experimental.AccumuloIndexer in project incubator-rya by apache.
the class AccumuloRyaDAO method init.
@Override
public void init() throws RyaDAOException {
if (isInitialized.get()) {
return;
}
try {
checkNotNull(conf);
checkNotNull(connector);
if (batchWriterConfig == null) {
batchWriterConfig = new BatchWriterConfig();
batchWriterConfig.setMaxMemory(MAX_MEMORY);
batchWriterConfig.setTimeout(MAX_TIME, TimeUnit.MILLISECONDS);
batchWriterConfig.setMaxWriteThreads(NUM_THREADS);
}
tableLayoutStrategy = conf.getTableLayoutStrategy();
ryaContext = RyaTripleContext.getInstance(conf);
ryaTableMutationsFactory = new RyaTableMutationsFactory(ryaContext);
secondaryIndexers = conf.getAdditionalIndexers();
flushEachUpdate.set(conf.flushEachUpdate());
final TableOperations tableOperations = connector.tableOperations();
AccumuloRdfUtils.createTableIfNotExist(tableOperations, tableLayoutStrategy.getSpo());
AccumuloRdfUtils.createTableIfNotExist(tableOperations, tableLayoutStrategy.getPo());
AccumuloRdfUtils.createTableIfNotExist(tableOperations, tableLayoutStrategy.getOsp());
AccumuloRdfUtils.createTableIfNotExist(tableOperations, tableLayoutStrategy.getNs());
for (final AccumuloIndexer index : secondaryIndexers) {
index.setConf(conf);
}
mt_bw = connector.createMultiTableBatchWriter(batchWriterConfig);
// get the batch writers for tables
bw_spo = mt_bw.getBatchWriter(tableLayoutStrategy.getSpo());
bw_po = mt_bw.getBatchWriter(tableLayoutStrategy.getPo());
bw_osp = mt_bw.getBatchWriter(tableLayoutStrategy.getOsp());
bw_ns = mt_bw.getBatchWriter(tableLayoutStrategy.getNs());
for (final AccumuloIndexer index : secondaryIndexers) {
index.setConnector(connector);
index.setMultiTableBatchWriter(mt_bw);
index.init();
}
queryEngine = new AccumuloRyaQueryEngine(connector, conf);
checkVersion();
isInitialized.set(true);
} catch (final Exception e) {
throw new RyaDAOException(e);
}
}
Aggregations