Search in sources :

Example 91 with RyaType

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

the class RyaContextTest method testTripleRowSerialization.

public void testTripleRowSerialization() throws Exception {
    RyaURI subj = new RyaURI("urn:test#subj");
    RyaURI pred = new RyaURI("urn:test#pred");
    RyaType obj = new RyaType("mydata");
    RyaStatement statement = new RyaStatement(subj, pred, obj);
    RyaTripleContext instance = RyaTripleContext.getInstance(new MockRdfCloudConfiguration());
    Map<TABLE_LAYOUT, TripleRow> map = instance.serializeTriple(statement);
    TripleRow tripleRow = map.get(TABLE_LAYOUT.SPO);
    assertEquals(statement, instance.deserializeTriple(TABLE_LAYOUT.SPO, tripleRow));
}
Also used : RyaURI(org.apache.rya.api.domain.RyaURI) TABLE_LAYOUT(org.apache.rya.api.RdfCloudTripleStoreConstants.TABLE_LAYOUT) TripleRow(org.apache.rya.api.resolver.triple.TripleRow) RyaStatement(org.apache.rya.api.domain.RyaStatement) RyaType(org.apache.rya.api.domain.RyaType) MockRdfCloudConfiguration(org.apache.rya.api.query.strategy.wholerow.MockRdfCloudConfiguration)

Example 92 with RyaType

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

the class DateTimeRyaTypeResolverTest method serializeAndDeserialize.

/**
 * Serialize a datetime string, then deserialize as a ryaType.
 * @param dateTimeString
 * @param type if null , use default: XMLSchema.DATETIME
 * @return
 * @throws RyaTypeResolverException
 */
private RyaType serializeAndDeserialize(String dateTimeString, org.openrdf.model.URI type) throws RyaTypeResolverException {
    if (type == null)
        type = XMLSchema.DATETIME;
    RyaType ryaType = new RyaType(type, dateTimeString);
    byte[] serialize = new DateTimeRyaTypeResolver().serialize(ryaType);
    return new DateTimeRyaTypeResolver().deserialize(serialize);
}
Also used : RyaType(org.apache.rya.api.domain.RyaType)

Example 93 with RyaType

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

the class DateTimeRyaTypeResolverTest method testMilliSecondsNoZone.

@Test
public void testMilliSecondsNoZone() throws Exception {
    String beforeDate = "2002-02-02T02:02:02.222";
    String afterDate = "2002-02-0(1|2|3)T\\d\\d:\\d\\d:02\\.222.*";
    RyaType deserialize = serializeAndDeserialize(beforeDate, XMLSchema.DATETIME);
    final String afterActual = deserialize.getData();
    assertTrue("Before='" + beforeDate + "'; Expected should match actual regex after='" + afterDate + "' deserialized:" + afterActual, afterActual.matches(afterDate));
    assertEquals(XMLSchema.DATETIME, deserialize.getDataType());
}
Also used : RyaType(org.apache.rya.api.domain.RyaType) Test(org.junit.Test)

Example 94 with RyaType

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

the class RyaURIResolverTest method testSerialization.

public void testSerialization() throws Exception {
    RyaURI ryaURI = new RyaURI("urn:testdata#data");
    byte[] serialize = new RyaURIResolver().serialize(ryaURI);
    RyaType deserialize = new RyaURIResolver().deserialize(serialize);
    assertEquals(ryaURI, deserialize);
}
Also used : RyaURI(org.apache.rya.api.domain.RyaURI) RyaType(org.apache.rya.api.domain.RyaType)

Example 95 with RyaType

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

the class CustomDatatypeResolverTest method testCustomDataTypeSerialization.

public void testCustomDataTypeSerialization() throws Exception {
    RyaType ryaType = new RyaType(new URIImpl("urn:test#datatype"), "testdata");
    byte[] serialize = new CustomDatatypeResolver().serialize(ryaType);
    RyaType deserialize = new CustomDatatypeResolver().deserialize(serialize);
    assertEquals(ryaType, deserialize);
}
Also used : URIImpl(org.openrdf.model.impl.URIImpl) 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