use of org.apache.rya.indexing.mongodb.temporal.MongoTemporalIndexer in project incubator-rya by apache.
the class MongoTemporalIndexerIT method testQueryIntervalEquals.
/**
* Test method for
* {@link org.apache.rya.indexing.Mongo.temporal.MongoTemporalIndexer#queryIntervalEquals(TemporalInterval, StatementConstraints)}
* .
* @throws IOException
* @throws QueryEvaluationException
*/
@Test
public void testQueryIntervalEquals() throws IOException, QueryEvaluationException {
try (MongoTemporalIndexer tIndexer = new MongoTemporalIndexer()) {
tIndexer.setConf(conf);
tIndexer.init();
// tiB02_E30 read as: Begins 2 seconds, ends at 30 seconds
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));
// instance at 4 seconds
tIndexer.storeStatement(convertStatement(seriesSpo[4]));
CloseableIteration<Statement, QueryEvaluationException> iter;
iter = tIndexer.queryIntervalEquals(tvB02_E40, EMPTY_CONSTRAINTS);
// Should be found twice:
assertTrue("queryIntervalEquals: spo_B02_E40 should be found, but actually returned empty results. spo_B02_E40=" + spo_B02_E40, iter.hasNext());
assertTrue("queryIntervalEquals: spo_B02_E40 should be found, but does not match.", spo_B02_E40.equals(iter.next()));
assertFalse("queryIntervalEquals: Find no more than one, but actually has more.", iter.hasNext());
}
}
use of org.apache.rya.indexing.mongodb.temporal.MongoTemporalIndexer in project incubator-rya by apache.
the class MongoTemporalIndexerIT method testQueryInstantInsideInterval.
/**
* Test instant inside given interval.
* Instance {before, after, inside} given Interval
*/
@Test
public void testQueryInstantInsideInterval() throws IOException, QueryEvaluationException {
try (MongoTemporalIndexer tIndexer = new MongoTemporalIndexer()) {
tIndexer.setConf(conf);
tIndexer.init();
// 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
final TemporalInterval searchInsideInterval = tvB02_E31;
// <== logic here, and next few lines.
final int beginningSeconds = 2;
final int endingSeconds = 31;
// 3,4,...,30 seconds.
final int expectedResultCount = endingSeconds - beginningSeconds - 1;
for (int s = 0; s <= 40; s++) {
tIndexer.storeStatement(convertStatement(seriesSpo[s]));
}
CloseableIteration<Statement, QueryEvaluationException> iter;
iter = tIndexer.queryInstantInsideInterval(searchInsideInterval, EMPTY_CONSTRAINTS);
int count = 0;
while (iter.hasNext()) {
final Statement s = iter.next();
// <== logic here
final Statement nextExpectedStatement = seriesSpo[count + beginningSeconds + 1];
assertTrue("Should match: " + nextExpectedStatement + " == " + s, nextExpectedStatement.equals(s));
count++;
}
assertEquals("Should find count of rows.", expectedResultCount, count);
}
}
use of org.apache.rya.indexing.mongodb.temporal.MongoTemporalIndexer in project incubator-rya by apache.
the class MongoTemporalIndexerIT method testQueryInstantAfterInstant.
/**
* Test instant after a given instant.
* From the series: instant {equal, before, after} instant
* @throws MongoSecurityException
* @throws MongoException
* @throws TableNotFoundException
*/
@Test
public void testQueryInstantAfterInstant() throws IOException, QueryEvaluationException, TableNotFoundException, MongoException {
try (MongoTemporalIndexer tIndexer = new MongoTemporalIndexer()) {
tIndexer.setConf(conf);
tIndexer.init();
// 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 instant for s seconds after the uniform time.
final int searchForSeconds = 4;
final int expectedResultCount = 9;
for (int s = 0; s <= searchForSeconds + expectedResultCount; s++) {
// <== logic here
tIndexer.storeStatement(convertStatement(seriesSpo[s]));
}
CloseableIteration<Statement, QueryEvaluationException> iter;
iter = tIndexer.queryInstantAfterInstant(seriesTs[searchForSeconds], EMPTY_CONSTRAINTS);
int count = 0;
while (iter.hasNext()) {
final Statement s = iter.next();
// <== logic here
final Statement nextExpectedStatement = seriesSpo[searchForSeconds + count + 1];
assertTrue("Should match: " + nextExpectedStatement + " == " + s, nextExpectedStatement.equals(s));
count++;
}
assertEquals("Should find count of rows.", expectedResultCount, count);
}
}
use of org.apache.rya.indexing.mongodb.temporal.MongoTemporalIndexer in project incubator-rya by apache.
the class MongoTemporalIndexerIT method testQueryInstantBeforeInterval.
/**
* Test instant before given interval.
* From the series: Instance {before, after, inside} given Interval
*/
@Test
public void testQueryInstantBeforeInterval() throws IOException, QueryEvaluationException {
try (MongoTemporalIndexer tIndexer = new MongoTemporalIndexer()) {
tIndexer.setConf(conf);
tIndexer.init();
// 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.
final TemporalInterval searchForSeconds = tvB02_E31;
// 00 and 01 seconds.
final int expectedResultCount = 2;
for (int s = 0; s <= 40; s++) {
// <== logic here
tIndexer.storeStatement(convertStatement(seriesSpo[s]));
}
CloseableIteration<Statement, QueryEvaluationException> iter;
iter = tIndexer.queryInstantBeforeInterval(searchForSeconds, EMPTY_CONSTRAINTS);
int count = 0;
while (iter.hasNext()) {
final Statement s = iter.next();
// <== logic here
final Statement nextExpectedStatement = seriesSpo[count];
assertTrue("Should match: " + nextExpectedStatement + " == " + s, nextExpectedStatement.equals(s));
count++;
}
assertEquals("Should find count of rows.", expectedResultCount, count);
}
}
use of org.apache.rya.indexing.mongodb.temporal.MongoTemporalIndexer in project incubator-rya by apache.
the class MongoTemporalIndexerIT method testQueryInstantAfterInterval.
/**
* Test instant after given interval.
* Instance {before, after, inside} given Interval
*/
@Test
public void testQueryInstantAfterInterval() throws IOException, QueryEvaluationException {
try (MongoTemporalIndexer tIndexer = new MongoTemporalIndexer()) {
tIndexer.setConf(conf);
tIndexer.init();
// 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
final TemporalInterval searchAfterInterval = tvB02_E31;
final int endingSeconds = 31;
// 32,33,...,40 seconds.
final int expectedResultCount = 9;
for (int s = 0; s <= endingSeconds + expectedResultCount; s++) {
// <== logic here
tIndexer.storeStatement(convertStatement(seriesSpo[s]));
}
CloseableIteration<Statement, QueryEvaluationException> iter;
iter = tIndexer.queryInstantAfterInterval(searchAfterInterval, EMPTY_CONSTRAINTS);
int count = 0;
while (iter.hasNext()) {
final Statement s = iter.next();
// <== logic here
final Statement nextExpectedStatement = seriesSpo[count + endingSeconds + 1];
assertTrue("Should match: " + nextExpectedStatement + " == " + s, nextExpectedStatement.equals(s));
count++;
}
assertEquals("Should find count of rows.", expectedResultCount, count);
}
}
Aggregations