use of org.apache.rya.api.resolver.triple.TripleRowResolverException 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();
}
}
use of org.apache.rya.api.resolver.triple.TripleRowResolverException in project incubator-rya by apache.
the class MergeToolMapper method nextRyaStatement.
private static RyaStatement nextRyaStatement(final Context context, final RyaTripleContext ryaContext) throws IOException, InterruptedException {
RyaStatement ryaStatement = null;
if (context.nextKeyValue()) {
final Key key = context.getCurrentKey();
final Value value = context.getCurrentValue();
try {
ryaStatement = createRyaStatement(key, value, ryaContext);
} catch (final TripleRowResolverException e) {
log.error("TripleRowResolverException encountered while creating statement", e);
}
}
return ryaStatement;
}
use of org.apache.rya.api.resolver.triple.TripleRowResolverException in project incubator-rya by apache.
the class RyaTableKeyValues method invoke.
@SuppressWarnings({ "unchecked", "rawtypes" })
public RyaTableKeyValues invoke() throws IOException {
/**
* TODO: If there are contexts, do we still replicate the information into the default graph as well
* as the named graphs?
*/
try {
Map<RdfCloudTripleStoreConstants.TABLE_LAYOUT, org.apache.rya.api.resolver.triple.TripleRow> rowMap = instance.serializeTriple(stmt);
TripleRow tripleRow = rowMap.get(RdfCloudTripleStoreConstants.TABLE_LAYOUT.SPO);
byte[] columnVisibility = tripleRow.getColumnVisibility();
Text cv = columnVisibility == null ? EMPTY_CV_TEXT : new Text(columnVisibility);
Long timestamp = tripleRow.getTimestamp();
timestamp = timestamp == null ? 0l : timestamp;
byte[] value = tripleRow.getValue();
Value v = value == null ? EMPTY_VALUE : new Value(value);
spo.add(new SimpleEntry(new Key(new Text(tripleRow.getRow()), new Text(tripleRow.getColumnFamily()), new Text(tripleRow.getColumnQualifier()), cv, timestamp), v));
tripleRow = rowMap.get(RdfCloudTripleStoreConstants.TABLE_LAYOUT.PO);
po.add(new SimpleEntry(new Key(new Text(tripleRow.getRow()), new Text(tripleRow.getColumnFamily()), new Text(tripleRow.getColumnQualifier()), cv, timestamp), v));
tripleRow = rowMap.get(RdfCloudTripleStoreConstants.TABLE_LAYOUT.OSP);
osp.add(new SimpleEntry(new Key(new Text(tripleRow.getRow()), new Text(tripleRow.getColumnFamily()), new Text(tripleRow.getColumnQualifier()), cv, timestamp), v));
} catch (TripleRowResolverException e) {
throw new IOException(e);
}
return this;
}
use of org.apache.rya.api.resolver.triple.TripleRowResolverException in project incubator-rya by apache.
the class RyaTableMutationsFactory method serializeDelete.
public Map<RdfCloudTripleStoreConstants.TABLE_LAYOUT, Collection<Mutation>> serializeDelete(RyaStatement stmt) throws IOException {
Collection<Mutation> spo_muts = new ArrayList<Mutation>();
Collection<Mutation> po_muts = new ArrayList<Mutation>();
Collection<Mutation> osp_muts = new ArrayList<Mutation>();
/**
* TODO: If there are contexts, do we still replicate the information into the default graph as well
* as the named graphs?
*/
try {
Map<TABLE_LAYOUT, TripleRow> rowMap = ryaContext.serializeTriple(stmt);
TripleRow tripleRow = rowMap.get(TABLE_LAYOUT.SPO);
spo_muts.add(deleteMutation(tripleRow));
tripleRow = rowMap.get(TABLE_LAYOUT.PO);
po_muts.add(deleteMutation(tripleRow));
tripleRow = rowMap.get(TABLE_LAYOUT.OSP);
osp_muts.add(deleteMutation(tripleRow));
} catch (TripleRowResolverException fe) {
throw new IOException(fe);
}
Map<RdfCloudTripleStoreConstants.TABLE_LAYOUT, Collection<Mutation>> mutations = new HashMap<RdfCloudTripleStoreConstants.TABLE_LAYOUT, Collection<Mutation>>();
mutations.put(RdfCloudTripleStoreConstants.TABLE_LAYOUT.SPO, spo_muts);
mutations.put(RdfCloudTripleStoreConstants.TABLE_LAYOUT.PO, po_muts);
mutations.put(RdfCloudTripleStoreConstants.TABLE_LAYOUT.OSP, osp_muts);
return mutations;
}
use of org.apache.rya.api.resolver.triple.TripleRowResolverException in project incubator-rya by apache.
the class RyaTableMutationsFactory method serialize.
// TODO: Does this still need to be collections
public Map<RdfCloudTripleStoreConstants.TABLE_LAYOUT, Collection<Mutation>> serialize(RyaStatement stmt) throws IOException {
Collection<Mutation> spo_muts = new ArrayList<Mutation>();
Collection<Mutation> po_muts = new ArrayList<Mutation>();
Collection<Mutation> osp_muts = new ArrayList<Mutation>();
/**
* TODO: If there are contexts, do we still replicate the information into the default graph as well
* as the named graphs?
*/
try {
Map<TABLE_LAYOUT, TripleRow> rowMap = ryaContext.serializeTriple(stmt);
TripleRow tripleRow = rowMap.get(TABLE_LAYOUT.SPO);
spo_muts.add(createMutation(tripleRow));
tripleRow = rowMap.get(TABLE_LAYOUT.PO);
po_muts.add(createMutation(tripleRow));
tripleRow = rowMap.get(TABLE_LAYOUT.OSP);
osp_muts.add(createMutation(tripleRow));
} catch (TripleRowResolverException fe) {
throw new IOException(fe);
}
Map<RdfCloudTripleStoreConstants.TABLE_LAYOUT, Collection<Mutation>> mutations = new HashMap<RdfCloudTripleStoreConstants.TABLE_LAYOUT, Collection<Mutation>>();
mutations.put(RdfCloudTripleStoreConstants.TABLE_LAYOUT.SPO, spo_muts);
mutations.put(RdfCloudTripleStoreConstants.TABLE_LAYOUT.PO, po_muts);
mutations.put(RdfCloudTripleStoreConstants.TABLE_LAYOUT.OSP, osp_muts);
return mutations;
}
Aggregations