Open-EO / openeo-geotrellis-extensions

Java/Scala extensions for Geotrellis, for use with OpenEO GeoPySpark backend.
Apache License 2.0
5 stars 3 forks source link

prevent unbounded cache growth in FileLayerProvider #183

Closed bossie closed 1 year ago

bossie commented 1 year ago

Added in the context of EP-3696, this remark should still apply:

https://github.com/Open-EO/openeo-geotrellis-extensions/blob/68143219e6882dffd0d05a46aaf29e530c0b93a5/openeo-geotrellis/src/main/scala/org/openeo/geotrellis/layers/FileLayerProvider.scala#L183

In particular, implementations of org.openeo.opensearch.OpenSearchClient and org.openeo.geotrellis.layers.PathDateExtractor should implement equals() and hashCode().

It should be possible to enforce this @ compile time by declaring these methods as abstract in those two base classes/traits:

def equals(obj: Any): Boolean
def hashCode(): Int

Then implement those methods in the implementations.

bossie commented 1 year ago

Implemented equals and hashCode for all OpenSearchClient implementations; tested these and those for PathDateExtractor implementations as well.

Looks like the abstract method "trick" works for abstract classes but not traits; there are apparently other ways to accomplish this but I deemed a runtime error Good Enough.