Search in sources :

Example 6 with TripleRowResolverException

use of org.apache.rya.api.resolver.triple.TripleRowResolverException in project incubator-rya by apache.

the class FileCopyToolMapper method addMetadataKeys.

@Override
protected void addMetadataKeys(final Context context) throws IOException {
    try {
        if (runTime != null) {
            log.info("Writing copy tool run time metadata to child table: " + runTime);
            final RyaStatement ryaStatement = AccumuloRyaUtils.createCopyToolRunTimeRyaStatement(runTime);
            writeRyaStatement(ryaStatement, context);
        }
        if (startTime != null) {
            log.info("Writing copy split time metadata to child table: " + startTime);
            final RyaStatement ryaStatement = AccumuloRyaUtils.createCopyToolSplitTimeRyaStatement(startTime);
            writeRyaStatement(ryaStatement, context);
        }
        if (timeOffset != null) {
            log.info("Writing copy tool time offset metadata to child table: " + timeOffset);
            final RyaStatement ryaStatement = AccumuloRyaUtils.createTimeOffsetRyaStatement(timeOffset);
            writeRyaStatement(ryaStatement, context);
        }
    } catch (TripleRowResolverException | IOException | InterruptedException e) {
        throw new IOException("Failed to write metadata key", e);
    }
}
Also used : TripleRowResolverException(org.apache.rya.api.resolver.triple.TripleRowResolverException) RyaStatement(org.apache.rya.api.domain.RyaStatement) IOException(java.io.IOException)

Example 7 with TripleRowResolverException

use of org.apache.rya.api.resolver.triple.TripleRowResolverException in project incubator-rya by apache.

the class InsertTriples method insert.

/**
 * Insert a batch of triples into Fluo.
 *
 * @param fluo - A connection to the Fluo table that will be updated. (not null)
 * @param triples - The triples to insert. (not null)
 * @param visibility - The visibility/permissions required to view the triples once stored.
 * Note: The same visibility will be applied to each triple.(not null)
 */
public void insert(final FluoClient fluo, final Collection<RyaStatement> triples, final Optional<String> visibility) {
    checkNotNull(fluo);
    checkNotNull(triples);
    checkNotNull(visibility);
    try (Transaction tx = fluo.newTransaction()) {
        for (final RyaStatement triple : triples) {
            try {
                tx.set(spoFormat(triple), FluoQueryColumns.TRIPLES, Bytes.of(visibility.or("")));
            } catch (final TripleRowResolverException e) {
                log.error("Could not convert a Triple into the SPO format: " + triple);
            }
        }
        tx.commit();
    }
}
Also used : TripleRowResolverException(org.apache.rya.api.resolver.triple.TripleRowResolverException) Transaction(org.apache.fluo.api.client.Transaction) RyaStatement(org.apache.rya.api.domain.RyaStatement)

Example 8 with TripleRowResolverException

use of org.apache.rya.api.resolver.triple.TripleRowResolverException in project incubator-rya by apache.

the class IncUpdateDAO method deserializeTriple.

/**
 * Deserializes a triple stored in the Fluo table.
 * @param row - serialized triple
 * @return - triple deserialized as a RyaStatement
 */
public static RyaStatement deserializeTriple(final Bytes row) {
    checkNotNull(row);
    final byte[] rowArray = removeTriplePrefixAndConvertToByteArray(row);
    RyaStatement rs = null;
    try {
        rs = tr.deserialize(TABLE_LAYOUT.SPO, new TripleRow(rowArray, new byte[0], new byte[0]));
    } catch (final TripleRowResolverException e) {
        e.printStackTrace();
    }
    return rs;
}
Also used : TripleRowResolverException(org.apache.rya.api.resolver.triple.TripleRowResolverException) TripleRow(org.apache.rya.api.resolver.triple.TripleRow) RyaStatement(org.apache.rya.api.domain.RyaStatement)

Example 9 with TripleRowResolverException

use of org.apache.rya.api.resolver.triple.TripleRowResolverException in project incubator-rya by apache.

the class RyaStatementKeyValueIterator method next.

@Override
public RyaStatement next() throws RyaDAOException {
    if (!hasNext()) {
        return null;
    }
    try {
        Map.Entry<Key, Value> next = dataIterator.next();
        Key key = next.getKey();
        RyaStatement statement = context.deserializeTriple(tableLayout, new TripleRow(key.getRowData().toArray(), key.getColumnFamilyData().toArray(), key.getColumnQualifierData().toArray(), key.getTimestamp(), key.getColumnVisibilityData().toArray(), next.getValue().get()));
        if (next.getValue() != null) {
            statement.setValue(next.getValue().get());
        }
        maxResults--;
        return statement;
    } catch (TripleRowResolverException e) {
        throw new RyaDAOException(e);
    }
}
Also used : TripleRowResolverException(org.apache.rya.api.resolver.triple.TripleRowResolverException) TripleRow(org.apache.rya.api.resolver.triple.TripleRow) Value(org.apache.accumulo.core.data.Value) RyaStatement(org.apache.rya.api.domain.RyaStatement) RyaDAOException(org.apache.rya.api.persist.RyaDAOException) Map(java.util.Map) Key(org.apache.accumulo.core.data.Key)

Example 10 with TripleRowResolverException

use of org.apache.rya.api.resolver.triple.TripleRowResolverException in project incubator-rya by apache.

the class RyaStatementBindingSetKeyValueIterator method next.

@Override
public Map.Entry<RyaStatement, BindingSet> next() throws RyaDAOException {
    if (!hasNext() || isClosed()) {
        throw new NoSuchElementException();
    }
    try {
        while (true) {
            if (bsIter != null && bsIter.hasNext()) {
                maxResults--;
                return new RdfCloudTripleStoreUtils.CustomEntry<RyaStatement, BindingSet>(statement, bsIter.next());
            }
            if (dataIterator.hasNext()) {
                Map.Entry<Key, Value> next = dataIterator.next();
                Key key = next.getKey();
                statement = ryaContext.deserializeTriple(tableLayout, new TripleRow(key.getRowData().toArray(), key.getColumnFamilyData().toArray(), key.getColumnQualifierData().toArray(), key.getTimestamp(), key.getColumnVisibilityData().toArray(), next.getValue().get()));
                if (next.getValue() != null) {
                    statement.setValue(next.getValue().get());
                }
                Collection<BindingSet> bindingSets = rangeMap.containsKey(key);
                if (!bindingSets.isEmpty()) {
                    bsIter = bindingSets.iterator();
                }
            } else {
                break;
            }
        }
        return null;
    } catch (TripleRowResolverException e) {
        throw new RyaDAOException(e);
    }
}
Also used : TripleRowResolverException(org.apache.rya.api.resolver.triple.TripleRowResolverException) BindingSet(org.openrdf.query.BindingSet) TripleRow(org.apache.rya.api.resolver.triple.TripleRow) Value(org.apache.accumulo.core.data.Value) RyaDAOException(org.apache.rya.api.persist.RyaDAOException) Map(java.util.Map) NoSuchElementException(java.util.NoSuchElementException) Key(org.apache.accumulo.core.data.Key)

Aggregations

TripleRowResolverException (org.apache.rya.api.resolver.triple.TripleRowResolverException)22 RyaStatement (org.apache.rya.api.domain.RyaStatement)14 TripleRow (org.apache.rya.api.resolver.triple.TripleRow)13 IOException (java.io.IOException)8 Key (org.apache.accumulo.core.data.Key)7 Value (org.apache.accumulo.core.data.Value)7 HashMap (java.util.HashMap)4 TABLE_LAYOUT (org.apache.rya.api.RdfCloudTripleStoreConstants.TABLE_LAYOUT)4 RyaURI (org.apache.rya.api.domain.RyaURI)4 RyaTypeResolverException (org.apache.rya.api.resolver.RyaTypeResolverException)4 RyaDAOException (org.apache.rya.api.persist.RyaDAOException)3 ArrayList (java.util.ArrayList)2 Collection (java.util.Collection)2 Map (java.util.Map)2 Mutation (org.apache.accumulo.core.data.Mutation)2 Transaction (org.apache.fluo.api.client.Transaction)2 RdfCloudTripleStoreConstants (org.apache.rya.api.RdfCloudTripleStoreConstants)2 RyaType (org.apache.rya.api.domain.RyaType)2 RyaTripleContext (org.apache.rya.api.resolver.RyaTripleContext)2 MessageDigest (java.security.MessageDigest)1