-
Notifications
You must be signed in to change notification settings - Fork 364
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2998 from jbouffard/feature/range-reader-spi-2
RangeReader SPI
- Loading branch information
Showing
52 changed files
with
314 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package geotrellis.layers | ||
|
||
import org.apache.hadoop.fs.Path | ||
|
||
package object hadoop extends Implicits { | ||
final val SCHEMES: Array[String] = Array("hdfs", "hdfs+file", "s3n", "s3a", "wasb", "wasbs") | ||
|
||
implicit def stringToPath(path: String): Path = new Path(path) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
s3-spark/src/test/scala/geotrellis/spark/store/s3/util/S3RangeReaderProviderSpec.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package geotrellis.spark.store.s3.util | ||
|
||
import geotrellis.spark.store.s3.S3TestUtils | ||
import geotrellis.store.s3.util._ | ||
import geotrellis.spark.store.s3.testkit.MockS3Client | ||
import geotrellis.store.s3.S3ClientProducer | ||
import geotrellis.util.RangeReader | ||
|
||
import org.scalatest._ | ||
|
||
class S3RangeReaderProviderSpec extends FunSpec with Matchers { | ||
val client = MockS3Client() | ||
S3TestUtils.cleanBucket(client, "fake-bucket") | ||
S3ClientProducer.set(() => client) | ||
|
||
describe("S3RangeReaderProviderSpec") { | ||
val uri = new java.net.URI("s3://fake-bucket/some-prefix") | ||
|
||
it("should create a S3RangeReader from a URI") { | ||
val reader = RangeReader(uri) | ||
|
||
assert(reader.isInstanceOf[S3RangeReader]) | ||
} | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
s3/src/main/resources/META-INF/services/geotrellis.util.RangeReaderProvider
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
geotrellis.store.s3.util.S3RangeReaderProvider |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
s3/src/main/scala/geotrellis/store/s3/util/S3RangeReaderProvider.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package geotrellis.store.s3.util | ||
|
||
import geotrellis.store.s3._ | ||
import geotrellis.util.RangeReaderProvider | ||
|
||
import software.amazon.awssdk.services.s3.S3Client | ||
|
||
import java.net.URI | ||
|
||
class S3RangeReaderProvider extends RangeReaderProvider { | ||
def canProcess(uri: URI): Boolean = uri.getScheme match { | ||
case str: String => if (str.toLowerCase == "s3") true else false | ||
case null => false | ||
} | ||
|
||
def rangeReader(uri: URI): S3RangeReader = | ||
rangeReader(uri, S3ClientProducer.get()) | ||
|
||
def rangeReader(uri: URI, s3Client: S3Client): S3RangeReader = { | ||
val s3Uri = new AmazonS3URI(uri) | ||
val prefix = Option(s3Uri.getKey()).getOrElse("") | ||
|
||
S3RangeReader(s3Uri.getBucket(), prefix, s3Client) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
spark/src/main/resources/META-INF/services/geotrellis.util.RangeReaderProvider
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
geotrellis.spark.store.http.util.HttpRangeReaderProvider |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.