Skip to content

Commit cf00ff8

Browse files
authored
Initial implementation of GeoWave query language for vector data. (#1639)
* Initial implementation of GeoWave query language for vector data. * Fix broken coveralls reports. * Bump dev-resources version following findbugs filter change.
1 parent c9f2ae0 commit cf00ff8

File tree

70 files changed

+3450
-26
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+3450
-26
lines changed

.utility/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ set -ev
33

44
if [ "$TRAVIS_REPO_SLUG" == "locationtech/geowave" ] && [ "$BUILD_AND_PUBLISH" == "true" ] && [ "$TRAVIS_BRANCH" == "master" ]; then
55
echo -e "Building docs...\n"
6-
mvn -P html -pl docs install -DskipTests -Dspotbug.skip
6+
mvn -P html -pl docs install -DskipTests -Dspotbugs.skip
77

88
echo -e "Installing local artifacts...\n"
99
mvn -q install -DskipTests -Dspotbugs.skip

core/geotime/pom.xml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,29 @@
4949
<groupId>com.fasterxml.jackson.core</groupId>
5050
<artifactId>jackson-annotations</artifactId>
5151
</dependency>
52+
<dependency>
53+
<groupId>org.locationtech.geowave</groupId>
54+
<artifactId>geowave-core-store</artifactId>
55+
<classifier>tests</classifier>
56+
<type>test-jar</type>
57+
<version>${project.version}</version>
58+
<scope>test</scope>
59+
</dependency>
5260
</dependencies>
61+
<build>
62+
<plugins>
63+
<plugin>
64+
<groupId>org.apache.maven.plugins</groupId>
65+
<artifactId>maven-jar-plugin</artifactId>
66+
<version>3.2.0</version>
67+
<executions>
68+
<execution>
69+
<goals>
70+
<goal>test-jar</goal>
71+
</goals>
72+
</execution>
73+
</executions>
74+
</plugin>
75+
</plugins>
76+
</build>
5377
</project>

core/geotime/src/main/java/org/locationtech/geowave/core/geotime/store/query/aggregate/BoundingBoxAggregation.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,7 @@ public P getParameters() {
3838
public void setParameters(final P parameters) {}
3939

4040
public boolean isSet() {
41-
if ((minX == Double.MAX_VALUE)
42-
|| (minY == Double.MAX_VALUE)
43-
|| (maxX == -Double.MAX_VALUE)
44-
|| (maxY == -Double.MAX_VALUE)) {
41+
if (minX > maxX || minY > maxY) {
4542
return false;
4643
}
4744
return true;
@@ -71,7 +68,7 @@ public Envelope merge(final Envelope result1, final Envelope result2) {
7168

7269
@Override
7370
public byte[] resultToBinary(final Envelope result) {
74-
final ByteBuffer buffer = ByteBuffer.allocate(32);
71+
final ByteBuffer buffer = ByteBuffer.allocate(Double.BYTES * 4);
7572
buffer.putDouble(minX);
7673
buffer.putDouble(minY);
7774
buffer.putDouble(maxX);
@@ -86,6 +83,11 @@ public Envelope resultFromBinary(final byte[] binary) {
8683
final double minY = buffer.getDouble();
8784
final double maxX = buffer.getDouble();
8885
final double maxY = buffer.getDouble();
86+
if (minX > maxX || minY > maxY) {
87+
// The Envelope implementation will swap min and max if min is greater than max, use a null
88+
// Envelope in this case to avoid an invalid result.
89+
return new Envelope();
90+
}
8991
return new Envelope(minX, maxX, minY, maxY);
9092
}
9193

core/geotime/src/main/java/org/locationtech/geowave/core/geotime/store/query/aggregate/FieldNameParam.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public void fromBinary(final byte[] bytes) {
4242
}
4343
}
4444

45-
protected boolean isEmpty() {
45+
public boolean isEmpty() {
4646
return (fieldName == null) || fieldName.isEmpty();
4747
}
4848

core/geotime/src/main/java/org/locationtech/geowave/core/geotime/store/query/aggregate/VectorBoundingBoxAggregation.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,7 @@ protected Envelope getEnvelope(final SimpleFeature entry) {
4545
}
4646
if ((o != null) && (o instanceof Geometry)) {
4747
final Geometry geometry = (Geometry) o;
48-
if (!geometry.isEmpty()) {
49-
return geometry.getEnvelopeInternal();
50-
}
48+
return geometry.getEnvelopeInternal();
5149
}
5250
return null;
5351
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/**
2+
* Copyright (c) 2013-2019 Contributors to the Eclipse Foundation
3+
*
4+
* <p> See the NOTICE file distributed with this work for additional information regarding copyright
5+
* ownership. All rights reserved. This program and the accompanying materials are made available
6+
* under the terms of the Apache License, Version 2.0 which accompanies this distribution and is
7+
* available at http://www.apache.org/licenses/LICENSE-2.0.txt
8+
*/
9+
package org.locationtech.geowave.core.geotime.store.query.aggregate;
10+
11+
import java.util.Date;
12+
import java.util.List;
13+
import org.geotools.feature.AttributeTypeBuilder;
14+
import org.geotools.feature.simple.SimpleFeatureBuilder;
15+
import org.geotools.feature.simple.SimpleFeatureTypeBuilder;
16+
import org.locationtech.geowave.core.geotime.util.GeometryUtils;
17+
import org.locationtech.geowave.core.index.persist.Persistable;
18+
import org.locationtech.geowave.core.store.query.aggregate.AbstractAggregationTest;
19+
import org.locationtech.jts.geom.Coordinate;
20+
import org.locationtech.jts.geom.Geometry;
21+
import org.opengis.feature.simple.SimpleFeature;
22+
import com.google.common.collect.Lists;
23+
24+
public class AbstractVectorAggregationTest<P extends Persistable, R> extends
25+
AbstractAggregationTest<P, R, SimpleFeature> {
26+
27+
protected static final String GEOMETRY_COLUMN = "geometry";
28+
protected static final String TIMESTAMP_COLUMN = "TimeStamp";
29+
protected static final String LATITUDE_COLUMN = "Latitude";
30+
protected static final String LONGITUDE_COLUMN = "Longitude";
31+
protected static final String VALUE_COLUMN = "Value";
32+
protected static final String ODDS_NULL_COLUMN = "OddsNull";
33+
protected static final String ALL_NULL_COLUMN = "AllNull";
34+
35+
public List<SimpleFeature> generateFeatures() {
36+
final SimpleFeatureTypeBuilder typeBuilder = new SimpleFeatureTypeBuilder();
37+
final AttributeTypeBuilder ab = new AttributeTypeBuilder();
38+
39+
typeBuilder.setName("features");
40+
typeBuilder.add(ab.binding(Geometry.class).nillable(false).buildDescriptor(GEOMETRY_COLUMN));
41+
typeBuilder.add(ab.binding(Date.class).nillable(true).buildDescriptor(TIMESTAMP_COLUMN));
42+
typeBuilder.add(ab.binding(Double.class).nillable(false).buildDescriptor(LATITUDE_COLUMN));
43+
typeBuilder.add(ab.binding(Double.class).nillable(false).buildDescriptor(LONGITUDE_COLUMN));
44+
typeBuilder.add(ab.binding(Long.class).nillable(false).buildDescriptor(VALUE_COLUMN));
45+
typeBuilder.add(ab.binding(String.class).nillable(true).buildDescriptor(ODDS_NULL_COLUMN));
46+
typeBuilder.add(ab.binding(String.class).nillable(true).buildDescriptor(ALL_NULL_COLUMN));
47+
48+
List<SimpleFeature> features = Lists.newArrayList();
49+
final SimpleFeatureBuilder featureBuilder =
50+
new SimpleFeatureBuilder(typeBuilder.buildFeatureType());
51+
52+
int featureId = 0;
53+
for (int longitude = -180; longitude <= 180; longitude += 1) {
54+
for (int latitude = -90; latitude <= 90; latitude += 1) {
55+
featureBuilder.set(
56+
GEOMETRY_COLUMN,
57+
GeometryUtils.GEOMETRY_FACTORY.createPoint(new Coordinate(longitude, latitude)));
58+
featureBuilder.set(TIMESTAMP_COLUMN, new Date());
59+
featureBuilder.set(LATITUDE_COLUMN, latitude);
60+
featureBuilder.set(LONGITUDE_COLUMN, longitude);
61+
featureBuilder.set(VALUE_COLUMN, (long) featureId);
62+
if (featureId % 2 == 0) {
63+
featureBuilder.set(ODDS_NULL_COLUMN, "NotNull");
64+
}
65+
66+
features.add(featureBuilder.buildFeature(String.valueOf(featureId)));
67+
featureId++;
68+
}
69+
}
70+
return features;
71+
}
72+
73+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/**
2+
* Copyright (c) 2013-2019 Contributors to the Eclipse Foundation
3+
*
4+
* <p> See the NOTICE file distributed with this work for additional information regarding copyright
5+
* ownership. All rights reserved. This program and the accompanying materials are made available
6+
* under the terms of the Apache License, Version 2.0 which accompanies this distribution and is
7+
* available at http://www.apache.org/licenses/LICENSE-2.0.txt
8+
*/
9+
package org.locationtech.geowave.core.geotime.store.query.aggregate;
10+
11+
import static org.junit.Assert.assertEquals;
12+
import java.util.List;
13+
import org.junit.Test;
14+
import org.locationtech.geowave.core.geotime.store.query.aggregate.FieldNameParam;
15+
import org.locationtech.geowave.core.geotime.store.query.aggregate.VectorBoundingBoxAggregation;
16+
import org.locationtech.jts.geom.Envelope;
17+
import org.opengis.feature.simple.SimpleFeature;
18+
19+
public class VectorBoundingBoxAggregationTest extends
20+
AbstractVectorAggregationTest<FieldNameParam, Envelope> {
21+
22+
@Test
23+
public void testVectorCountAggregation() {
24+
List<SimpleFeature> features = generateFeatures();
25+
VectorBoundingBoxAggregation aggregation = new VectorBoundingBoxAggregation(null);
26+
Envelope expected = new Envelope(-180, 180, -90, 90);
27+
Envelope result = aggregateObjects(aggregation, features);
28+
assertEquals(expected, result);
29+
30+
aggregation = new VectorBoundingBoxAggregation(new FieldNameParam(GEOMETRY_COLUMN));
31+
result = aggregateObjects(aggregation, features);
32+
assertEquals(expected, result);
33+
}
34+
35+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/**
2+
* Copyright (c) 2013-2019 Contributors to the Eclipse Foundation
3+
*
4+
* <p> See the NOTICE file distributed with this work for additional information regarding copyright
5+
* ownership. All rights reserved. This program and the accompanying materials are made available
6+
* under the terms of the Apache License, Version 2.0 which accompanies this distribution and is
7+
* available at http://www.apache.org/licenses/LICENSE-2.0.txt
8+
*/
9+
package org.locationtech.geowave.core.index.persist;
10+
11+
import java.nio.ByteBuffer;
12+
import java.util.List;
13+
import com.google.common.collect.Lists;
14+
15+
/**
16+
* A Persistable list of Persistables.
17+
*/
18+
public class PersistableList implements Persistable {
19+
20+
private final List<Persistable> persistables;
21+
22+
public PersistableList() {
23+
persistables = Lists.newArrayList();
24+
}
25+
26+
public PersistableList(final List<Persistable> persistables) {
27+
this.persistables = persistables;
28+
}
29+
30+
@Override
31+
public byte[] toBinary() {
32+
final List<byte[]> parts = Lists.newArrayListWithCapacity(persistables.size());
33+
int length = 4;
34+
for (final Persistable persistable : persistables) {
35+
final byte[] binary = PersistenceUtils.toBinary(persistable);
36+
length += binary.length + 4;
37+
parts.add(binary);
38+
}
39+
final ByteBuffer buffer = ByteBuffer.allocate(length);
40+
buffer.putInt(persistables.size());
41+
for (final byte[] part : parts) {
42+
buffer.putInt(part.length);
43+
buffer.put(part);
44+
}
45+
return buffer.array();
46+
}
47+
48+
@Override
49+
public void fromBinary(final byte[] bytes) {
50+
final ByteBuffer buffer = ByteBuffer.wrap(bytes);
51+
final int length = buffer.getInt();
52+
persistables.clear();
53+
for (int i = 0; i < length; i++) {
54+
final int partLength = buffer.getInt();
55+
final byte[] part = new byte[partLength];
56+
buffer.get(part);
57+
persistables.add(PersistenceUtils.fromBinary(part));
58+
}
59+
}
60+
61+
public List<Persistable> getPersistables() {
62+
return persistables;
63+
}
64+
65+
}

core/store/pom.xml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
1+
<project xmlns="http://maven.apache.org/POM/4.0.0"
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
24
<modelVersion>4.0.0</modelVersion>
35
<parent>
46
<artifactId>geowave-core-parent</artifactId>
@@ -33,4 +35,20 @@
3335
<version>3.2</version>
3436
</dependency>
3537
</dependencies>
38+
<build>
39+
<plugins>
40+
<plugin>
41+
<groupId>org.apache.maven.plugins</groupId>
42+
<artifactId>maven-jar-plugin</artifactId>
43+
<version>3.2.0</version>
44+
<executions>
45+
<execution>
46+
<goals>
47+
<goal>test-jar</goal>
48+
</goals>
49+
</execution>
50+
</executions>
51+
</plugin>
52+
</plugins>
53+
</build>
3654
</project>

core/store/src/main/java/org/locationtech/geowave/core/store/StorePersistableRegistry.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
import org.locationtech.geowave.core.index.persist.PersistableRegistrySpi;
1212
import org.locationtech.geowave.core.store.adapter.BinaryDataAdapter;
13+
import org.locationtech.geowave.core.store.adapter.InternalDataAdapterWrapper;
1314
import org.locationtech.geowave.core.store.adapter.SimpleRowTransform;
1415
import org.locationtech.geowave.core.store.adapter.statistics.BaseStatisticsType;
1516
import org.locationtech.geowave.core.store.adapter.statistics.CountDataStatistics;
@@ -130,6 +131,7 @@ public PersistableIdAndConstructor[] getSupportedPersistables() {
130131
new PersistableIdAndConstructor((short) 258, OrderedConstraints::new),
131132
new PersistableIdAndConstructor((short) 259, BasicOrderedConstraintQuery::new),
132133
new PersistableIdAndConstructor((short) 260, BasicQuery::new),
133-
new PersistableIdAndConstructor((short) 261, BinaryDataAdapter::new)};
134+
new PersistableIdAndConstructor((short) 261, BinaryDataAdapter::new),
135+
new PersistableIdAndConstructor((short) 262, InternalDataAdapterWrapper::new)};
134136
}
135137
}

0 commit comments

Comments
 (0)