Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect Feature count on WFS Queries from HBase #1365

Closed
worky68 opened this issue Aug 3, 2018 · 3 comments
Closed

Incorrect Feature count on WFS Queries from HBase #1365

worky68 opened this issue Aug 3, 2018 · 3 comments

Comments

@worky68
Copy link

worky68 commented Aug 3, 2018

We have created an HBase Datastore in Geoserver using the GeoWave plugin. We then make requests using the WFS service in Geoserver to this Datastore. Inside of this Datastore we have ingested a number of SimpleFeatures with row visibility set. In addition, we have our own implementation of AuthorizationSPI that we use to filter results.

Expected Behavior

We expect the WFS numOfFeatures attribute to reflect the number of features returned with the current response.

Actual Behavior

The WFS numOfFeatures attribute reflects the total number of features within the Datastore regardless of the authorizations provided. However, the features returned in the resulting featurecollection are correct in terms of the authorizations provided.

Workaround

The problem seems to stem from two places within the code that prefer a cached count over the actual count. As a workaround to the issue, we have removed the code below.

if (query.getFilter().equals(
Filter.INCLUDE)) {
// GEOWAVE-60 optimization
final Map<ByteArrayId, DataStatistics<SimpleFeature>> statsMap = reader
.getTransaction()
.getDataStatistics();
if (statsMap.containsKey(CountDataStatistics.STATS_TYPE)) {
final CountDataStatistics stats = (CountDataStatistics) statsMap.get(CountDataStatistics.STATS_TYPE);
if ((stats != null) && stats.isSet()) {
return (int) stats.getCount();
}
}
}
else if (query.getFilter().equals(
Filter.EXCLUDE)) {
return 0;
}

final Map<ByteArrayId, DataStatistics<SimpleFeature>> stats = new GeoWaveEmptyTransaction(
components).getDataStatistics();
final DataStatistics<SimpleFeature> countStats = stats.get(CountDataStatistics.STATS_TYPE);
if ((countStats != null) && query.getFilter().equals(
Filter.INCLUDE)) {
return (int) ((CountDataStatistics) countStats).getCount();
}

After removing the code we are now receiving the proper count on our queries. Of course, sacrificing some efficiency.

Specifications

  • Version: 0.9.4
@rfecher
Copy link
Contributor

rfecher commented Sep 14, 2018

Thanks @worky68 for this good supporting documentation along with the issue. Apologies for not following up immediately, the developers were pushing hard to get 0.9.8 released and now we're going to investigate this prior to 1.0.0.

@rfecher
Copy link
Contributor

rfecher commented Sep 19, 2018

after investigating, I believe this is a bug in 0.9.4 related to how we cache statistics results in HBase that no longer exists.
In 0.9.4 we'd cache the count result the first time regardless of authorizations here.

We currently cache statistics results only associated by appropriate authorizations.

We also have fairly involved testing with visibility/auth but I noticed for our primary integration test we use a Count Aggregation rather than a statistic. I added to that test t o also verify statistics are using proper authorization in PR #1429 ... thanks for the feedback, in that it helped bulk up our testing. Please re-open if by chance I am mistaken and you find this still to be an issue in 0.9.8, but I am fairly confident this was resolved.

@rfecher rfecher closed this as completed Sep 19, 2018
@worky68
Copy link
Author

worky68 commented Oct 3, 2018

Thanks @rfecher! We are planning to upgrade to 1.0.0 in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants