use of org.locationtech.geowave.core.geotime.store.statistics.TimeRangeStatistic in project geowave by locationtech.
the class FeatureDataAdapter method getDefaultStatistics.
@Override
public List<Statistic<? extends StatisticValue<?>>> getDefaultStatistics() {
final List<Statistic<?>> statistics = Lists.newArrayList();
final CountStatistic count = new CountStatistic(getTypeName());
count.setInternal();
statistics.add(count);
for (int i = 0; i < featureType.getAttributeCount(); i++) {
final AttributeDescriptor ad = featureType.getDescriptor(i);
if (Geometry.class.isAssignableFrom(ad.getType().getBinding())) {
final BoundingBoxStatistic bbox = new BoundingBoxStatistic(getTypeName(), ad.getLocalName());
bbox.setInternal();
statistics.add(bbox);
}
}
final TimeDescriptors timeDescriptors = getTimeDescriptors();
if (timeDescriptors.hasTime()) {
if (timeDescriptors.getTime() != null) {
final TimeRangeStatistic timeRange = new TimeRangeStatistic(getTypeName(), timeDescriptors.getTime().getLocalName());
timeRange.setInternal();
statistics.add(timeRange);
}
if (timeDescriptors.getStartRange() != null) {
final TimeRangeStatistic timeRange = new TimeRangeStatistic(getTypeName(), timeDescriptors.getStartRange().getLocalName());
timeRange.setInternal();
statistics.add(timeRange);
}
if (timeDescriptors.getEndRange() != null) {
final TimeRangeStatistic timeRange = new TimeRangeStatistic(getTypeName(), timeDescriptors.getEndRange().getLocalName());
timeRange.setInternal();
statistics.add(timeRange);
}
}
return statistics;
}
use of org.locationtech.geowave.core.geotime.store.statistics.TimeRangeStatistic in project geowave by locationtech.
the class TemporalRangeTest method test.
@Test
public void test() throws ParseException, IOException {
final Calendar gmt = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
final Calendar local = Calendar.getInstance(TimeZone.getTimeZone("EDT"));
local.setTimeInMillis(gmt.getTimeInMillis());
final TemporalRange rGmt = new TemporalRange(gmt.getTime(), gmt.getTime());
final TemporalRange rLocal = new TemporalRange(local.getTime(), local.getTime());
rGmt.fromBinary(rGmt.toBinary());
assertEquals(gmt.getTime(), rGmt.getEndTime());
assertEquals(rLocal.getEndTime(), rGmt.getEndTime());
assertEquals(rLocal.getEndTime().getTime(), rGmt.getEndTime().getTime());
final Transaction transaction1 = new DefaultTransaction();
final FeatureWriter<SimpleFeatureType, SimpleFeature> writer = dataStore.getFeatureWriter(type.getTypeName(), transaction1);
final SimpleFeature newFeature = writer.next();
newFeature.setAttribute("pop", Long.valueOf(77));
newFeature.setAttribute("pid", UUID.randomUUID().toString());
newFeature.setAttribute("when", DateUtilities.parseISO("2005-05-19T19:32:56-04:00"));
newFeature.setAttribute("geometry", factory.createPoint(new Coordinate(43.454, 28.232)));
FeatureDataAdapter adapter = new FeatureDataAdapter(type);
final TimeRangeStatistic stats = new TimeRangeStatistic(type.getTypeName(), "when");
final TimeRangeValue statValue = stats.createEmpty();
statValue.entryIngested(adapter, newFeature);
assertEquals(DateUtilities.parseISO("2005-05-19T23:32:56Z"), statValue.asTemporalRange().getStartTime());
writer.close();
transaction1.close();
}
use of org.locationtech.geowave.core.geotime.store.statistics.TimeRangeStatistic in project geowave by locationtech.
the class QueryIndexHelperTest method testGetTemporalConstraintsForSingleClippedRange.
@Test
public void testGetTemporalConstraintsForSingleClippedRange() throws ParseException {
final Date stime = DateUtilities.parseISO("2005-05-14T20:32:56Z");
final Date etime = DateUtilities.parseISO("2005-05-18T20:32:56Z");
final Date stime1 = DateUtilities.parseISO("2005-05-18T20:32:56Z");
final Date etime1 = DateUtilities.parseISO("2005-05-19T20:32:56Z");
final TestStatisticsCache statsCache = new TestStatisticsCache();
final TimeRangeStatistic whenStats = new TimeRangeStatistic(singleType.getTypeName(), "when");
final TimeRangeValue whenValue = whenStats.createEmpty();
statsCache.putFieldStatistic(TimeRangeStatistic.STATS_TYPE, "when", whenValue);
final TemporalConstraintsSet constraintsSet = new TemporalConstraintsSet();
constraintsSet.getConstraintsFor("when").add(new TemporalRange(stime, etime));
final FeatureDataAdapter singleDataAdapter = new FeatureDataAdapter(singleType);
final SimpleFeature notIntersectSingle1 = createSingleTimeFeature(startTime);
whenValue.entryIngested(singleDataAdapter, notIntersectSingle1);
final SimpleFeature notIntersectSingle = createSingleTimeFeature(endTime);
whenValue.entryIngested(singleDataAdapter, notIntersectSingle);
final TemporalConstraintsSet resultConstraintsSet = QueryIndexHelper.clipIndexedTemporalConstraints(statsCache, singleTimeDescriptors, constraintsSet);
final TemporalConstraints constraints = resultConstraintsSet.getConstraintsFor("when");
assertEquals(1, constraints.getRanges().size());
assertEquals(startTime, constraints.getStartRange().getStartTime());
assertEquals(etime, constraints.getStartRange().getEndTime());
final TemporalConstraintsSet constraintsSet1 = new TemporalConstraintsSet();
constraintsSet1.getConstraintsFor("when").add(new TemporalRange(stime1, etime1));
final TemporalConstraintsSet resultConstraintsSet1 = QueryIndexHelper.clipIndexedTemporalConstraints(statsCache, singleTimeDescriptors, constraintsSet1);
final TemporalConstraints constraints1 = resultConstraintsSet1.getConstraintsFor("when");
assertEquals(1, constraints1.getRanges().size());
assertEquals(stime1, constraints1.getStartRange().getStartTime());
assertEquals(etime1, constraints1.getStartRange().getEndTime());
}
use of org.locationtech.geowave.core.geotime.store.statistics.TimeRangeStatistic in project geowave by locationtech.
the class QueryIndexHelperTest method testComposeSubsetConstraints.
@Test
public void testComposeSubsetConstraints() throws ParseException {
final TestStatisticsCache statsCache = new TestStatisticsCache();
final TimeRangeStatistic startStats = new TimeRangeStatistic("type", "start");
final TimeRangeValue startValue = startStats.createEmpty();
statsCache.putFieldStatistic(TimeRangeStatistic.STATS_TYPE, "start", startValue);
final TimeRangeStatistic endStats = new TimeRangeStatistic("type", "end");
final TimeRangeValue endValue = endStats.createEmpty();
statsCache.putFieldStatistic(TimeRangeStatistic.STATS_TYPE, "end", endValue);
final Date statsStart1 = DateUtilities.parseISO("2005-05-18T20:32:56Z");
final Date statsStart2 = DateUtilities.parseISO("2005-05-20T20:32:56Z");
final Date statsEnd1 = DateUtilities.parseISO("2005-05-21T20:32:56Z");
final Date statsEnd2 = DateUtilities.parseISO("2005-05-24T20:32:56Z");
final SimpleFeature firstRangFeature = createFeature(statsStart1, statsEnd1);
FeatureDataAdapter adapter = new FeatureDataAdapter(firstRangFeature.getFeatureType());
startValue.entryIngested(adapter, firstRangFeature);
endValue.entryIngested(adapter, firstRangFeature);
final SimpleFeature secondRangFeature = createFeature(statsStart2, statsEnd2);
startValue.entryIngested(adapter, secondRangFeature);
endValue.entryIngested(adapter, secondRangFeature);
final Date stime = DateUtilities.parseISO("2005-05-18T20:32:56Z");
final Date etime = DateUtilities.parseISO("2005-05-19T20:32:56Z");
final TemporalConstraintsSet constraintsSet = new TemporalConstraintsSet();
constraintsSet.getConstraintsForRange("start", "end").add(new TemporalRange(stime, etime));
final Constraints constraints = QueryIndexHelper.composeTimeBoundedConstraints(rangeType, rangeTimeDescriptors, constraintsSet);
final List<MultiDimensionalNumericData> nd = constraints.getIndexConstraints(SPATIAL_TEMPORAL_INDEX);
assertTrue(nd.isEmpty());
final BoundingBoxStatistic geoStats = new BoundingBoxStatistic("type", "geometry");
final BoundingBoxValue geoValue = geoStats.createEmpty();
statsCache.putFieldStatistic(BoundingBoxStatistic.STATS_TYPE, "geometry", geoValue);
final SimpleFeature firstFeature = createGeoFeature(factory.createPoint(new Coordinate(22.25, 42.25)));
geoValue.entryIngested(adapter, firstFeature);
final SimpleFeature secondFeature = createGeoFeature(factory.createPoint(new Coordinate(27.25, 41.25)));
geoValue.entryIngested(adapter, secondFeature);
final Constraints constraints1 = QueryIndexHelper.composeConstraints(statsCache, rangeType, rangeTimeDescriptors, null, constraintsSet);
final List<MultiDimensionalNumericData> nd1 = constraints1.getIndexConstraints(SPATIAL_TEMPORAL_INDEX);
assertTrue(nd1.isEmpty());
/*
* assertEquals( stime.getTime(), (long) nd1.get( 0).getDataPerDimension()[2].getMin());
* assertEquals( etime.getTime(), (long) nd1.get( 0).getDataPerDimension()[2].getMax());
*/
final TemporalConstraintsSet constraintsSet2 = new TemporalConstraintsSet();
constraintsSet2.getConstraintsForRange("start", "end").add(new TemporalRange(statsStart1, statsEnd2));
final Constraints constraints2 = QueryIndexHelper.composeTimeBoundedConstraints(rangeType, rangeTimeDescriptors, constraintsSet2);
final List<MultiDimensionalNumericData> nd2 = constraints2.getIndexConstraints(SPATIAL_TEMPORAL_INDEX);
assertTrue(nd2.isEmpty());
}
use of org.locationtech.geowave.core.geotime.store.statistics.TimeRangeStatistic in project geowave by locationtech.
the class QueryIndexHelperTest method testComposeQueryWithTimeRange.
@Test
public void testComposeQueryWithTimeRange() throws ParseException {
final TestStatisticsCache statsCache = new TestStatisticsCache();
final TimeRangeStatistic startStats = new TimeRangeStatistic("type", "start");
final TimeRangeValue startValue = startStats.createEmpty();
statsCache.putFieldStatistic(TimeRangeStatistic.STATS_TYPE, "start", startValue);
final TimeRangeStatistic endStats = new TimeRangeStatistic("type", "end");
final TimeRangeValue endValue = endStats.createEmpty();
statsCache.putFieldStatistic(TimeRangeStatistic.STATS_TYPE, "end", endValue);
final Date statsStart1 = DateUtilities.parseISO("2005-05-18T20:32:56Z");
final Date statsStart2 = DateUtilities.parseISO("2005-05-20T20:32:56Z");
final Date statsEnd1 = DateUtilities.parseISO("2005-05-21T20:32:56Z");
final Date statsEnd2 = DateUtilities.parseISO("2005-05-24T20:32:56Z");
final SimpleFeature firstRangFeature = createFeature(statsStart1, statsEnd1);
FeatureDataAdapter adapter = new FeatureDataAdapter(firstRangFeature.getFeatureType());
startValue.entryIngested(adapter, firstRangFeature);
endValue.entryIngested(adapter, firstRangFeature);
final SimpleFeature secondRangFeature = createFeature(statsStart2, statsEnd2);
startValue.entryIngested(adapter, secondRangFeature);
endValue.entryIngested(adapter, secondRangFeature);
final Date stime = DateUtilities.parseISO("2005-05-18T20:32:56Z");
final Date etime = DateUtilities.parseISO("2005-05-19T20:32:56Z");
final TemporalConstraintsSet constraintsSet = new TemporalConstraintsSet();
constraintsSet.getConstraintsForRange("start", "end").add(new TemporalRange(stime, etime));
final BasicQueryByClass query = new BasicQueryByClass(QueryIndexHelper.composeConstraints(statsCache, rangeType, rangeTimeDescriptors, factory.toGeometry(factory.createPoint(new Coordinate(27.25, 41.25)).getEnvelopeInternal()), constraintsSet));
final List<MultiDimensionalNumericData> nd = query.getIndexConstraints(SPATIAL_TEMPORAL_INDEX);
assertEquals(stime.getTime(), nd.get(0).getDataPerDimension()[2].getMin().longValue());
assertEquals(etime.getTime(), nd.get(0).getDataPerDimension()[2].getMax().longValue());
final BasicQueryByClass query1 = new BasicQueryByClass(QueryIndexHelper.composeConstraints(statsCache, rangeType, rangeTimeDescriptors, factory.toGeometry(factory.createPoint(new Coordinate(27.25, 41.25)).getEnvelopeInternal()), null));
final List<MultiDimensionalNumericData> nd1 = query1.getIndexConstraints(SPATIAL_TEMPORAL_INDEX);
assertEquals(statsStart1.getTime(), nd1.get(0).getDataPerDimension()[2].getMin().longValue());
assertEquals(statsEnd2.getTime(), nd1.get(0).getDataPerDimension()[2].getMax().longValue());
}
Aggregations