use of org.locationtech.geowave.core.store.query.constraints.FilteredEverythingQuery in project geowave by locationtech.
the class ExpressionQueryIT method testSpatialExpressionQueries.
@Test
public void testSpatialExpressionQueries() {
final DataStore ds = dataStore.createDataStore();
final DataTypeAdapter<SimpleFeature> adapter = createDataAdapter();
final Index spatialIndex = SpatialDimensionalityTypeProvider.createIndexFromOptions(new SpatialOptions());
ds.addType(adapter, spatialIndex);
final Index altIndex = AttributeDimensionalityTypeProvider.createIndexFromOptions(ds, new AttributeIndexOptions(TYPE_NAME, ALTERNATE_GEOMETRY_FIELD));
final Index polyIndex = AttributeDimensionalityTypeProvider.createIndexFromOptions(ds, new AttributeIndexOptions(TYPE_NAME, POLYGON_FIELD));
ds.addIndex(TYPE_NAME, altIndex, polyIndex);
final PersistentAdapterStore adapterStore = dataStore.createAdapterStore();
final InternalAdapterStore internalAdapterStore = dataStore.createInternalAdapterStore();
final AdapterIndexMappingStore aimStore = dataStore.createAdapterIndexMappingStore();
final IndexStore indexStore = dataStore.createIndexStore();
final DataStatisticsStore statsStore = dataStore.createDataStatisticsStore();
final InternalDataAdapter<?> internalAdapter = adapterStore.getAdapter(internalAdapterStore.getAdapterId(TYPE_NAME));
final Polygon boxPoly = GeometryUtils.GEOMETRY_FACTORY.createPolygon(new Coordinate[] { new Coordinate(-20.5, -20.5), new Coordinate(-20.5, 20.5), new Coordinate(20.5, 20.5), new Coordinate(20.5, -20.5), new Coordinate(-20.5, -20.5) });
final Polygon boxPoly2 = GeometryUtils.GEOMETRY_FACTORY.createPolygon(new Coordinate[] { new Coordinate(-20, -20), new Coordinate(-20, 20), new Coordinate(20, 20), new Coordinate(20, -20), new Coordinate(-20, -20) });
// Large diagonal line
final LineString line = GeometryUtils.GEOMETRY_FACTORY.createLineString(new Coordinate[] { new Coordinate(-20.5, -20.5), new Coordinate(20.5, 20.5) });
// Ingest data
ingestData(ds);
// ///////////////////////////////////////////////////
// Basic BBOX
// ///////////////////////////////////////////////////
Query<SimpleFeature> query = QueryBuilder.newBuilder(SimpleFeature.class).filter(GEOM.bbox(0.5, 0.5, 64.5, 64.5)).build();
QueryConstraints queryConstraints = assertBestIndex(internalAdapter, spatialIndex, query, adapterStore, internalAdapterStore, aimStore, indexStore, statsStore);
assertTrue(queryConstraints instanceof ExplicitFilteredQuery);
ExplicitFilteredQuery constraints = (ExplicitFilteredQuery) queryConstraints;
List<QueryFilter> filters = constraints.createFilters(spatialIndex);
assertEquals(1, filters.size());
assertTrue(filters.get(0) instanceof ExpressionQueryFilter);
Filter filter = ((ExpressionQueryFilter<?>) filters.get(0)).getFilter();
assertTrue(filter instanceof BBox);
// Query data
try (CloseableIterator<SimpleFeature> iterator = ds.query(query)) {
assertTrue(iterator.hasNext());
assertEquals(TOTAL_FEATURES / 2 - 1, Iterators.size(iterator));
}
// ///////////////////////////////////////////////////
// Loose BBOX
// ///////////////////////////////////////////////////
query = QueryBuilder.newBuilder(SimpleFeature.class).filter(GEOM.bboxLoose(0.5, 0.5, 64.5, 64.5)).build();
queryConstraints = assertBestIndex(internalAdapter, spatialIndex, query, adapterStore, internalAdapterStore, aimStore, indexStore, statsStore);
assertTrue(queryConstraints instanceof ExplicitFilteredQuery);
constraints = (ExplicitFilteredQuery) queryConstraints;
filters = constraints.createFilters(spatialIndex);
assertEquals(0, filters.size());
// Query data
try (CloseableIterator<SimpleFeature> iterator = ds.query(query)) {
assertTrue(iterator.hasNext());
assertEquals(TOTAL_FEATURES / 2 - 1, Iterators.size(iterator));
}
// ///////////////////////////////////////////////////
// Intersects
// ///////////////////////////////////////////////////
query = QueryBuilder.newBuilder(SimpleFeature.class).filter(ALT.intersects(boxPoly)).build();
queryConstraints = assertBestIndex(internalAdapter, altIndex, query, adapterStore, internalAdapterStore, aimStore, indexStore, statsStore);
assertTrue(queryConstraints instanceof ExplicitFilteredQuery);
constraints = (ExplicitFilteredQuery) queryConstraints;
filters = constraints.createFilters(altIndex);
assertEquals(1, filters.size());
assertTrue(filters.get(0) instanceof ExpressionQueryFilter);
filter = ((ExpressionQueryFilter<?>) filters.get(0)).getFilter();
assertTrue(filter instanceof Intersects);
// Query data
try (CloseableIterator<SimpleFeature> iterator = ds.query(query)) {
assertTrue(iterator.hasNext());
assertEquals(20, Iterators.size(iterator));
}
// ///////////////////////////////////////////////////
// Loose Intersects
// ///////////////////////////////////////////////////
query = QueryBuilder.newBuilder(SimpleFeature.class).filter(ALT.intersectsLoose(boxPoly)).build();
queryConstraints = assertBestIndex(internalAdapter, altIndex, query, adapterStore, internalAdapterStore, aimStore, indexStore, statsStore);
assertTrue(queryConstraints instanceof ExplicitFilteredQuery);
constraints = (ExplicitFilteredQuery) queryConstraints;
filters = constraints.createFilters(altIndex);
assertEquals(0, filters.size());
// Query data
try (CloseableIterator<SimpleFeature> iterator = ds.query(query)) {
assertTrue(iterator.hasNext());
assertEquals(20, Iterators.size(iterator));
}
// ///////////////////////////////////////////////////
// Disjoint
// ///////////////////////////////////////////////////
query = QueryBuilder.newBuilder(SimpleFeature.class).filter(GEOM.disjoint(boxPoly)).build();
queryConstraints = assertBestIndex(internalAdapter, spatialIndex, query, adapterStore, internalAdapterStore, aimStore, indexStore, statsStore);
assertTrue(queryConstraints instanceof FilteredEverythingQuery);
FilteredEverythingQuery everything = (FilteredEverythingQuery) queryConstraints;
filters = everything.createFilters(spatialIndex);
assertEquals(1, filters.size());
assertTrue(filters.get(0) instanceof ExpressionQueryFilter);
filter = ((ExpressionQueryFilter<?>) filters.get(0)).getFilter();
assertTrue(filter instanceof Disjoint);
// Query data
try (CloseableIterator<SimpleFeature> iterator = ds.query(query)) {
assertTrue(iterator.hasNext());
assertEquals(TOTAL_FEATURES - 41, Iterators.size(iterator));
}
// ///////////////////////////////////////////////////
// Loose Disjoint
// ///////////////////////////////////////////////////
query = QueryBuilder.newBuilder(SimpleFeature.class).filter(GEOM.disjointLoose(boxPoly)).build();
queryConstraints = assertBestIndex(internalAdapter, spatialIndex, query, adapterStore, internalAdapterStore, aimStore, indexStore, statsStore);
assertTrue(queryConstraints instanceof FilteredEverythingQuery);
everything = (FilteredEverythingQuery) queryConstraints;
filters = everything.createFilters(spatialIndex);
assertEquals(1, filters.size());
assertTrue(filters.get(0) instanceof ExpressionQueryFilter);
filter = ((ExpressionQueryFilter<?>) filters.get(0)).getFilter();
assertTrue(filter instanceof Disjoint);
// Query data
try (CloseableIterator<SimpleFeature> iterator = ds.query(query)) {
assertTrue(iterator.hasNext());
assertEquals(TOTAL_FEATURES - 41, Iterators.size(iterator));
}
// ///////////////////////////////////////////////////
// Crosses
// ///////////////////////////////////////////////////
query = QueryBuilder.newBuilder(SimpleFeature.class).filter(POLY.crosses(line)).build();
queryConstraints = assertBestIndex(internalAdapter, polyIndex, query, adapterStore, internalAdapterStore, aimStore, indexStore, statsStore);
assertTrue(queryConstraints instanceof ExplicitFilteredQuery);
constraints = (ExplicitFilteredQuery) queryConstraints;
filters = constraints.createFilters(polyIndex);
assertEquals(1, filters.size());
assertTrue(filters.get(0) instanceof ExpressionQueryFilter);
filter = ((ExpressionQueryFilter<?>) filters.get(0)).getFilter();
assertTrue(filter instanceof Crosses);
// Query data
try (CloseableIterator<SimpleFeature> iterator = ds.query(query)) {
assertTrue(iterator.hasNext());
assertEquals(43, Iterators.size(iterator));
}
// ///////////////////////////////////////////////////
// Overlaps
// ///////////////////////////////////////////////////
query = QueryBuilder.newBuilder(SimpleFeature.class).filter(POLY.overlaps(boxPoly)).build();
queryConstraints = assertBestIndex(internalAdapter, polyIndex, query, adapterStore, internalAdapterStore, aimStore, indexStore, statsStore);
assertTrue(queryConstraints instanceof ExplicitFilteredQuery);
constraints = (ExplicitFilteredQuery) queryConstraints;
filters = constraints.createFilters(polyIndex);
assertEquals(1, filters.size());
assertTrue(filters.get(0) instanceof ExpressionQueryFilter);
filter = ((ExpressionQueryFilter<?>) filters.get(0)).getFilter();
assertTrue(filter instanceof Overlaps);
// Query data
try (CloseableIterator<SimpleFeature> iterator = ds.query(query)) {
assertTrue(iterator.hasNext());
// it overlaps 2 polygons in each corner
assertEquals(4, Iterators.size(iterator));
}
// ///////////////////////////////////////////////////
// Contains
// ///////////////////////////////////////////////////
query = QueryBuilder.newBuilder(SimpleFeature.class).filter(GEOM.contains(boxPoly)).build();
queryConstraints = assertBestIndex(internalAdapter, spatialIndex, query, adapterStore, internalAdapterStore, aimStore, indexStore, statsStore);
assertTrue(queryConstraints instanceof ExplicitFilteredQuery);
constraints = (ExplicitFilteredQuery) queryConstraints;
filters = constraints.createFilters(spatialIndex);
assertEquals(1, filters.size());
assertTrue(filters.get(0) instanceof ExpressionQueryFilter);
filter = ((ExpressionQueryFilter<?>) filters.get(0)).getFilter();
assertTrue(filter instanceof SpatialContains);
// Query data
try (CloseableIterator<SimpleFeature> iterator = ds.query(query)) {
assertFalse(iterator.hasNext());
}
query = QueryBuilder.newBuilder(SimpleFeature.class).filter(SpatialLiteral.of(boxPoly).contains(GEOM)).build();
queryConstraints = assertBestIndex(internalAdapter, spatialIndex, query, adapterStore, internalAdapterStore, aimStore, indexStore, statsStore);
assertTrue(queryConstraints instanceof ExplicitFilteredQuery);
constraints = (ExplicitFilteredQuery) queryConstraints;
filters = constraints.createFilters(spatialIndex);
assertEquals(1, filters.size());
assertTrue(filters.get(0) instanceof ExpressionQueryFilter);
filter = ((ExpressionQueryFilter<?>) filters.get(0)).getFilter();
assertTrue(filter instanceof SpatialContains);
// Query data
try (CloseableIterator<SimpleFeature> iterator = ds.query(query)) {
assertTrue(iterator.hasNext());
assertEquals(41, Iterators.size(iterator));
}
// ///////////////////////////////////////////////////
// Touches
// ///////////////////////////////////////////////////
query = QueryBuilder.newBuilder(SimpleFeature.class).filter(POLY.touches(boxPoly2)).build();
queryConstraints = assertBestIndex(internalAdapter, polyIndex, query, adapterStore, internalAdapterStore, aimStore, indexStore, statsStore);
assertTrue(queryConstraints instanceof ExplicitFilteredQuery);
constraints = (ExplicitFilteredQuery) queryConstraints;
filters = constraints.createFilters(polyIndex);
assertEquals(1, filters.size());
assertTrue(filters.get(0) instanceof ExpressionQueryFilter);
filter = ((ExpressionQueryFilter<?>) filters.get(0)).getFilter();
assertTrue(filter instanceof Touches);
// Query data
try (CloseableIterator<SimpleFeature> iterator = ds.query(query)) {
assertTrue(iterator.hasNext());
assertEquals(2, Iterators.size(iterator));
}
// ///////////////////////////////////////////////////
// Within
// ///////////////////////////////////////////////////
query = QueryBuilder.newBuilder(SimpleFeature.class).filter(GEOM.within(boxPoly)).build();
queryConstraints = assertBestIndex(internalAdapter, spatialIndex, query, adapterStore, internalAdapterStore, aimStore, indexStore, statsStore);
assertTrue(queryConstraints instanceof ExplicitFilteredQuery);
constraints = (ExplicitFilteredQuery) queryConstraints;
filters = constraints.createFilters(spatialIndex);
assertEquals(1, filters.size());
assertTrue(filters.get(0) instanceof ExpressionQueryFilter);
filter = ((ExpressionQueryFilter<?>) filters.get(0)).getFilter();
assertTrue(filter instanceof Within);
// Query data
try (CloseableIterator<SimpleFeature> iterator = ds.query(query)) {
assertTrue(iterator.hasNext());
assertEquals(41, Iterators.size(iterator));
}
query = QueryBuilder.newBuilder(SimpleFeature.class).filter(SpatialLiteral.of(boxPoly).within(GEOM)).build();
queryConstraints = assertBestIndex(internalAdapter, spatialIndex, query, adapterStore, internalAdapterStore, aimStore, indexStore, statsStore);
assertTrue(queryConstraints instanceof ExplicitFilteredQuery);
constraints = (ExplicitFilteredQuery) queryConstraints;
filters = constraints.createFilters(spatialIndex);
assertEquals(1, filters.size());
assertTrue(filters.get(0) instanceof ExpressionQueryFilter);
filter = ((ExpressionQueryFilter<?>) filters.get(0)).getFilter();
assertTrue(filter instanceof Within);
// Query data
try (CloseableIterator<SimpleFeature> iterator = ds.query(query)) {
assertFalse(iterator.hasNext());
}
// ///////////////////////////////////////////////////
// EqualTo
// ///////////////////////////////////////////////////
query = QueryBuilder.newBuilder(SimpleFeature.class).filter(GEOM.isEqualTo(GeometryUtils.GEOMETRY_FACTORY.createPoint(new Coordinate(1, 1)))).build();
queryConstraints = assertBestIndex(internalAdapter, spatialIndex, query, adapterStore, internalAdapterStore, aimStore, indexStore, statsStore);
assertTrue(queryConstraints instanceof ExplicitFilteredQuery);
constraints = (ExplicitFilteredQuery) queryConstraints;
filters = constraints.createFilters(spatialIndex);
assertEquals(1, filters.size());
assertTrue(filters.get(0) instanceof ExpressionQueryFilter);
filter = ((ExpressionQueryFilter<?>) filters.get(0)).getFilter();
assertTrue(filter instanceof SpatialEqualTo);
// Query data
try (CloseableIterator<SimpleFeature> iterator = ds.query(query)) {
assertTrue(iterator.hasNext());
assertEquals(1, Iterators.size(iterator));
}
// ///////////////////////////////////////////////////
// NotEqualTo
// ///////////////////////////////////////////////////
query = QueryBuilder.newBuilder(SimpleFeature.class).filter(GEOM.isNotEqualTo(GeometryUtils.GEOMETRY_FACTORY.createPoint(new Coordinate(1, 1)))).build();
queryConstraints = assertBestIndex(internalAdapter, spatialIndex, query, adapterStore, internalAdapterStore, aimStore, indexStore, statsStore);
assertTrue(queryConstraints instanceof FilteredEverythingQuery);
everything = (FilteredEverythingQuery) queryConstraints;
filters = everything.createFilters(spatialIndex);
assertEquals(1, filters.size());
assertTrue(filters.get(0) instanceof ExpressionQueryFilter);
filter = ((ExpressionQueryFilter<?>) filters.get(0)).getFilter();
assertTrue(filter instanceof SpatialNotEqualTo);
// Query data
try (CloseableIterator<SimpleFeature> iterator = ds.query(query)) {
assertTrue(iterator.hasNext());
assertEquals(TOTAL_FEATURES - 1, Iterators.size(iterator));
}
}
use of org.locationtech.geowave.core.store.query.constraints.FilteredEverythingQuery in project geowave by locationtech.
the class ExpressionQueryIT method testTextExpressionQueries.
@Test
public void testTextExpressionQueries() {
final DataStore ds = dataStore.createDataStore();
final DataTypeAdapter<SimpleFeature> adapter = createDataAdapter();
final Index spatialIndex = SpatialDimensionalityTypeProvider.createIndexFromOptions(new SpatialOptions());
ds.addType(adapter, spatialIndex);
final Index commentIndex = AttributeDimensionalityTypeProvider.createIndexFromOptions(ds, new AttributeIndexOptions(TYPE_NAME, COMMENT_FIELD));
final Index idIndex = AttributeDimensionalityTypeProvider.createIndexFromOptions(ds, new AttributeIndexOptions(TYPE_NAME, ID_FIELD));
ds.addIndex(TYPE_NAME, commentIndex, idIndex);
final PersistentAdapterStore adapterStore = dataStore.createAdapterStore();
final InternalAdapterStore internalAdapterStore = dataStore.createInternalAdapterStore();
final AdapterIndexMappingStore aimStore = dataStore.createAdapterIndexMappingStore();
final IndexStore indexStore = dataStore.createIndexStore();
final DataStatisticsStore statsStore = dataStore.createDataStatisticsStore();
final InternalDataAdapter<?> internalAdapter = adapterStore.getAdapter(internalAdapterStore.getAdapterId(TYPE_NAME));
// Ingest data
ingestData(ds);
// ///////////////////////////////////////////////////
// Starts With
// ///////////////////////////////////////////////////
Query<SimpleFeature> query = QueryBuilder.newBuilder(SimpleFeature.class).filter(COMMENT.startsWith("Br")).build();
QueryConstraints queryConstraints = assertBestIndex(internalAdapter, commentIndex, query, adapterStore, internalAdapterStore, aimStore, indexStore, statsStore);
assertTrue(queryConstraints instanceof CustomQueryConstraints);
CustomQueryConstraints<?> customConstraints = (CustomQueryConstraints<?>) queryConstraints;
List<QueryFilter> filters = customConstraints.createFilters(commentIndex);
assertEquals(0, filters.size());
// Query data
try (CloseableIterator<SimpleFeature> iterator = ds.query(query)) {
assertTrue(iterator.hasNext());
assertEquals(TOTAL_FEATURES / 4, Iterators.size(iterator));
}
// ///////////////////////////////////////////////////
// Starts With (ignore case)
// ///////////////////////////////////////////////////
query = QueryBuilder.newBuilder(SimpleFeature.class).filter(COMMENT.startsWith("br", true)).build();
queryConstraints = assertBestIndex(internalAdapter, commentIndex, query, adapterStore, internalAdapterStore, aimStore, indexStore, statsStore);
assertTrue(queryConstraints instanceof CustomQueryConstraints);
customConstraints = (CustomQueryConstraints<?>) queryConstraints;
filters = customConstraints.createFilters(commentIndex);
assertEquals(0, filters.size());
// Query data
try (CloseableIterator<SimpleFeature> iterator = ds.query(query)) {
assertTrue(iterator.hasNext());
assertEquals(TOTAL_FEATURES / 4, Iterators.size(iterator));
}
// ///////////////////////////////////////////////////
// Ends With
// ///////////////////////////////////////////////////
query = QueryBuilder.newBuilder(SimpleFeature.class).filter(COMMENT.endsWith("phA")).build();
queryConstraints = assertBestIndex(internalAdapter, commentIndex, query, adapterStore, internalAdapterStore, aimStore, indexStore, statsStore);
assertTrue(queryConstraints instanceof CustomQueryConstraints);
customConstraints = (CustomQueryConstraints<?>) queryConstraints;
filters = customConstraints.createFilters(commentIndex);
assertEquals(0, filters.size());
// Query data
try (CloseableIterator<SimpleFeature> iterator = ds.query(query)) {
assertTrue(iterator.hasNext());
assertEquals(TOTAL_FEATURES / 4, Iterators.size(iterator));
}
// ///////////////////////////////////////////////////
// Ends With (ignore case)
// ///////////////////////////////////////////////////
query = QueryBuilder.newBuilder(SimpleFeature.class).filter(COMMENT.endsWith("pha", true)).build();
queryConstraints = assertBestIndex(internalAdapter, commentIndex, query, adapterStore, internalAdapterStore, aimStore, indexStore, statsStore);
assertTrue(queryConstraints instanceof CustomQueryConstraints);
customConstraints = (CustomQueryConstraints<?>) queryConstraints;
filters = customConstraints.createFilters(commentIndex);
assertEquals(0, filters.size());
// Query data
try (CloseableIterator<SimpleFeature> iterator = ds.query(query)) {
assertTrue(iterator.hasNext());
assertEquals(TOTAL_FEATURES / 4, Iterators.size(iterator));
}
// ///////////////////////////////////////////////////
// Contains
// ///////////////////////////////////////////////////
query = QueryBuilder.newBuilder(SimpleFeature.class).filter(COMMENT.contains("lph")).build();
// Spatial index will be selected since contains is a full scan
queryConstraints = assertBestIndex(internalAdapter, spatialIndex, query, adapterStore, internalAdapterStore, aimStore, indexStore, statsStore);
assertTrue(queryConstraints instanceof FilteredEverythingQuery);
FilteredEverythingQuery everything = (FilteredEverythingQuery) queryConstraints;
filters = everything.createFilters(spatialIndex);
assertEquals(1, filters.size());
assertTrue(filters.get(0) instanceof ExpressionQueryFilter);
Filter filter = ((ExpressionQueryFilter<?>) filters.get(0)).getFilter();
assertTrue(filter instanceof Contains);
// Query data
try (CloseableIterator<SimpleFeature> iterator = ds.query(query)) {
assertTrue(iterator.hasNext());
assertEquals(TOTAL_FEATURES / 4, Iterators.size(iterator));
}
// ///////////////////////////////////////////////////
// Contains (ignore case)
// ///////////////////////////////////////////////////
query = QueryBuilder.newBuilder(SimpleFeature.class).filter(COMMENT.contains("al", true)).build();
// Spatial index will be selected since contains is a full scan
queryConstraints = assertBestIndex(internalAdapter, spatialIndex, query, adapterStore, internalAdapterStore, aimStore, indexStore, statsStore);
assertTrue(queryConstraints instanceof FilteredEverythingQuery);
everything = (FilteredEverythingQuery) queryConstraints;
filters = everything.createFilters(spatialIndex);
assertEquals(1, filters.size());
assertTrue(filters.get(0) instanceof ExpressionQueryFilter);
filter = ((ExpressionQueryFilter<?>) filters.get(0)).getFilter();
assertTrue(filter instanceof Contains);
// Query data
try (CloseableIterator<SimpleFeature> iterator = ds.query(query)) {
assertTrue(iterator.hasNext());
assertEquals(TOTAL_FEATURES / 4, Iterators.size(iterator));
}
// ///////////////////////////////////////////////////
// Between
// ///////////////////////////////////////////////////
query = QueryBuilder.newBuilder(SimpleFeature.class).filter(COMMENT.isBetween("A", "C")).build();
queryConstraints = assertBestIndex(internalAdapter, commentIndex, query, adapterStore, internalAdapterStore, aimStore, indexStore, statsStore);
assertTrue(queryConstraints instanceof CustomQueryConstraints);
customConstraints = (CustomQueryConstraints<?>) queryConstraints;
filters = customConstraints.createFilters(commentIndex);
assertEquals(1, filters.size());
assertTrue(filters.get(0) instanceof ExpressionQueryFilter);
filter = ((ExpressionQueryFilter<?>) filters.get(0)).getFilter();
assertTrue(filter instanceof Between);
// Query data
try (CloseableIterator<SimpleFeature> iterator = ds.query(query)) {
assertTrue(iterator.hasNext());
assertEquals(TOTAL_FEATURES / 2, Iterators.size(iterator));
}
// ///////////////////////////////////////////////////
// Between (ignore case)
// ///////////////////////////////////////////////////
query = QueryBuilder.newBuilder(SimpleFeature.class).filter(COMMENT.isBetween("alpha", "bravo", true)).build();
queryConstraints = assertBestIndex(internalAdapter, commentIndex, query, adapterStore, internalAdapterStore, aimStore, indexStore, statsStore);
assertTrue(queryConstraints instanceof CustomQueryConstraints);
customConstraints = (CustomQueryConstraints<?>) queryConstraints;
filters = customConstraints.createFilters(commentIndex);
assertEquals(1, filters.size());
assertTrue(filters.get(0) instanceof ExpressionQueryFilter);
filter = ((ExpressionQueryFilter<?>) filters.get(0)).getFilter();
assertTrue(filter instanceof Between);
// Query data
try (CloseableIterator<SimpleFeature> iterator = ds.query(query)) {
assertTrue(iterator.hasNext());
assertEquals(TOTAL_FEATURES / 2, Iterators.size(iterator));
}
// ///////////////////////////////////////////////////
// Greater Than
// ///////////////////////////////////////////////////
query = QueryBuilder.newBuilder(SimpleFeature.class).filter(COMMENT.isGreaterThan("B")).build();
queryConstraints = assertBestIndex(internalAdapter, commentIndex, query, adapterStore, internalAdapterStore, aimStore, indexStore, statsStore);
assertTrue(queryConstraints instanceof CustomQueryConstraints);
customConstraints = (CustomQueryConstraints<?>) queryConstraints;
filters = customConstraints.createFilters(commentIndex);
assertEquals(1, filters.size());
assertTrue(filters.get(0) instanceof ExpressionQueryFilter);
filter = ((ExpressionQueryFilter<?>) filters.get(0)).getFilter();
assertTrue(filter instanceof ComparisonOperator);
// Query data
try (CloseableIterator<SimpleFeature> iterator = ds.query(query)) {
assertTrue(iterator.hasNext());
assertEquals(TOTAL_FEATURES / 2, Iterators.size(iterator));
}
// ///////////////////////////////////////////////////
// Greater Than (ignore case)
// ///////////////////////////////////////////////////
query = QueryBuilder.newBuilder(SimpleFeature.class).filter(COMMENT.isGreaterThan("c", true)).build();
queryConstraints = assertBestIndex(internalAdapter, commentIndex, query, adapterStore, internalAdapterStore, aimStore, indexStore, statsStore);
assertTrue(queryConstraints instanceof CustomQueryConstraints);
customConstraints = (CustomQueryConstraints<?>) queryConstraints;
filters = customConstraints.createFilters(commentIndex);
assertEquals(1, filters.size());
assertTrue(filters.get(0) instanceof ExpressionQueryFilter);
filter = ((ExpressionQueryFilter<?>) filters.get(0)).getFilter();
assertTrue(filter instanceof ComparisonOperator);
// Query data
try (CloseableIterator<SimpleFeature> iterator = ds.query(query)) {
assertTrue(iterator.hasNext());
assertEquals(TOTAL_FEATURES / 4, Iterators.size(iterator));
}
// ///////////////////////////////////////////////////
// Less Than
// ///////////////////////////////////////////////////
query = QueryBuilder.newBuilder(SimpleFeature.class).filter(COMMENT.isLessThan("B")).build();
queryConstraints = assertBestIndex(internalAdapter, commentIndex, query, adapterStore, internalAdapterStore, aimStore, indexStore, statsStore);
assertTrue(queryConstraints instanceof CustomQueryConstraints);
customConstraints = (CustomQueryConstraints<?>) queryConstraints;
filters = customConstraints.createFilters(commentIndex);
// Less than can be an exact query and doesn't need filtering
assertEquals(0, filters.size());
// Query data
try (CloseableIterator<SimpleFeature> iterator = ds.query(query)) {
assertTrue(iterator.hasNext());
assertEquals(TOTAL_FEATURES / 4, Iterators.size(iterator));
}
// ///////////////////////////////////////////////////
// Less Than (ignore case)
// ///////////////////////////////////////////////////
query = QueryBuilder.newBuilder(SimpleFeature.class).filter(COMMENT.isLessThan("c", true)).build();
queryConstraints = assertBestIndex(internalAdapter, commentIndex, query, adapterStore, internalAdapterStore, aimStore, indexStore, statsStore);
assertTrue(queryConstraints instanceof CustomQueryConstraints);
customConstraints = (CustomQueryConstraints<?>) queryConstraints;
filters = customConstraints.createFilters(commentIndex);
// Less than can be an exact query and doesn't need filtering
assertEquals(0, filters.size());
// Query data
try (CloseableIterator<SimpleFeature> iterator = ds.query(query)) {
assertTrue(iterator.hasNext());
assertEquals(TOTAL_FEATURES / 2, Iterators.size(iterator));
}
// ///////////////////////////////////////////////////
// Greater Than Or Equal To
// ///////////////////////////////////////////////////
query = QueryBuilder.newBuilder(SimpleFeature.class).filter(COMMENT.isGreaterThanOrEqualTo("B")).build();
queryConstraints = assertBestIndex(internalAdapter, commentIndex, query, adapterStore, internalAdapterStore, aimStore, indexStore, statsStore);
assertTrue(queryConstraints instanceof CustomQueryConstraints);
customConstraints = (CustomQueryConstraints<?>) queryConstraints;
filters = customConstraints.createFilters(commentIndex);
// Greater than or equal to can be an exact query and doesn't need filtering
assertEquals(0, filters.size());
// Query data
try (CloseableIterator<SimpleFeature> iterator = ds.query(query)) {
assertTrue(iterator.hasNext());
assertEquals(TOTAL_FEATURES / 2, Iterators.size(iterator));
}
// ///////////////////////////////////////////////////
// Greater Than Or Equal To (ignore case)
// ///////////////////////////////////////////////////
query = QueryBuilder.newBuilder(SimpleFeature.class).filter(COMMENT.isGreaterThanOrEqualTo("c", true)).build();
queryConstraints = assertBestIndex(internalAdapter, commentIndex, query, adapterStore, internalAdapterStore, aimStore, indexStore, statsStore);
assertTrue(queryConstraints instanceof CustomQueryConstraints);
customConstraints = (CustomQueryConstraints<?>) queryConstraints;
filters = customConstraints.createFilters(commentIndex);
// Greater than or equal to can be an exact query and doesn't need filtering
assertEquals(0, filters.size());
// Query data
try (CloseableIterator<SimpleFeature> iterator = ds.query(query)) {
assertTrue(iterator.hasNext());
assertEquals(TOTAL_FEATURES / 4, Iterators.size(iterator));
}
// ///////////////////////////////////////////////////
// Less Than Or Equal To
// ///////////////////////////////////////////////////
query = QueryBuilder.newBuilder(SimpleFeature.class).filter(COMMENT.isLessThanOrEqualTo("B")).build();
queryConstraints = assertBestIndex(internalAdapter, commentIndex, query, adapterStore, internalAdapterStore, aimStore, indexStore, statsStore);
assertTrue(queryConstraints instanceof CustomQueryConstraints);
customConstraints = (CustomQueryConstraints<?>) queryConstraints;
filters = customConstraints.createFilters(commentIndex);
assertEquals(1, filters.size());
assertTrue(filters.get(0) instanceof ExpressionQueryFilter);
filter = ((ExpressionQueryFilter<?>) filters.get(0)).getFilter();
assertTrue(filter instanceof ComparisonOperator);
// Query data
try (CloseableIterator<SimpleFeature> iterator = ds.query(query)) {
assertTrue(iterator.hasNext());
assertEquals(TOTAL_FEATURES / 4, Iterators.size(iterator));
}
// ///////////////////////////////////////////////////
// Less Than Or Equal To (ignore case)
// ///////////////////////////////////////////////////
query = QueryBuilder.newBuilder(SimpleFeature.class).filter(COMMENT.isLessThanOrEqualTo("bravo", true)).build();
queryConstraints = assertBestIndex(internalAdapter, commentIndex, query, adapterStore, internalAdapterStore, aimStore, indexStore, statsStore);
assertTrue(queryConstraints instanceof CustomQueryConstraints);
customConstraints = (CustomQueryConstraints<?>) queryConstraints;
filters = customConstraints.createFilters(commentIndex);
assertEquals(1, filters.size());
assertTrue(filters.get(0) instanceof ExpressionQueryFilter);
filter = ((ExpressionQueryFilter<?>) filters.get(0)).getFilter();
assertTrue(filter instanceof ComparisonOperator);
// Query data
try (CloseableIterator<SimpleFeature> iterator = ds.query(query)) {
assertTrue(iterator.hasNext());
assertEquals(TOTAL_FEATURES / 2, Iterators.size(iterator));
}
}
Aggregations