Skip to content

Commit

Permalink
Fixed issue with S3 URI not having a key prefix
Browse files Browse the repository at this point in the history
Signed-off-by: lossyrob <rdemanuele@gmail.com>
  • Loading branch information
lossyrob committed Aug 6, 2017
1 parent 0f4fda2 commit c42438e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Expand Up @@ -27,6 +27,13 @@ class S3LayerProviderSpec extends FunSpec with TestEnvironment {
assert(store.isInstanceOf[S3AttributeStore])
}

it("construct S3AttributeStore from URI with no prefix"){
val store = AttributeStore(new java.net.URI("s3://fake-bucket"))
assert(store.isInstanceOf[S3AttributeStore])
assert(store.asInstanceOf[S3AttributeStore].prefix != null)
}


it("construct S3LayerReader from URI") {
val reader = LayerReader(uri)
assert(reader.isInstanceOf[S3LayerReader])
Expand Down
Expand Up @@ -33,7 +33,12 @@ class S3LayerProvider extends AttributeStoreProvider

def attributeStore(uri: URI): AttributeStore = {
val s3Uri = new AmazonS3URI(uri)
new S3AttributeStore(bucket = s3Uri.getBucket, prefix = s3Uri.getKey)
val prefix =
Option(s3Uri.getKey) match {
case Some(s) => s
case None => ""
}
new S3AttributeStore(bucket = s3Uri.getBucket, prefix = prefix)
}

def layerReader(uri: URI, store: AttributeStore, sc: SparkContext): FilteringLayerReader[LayerId] = {
Expand Down

0 comments on commit c42438e

Please sign in to comment.