Search in sources :

Example 1 with OspWholeRowTriplePatternStrategy

use of org.apache.rya.api.query.strategy.wholerow.OspWholeRowTriplePatternStrategy in project incubator-rya by apache.

the class RyaTripleContext method addDefaultTriplePatternStrategies.

protected void addDefaultTriplePatternStrategies(final boolean addPrefixHash) {
    if (addPrefixHash) {
        triplePatternStrategyList.add(new HashedSpoWholeRowTriplePatternStrategy());
        triplePatternStrategyList.add(new HashedPoWholeRowTriplePatternStrategy());
    } else {
        triplePatternStrategyList.add(new SpoWholeRowTriplePatternStrategy());
        triplePatternStrategyList.add(new PoWholeRowTriplePatternStrategy());
        triplePatternStrategyList.add(new NullRowTriplePatternStrategy());
    }
    triplePatternStrategyList.add(new OspWholeRowTriplePatternStrategy());
}
Also used : HashedPoWholeRowTriplePatternStrategy(org.apache.rya.api.query.strategy.wholerow.HashedPoWholeRowTriplePatternStrategy) PoWholeRowTriplePatternStrategy(org.apache.rya.api.query.strategy.wholerow.PoWholeRowTriplePatternStrategy) HashedPoWholeRowTriplePatternStrategy(org.apache.rya.api.query.strategy.wholerow.HashedPoWholeRowTriplePatternStrategy) SpoWholeRowTriplePatternStrategy(org.apache.rya.api.query.strategy.wholerow.SpoWholeRowTriplePatternStrategy) HashedSpoWholeRowTriplePatternStrategy(org.apache.rya.api.query.strategy.wholerow.HashedSpoWholeRowTriplePatternStrategy) OspWholeRowTriplePatternStrategy(org.apache.rya.api.query.strategy.wholerow.OspWholeRowTriplePatternStrategy) HashedSpoWholeRowTriplePatternStrategy(org.apache.rya.api.query.strategy.wholerow.HashedSpoWholeRowTriplePatternStrategy) NullRowTriplePatternStrategy(org.apache.rya.api.query.strategy.wholerow.NullRowTriplePatternStrategy)

Example 2 with OspWholeRowTriplePatternStrategy

use of org.apache.rya.api.query.strategy.wholerow.OspWholeRowTriplePatternStrategy in project incubator-rya by apache.

the class AbstractTriplePatternStrategyTest method testObjectTypeInfo.

public void testObjectTypeInfo() throws Exception {
    RyaURI subj = new RyaURI("urn:test#1234");
    RyaURI pred = new RyaURI("urn:test#pred");
    RyaType obj = new RyaType(XMLSchema.LONG, "10");
    RyaStatement ryaStatement = new RyaStatement(subj, pred, obj);
    Map<RdfCloudTripleStoreConstants.TABLE_LAYOUT, TripleRow> serialize = RyaTripleContext.getInstance(new MockRdfConfiguration()).serializeTriple(ryaStatement);
    TripleRow tripleRow = serialize.get(SPO);
    String row = new String(tripleRow.getRow());
    TriplePatternStrategy spoStrategy = new SpoWholeRowTriplePatternStrategy();
    // obj
    byte[][] bytes = RyaContext.getInstance().serializeType(obj);
    String objStr = new String(bytes[0]);
    byte[] objectTypeInfo = bytes[1];
    TripleRowRegex tripleRowRegex = spoStrategy.buildRegex(null, null, objStr, null, objectTypeInfo);
    Pattern p = Pattern.compile(tripleRowRegex.getRow());
    Matcher matcher = p.matcher(row);
    assertTrue(matcher.matches());
    // build row with same object str data
    Map<RdfCloudTripleStoreConstants.TABLE_LAYOUT, TripleRow> dupTriple_str = RyaTripleContext.getInstance(new MockRdfConfiguration()).serializeTriple(new RyaStatement(subj, pred, new RyaType(XMLSchema.STRING, objStr)));
    TripleRow tripleRow_dup_str = dupTriple_str.get(SPO);
    row = new String(tripleRow_dup_str.getRow());
    spoStrategy = new SpoWholeRowTriplePatternStrategy();
    tripleRowRegex = spoStrategy.buildRegex(null, null, objStr, null, objectTypeInfo);
    p = Pattern.compile(tripleRowRegex.getRow());
    matcher = p.matcher(row);
    assertFalse(matcher.matches());
    // po table
    TriplePatternStrategy poStrategy = new PoWholeRowTriplePatternStrategy();
    tripleRowRegex = poStrategy.buildRegex(null, null, objStr, null, objectTypeInfo);
    p = Pattern.compile(tripleRowRegex.getRow());
    String po_row = new String(serialize.get(PO).getRow());
    matcher = p.matcher(po_row);
    assertTrue(matcher.matches());
    tripleRowRegex = poStrategy.buildRegex(null, null, objStr, null, objectTypeInfo);
    p = Pattern.compile(tripleRowRegex.getRow());
    matcher = p.matcher(new String(dupTriple_str.get(PO).getRow()));
    assertFalse(matcher.matches());
    // osp table
    TriplePatternStrategy ospStrategy = new OspWholeRowTriplePatternStrategy();
    tripleRowRegex = ospStrategy.buildRegex(null, null, objStr, null, objectTypeInfo);
    p = Pattern.compile(tripleRowRegex.getRow());
    String osp_row = new String(serialize.get(OSP).getRow());
    matcher = p.matcher(osp_row);
    assertTrue(matcher.matches());
    tripleRowRegex = ospStrategy.buildRegex(null, null, objStr, null, objectTypeInfo);
    p = Pattern.compile(tripleRowRegex.getRow());
    matcher = p.matcher(new String(dupTriple_str.get(OSP).getRow()));
    assertFalse(matcher.matches());
}
Also used : PoWholeRowTriplePatternStrategy(org.apache.rya.api.query.strategy.wholerow.PoWholeRowTriplePatternStrategy) Pattern(java.util.regex.Pattern) SpoWholeRowTriplePatternStrategy(org.apache.rya.api.query.strategy.wholerow.SpoWholeRowTriplePatternStrategy) PoWholeRowTriplePatternStrategy(org.apache.rya.api.query.strategy.wholerow.PoWholeRowTriplePatternStrategy) OspWholeRowTriplePatternStrategy(org.apache.rya.api.query.strategy.wholerow.OspWholeRowTriplePatternStrategy) Matcher(java.util.regex.Matcher) RyaStatement(org.apache.rya.api.domain.RyaStatement) RyaType(org.apache.rya.api.domain.RyaType) RyaURI(org.apache.rya.api.domain.RyaURI) SpoWholeRowTriplePatternStrategy(org.apache.rya.api.query.strategy.wholerow.SpoWholeRowTriplePatternStrategy) OspWholeRowTriplePatternStrategy(org.apache.rya.api.query.strategy.wholerow.OspWholeRowTriplePatternStrategy) TripleRow(org.apache.rya.api.resolver.triple.TripleRow) TripleRowRegex(org.apache.rya.api.resolver.triple.TripleRowRegex)

Example 3 with OspWholeRowTriplePatternStrategy

use of org.apache.rya.api.query.strategy.wholerow.OspWholeRowTriplePatternStrategy in project incubator-rya by apache.

the class AbstractTriplePatternStrategyTest method testRegex.

public void testRegex() throws Exception {
    RyaURI subj = new RyaURI("urn:test#1234");
    RyaURI pred = new RyaURI("urn:test#pred");
    RyaURI obj = new RyaURI("urn:test#obj");
    RyaStatement ryaStatement = new RyaStatement(subj, pred, obj);
    Map<RdfCloudTripleStoreConstants.TABLE_LAYOUT, TripleRow> serialize = new WholeRowTripleResolver().serialize(ryaStatement);
    TripleRow tripleRow = serialize.get(RdfCloudTripleStoreConstants.TABLE_LAYOUT.SPO);
    String row = new String(tripleRow.getRow());
    TriplePatternStrategy spoStrategy = new SpoWholeRowTriplePatternStrategy();
    TriplePatternStrategy poStrategy = new PoWholeRowTriplePatternStrategy();
    TriplePatternStrategy ospStrategy = new OspWholeRowTriplePatternStrategy();
    // pred
    TripleRowRegex tripleRowRegex = spoStrategy.buildRegex(null, pred.getData(), null, null, null);
    Pattern p = Pattern.compile(tripleRowRegex.getRow());
    Matcher matcher = p.matcher(row);
    assertTrue(matcher.matches());
    // subj
    tripleRowRegex = spoStrategy.buildRegex(subj.getData(), null, null, null, null);
    p = Pattern.compile(tripleRowRegex.getRow());
    matcher = p.matcher(row);
    assertTrue(matcher.matches());
    // obj
    tripleRowRegex = spoStrategy.buildRegex(null, null, obj.getData(), null, null);
    p = Pattern.compile(tripleRowRegex.getRow());
    matcher = p.matcher(row);
    assertTrue(matcher.matches());
    // po table
    row = new String(serialize.get(RdfCloudTripleStoreConstants.TABLE_LAYOUT.PO).getRow());
    tripleRowRegex = poStrategy.buildRegex(null, pred.getData(), null, null, null);
    p = Pattern.compile(tripleRowRegex.getRow());
    matcher = p.matcher(row);
    assertTrue(matcher.matches());
    tripleRowRegex = poStrategy.buildRegex(null, pred.getData(), obj.getData(), null, null);
    p = Pattern.compile(tripleRowRegex.getRow());
    matcher = p.matcher(row);
    assertTrue(matcher.matches());
    tripleRowRegex = poStrategy.buildRegex(subj.getData(), pred.getData(), obj.getData(), null, null);
    p = Pattern.compile(tripleRowRegex.getRow());
    matcher = p.matcher(row);
    assertTrue(matcher.matches());
    // various regex
    tripleRowRegex = poStrategy.buildRegex(null, "urn:test#pr[e|d]{2}", null, null, null);
    p = Pattern.compile(tripleRowRegex.getRow());
    matcher = p.matcher(row);
    assertTrue(matcher.matches());
    // does not match
    tripleRowRegex = poStrategy.buildRegex(null, "hello", null, null, null);
    p = Pattern.compile(tripleRowRegex.getRow());
    matcher = p.matcher(row);
    assertFalse(matcher.matches());
}
Also used : PoWholeRowTriplePatternStrategy(org.apache.rya.api.query.strategy.wholerow.PoWholeRowTriplePatternStrategy) Pattern(java.util.regex.Pattern) SpoWholeRowTriplePatternStrategy(org.apache.rya.api.query.strategy.wholerow.SpoWholeRowTriplePatternStrategy) PoWholeRowTriplePatternStrategy(org.apache.rya.api.query.strategy.wholerow.PoWholeRowTriplePatternStrategy) OspWholeRowTriplePatternStrategy(org.apache.rya.api.query.strategy.wholerow.OspWholeRowTriplePatternStrategy) Matcher(java.util.regex.Matcher) RyaStatement(org.apache.rya.api.domain.RyaStatement) RyaURI(org.apache.rya.api.domain.RyaURI) SpoWholeRowTriplePatternStrategy(org.apache.rya.api.query.strategy.wholerow.SpoWholeRowTriplePatternStrategy) OspWholeRowTriplePatternStrategy(org.apache.rya.api.query.strategy.wholerow.OspWholeRowTriplePatternStrategy) TripleRow(org.apache.rya.api.resolver.triple.TripleRow) TripleRowRegex(org.apache.rya.api.resolver.triple.TripleRowRegex) WholeRowTripleResolver(org.apache.rya.api.resolver.triple.impl.WholeRowTripleResolver)

Aggregations

OspWholeRowTriplePatternStrategy (org.apache.rya.api.query.strategy.wholerow.OspWholeRowTriplePatternStrategy)3 PoWholeRowTriplePatternStrategy (org.apache.rya.api.query.strategy.wholerow.PoWholeRowTriplePatternStrategy)3 SpoWholeRowTriplePatternStrategy (org.apache.rya.api.query.strategy.wholerow.SpoWholeRowTriplePatternStrategy)3 Matcher (java.util.regex.Matcher)2 Pattern (java.util.regex.Pattern)2 RyaStatement (org.apache.rya.api.domain.RyaStatement)2 RyaURI (org.apache.rya.api.domain.RyaURI)2 TripleRow (org.apache.rya.api.resolver.triple.TripleRow)2 TripleRowRegex (org.apache.rya.api.resolver.triple.TripleRowRegex)2 RyaType (org.apache.rya.api.domain.RyaType)1 HashedPoWholeRowTriplePatternStrategy (org.apache.rya.api.query.strategy.wholerow.HashedPoWholeRowTriplePatternStrategy)1 HashedSpoWholeRowTriplePatternStrategy (org.apache.rya.api.query.strategy.wholerow.HashedSpoWholeRowTriplePatternStrategy)1 NullRowTriplePatternStrategy (org.apache.rya.api.query.strategy.wholerow.NullRowTriplePatternStrategy)1 WholeRowTripleResolver (org.apache.rya.api.resolver.triple.impl.WholeRowTripleResolver)1