use of org.apache.rya.api.domain.RyaType in project incubator-rya by apache.
the class AccumuloRyaDAOTest method newRyaStatement.
private RyaStatement newRyaStatement() {
RyaURI subject = new RyaURI(litdupsNS + randomString());
RyaURI predicate = new RyaURI(litdupsNS + randomString());
RyaType object = new RyaType(randomString());
return new RyaStatement(subject, predicate, object);
}
use of org.apache.rya.api.domain.RyaType in project incubator-rya by apache.
the class AccumuloRyaDAOTest method testAddEmptyString.
@Test
public void testAddEmptyString() throws Exception {
RyaURI cpu = RdfToRyaConversions.convertURI(vf.createURI(litdupsNS, "cpu"));
RyaURI loadPerc = RdfToRyaConversions.convertURI(vf.createURI(litdupsNS, "loadPerc"));
RyaType empty = new RyaType("");
dao.add(new RyaStatement(cpu, loadPerc, empty));
CloseableIteration<RyaStatement, RyaDAOException> iter = dao.getQueryEngine().query(new RyaStatement(cpu, loadPerc, null), conf);
while (iter.hasNext()) {
assertEquals("", iter.next().getObject().getData());
}
iter.close();
}
use of org.apache.rya.api.domain.RyaType in project incubator-rya by apache.
the class AggregationPipelineQueryNode method getMatchExpression.
/**
* Given a StatementPattern, generate an object representing the arguments
* to a "$match" command that will find matching triples.
* @param sp The StatementPattern to search for
* @param path If given, specify the field that should be matched against
* the statement pattern, using an ordered list of field names for a nested
* field. E.g. to match records { "x": { "y": <statement pattern } }, pass
* "x" followed by "y".
* @return The argument of a "$match" query
*/
private static BasicDBObject getMatchExpression(StatementPattern sp, String... path) {
final Var subjVar = sp.getSubjectVar();
final Var predVar = sp.getPredicateVar();
final Var objVar = sp.getObjectVar();
final Var contextVar = sp.getContextVar();
RyaURI s = null;
RyaURI p = null;
RyaType o = null;
RyaURI c = null;
if (subjVar != null && subjVar.getValue() instanceof Resource) {
s = RdfToRyaConversions.convertResource((Resource) subjVar.getValue());
}
if (predVar != null && predVar.getValue() instanceof URI) {
p = RdfToRyaConversions.convertURI((URI) predVar.getValue());
}
if (objVar != null && objVar.getValue() != null) {
o = RdfToRyaConversions.convertValue(objVar.getValue());
}
if (contextVar != null && contextVar.getValue() instanceof URI) {
c = RdfToRyaConversions.convertURI((URI) contextVar.getValue());
}
RyaStatement rs = new RyaStatement(s, p, o, c);
DBObject obj = strategy.getQuery(rs);
// Add path prefix, if given
if (path.length > 0) {
StringBuilder sb = new StringBuilder();
for (String str : path) {
sb.append(str).append(".");
}
String prefix = sb.toString();
Set<String> originalKeys = new HashSet<>(obj.keySet());
originalKeys.forEach(key -> {
Object value = obj.removeField(key);
obj.put(prefix + key, value);
});
}
return (BasicDBObject) obj;
}
use of org.apache.rya.api.domain.RyaType in project incubator-rya by apache.
the class NullRowTriplePatternStrategyTest method testHandles.
/**
* Test of handles method, of class NullRowTriplePatternStrategy.
*/
@Test
public void testHandles() {
RyaURI subject = null;
RyaURI predicate = null;
RyaType object = null;
RyaURI context = null;
NullRowTriplePatternStrategy instance = new NullRowTriplePatternStrategy();
assertTrue(instance.handles(subject, predicate, object, context));
RyaURI uri = new RyaURI("urn:test#1234");
assertFalse(instance.handles(uri, predicate, object, context));
assertFalse(instance.handles(subject, uri, object, context));
assertFalse(instance.handles(subject, predicate, uri, context));
}
use of org.apache.rya.api.domain.RyaType in project incubator-rya by apache.
the class NullRowTriplePatternStrategyTest method testDefineRange.
/**
* Test of defineRange method, of class NullRowTriplePatternStrategy.
* @throws java.lang.Exception
*/
@Test
public void testDefineRange() throws Exception {
RyaURI subject = null;
RyaURI predicate = null;
RyaType object = null;
RyaURI context = null;
RdfCloudTripleStoreConfiguration conf = new MockRdfConfiguration();
NullRowTriplePatternStrategy instance = new NullRowTriplePatternStrategy();
Map.Entry<RdfCloudTripleStoreConstants.TABLE_LAYOUT, ByteRange> expResult = new RdfCloudTripleStoreUtils.CustomEntry<>(RdfCloudTripleStoreConstants.TABLE_LAYOUT.SPO, new ByteRange(new byte[] {}, LAST_BYTES));
Map.Entry<RdfCloudTripleStoreConstants.TABLE_LAYOUT, ByteRange> result = instance.defineRange(subject, predicate, object, context, conf);
assertEquals(expResult.getKey(), result.getKey());
assertTrue(Arrays.equals(expResult.getValue().getStart(), result.getValue().getStart()));
assertTrue(Arrays.equals(expResult.getValue().getEnd(), result.getValue().getEnd()));
}
Aggregations