Search in sources :

Example 96 with RyaType

use of org.apache.rya.api.domain.RyaType in project incubator-rya by apache.

the class DoubleRyaTypeResolverTest method testDoubleSerialization.

public void testDoubleSerialization() throws Exception {
    Double d = randomDouble();
    RyaType ryaType = new RyaType(XMLSchema.DOUBLE, d.toString());
    byte[] serialize = new DoubleRyaTypeResolver().serialize(ryaType);
    assertEquals(d, Double.parseDouble(new DoubleRyaTypeResolver().deserialize(serialize).getData()));
}
Also used : RyaType(org.apache.rya.api.domain.RyaType)

Example 97 with RyaType

use of org.apache.rya.api.domain.RyaType in project incubator-rya by apache.

the class LongRyaTypeResolverTest method testSerialization.

@Test
public void testSerialization() throws Exception {
    Long i = randomLong();
    byte[] serialize = new LongRyaTypeResolver().serialize(new RyaType(XMLSchema.LONG, i.toString()));
    assertEquals(i, new Long(new LongRyaTypeResolver().deserialize(serialize).getData()));
}
Also used : RyaType(org.apache.rya.api.domain.RyaType) Test(org.junit.Test)

Example 98 with RyaType

use of org.apache.rya.api.domain.RyaType in project incubator-rya by apache.

the class ITBase method makeRyaStatement.

/**
 * A helper function for creating a {@link RyaStatement} that represents a
 * Triple.
 *
 * @param subject
 *            - The Subject of the Triple. (not null)
 * @param predicate
 *            - The Predicate of the Triple. (not null)
 * @param object
 *            - The Object of the Triple. (not null)
 * @return A Triple as a {@link RyaStatement}.
 */
protected static RyaStatement makeRyaStatement(final String subject, final String predicate, final int object) {
    checkNotNull(subject);
    checkNotNull(predicate);
    return RyaStatement.builder().setSubject(new RyaURI(subject)).setPredicate(new RyaURI(predicate)).setObject(new RyaType(XMLSchema.INT, "" + object)).build();
}
Also used : RyaURI(org.apache.rya.api.domain.RyaURI) RyaType(org.apache.rya.api.domain.RyaType)

Example 99 with RyaType

use of org.apache.rya.api.domain.RyaType in project incubator-rya by apache.

the class ITBase method makeRyaStatement.

/**
 * A helper function for creating a {@link RyaStatement} that represents a
 * Triple.
 *
 * @param subject
 *            - The Subject of the Triple. (not null)
 * @param predicate
 *            - The Predicate of the Triple. (not null)
 * @param object
 *            - The Object of the Triple. (not null)
 * @return A Triple as a {@link RyaStatement}.
 */
protected static RyaStatement makeRyaStatement(final String subject, final String predicate, final String object) {
    checkNotNull(subject);
    checkNotNull(predicate);
    checkNotNull(object);
    final RyaStatementBuilder builder = RyaStatement.builder().setSubject(new RyaURI(subject)).setPredicate(new RyaURI(predicate));
    if (object.startsWith("http://")) {
        builder.setObject(new RyaURI(object));
    } else {
        builder.setObject(new RyaType(object));
    }
    builder.setTimestamp(new Date().getTime());
    return builder.build();
}
Also used : RyaURI(org.apache.rya.api.domain.RyaURI) RyaStatementBuilder(org.apache.rya.api.domain.RyaStatement.RyaStatementBuilder) RyaType(org.apache.rya.api.domain.RyaType) Date(java.util.Date)

Example 100 with RyaType

use of org.apache.rya.api.domain.RyaType in project incubator-rya by apache.

the class BindingHashShardingFunction method getShardedScanPrefix.

/**
 * Generates a sharded rowId. The rowId is of the form: node_prefix:shardId:nodeId//Binding_values. For
 * example, the row key generated from nodeId = SP_123, varOrder = a;b, bs = [a = uri:Bob, b = uri:Doug] would be
 * SP:HASH(uri:Bob):123//uri:Bob;uri:Doug, where HASH(uri:Bob) indicates the shard id hash generated from the
 * Binding value "uri:Bob".
 *
 * @param nodeId - Node Id with type and UUID
 * @param firstBsVal - String representation of the first BsValue
 * @return - serialized Bytes prefix for scanning rows
 */
public static Bytes getShardedScanPrefix(String nodeId, Value firstBsVal) {
    checkNotNull(nodeId);
    checkNotNull(firstBsVal);
    final RyaType ryaValue = RdfToRyaConversions.convertValue(firstBsVal);
    final String bindingString = ryaValue.getData() + TYPE_DELIM + ryaValue.getDataType();
    return getShardedScanPrefix(nodeId, bindingString);
}
Also used : RyaType(org.apache.rya.api.domain.RyaType)

Aggregations

RyaType (org.apache.rya.api.domain.RyaType)178 RyaURI (org.apache.rya.api.domain.RyaURI)146 RyaStatement (org.apache.rya.api.domain.RyaStatement)115 Test (org.junit.Test)109 BindingSet (org.openrdf.query.BindingSet)42 QueryBindingSet (org.openrdf.query.algebra.evaluation.QueryBindingSet)42 ArrayList (java.util.ArrayList)35 StatementPattern (org.openrdf.query.algebra.StatementPattern)35 ParsedQuery (org.openrdf.query.parser.ParsedQuery)35 SPARQLParser (org.openrdf.query.parser.sparql.SPARQLParser)35 StatementMetadata (org.apache.rya.api.domain.StatementMetadata)34 QueryEvaluationException (org.openrdf.query.QueryEvaluationException)34 RyaDAOException (org.apache.rya.api.persist.RyaDAOException)28 Property (org.apache.rya.indexing.entity.model.Property)23 URIImpl (org.openrdf.model.impl.URIImpl)23 HashSet (java.util.HashSet)22 Entity (org.apache.rya.indexing.entity.model.Entity)20 Value (org.openrdf.model.Value)19 LiteralImpl (org.openrdf.model.impl.LiteralImpl)19 BatchWriter (org.apache.accumulo.core.client.BatchWriter)18