use of org.apache.rya.export.api.store.FetchStatementException in project incubator-rya by apache.
the class MemoryTimeMerger method runJob.
@Override
public void runJob() {
final Optional<MergeParentMetadata> metadata = parentStore.getParentMetadata();
// check the parent for a parent metadata repo
if (metadata.isPresent()) {
LOG.info("Merging statements...");
final MergeParentMetadata parentMetadata = metadata.get();
if (parentMetadata.getRyaInstanceName().equals(ryaInstanceName)) {
try {
importStatements(parentMetadata);
} catch (AddStatementException | ContainsStatementException | RemoveStatementException | FetchStatementException e) {
LOG.error("Failed to import statements.", e);
}
}
} else {
try {
LOG.info("Cloning statements...");
export();
} catch (final ParentMetadataExistsException | FetchStatementException e) {
LOG.error("Failed to export statements.", e);
}
}
}
use of org.apache.rya.export.api.store.FetchStatementException in project incubator-rya by apache.
the class AccumuloRyaStatementStore method fetchStatements.
@Override
public Iterator<RyaStatement> fetchStatements() throws FetchStatementException {
try {
final RyaTripleContext ryaTripleContext = RyaTripleContext.getInstance(accumuloRyaDao.getConf());
Scanner scanner = null;
try {
scanner = AccumuloRyaUtils.getScanner(tablePrefix + RdfCloudTripleStoreConstants.TBL_SPO_SUFFIX, accumuloRyaDao.getConf());
for (final IteratorSetting iteratorSetting : iteratorSettings) {
scanner.addScanIterator(iteratorSetting);
}
} catch (final IOException e) {
throw new FetchStatementException("Unable to get scanner to fetch Rya Statements", e);
}
// Convert Entry iterator to RyaStatement iterator
final Iterator<Entry<Key, Value>> entryIter = scanner.iterator();
final Iterator<RyaStatement> ryaStatementIter = Iterators.transform(entryIter, new Function<Entry<Key, Value>, RyaStatement>() {
@Override
public RyaStatement apply(final Entry<Key, Value> entry) {
final Key key = entry.getKey();
final Value value = entry.getValue();
RyaStatement ryaStatement = null;
try {
ryaStatement = AccumuloRyaUtils.createRyaStatement(key, value, ryaTripleContext);
} catch (final TripleRowResolverException e) {
log.error("Unable to convert the key/value pair into a Rya Statement", e);
}
return ryaStatement;
}
});
return ryaStatementIter;
} catch (final Exception e) {
throw new FetchStatementException("Failed to fetch statements.", e);
}
}
Aggregations