We are just about to start a new release cycle, API changes are a
short-term pain, but the most maintainable approach long term.

As for the change, how about returning a returning long? Existing client
code that used integrer would be easy to update.

long count = featureSource.getCount(query);

Or:

int count = (int) featureSource.getCount(query);


If you really want Java 8 has Math.toIntExact method, that produces an
exception if the long is out of range:

int count = Math. toIntExact( featureSource.getCount(query) );


--
Jody Garnett


On Thu, 27 Aug 2020 at 10:06, Andrea Aime <andrea.a...@geo-solutions.it>
wrote:

> Hi,
> lately I've been working more and more with datasets that are large
> enough, that their feature
> count is approaching the maximum value integer can represent (roughly 2
> billions).
>
> For example, the full Ordnance Survey Mastermap Topography, a large but
> real, currently distributed dataset
> that, if purchased fully, contains also 500 million records in its
> database.
>
> Today I stumbled into a dataset that just cannot be counted... the H3 DGGS
> hierarchy, fully developed at
> its maximum resolution level, 15, would cover the earth
> with 569,707,381,193,330 hexagons (597 trillions).
> Even just resolution level 9 contains 4,842,432,938, twice as much as
> integer can represent.
>
> I guess we need to expand how we count in GeoTools, at least to use long
> instead of int, which
> has a maximum value of 9,223,372,036,854,775,807 (9 millions of trillions,
> if I read it correctly?).
> Or just go towards BigInteger and be done with it.
>
> Downside, this would be a pretty significant API break in both
> FeatureSource and FeatureCollection.
> What to do? A non breaking change would be to add default methods, like
> "getLargeCount(Query) -> long"
> which, in the default implementation, would just wrap the existing
> getCount result. Data stores could then
> decide to implement the new methods as they see fit.
>
> Ideas? Suggestions? Reactions? :-D
>
> Cheers
> Andrea
>
> == GeoServer Professional Services from the experts! Visit
> http://goo.gl/it488V for more information. == Ing. Andrea Aime @geowolf
> Technical Lead GeoSolutions S.A.S. Via di Montramito 3/A 55054 Massarosa
> (LU) phone: +39 0584 962313 fax: +39 0584 1660272 mob: +39 339 8844549
> http://www.geo-solutions.it http://twitter.com/geosolutions_it
> ------------------------------------------------------- *Con riferimento
> alla normativa sul trattamento dei dati personali (Reg. UE 2016/679 -
> Regolamento generale sulla protezione dei dati “GDPR”), si precisa che ogni
> circostanza inerente alla presente email (il suo contenuto, gli eventuali
> allegati, etc.) è un dato la cui conoscenza è riservata al/i solo/i
> destinatario/i indicati dallo scrivente. Se il messaggio Le è giunto per
> errore, è tenuta/o a cancellarlo, ogni altra operazione è illecita. Le
> sarei comunque grato se potesse darmene notizia. This email is intended
> only for the person or entity to which it is addressed and may contain
> information that is privileged, confidential or otherwise protected from
> disclosure. We remind that - as provided by European Regulation 2016/679
> “GDPR” - copying, dissemination or use of this e-mail or the information
> herein by anyone other than the intended recipient is prohibited. If you
> have received this email by mistake, please notify us immediately by
> telephone or e-mail.*
> _______________________________________________
> GeoTools-Devel mailing list
> GeoTools-Devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/geotools-devel
>
_______________________________________________
GeoTools-Devel mailing list
GeoTools-Devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-devel

Reply via email to