Search in sources :

Example 1 with TemporalInterval

use of org.apache.rya.indexing.TemporalInterval in project incubator-rya by apache.

the class AccumuloTemporalIndexerTest method testQueryInstantHasBeginningInterval.

/**
 * Test instant is the Beginning of the given interval.
 * from the series: Instance {hasBeginning, hasEnd} Interval
 */
@Test
public void testQueryInstantHasBeginningInterval() throws IOException, QueryEvaluationException {
    // tiB02_E30 read as: Begins 2 seconds, ends at 30 seconds
    // these should not match as they are not instances.
    tIndexer.storeStatement(convertStatement(spo_B03_E20));
    tIndexer.storeStatement(convertStatement(spo_B02_E30));
    tIndexer.storeStatement(convertStatement(spo_B02_E40));
    tIndexer.storeStatement(convertStatement(spo_B02_E31));
    tIndexer.storeStatement(convertStatement(spo_B30_E32));
    // seriesSpo[s] and seriesTs[s] are statements and instants for s seconds after the uniform time.
    // from 2 to 31 seconds
    TemporalInterval searchInsideInterval = tvB02_E31;
    // <== logic here, and next few lines.
    int searchSeconds = 2;
    // 2 seconds.
    int expectedResultCount = 1;
    for (int s = 0; s <= 10; s++) {
        tIndexer.storeStatement(convertStatement(seriesSpo[s]));
    }
    tIndexer.flush();
    CloseableIteration<Statement, QueryEvaluationException> iter;
    iter = tIndexer.queryInstantHasBeginningInterval(searchInsideInterval, EMPTY_CONSTRAINTS);
    int count = 0;
    while (iter.hasNext()) {
        Statement s = iter.next();
        // <== logic here
        Statement nextExpectedStatement = seriesSpo[searchSeconds];
        assertTrue("Should match: " + nextExpectedStatement + " == " + s, nextExpectedStatement.equals(s));
        count++;
    }
    Assert.assertEquals("Should find count of rows.", expectedResultCount, count);
}
Also used : QueryEvaluationException(org.openrdf.query.QueryEvaluationException) RyaStatement(org.apache.rya.api.domain.RyaStatement) Statement(org.openrdf.model.Statement) RdfToRyaConversions.convertStatement(org.apache.rya.api.resolver.RdfToRyaConversions.convertStatement) TemporalInterval(org.apache.rya.indexing.TemporalInterval) Test(org.junit.Test)

Example 2 with TemporalInterval

use of org.apache.rya.indexing.TemporalInterval in project incubator-rya by apache.

the class AccumuloTemporalIndexerTest method testQueryInstantInsideInterval.

/**
 * Test instant inside given interval.
 * Instance {before, after, inside} given Interval
 */
@Test
public void testQueryInstantInsideInterval() throws IOException, QueryEvaluationException {
    // tiB02_E30 read as: Begins 2 seconds, ends at 30 seconds
    // these should not match as they are not instances.
    tIndexer.storeStatement(convertStatement(spo_B03_E20));
    tIndexer.storeStatement(convertStatement(spo_B02_E30));
    tIndexer.storeStatement(convertStatement(spo_B02_E40));
    tIndexer.storeStatement(convertStatement(spo_B02_E31));
    tIndexer.storeStatement(convertStatement(spo_B30_E32));
    // seriesSpo[s] and seriesTs[s] are statements and instants for s seconds after the uniform time.
    // from 2 to 31 seconds
    TemporalInterval searchInsideInterval = tvB02_E31;
    // <== logic here, and next few lines.
    int beginningSeconds = 2;
    int endingSeconds = 31;
    // 3,4,...,30 seconds.
    int expectedResultCount = endingSeconds - beginningSeconds - 1;
    for (int s = 0; s <= 40; s++) {
        tIndexer.storeStatement(convertStatement(seriesSpo[s]));
    }
    tIndexer.flush();
    CloseableIteration<Statement, QueryEvaluationException> iter;
    iter = tIndexer.queryInstantInsideInterval(searchInsideInterval, EMPTY_CONSTRAINTS);
    int count = 0;
    while (iter.hasNext()) {
        Statement s = iter.next();
        // <== logic here
        Statement nextExpectedStatement = seriesSpo[count + beginningSeconds + 1];
        assertTrue("Should match: " + nextExpectedStatement + " == " + s, nextExpectedStatement.equals(s));
        count++;
    }
    Assert.assertEquals("Should find count of rows.", expectedResultCount, count);
}
Also used : QueryEvaluationException(org.openrdf.query.QueryEvaluationException) RyaStatement(org.apache.rya.api.domain.RyaStatement) Statement(org.openrdf.model.Statement) RdfToRyaConversions.convertStatement(org.apache.rya.api.resolver.RdfToRyaConversions.convertStatement) TemporalInterval(org.apache.rya.indexing.TemporalInterval) Test(org.junit.Test)

Example 3 with TemporalInterval

use of org.apache.rya.indexing.TemporalInterval in project incubator-rya by apache.

the class AccumuloTemporalIndexerTest method testQueryInstantHasEndInterval.

/**
 * Test instant is the end of the given interval.
 * from the series: Instance {hasBeginning, hasEnd} Interval
 */
@Test
public void testQueryInstantHasEndInterval() throws IOException, QueryEvaluationException {
    // tiB02_E30 read as: Begins 2 seconds, ends at 30 seconds
    // these should not match as they are not instances.
    tIndexer.storeStatement(convertStatement(spo_B03_E20));
    tIndexer.storeStatement(convertStatement(spo_B02_E30));
    tIndexer.storeStatement(convertStatement(spo_B02_E40));
    tIndexer.storeStatement(convertStatement(spo_B02_E31));
    tIndexer.storeStatement(convertStatement(spo_B30_E32));
    // seriesSpo[s] and seriesTs[s] are statements and instants for s seconds after the uniform time.
    // from 2 to 31 seconds
    TemporalInterval searchInsideInterval = tvB02_E31;
    // <== logic here, and next few lines.
    int searchSeconds = 31;
    // 31 seconds.
    int expectedResultCount = 1;
    for (int s = 0; s <= 40; s++) {
        tIndexer.storeStatement(convertStatement(seriesSpo[s]));
    }
    tIndexer.flush();
    CloseableIteration<Statement, QueryEvaluationException> iter;
    iter = tIndexer.queryInstantHasEndInterval(searchInsideInterval, EMPTY_CONSTRAINTS);
    int count = 0;
    while (iter.hasNext()) {
        Statement s = iter.next();
        // <== logic here
        Statement nextExpectedStatement = seriesSpo[searchSeconds];
        assertTrue("Should match: " + nextExpectedStatement + " == " + s, nextExpectedStatement.equals(s));
        count++;
    }
    Assert.assertEquals("Should find count of rows.", expectedResultCount, count);
}
Also used : QueryEvaluationException(org.openrdf.query.QueryEvaluationException) RyaStatement(org.apache.rya.api.domain.RyaStatement) Statement(org.openrdf.model.Statement) RdfToRyaConversions.convertStatement(org.apache.rya.api.resolver.RdfToRyaConversions.convertStatement) TemporalInterval(org.apache.rya.indexing.TemporalInterval) Test(org.junit.Test)

Example 4 with TemporalInterval

use of org.apache.rya.indexing.TemporalInterval in project incubator-rya by apache.

the class AccumuloTemporalIndexerTest method testQueryInstantAfterInterval.

/**
 * Test instant after given interval.
 * Instance {before, after, inside} given Interval
 */
@Test
public void testQueryInstantAfterInterval() throws IOException, QueryEvaluationException {
    // tiB02_E30 read as: Begins 2 seconds, ends at 30 seconds
    // these should not match as they are not instances.
    tIndexer.storeStatement(convertStatement(spo_B03_E20));
    tIndexer.storeStatement(convertStatement(spo_B02_E30));
    tIndexer.storeStatement(convertStatement(spo_B02_E40));
    tIndexer.storeStatement(convertStatement(spo_B02_E31));
    tIndexer.storeStatement(convertStatement(spo_B30_E32));
    // seriesSpo[s] and seriesTs[s] are statements and instants for s seconds after the uniform time.
    // from 2 to 31 seconds
    TemporalInterval searchAfterInterval = tvB02_E31;
    int endingSeconds = 31;
    // 32,33,...,40 seconds.
    int expectedResultCount = 9;
    for (int s = 0; s <= endingSeconds + expectedResultCount; s++) {
        // <== logic here
        tIndexer.storeStatement(convertStatement(seriesSpo[s]));
    }
    tIndexer.flush();
    CloseableIteration<Statement, QueryEvaluationException> iter;
    iter = tIndexer.queryInstantAfterInterval(searchAfterInterval, EMPTY_CONSTRAINTS);
    int count = 0;
    while (iter.hasNext()) {
        Statement s = iter.next();
        // <== logic here
        Statement nextExpectedStatement = seriesSpo[count + endingSeconds + 1];
        assertTrue("Should match: " + nextExpectedStatement + " == " + s, nextExpectedStatement.equals(s));
        count++;
    }
    Assert.assertEquals("Should find count of rows.", expectedResultCount, count);
}
Also used : QueryEvaluationException(org.openrdf.query.QueryEvaluationException) RyaStatement(org.apache.rya.api.domain.RyaStatement) Statement(org.openrdf.model.Statement) RdfToRyaConversions.convertStatement(org.apache.rya.api.resolver.RdfToRyaConversions.convertStatement) TemporalInterval(org.apache.rya.indexing.TemporalInterval) Test(org.junit.Test)

Example 5 with TemporalInterval

use of org.apache.rya.indexing.TemporalInterval in project incubator-rya by apache.

the class AccumuloTemporalIndexerTest method testQueryInstantBeforeInterval.

/**
 * Test instant before given interval.
 * From the series:  Instance {before, after, inside} given Interval
 */
@Test
public void testQueryInstantBeforeInterval() throws IOException, QueryEvaluationException {
    // tiB02_E30 read as: Begins 2 seconds, ends at 30 seconds
    // these should not match as they are not instances.
    tIndexer.storeStatement(convertStatement(spo_B03_E20));
    tIndexer.storeStatement(convertStatement(spo_B02_E30));
    tIndexer.storeStatement(convertStatement(spo_B02_E40));
    tIndexer.storeStatement(convertStatement(spo_B02_E31));
    tIndexer.storeStatement(convertStatement(spo_B30_E32));
    // seriesSpo[s] and seriesTs[s] are statements and instants for s seconds after the uniform time.
    TemporalInterval searchForSeconds = tvB02_E31;
    // 00 and 01 seconds.
    int expectedResultCount = 2;
    for (int s = 0; s <= 40; s++) {
        // <== logic here
        tIndexer.storeStatement(convertStatement(seriesSpo[s]));
    }
    tIndexer.flush();
    CloseableIteration<Statement, QueryEvaluationException> iter;
    iter = tIndexer.queryInstantBeforeInterval(searchForSeconds, EMPTY_CONSTRAINTS);
    int count = 0;
    while (iter.hasNext()) {
        Statement s = iter.next();
        // <== logic here
        Statement nextExpectedStatement = seriesSpo[count];
        assertTrue("Should match: " + nextExpectedStatement + " == " + s, nextExpectedStatement.equals(s));
        count++;
    }
    Assert.assertEquals("Should find count of rows.", expectedResultCount, count);
}
Also used : QueryEvaluationException(org.openrdf.query.QueryEvaluationException) RyaStatement(org.apache.rya.api.domain.RyaStatement) Statement(org.openrdf.model.Statement) RdfToRyaConversions.convertStatement(org.apache.rya.api.resolver.RdfToRyaConversions.convertStatement) TemporalInterval(org.apache.rya.indexing.TemporalInterval) Test(org.junit.Test)

Aggregations

TemporalInterval (org.apache.rya.indexing.TemporalInterval)24 Test (org.junit.Test)16 TemporalInstantRfc3339 (org.apache.rya.indexing.TemporalInstantRfc3339)12 Statement (org.openrdf.model.Statement)11 RdfToRyaConversions.convertStatement (org.apache.rya.api.resolver.RdfToRyaConversions.convertStatement)10 QueryEvaluationException (org.openrdf.query.QueryEvaluationException)10 TemporalInstant (org.apache.rya.indexing.TemporalInstant)7 RyaStatement (org.apache.rya.api.domain.RyaStatement)6 MongoTemporalIndexer (org.apache.rya.indexing.mongodb.temporal.MongoTemporalIndexer)5 DateTime (org.joda.time.DateTime)5 Matcher (java.util.regex.Matcher)4 IOException (java.io.IOException)3 RyaURI (org.apache.rya.api.domain.RyaURI)3 Event (org.apache.rya.indexing.geotemporal.model.Event)3 Geometry (com.vividsolutions.jts.geom.Geometry)2 ParseException (com.vividsolutions.jts.io.ParseException)2 MutationsRejectedException (org.apache.accumulo.core.client.MutationsRejectedException)2 EventStorage (org.apache.rya.indexing.geotemporal.storage.EventStorage)2 GmlParser (org.apache.rya.indexing.mongodb.geo.GmlParser)2 Literal (org.openrdf.model.Literal)2