use of org.apache.rya.api.persist.index.RyaSecondaryIndexer in project incubator-rya by apache.
the class MongoDBRyaDAO method add.
@Override
public void add(final Iterator<RyaStatement> statementIter) throws RyaDAOException {
final List<DBObject> dbInserts = new ArrayList<>();
while (statementIter.hasNext()) {
final RyaStatement ryaStatement = statementIter.next();
final boolean canAdd = DocumentVisibilityUtil.doesUserHaveDocumentAccess(auths, ryaStatement.getColumnVisibility());
if (canAdd) {
final DBObject insert = storageStrategy.serialize(ryaStatement);
dbInserts.add(insert);
try {
for (final RyaSecondaryIndexer index : secondaryIndexers) {
index.storeStatement(ryaStatement);
}
} catch (final IOException e) {
log.error("Failed to add: " + ryaStatement.toString() + " to the indexer");
}
} else {
throw new RyaDAOException("User does not have the required authorizations to add statement");
}
}
try {
mongoDbBatchWriter.addObjectsToQueue(dbInserts);
if (flushEachUpdate.get()) {
flush();
}
} catch (final MongoDbBatchWriterException e) {
throw new RyaDAOException("Error adding statements", e);
}
}
use of org.apache.rya.api.persist.index.RyaSecondaryIndexer in project incubator-rya by apache.
the class MongoDBRyaDAO method delete.
@Override
public void delete(final Iterator<RyaStatement> statements, final StatefulMongoDBRdfConfiguration conf) throws RyaDAOException {
while (statements.hasNext()) {
final RyaStatement ryaStatement = statements.next();
final boolean canDelete = DocumentVisibilityUtil.doesUserHaveDocumentAccess(auths, ryaStatement.getColumnVisibility());
if (canDelete) {
coll.remove(storageStrategy.getQuery(ryaStatement));
for (final RyaSecondaryIndexer index : secondaryIndexers) {
try {
index.deleteStatement(ryaStatement);
} catch (final IOException e) {
log.error("Unable to remove statement: " + ryaStatement.toString() + " from secondary indexer: " + index.getTableName(), e);
}
}
} else {
throw new RyaDAOException("User does not have the required authorizations to delete statement");
}
}
}
use of org.apache.rya.api.persist.index.RyaSecondaryIndexer in project incubator-rya by apache.
the class MongoDBRyaDAO method delete.
@Override
public void delete(final RyaStatement statement, final StatefulMongoDBRdfConfiguration conf) throws RyaDAOException {
final boolean canDelete = DocumentVisibilityUtil.doesUserHaveDocumentAccess(auths, statement.getColumnVisibility());
if (canDelete) {
final DBObject obj = storageStrategy.getQuery(statement);
coll.remove(obj);
for (final RyaSecondaryIndexer index : secondaryIndexers) {
try {
index.deleteStatement(statement);
} catch (final IOException e) {
log.error("Unable to remove statement: " + statement.toString() + " from secondary indexer: " + index.getTableName(), e);
}
}
} else {
throw new RyaDAOException("User does not have the required authorizations to delete statement");
}
}
Aggregations