Repository navigation
Generate Windows That Conform To GeoTiff Segments - #2402
Conversation
bc6626c to
860cf98
Compare
bb9d4d1 to
bccb415
Compare
| val segments: RDD[(String, Array[GridBounds])] = | ||
| sourceGeoTiffInfo.segmentsByPartitionBytes(partitionBytes, windowSize) | ||
| case (_, Some(partitionBytes)) => { | ||
| val maxSize = math.min(options.maxTileSize.getOrElse(1<<10), windowSize.getOrElse(1<<10)) // XXX is windowSize a length or an area? |
There was a problem hiding this comment.
windowSize is length, implicitly for square windows.
There was a problem hiding this comment.
- Why can't we write here just
1024instead of1 << 10? - Don't think that
getOrElseis a good idea here, as it can hide a possible user error. What logic do you want to follow here? Mb we can add these attributes into thematchfunction above?matchsupports logicalortoo. windowSizeis length
It seems strange but the thinking went is that if you don't have an opinion about the shape of tiles you want you're probably using this RDD as input to tiler. From the perspective of optimizing for IO reading the segments as skinny tiles is fine, from the perspective of tiler chunking a skinny tile into multiple tiles is not problematic either. |
Sounds capital. |
pomadchin
left a comment
There was a problem hiding this comment.
It works fine! A couple of comments and most of them are related to code style / api questions.
| val segments: RDD[(String, Array[GridBounds])] = | ||
| sourceGeoTiffInfo.segmentsByPartitionBytes(partitionBytes, windowSize) | ||
| case (_, Some(partitionBytes)) => { | ||
| val maxSize = math.min(options.maxTileSize.getOrElse(1<<10), windowSize.getOrElse(1<<10)) // XXX is windowSize a length or an area? |
There was a problem hiding this comment.
- Why can't we write here just
1024instead of1 << 10? - Don't think that
getOrElseis a good idea here, as it can hide a possible user error. What logic do you want to follow here? Mb we can add these attributes into thematchfunction above?matchsupports logicalortoo. windowSizeis length
| val layout = sourceGeoTiffInfo.getGeoTiffInfo(s"s3://$bucket/$key").segmentLayout.tileLayout | ||
|
|
||
| RasterReader | ||
| .listWindows(cols, rows, options.maxTileSize.getOrElse(1<<10), layout.tileCols, layout.tileRows) |
There was a problem hiding this comment.
The same is here:
Looks not safe:
options.maxTileSize.getOrElse(1<<10)Mb to throw an exception or to handle it in a way user will know that smth is used by default (at least to add some warning). In addition, somewhere above you already used getOrElse two times with 1024 default value, mb it makes sense to add these default values somewhere? As we can easily forget about these default values.
Finally the question, mb Options should contain 1024 value for maxTileSize and windowSize by default? (everything is defined in S3GeoTiffRDD object).
There was a problem hiding this comment.
As long as changing the default maxTileSize is not construed to constitute an API change, I prefer that.
| } | ||
| } | ||
|
|
||
| def windowsByBytes( |
There was a problem hiding this comment.
Function description is missing, would be good to add.
Btw have you compared it to segmentsByPartitionBytes? Should we remove segmentsByPartitionBytes at all?
| (options.maxTileSize, options.partitionBytes) match { | ||
| case (_, Some(partitionBytes)) => { | ||
| val windows: RDD[(String, Array[GridBounds])] = | ||
| sourceGeoTiffInfo.windowsByBytes(partitionBytes, options.maxTileSize.getOrElse(1<<10)) |
There was a problem hiding this comment.
The same comments about maxTileSize and windowSize and 1 << 10 are valid for Hadoop too.
| options: Options | ||
| )(implicit sc: SparkContext, rr: RasterReader[Options, (I, V)]): RDD[(K, V)] = { | ||
|
|
||
| val conf = new SerializableConfiguration(configuration(path, options)) |
There was a problem hiding this comment.
Why conf should be wrapped here? Looks like it's only used for input formats arguments => can be used a common configuration without extra wrapper.
There was a problem hiding this comment.
That variable makes its way into a sc.parallelize inside of HadoopGeoTiffInfoReader.
| )(implicit sc: SparkContext, rr: RasterReader[Options, (I, V)]): RDD[(K, V)] = { | ||
|
|
||
| val conf = new SerializableConfiguration(configuration(path, options)) | ||
| val path2 = path.toString |
There was a problem hiding this comment.
Well it's always a bit confusing when you see in the code base such variable names. In fact you can write just: // to avoid variable naming confusion
HadoopGeoTiffInfoReader(path.toString, conf, options.tiffExtensions)| val layout = info.getGeoTiffInfo(objectRequest.toString).segmentLayout.tileLayout | ||
|
|
||
| RasterReader | ||
| .listWindows(cols, rows, options.maxTileSize.getOrElse(1<<10), layout.tileCols, layout.tileRows) |
These are given in the respective Options classes to avoid changing semantics.
80cdadb to
395fe2d
Compare
|
All comments have been addressed, I believe. |
|
💯 |
windowsSizea length or an area in this context?)Connects #2173