clintropolis commented on a change in pull request #8903: S3 input source
URL: https://github.com/apache/incubator-druid/pull/8903#discussion_r349781929
 
 

 ##########
 File path: 
extensions-core/s3-extensions/src/main/java/org/apache/druid/data/input/s3/S3Entity.java
 ##########
 @@ -20,56 +20,60 @@
 package org.apache.druid.data.input.s3;
 
 import com.amazonaws.services.s3.model.AmazonS3Exception;
+import com.amazonaws.services.s3.model.GetObjectRequest;
 import com.amazonaws.services.s3.model.S3Object;
 import com.google.common.base.Predicate;
-import org.apache.druid.data.input.InputEntity;
+import org.apache.druid.data.input.RetryingInputEntity;
+import org.apache.druid.data.input.impl.CloudObjectLocation;
 import org.apache.druid.java.util.common.ISE;
 import org.apache.druid.storage.s3.S3Utils;
 import org.apache.druid.storage.s3.ServerSideEncryptingAmazonS3;
-import org.apache.druid.utils.CompressionUtils;
 
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.URI;
 
-public class S3Entity implements InputEntity
+public class S3Entity implements RetryingInputEntity
 {
   private final ServerSideEncryptingAmazonS3 s3Client;
-  private final URI uri;
+  private final CloudObjectLocation object;
 
-  S3Entity(ServerSideEncryptingAmazonS3 s3Client, URI uri)
+  S3Entity(ServerSideEncryptingAmazonS3 s3Client, CloudObjectLocation coords)
   {
     this.s3Client = s3Client;
-    this.uri = uri;
+    this.object = coords;
   }
 
   @Override
   public URI getUri()
   {
-    return uri;
+    return null;
   }
 
   @Override
-  public InputStream open() throws IOException
+  public InputStream readFrom(long offset) throws IOException
   {
+    final GetObjectRequest request = new GetObjectRequest(object.getBucket(), 
object.getPath());
+    request.setRange(offset);
     try {
-      // Get data of the given object and open an input stream
-      final String bucket = uri.getAuthority();
-      final String key = S3Utils.extractS3Key(uri);
-
-      final S3Object s3Object = s3Client.getObject(bucket, key);
+      final S3Object s3Object = s3Client.getObject(request);
       if (s3Object == null) {
-        throw new ISE("Failed to get an s3 object for bucket[%s] and key[%s]", 
bucket, key);
+        throw new ISE(
+            "Failed to get an s3 object for bucket[%s], key[%s], and 
start[%d]",
+            object.getBucket(),
+            object.getPath(),
+            offset
+        );
       }
-      return CompressionUtils.decompress(s3Object.getObjectContent(), key);
+      return s3Object.getObjectContent();
 
 Review comment:
   good catch

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to