Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 6B9ED200ACC for ; Mon, 2 May 2016 08:48:17 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 68C5C1609A1; Mon, 2 May 2016 08:48:17 +0200 (CEST) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id B391E1609B0 for ; Mon, 2 May 2016 08:48:16 +0200 (CEST) Received: (qmail 20680 invoked by uid 500); 2 May 2016 06:48:15 -0000 Mailing-List: contact dev-help@apex.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@apex.incubator.apache.org Delivered-To: mailing list dev@apex.incubator.apache.org Received: (qmail 20663 invoked by uid 99); 2 May 2016 06:48:15 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 02 May 2016 06:48:15 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 77C58C04B9 for ; Mon, 2 May 2016 06:48:15 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -4.021 X-Spam-Level: X-Spam-Status: No, score=-4.021 tagged_above=-999 required=6.31 tests=[KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-0.001] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id CEpCkYqkUAX7 for ; Mon, 2 May 2016 06:48:14 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with SMTP id D188B5FACB for ; Mon, 2 May 2016 06:48:13 +0000 (UTC) Received: (qmail 20483 invoked by uid 99); 2 May 2016 06:48:13 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 02 May 2016 06:48:13 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id E9D722C1F5D for ; Mon, 2 May 2016 06:48:12 +0000 (UTC) Date: Mon, 2 May 2016 06:48:12 +0000 (UTC) From: "ASF GitHub Bot (JIRA)" To: dev@apex.incubator.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (APEXMALHAR-2019) Creation of S3 Input Module MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Mon, 02 May 2016 06:48:17 -0000 [ https://issues.apache.org/jira/browse/APEXMALHAR-2019?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15266165#comment-15266165 ] ASF GitHub Bot commented on APEXMALHAR-2019: -------------------------------------------- Github user yogidevendra commented on a diff in the pull request: https://github.com/apache/incubator-apex-malhar/pull/263#discussion_r61707966 --- Diff: library/src/main/java/com/datatorrent/lib/io/fs/S3BlockReader.java --- @@ -0,0 +1,89 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package com.datatorrent.lib.io.fs; + +import java.io.IOException; +import org.apache.hadoop.fs.FSDataInputStream; +import org.apache.hadoop.fs.Path; + +import com.google.common.annotations.VisibleForTesting; +import com.datatorrent.api.Context; +import com.datatorrent.lib.io.block.BlockMetadata; +import com.datatorrent.lib.io.block.BlockReader; +import com.datatorrent.lib.io.block.ReaderContext; + +/** + * S3BlockReader extends from BlockReader and serves the functionality of read objects and + * parse Block metadata + */ +public class S3BlockReader extends BlockReader +{ + protected transient String s3bucketUri; + + public S3BlockReader() + { + this.readerContext = new S3BlockReaderContext(); + } + + @Override + public void setup(Context.OperatorContext context) + { + super.setup(context); + s3bucketUri = fs.getScheme() + "://" + extractBucket(uri); + } + + @VisibleForTesting + protected String extractBucket(String s3uri) + { + return s3uri.substring(s3uri.indexOf('@') + 1, s3uri.indexOf("/", s3uri.indexOf('@'))); + } + + @Override + protected FSDataInputStream setupStream(BlockMetadata.FileBlockMetadata block) throws IOException + { + FSDataInputStream ins = fs.open(new Path(s3bucketUri + block.getFilePath())); + ins.seek(block.getOffset()); + return ins; + } + + /** + * BlockReadeContext for reading S3 Blocks.
+ * This should use read API without offset. + */ + private static class S3BlockReaderContext extends ReaderContext.FixedBytesReaderContext + { + @Override + protected Entity readEntity() throws IOException --- End diff -- mention the difference from super in javadocs. > Creation of S3 Input Module > --------------------------- > > Key: APEXMALHAR-2019 > URL: https://issues.apache.org/jira/browse/APEXMALHAR-2019 > Project: Apache Apex Malhar > Issue Type: Task > Reporter: Chaitanya > Assignee: Chaitanya > Priority: Minor > > This module serves the functionality of parallel read files from S3 bucket. -- This message was sent by Atlassian JIRA (v6.3.4#6332)