use of org.locationtech.geowave.adapter.vector.plugin.GeoWavePluginConfig in project geowave by locationtech.
the class BaseDataStoreTest method createDataStore.
protected DataStore createDataStore() throws IOException, GeoWavePluginException {
final Map<String, Serializable> params = new HashMap<>();
params.put("gwNamespace", "test_" + getClass().getName() + "_" + name.getMethodName());
final StoreFactoryFamilySpi storeFactoryFamily = new MemoryStoreFactoryFamily();
// delete existing data
new GeoWavePluginConfig(storeFactoryFamily, params).getDataStore().delete(QueryBuilder.newBuilder().build());
return new GeoWaveGTDataStoreFactory(storeFactoryFamily).createNewDataStore(params);
}
use of org.locationtech.geowave.adapter.vector.plugin.GeoWavePluginConfig in project geowave by locationtech.
the class GeoWaveGrpcVectorService method vectorQuery.
@Override
public void vectorQuery(final VectorQueryParametersProtos request, final StreamObserver<FeatureProtos> responseObserver) {
final String storeName = request.getStoreName();
final StoreLoader storeLoader = new StoreLoader(storeName);
// first check to make sure the data store exists
if (!storeLoader.loadFromConfig(GeoWaveGrpcServiceOptions.geowaveConfigFile)) {
throw new ParameterException("Cannot find store name: " + storeLoader.getStoreName());
}
GeoWaveGTDataStore gtStore = null;
try {
gtStore = new GeoWaveGTDataStore(new GeoWavePluginConfig(storeLoader.getDataStorePlugin()));
} catch (final IOException | GeoWavePluginException e) {
LOGGER.error("Exception encountered instantiating GeoWaveGTDataStore", e);
responseObserver.onError(e);
}
Filter filter = null;
try {
filter = ECQL.toFilter(request.getQuery());
} catch (final CQLException e) {
LOGGER.error("Exception encountered creating filter from CQL", e);
responseObserver.onError(e);
}
ContentFeatureCollection featureCollection = null;
try {
final String typeName = request.getTypeName();
featureCollection = gtStore.getFeatureSource(typeName).getFeatures(filter);
} catch (final IOException | NullPointerException e) {
LOGGER.error("Exception encountered getting feature collection", e);
responseObserver.onError(e);
}
try (final SimpleFeatureIterator iterator = featureCollection.features()) {
while (iterator.hasNext()) {
final SimpleFeature simpleFeature = iterator.next();
final SimpleFeatureType type = simpleFeature.getType();
final FeatureProtos.Builder b = FeatureProtos.newBuilder();
final FeatureAttributeProtos.Builder attBuilder = FeatureAttributeProtos.newBuilder();
for (int i = 0; i < type.getAttributeDescriptors().size(); i++) {
setAttributeBuilderValue(simpleFeature.getAttribute(i), attBuilder);
b.putAttributes(type.getAttributeDescriptors().get(i).getLocalName(), attBuilder.build());
/*
* b.putAttributes( type.getAttributeDescriptors().get( i).getLocalName(),
* simpleFeature.getAttribute(i) == null ? "" : simpleFeature.getAttribute(
* i).toString());
*/
}
final FeatureProtos f = b.build();
responseObserver.onNext(f);
}
responseObserver.onCompleted();
} catch (final NullPointerException e) {
LOGGER.error("Exception encountered", e);
responseObserver.onError(e);
}
}
use of org.locationtech.geowave.adapter.vector.plugin.GeoWavePluginConfig in project geowave by locationtech.
the class SpatialTemporalQueryIT method initSpatialTemporalTestData.
@Before
public void initSpatialTemporalTestData() throws IOException, GeoWavePluginException {
dataStore = dataStoreOptions.createDataStore();
SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder();
builder.setName("simpletimestamp");
builder.add("geo", Point.class);
builder.add("timestamp", Date.class);
timeStampAdapter = new FeatureDataAdapter(builder.buildFeatureType());
builder = new SimpleFeatureTypeBuilder();
builder.setName("simpletimerange");
builder.add("geo", Point.class);
builder.add("startTime", Date.class);
builder.add("endTime", Date.class);
timeRangeAdapter = new FeatureDataAdapter(builder.buildFeatureType());
Calendar cal = getInitialDayCalendar();
final GeometryFactory geomFactory = new GeometryFactory();
final SimpleFeatureBuilder featureBuilder = new SimpleFeatureBuilder(timeStampAdapter.getFeatureType());
final SimpleFeatureBuilder featureTimeRangeBuilder = new SimpleFeatureBuilder(timeRangeAdapter.getFeatureType());
dataStore.addType(timeStampAdapter, YEAR_INDEX, MONTH_INDEX, DAY_INDEX);
final Writer timeWriters = dataStore.createWriter(timeStampAdapter.getTypeName());
// time ranges for days isn't tested so we don't have to deal with
// ingesting into the day index, the multi-year test case (requiring
// 1000+ partitions)
dataStore.addType(timeRangeAdapter, YEAR_INDEX, MONTH_INDEX);
final Writer rangeWriters = dataStore.createWriter(timeRangeAdapter.getTypeName());
try {
for (int day = cal.getActualMinimum(Calendar.DAY_OF_MONTH); day <= cal.getActualMaximum(Calendar.DAY_OF_MONTH); day++) {
final double ptVal = ((((day + 1.0) - cal.getActualMinimum(Calendar.DAY_OF_MONTH)) / ((cal.getActualMaximum(Calendar.DAY_OF_MONTH) - cal.getActualMinimum(Calendar.DAY_OF_MONTH)) + 2.0)) * 2) - 1;
cal.set(Calendar.DAY_OF_MONTH, day);
final Point pt = geomFactory.createPoint(new Coordinate(ptVal, ptVal));
featureBuilder.add(pt);
featureBuilder.add(cal.getTime());
final SimpleFeature feature = featureBuilder.buildFeature("day:" + day);
timeWriters.write(feature);
}
cal = getInitialMonthCalendar();
for (int month = cal.getActualMinimum(Calendar.MONTH); month <= cal.getActualMaximum(Calendar.MONTH); month++) {
cal.set(Calendar.MONTH, month);
final double ptVal = ((((month + 1.0) - cal.getActualMinimum(Calendar.MONTH)) / ((cal.getActualMaximum(Calendar.MONTH) - cal.getActualMinimum(Calendar.MONTH)) + 2.0)) * 2) - 1;
final Point pt = geomFactory.createPoint(new Coordinate(ptVal, ptVal));
featureBuilder.add(pt);
featureBuilder.add(cal.getTime());
final SimpleFeature feature = featureBuilder.buildFeature("month:" + month);
timeWriters.write(feature);
}
ingestTimeRangeData(cal, rangeWriters, featureTimeRangeBuilder, cal.getActualMinimum(Calendar.MONTH), cal.getActualMaximum(Calendar.MONTH), Calendar.MONTH, "month");
cal = getInitialYearCalendar();
for (int year = MULTI_YEAR_MIN; year <= MULTI_YEAR_MAX; year++) {
final double ptVal = ((((year + 1.0) - MULTI_YEAR_MIN) / ((MULTI_YEAR_MAX - MULTI_YEAR_MIN) + 2.0)) * 2) - 1;
cal.set(Calendar.YEAR, year);
final Point pt = geomFactory.createPoint(new Coordinate(ptVal, ptVal));
featureBuilder.add(pt);
featureBuilder.add(cal.getTime());
final SimpleFeature feature = featureBuilder.buildFeature("year:" + year);
timeWriters.write(feature);
}
ingestTimeRangeData(cal, rangeWriters, featureTimeRangeBuilder, MULTI_YEAR_MIN, MULTI_YEAR_MAX, Calendar.YEAR, "year");
Point pt = geomFactory.createPoint(new Coordinate(-50, -50));
featureBuilder.add(pt);
featureBuilder.add(cal.getTime());
SimpleFeature feature = featureBuilder.buildFeature("outlier1timestamp");
timeWriters.write(feature);
pt = geomFactory.createPoint(new Coordinate(50, 50));
featureBuilder.add(pt);
featureBuilder.add(cal.getTime());
feature = featureBuilder.buildFeature("outlier2timestamp");
timeWriters.write(feature);
pt = geomFactory.createPoint(new Coordinate(-50, -50));
featureTimeRangeBuilder.add(pt);
featureTimeRangeBuilder.add(cal.getTime());
cal.roll(Calendar.MINUTE, 5);
featureTimeRangeBuilder.add(cal.getTime());
feature = featureTimeRangeBuilder.buildFeature("outlier1timerange");
rangeWriters.write(feature);
pt = geomFactory.createPoint(new Coordinate(50, 50));
featureTimeRangeBuilder.add(pt);
featureTimeRangeBuilder.add(cal.getTime());
cal.roll(Calendar.MINUTE, 5);
featureTimeRangeBuilder.add(cal.getTime());
feature = featureTimeRangeBuilder.buildFeature("outlier2timerange");
rangeWriters.write(feature);
// Ingest data for duplicate deletion, should not overlap time
// ranges from other tests
ingestTimeRangeDataForDuplicateDeletion(cal, rangeWriters, featureTimeRangeBuilder, DUPLICATE_DELETION_YEAR_MIN, DUPLICATE_DELETION_YEAR_MAX, Calendar.YEAR, "ranged_year");
} finally {
timeWriters.close();
rangeWriters.close();
}
geowaveGtDataStore = new GeoWaveGTDataStore(new GeoWavePluginConfig(dataStoreOptions) {
@Override
public IndexQueryStrategySPI getIndexQueryStrategy() {
return new IndexQueryStrategySPI() {
@Override
public boolean requiresStats() {
return false;
}
@Override
public CloseableIterator<Index> getIndices(final DataStatisticsStore statisticsStore, final AdapterIndexMappingStore mappingStore, final QueryConstraints query, final Index[] indices, final InternalDataAdapter<?> adapter, final Map<QueryHint, Object> hints) {
return new CloseableIteratorWrapper<>(new Closeable() {
@Override
public void close() throws IOException {
}
}, Collections.singleton(currentGeotoolsIndex).iterator());
}
};
}
});
}
Aggregations