Skip to content

Commit d05ca9f

Browse files
committed
Improve python bindings to behave like the programmatic API.
Fix temporal query on spatial index not being inclusive on start time. Add boolean array field support. Add and improve documentation for python modules. Update travis build matrix to run python tests. Signed-off-by: Johnathan Garrett <jd@prominentedge.com>
1 parent d7dcfd2 commit d05ca9f

File tree

110 files changed

+6595
-1554
lines changed

Some content is hidden

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

110 files changed

+6595
-1554
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ env:
1010
# The rest skip the unit tests and run ITs only
1111
- NAME='Publish Maven Artifacts and Docs' MAVEN_PROFILES='""' BUILD_AND_PUBLISH=true IT_ONLY=false
1212
- NAME='Unit Tests on Latest ASF Versions' MAVEN_PROFILES='""' BUILD_AND_PUBLISH=false IT_ONLY=false
13+
- NAME='Python Bindings Tests' MAVEN_PROFILES='""' BUILD_AND_PUBLISH=false IT_ONLY=false PYTHON_BUILD=true
1314
- NAME='Redis IT on Latest ASF Versions' MAVEN_PROFILES='redis-it' BUILD_AND_PUBLISH=false IT_ONLY=true
1415
- NAME='RocksDB IT on Latest ASF Versions' MAVEN_PROFILES='rocksdb-it' BUILD_AND_PUBLISH=false IT_ONLY=true
1516
- NAME='Accumulo Client IT on Latest ASF Versions' MAVEN_PROFILES='accumulo-it-client' BUILD_AND_PUBLISH=false IT_ONLY=true

.utility/run-python-tests.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
3+
# Build and Run Java Gateway
4+
mvn -q package -P geowave-tools-singlejar -Dfindbugs.skip=true -DskipTests=true >/dev/null
5+
GEOWAVE_VERSION=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec)
6+
nohup java -cp deploy/target/geowave-deploy-${GEOWAVE_VERSION}-tools.jar org.locationtech.geowave.core.cli.GeoWaveMain python rungateway &
7+
8+
# Install pip and venv
9+
sudo apt-get install -yq python3-pip python3-venv
10+
11+
# Run Python tests
12+
cd python/src/main/python
13+
python3 -m venv tests-venv
14+
15+
source ./tests-venv/bin/activate
16+
17+
pip install -r requirements.txt
18+
19+
pytest
20+
EXIT_CODE=$?
21+
22+
deactivate
23+
rm -rf tests-venv
24+
25+
exit $EXIT_CODE

.utility/run-tests.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#!/bin/bash
22
set -ev
3-
if [ "$BUILD_AND_PUBLISH" == "false" ]; then
3+
if [ "$PYTHON_BUILD" == "true" ]; then
4+
echo -e "Running Python tests...\n"
5+
source .utility/run-python-tests.sh
6+
elif [ "$BUILD_AND_PUBLISH" == "false" ]; then
47
if [ "$IT_ONLY" == "true" ]; then
58
echo -e "Skipping unit tests w/ verify...\n"
69
mvn -q verify -am -pl test -Dtest=SkipUnitTests -DfailIfNoTests=false -P $MAVEN_PROFILES

core/geotime/src/main/java/org/locationtech/geowave/core/geotime/store/query/api/SpatialTemporalConstraintsBuilder.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ SpatialTemporalConstraintsBuilder spatialConstraintsCompareOperation(
6060
/**
6161
* add a time range
6262
*
63-
* @param startTime the start of the range
64-
* @param endTime the end of the range
63+
* @param startTime the start of the range (inclusive)
64+
* @param endTime the end of the range (exclusive)
6565
* @return this builder
6666
*/
6767
SpatialTemporalConstraintsBuilder addTimeRange(Date startTime, Date endTime);

core/geotime/src/main/java/org/locationtech/geowave/core/geotime/util/TimeUtils.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,18 @@ public static long calendarToGMTMillis(final Calendar cal) {
5858
return time;
5959
}
6060

61+
/**
62+
* @param startTimeMillis start time (inclusive)
63+
* @param endTimeMillis end time (exclusive)
64+
* @param singleTimeField
65+
* @return
66+
*/
6167
public static Filter toDuringFilter(
6268
final long startTimeMillis,
6369
final long endTimeMillis,
6470
final String singleTimeField) {
6571
final FilterFactory2 factory = CommonFactoryFinder.getFilterFactory2();
66-
final Position ip1 = new DefaultPosition(new Date(startTimeMillis));
72+
final Position ip1 = new DefaultPosition(new Date(startTimeMillis - 1));
6773
final Position ip2 = new DefaultPosition(new Date(endTimeMillis));
6874
final Period period = new DefaultPeriod(new DefaultInstant(ip1), new DefaultInstant(ip2));
6975
return factory.during(factory.property(singleTimeField), factory.literal(period));

core/store/src/main/java/org/locationtech/geowave/core/store/api/DataStore.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,9 @@ public interface DataStore {
181181
void removeIndex(String typeName, String indexName) throws IllegalStateException;
182182

183183
/**
184-
* remove statistics for type
184+
* Remove all data and statistics associated with the given type.
185185
*
186-
* @param typeName
186+
* @param typeName the type
187187
*/
188188
void removeType(String typeName);
189189

core/store/src/main/java/org/locationtech/geowave/core/store/base/BaseDataStore.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ public void close() throws IOException {
401401
final List<Pair<Index, List<InternalDataAdapter<?>>>> indexAdapterPairList =
402402
(deleteAllIndicesByConstraints)
403403
? queryOptions.getIndicesForAdapters(tempAdapterStore, indexMappingStore, indexStore)
404-
: queryOptions.getBestQueryIndicies(
404+
: queryOptions.getBestQueryIndices(
405405
tempAdapterStore,
406406
indexMappingStore,
407407
indexStore,
@@ -422,12 +422,12 @@ public void close() throws IOException {
422422
}
423423
}
424424
for (final InternalDataAdapter<?> adapter : allPair.getRight()) {
425-
List<Index> indicies = additionalIndicesToDelete.get(adapter.getAdapterId());
426-
if (indicies == null) {
427-
indicies = new ArrayList<>();
428-
additionalIndicesToDelete.put(adapter.getAdapterId(), indicies);
425+
List<Index> indices = additionalIndicesToDelete.get(adapter.getAdapterId());
426+
if (indices == null) {
427+
indices = new ArrayList<>();
428+
additionalIndicesToDelete.put(adapter.getAdapterId(), indices);
429429
}
430-
indicies.add(allPair.getLeft());
430+
indices.add(allPair.getLeft());
431431
}
432432
}
433433
}
@@ -1410,7 +1410,7 @@ public void copyTo(final DataStore other, final Query<?> query) {
14101410

14111411
final String[] typeNames = query.getDataTypeQueryOptions().getTypeNames();
14121412
final String indexName = query.getIndexQueryOptions().getIndexName();
1413-
final boolean isAllIndices = query.getIndexQueryOptions().isAllIndicies();
1413+
final boolean isAllIndices = query.getIndexQueryOptions().isAllIndices();
14141414
final List<DataTypeAdapter<?>> typesToCopy;
14151415

14161416
// if typeNames are not specified, then it means 'everything' as well

core/store/src/main/java/org/locationtech/geowave/core/store/base/BaseDataStoreUtils.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -665,12 +665,12 @@ public static <T> List<Pair<Index, List<T>>> chooseBestIndex(
665665
final Map<T, List<Index>> indicesPerAdapter = new HashMap<>();
666666
for (final Pair<Index, List<T>> pair : indexAdapterPairList) {
667667
for (final T adapter : pair.getRight()) {
668-
List<Index> indicies = indicesPerAdapter.get(adapter);
669-
if (indicies == null) {
670-
indicies = new ArrayList<>();
671-
indicesPerAdapter.put(adapter, indicies);
668+
List<Index> indices = indicesPerAdapter.get(adapter);
669+
if (indices == null) {
670+
indices = new ArrayList<>();
671+
indicesPerAdapter.put(adapter, indices);
672672
}
673-
indicies.add(pair.getLeft());
673+
indices.add(pair.getLeft());
674674
}
675675
}
676676
final Map<Index, List<T>> retVal = new HashMap<>();

core/store/src/main/java/org/locationtech/geowave/core/store/base/BaseQueryOptions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ public void setAggregation(
427427
* most dimensions of the given constraint.
428428
*
429429
*/
430-
public List<Pair<Index, List<InternalDataAdapter<?>>>> getBestQueryIndicies(
430+
public List<Pair<Index, List<InternalDataAdapter<?>>>> getBestQueryIndices(
431431
final PersistentAdapterStore adapterStore,
432432
final AdapterIndexMappingStore adapterIndexMappingStore,
433433
final IndexStore indexStore,
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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.store.data.field.base;
10+
11+
import org.locationtech.geowave.core.store.data.field.ArrayReader;
12+
import org.locationtech.geowave.core.store.data.field.ArrayWriter.FixedSizeObjectArrayWriter;
13+
import org.locationtech.geowave.core.store.data.field.FieldReader;
14+
import org.locationtech.geowave.core.store.data.field.FieldSerializationProviderSpi;
15+
import org.locationtech.geowave.core.store.data.field.FieldWriter;
16+
import org.locationtech.geowave.core.store.data.field.base.BooleanSerializationProvider.BooleanReader;
17+
import org.locationtech.geowave.core.store.data.field.base.BooleanSerializationProvider.BooleanWriter;
18+
19+
public class BooleanArraySerializationProvider implements FieldSerializationProviderSpi<Boolean[]> {
20+
@Override
21+
public FieldReader<Boolean[]> getFieldReader() {
22+
return new BooleanArrayReader();
23+
}
24+
25+
@Override
26+
public FieldWriter<Object, Boolean[]> getFieldWriter() {
27+
return new BooleanArrayWriter();
28+
}
29+
30+
private static class BooleanArrayReader extends ArrayReader<Boolean> {
31+
public BooleanArrayReader() {
32+
super(new BooleanReader());
33+
}
34+
}
35+
36+
private static class BooleanArrayWriter extends FixedSizeObjectArrayWriter<Object, Boolean> {
37+
public BooleanArrayWriter() {
38+
super(new BooleanWriter());
39+
}
40+
}
41+
}

0 commit comments

Comments
 (0)