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()));
}
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()));
}
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();
}
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();
}
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);
}
Aggregations