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