Search in sources :

Example 1 with TimeRangeStatistic

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;
}
Also used : BoundingBoxStatistic(org.locationtech.geowave.core.geotime.store.statistics.BoundingBoxStatistic) TimeDescriptors(org.locationtech.geowave.core.geotime.util.TimeDescriptors) Statistic(org.locationtech.geowave.core.store.api.Statistic) CountStatistic(org.locationtech.geowave.core.store.statistics.adapter.CountStatistic) BoundingBoxStatistic(org.locationtech.geowave.core.geotime.store.statistics.BoundingBoxStatistic) TimeRangeStatistic(org.locationtech.geowave.core.geotime.store.statistics.TimeRangeStatistic) AttributeDescriptor(org.opengis.feature.type.AttributeDescriptor) CountStatistic(org.locationtech.geowave.core.store.statistics.adapter.CountStatistic) TimeRangeStatistic(org.locationtech.geowave.core.geotime.store.statistics.TimeRangeStatistic)

Example 2 with TimeRangeStatistic

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();
}
Also used : Transaction(org.geotools.data.Transaction) DefaultTransaction(org.geotools.data.DefaultTransaction) SimpleFeatureType(org.opengis.feature.simple.SimpleFeatureType) Coordinate(org.locationtech.jts.geom.Coordinate) Calendar(java.util.Calendar) TemporalRange(org.locationtech.geowave.core.geotime.store.query.TemporalRange) FeatureDataAdapter(org.locationtech.geowave.adapter.vector.FeatureDataAdapter) TimeRangeStatistic(org.locationtech.geowave.core.geotime.store.statistics.TimeRangeStatistic) TimeRangeValue(org.locationtech.geowave.core.geotime.store.statistics.TimeRangeStatistic.TimeRangeValue) DefaultTransaction(org.geotools.data.DefaultTransaction) SimpleFeature(org.opengis.feature.simple.SimpleFeature) BaseDataStoreTest(org.locationtech.geowave.adapter.vector.BaseDataStoreTest) Test(org.junit.Test)

Example 3 with TimeRangeStatistic

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());
}
Also used : TemporalConstraintsSet(org.locationtech.geowave.core.geotime.store.query.TemporalConstraintsSet) TemporalRange(org.locationtech.geowave.core.geotime.store.query.TemporalRange) TemporalConstraints(org.locationtech.geowave.core.geotime.store.query.TemporalConstraints) TimeRangeStatistic(org.locationtech.geowave.core.geotime.store.statistics.TimeRangeStatistic) TimeRangeValue(org.locationtech.geowave.core.geotime.store.statistics.TimeRangeStatistic.TimeRangeValue) FeatureDataAdapter(org.locationtech.geowave.adapter.vector.FeatureDataAdapter) Date(java.util.Date) SimpleFeature(org.opengis.feature.simple.SimpleFeature) Test(org.junit.Test)

Example 4 with TimeRangeStatistic

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());
}
Also used : BoundingBoxStatistic(org.locationtech.geowave.core.geotime.store.statistics.BoundingBoxStatistic) MultiDimensionalNumericData(org.locationtech.geowave.core.index.numeric.MultiDimensionalNumericData) TemporalConstraintsSet(org.locationtech.geowave.core.geotime.store.query.TemporalConstraintsSet) BoundingBoxValue(org.locationtech.geowave.core.geotime.store.statistics.BoundingBoxStatistic.BoundingBoxValue) Date(java.util.Date) SimpleFeature(org.opengis.feature.simple.SimpleFeature) Constraints(org.locationtech.geowave.core.store.query.constraints.Constraints) TemporalConstraints(org.locationtech.geowave.core.geotime.store.query.TemporalConstraints) Coordinate(org.locationtech.jts.geom.Coordinate) TemporalRange(org.locationtech.geowave.core.geotime.store.query.TemporalRange) TimeRangeStatistic(org.locationtech.geowave.core.geotime.store.statistics.TimeRangeStatistic) TimeRangeValue(org.locationtech.geowave.core.geotime.store.statistics.TimeRangeStatistic.TimeRangeValue) FeatureDataAdapter(org.locationtech.geowave.adapter.vector.FeatureDataAdapter) Test(org.junit.Test)

Example 5 with TimeRangeStatistic

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());
}
Also used : MultiDimensionalNumericData(org.locationtech.geowave.core.index.numeric.MultiDimensionalNumericData) Coordinate(org.locationtech.jts.geom.Coordinate) TemporalConstraintsSet(org.locationtech.geowave.core.geotime.store.query.TemporalConstraintsSet) TemporalRange(org.locationtech.geowave.core.geotime.store.query.TemporalRange) TimeRangeStatistic(org.locationtech.geowave.core.geotime.store.statistics.TimeRangeStatistic) TimeRangeValue(org.locationtech.geowave.core.geotime.store.statistics.TimeRangeStatistic.TimeRangeValue) FeatureDataAdapter(org.locationtech.geowave.adapter.vector.FeatureDataAdapter) Date(java.util.Date) SimpleFeature(org.opengis.feature.simple.SimpleFeature) BasicQueryByClass(org.locationtech.geowave.core.store.query.constraints.BasicQueryByClass) Test(org.junit.Test)

Aggregations

TimeRangeStatistic (org.locationtech.geowave.core.geotime.store.statistics.TimeRangeStatistic)11 Date (java.util.Date)8 TimeRangeValue (org.locationtech.geowave.core.geotime.store.statistics.TimeRangeStatistic.TimeRangeValue)8 Test (org.junit.Test)7 SimpleFeature (org.opengis.feature.simple.SimpleFeature)7 TemporalRange (org.locationtech.geowave.core.geotime.store.query.TemporalRange)6 FeatureDataAdapter (org.locationtech.geowave.adapter.vector.FeatureDataAdapter)5 TemporalConstraintsSet (org.locationtech.geowave.core.geotime.store.query.TemporalConstraintsSet)4 NumericRangeStatistic (org.locationtech.geowave.core.store.statistics.field.NumericRangeStatistic)4 TemporalConstraints (org.locationtech.geowave.core.geotime.store.query.TemporalConstraints)3 BoundingBoxStatistic (org.locationtech.geowave.core.geotime.store.statistics.BoundingBoxStatistic)3 NumericRangeValue (org.locationtech.geowave.core.store.statistics.field.NumericRangeStatistic.NumericRangeValue)3 Coordinate (org.locationtech.jts.geom.Coordinate)3 Calendar (java.util.Calendar)2 BoundingBoxValue (org.locationtech.geowave.core.geotime.store.statistics.BoundingBoxStatistic.BoundingBoxValue)2 MultiDimensionalNumericData (org.locationtech.geowave.core.index.numeric.MultiDimensionalNumericData)2 DataStore (org.locationtech.geowave.core.store.api.DataStore)2 DataStatisticsStore (org.locationtech.geowave.core.store.statistics.DataStatisticsStore)2 CountStatistic (org.locationtech.geowave.core.store.statistics.adapter.CountStatistic)2 CountValue (org.locationtech.geowave.core.store.statistics.adapter.CountStatistic.CountValue)2