Skip to content

HadoopGeoTiffRDD and S3GeoTiffRDD add overloads to use file names in keys - #2050

Merged
echeipesh merged 6 commits into
locationtech:masterfrom
pomadchin:feature/input-path-handle
Mar 14, 2017
Merged

echeipesh merged 6 commits into
locationtech:masterfrom
pomadchin:feature/input-path-handle

Conversation

@pomadchin

@pomadchin pomadchin commented Mar 10, 2017 •

Copy link
Copy Markdown
Member

Fixes #1958 without a significant API change. This PR introduces a keyTransform: (URI, I) => K function to have ability to read necessary metadata from files paths, and to modify Input key.

  • Tests

@pomadchin pomadchin changed the title Collect metadata from file names [WIP] Collect metadata from file names Mar 10, 2017
Signed-off-by: Grigory Pomadchin <[email protected]>
@pomadchin
pomadchin force-pushed the feature/input-path-handle branch from 50f42c3 to 80ffe05 Compare March 10, 2017 16:30
@pomadchin pomadchin added this to the 1.1 milestone Mar 12, 2017
@lossyrob lossyrob modified the milestones: 1.2, 1.1 Mar 12, 2017
@lossyrob

Copy link
Copy Markdown
Member

This breaks API - I'd want to think through this in a way that won't break the API if possible... Is this the only way to accomplish this?

@lossyrob

Copy link
Copy Markdown
Member

Maybe if we just create the necessary overloads of public methods to maintain the signatures that existed before, this will work.

@lossyrob lossyrob left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs overloads to not break public API.

* @tparam K
* @return
*/
def keyTransformId[K] = (_: URI, key: K) => key

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unclear that this is necessary, if the overloads are properly aligned.

@pomadchin

pomadchin commented Mar 12, 2017 •

Copy link
Copy Markdown
Member Author

@lossyrob sure: first approach to create smth like spark did: ~ NewHadoopGeoTiffRDD and to deprecate the old one, or I can create functions with keyTransform different and still to keep them. P.S. all public signatures are here, except old apply

P.P.S. I wrote it before comments above, didn't notice;

@lossyrob

Copy link
Copy Markdown
Member

We can just overload apply to pass through the same sort of default keyTransform as the other methods.

@pomadchin pomadchin changed the title [WIP] Collect metadata from file names Collect metadata from file names Mar 13, 2017
@pomadchin
pomadchin force-pushed the feature/input-path-handle branch from ece8450 to fb01b0b Compare March 13, 2017 11:26
Signed-off-by: Grigory Pomadchin <[email protected]>
@pomadchin

pomadchin commented Mar 13, 2017 •

Copy link
Copy Markdown
Member Author

Usage example are in tests and here.

@lossyrob

Copy link
Copy Markdown
Member

Is there a good spot in docs for noting this?

@pomadchin pomadchin modified the milestones: 1.2, 1.1 Mar 13, 2017
@pomadchin

Copy link
Copy Markdown
Member Author

@lossyrob eh we don't have a section for it, @fosskers can you navigate me where it would be better to write this information? Looks like it should be done as a separate PR, as it would include the whole new section with this part of API description.

@fosskers

fosskers commented Mar 13, 2017 •

Copy link
Copy Markdown
Contributor

What needs to be noted, exactly? If there was a deprecation, it should be explained in a @deprecated annotation on the old, overloaded method. The note will appear at compile time for the user, so that they'll know they have to switch eventually.

I don't think deprecation notices need to go into ReadTheDocs, other than in the CHANGELOG.

rr.readWindow(reader, pixelWindow, options)
val (k, v) = rr.readWindow(reader, pixelWindow, options)

keyTransform(new URI(objectRequest.getKey), k) -> v

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getKey will only give you the path without the s3://bucket/ prefix

* @param bucket Name of the bucket on S3 where the files are kept.
* @param prefix Prefix of all of the keys on S3 that are to be read in.
* @param keyTransform function to transform input key basing on the URI information.
*/

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

keyTransform is a little overloaded with the way we use it for SFC. This should be renamed to uriToKey or something similar.

* @param options An instance of [[Options]] that contains any user defined or default settings.
*/
def apply[K, V](path: Path, options: Options = Options.DEFAULT)(implicit sc: SparkContext, rr: RasterReader[Options, (K, V)]): RDD[(K, V)] = {
def apply[I, K, V](path: Path, keyTransform: (URI, I) => K, options: Options)(implicit sc: SparkContext, rr: RasterReader[Options, (I, V)]): RDD[(K, V)] = {

@echeipesh echeipesh Mar 13, 2017 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not certain if use of URI here provides opportunity to use a more general function. We should probably just use Path here.

@echeipesh
echeipesh force-pushed the feature/input-path-handle branch from ec71d1f to 004d984 Compare March 14, 2017 01:44
@echeipesh echeipesh changed the title Collect metadata from file names HadoopGeoTiffRDD and S3GeoTiffRDD add overloads to use file names in keys Mar 14, 2017
@echeipesh
echeipesh merged commit 580fa28 into locationtech:master Mar 14, 2017
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

Successfully merging this pull request may close these issues.

4 participants