[ 
https://issues.apache.org/jira/browse/BEAM-7450?focusedWorklogId=260577&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-260577
 ]

ASF GitHub Bot logged work on BEAM-7450:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 14/Jun/19 17:14
            Start Date: 14/Jun/19 17:14
    Worklog Time Spent: 10m 
      Work Description: jkff commented on pull request #8718: [BEAM-7450] 
Support unbounded reads with HCatalogIO
URL: https://github.com/apache/beam/pull/8718#discussion_r293900172
 
 

 ##########
 File path: 
sdks/java/io/hcatalog/src/main/java/org/apache/beam/sdk/io/hcatalog/PartitionPollerFn.java
 ##########
 @@ -0,0 +1,56 @@
+/*
+ * 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 org.apache.beam.sdk.io.hcatalog;
+
+import java.util.List;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
+import org.apache.beam.sdk.io.hcatalog.HCatalogIO.Read;
+import org.apache.beam.sdk.transforms.Watch.Growth.PollFn;
+import org.apache.beam.sdk.transforms.Watch.Growth.PollResult;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hive.metastore.IMetaStoreClient;
+import org.joda.time.Instant;
+
+/** Return the list of current partitions present. */
+class PartitionPollerFn extends PollFn<Read, Integer> {
+  private transient IMetaStoreClient metaStoreClient;
+
+  @Override
+  public PollResult<Integer> apply(Read element, Context c) throws Exception {
+    final Configuration conf = 
HCatalogUtils.createConfiguration(element.getConfigProperties());
+    metaStoreClient = HCatalogUtils.createMetaStoreClient(conf);
+    final Instant now = Instant.now();
+    final PollResult<Integer> pollResult =
+        PollResult.incomplete(now, 
getPartitionIndices(element)).withWatermark(now);
+    if (metaStoreClient != null) {
+      metaStoreClient.close();
+    }
+    return pollResult;
+  }
+
+  private List<Integer> getPartitionIndices(Read read) throws Exception {
+    return IntStream.range(
+            0,
+            metaStoreClient
+                .listPartitions(read.getDatabase(), read.getTable(), 
Short.MAX_VALUE)
 
 Review comment:
   What does Short.MAX_VALUE stand for here, and is it in any way related to 
Integer.MAX_VALUE above?
 
----------------------------------------------------------------
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:
us...@infra.apache.org


Issue Time Tracking
-------------------

    Worklog Id:     (was: 260577)
    Time Spent: 10h 20m  (was: 10h 10m)

> Support unbounded reads with HCatalogIO
> ---------------------------------------
>
>                 Key: BEAM-7450
>                 URL: https://issues.apache.org/jira/browse/BEAM-7450
>             Project: Beam
>          Issue Type: New Feature
>          Components: io-java-hcatalog
>            Reporter: Ankit Jhalaria
>            Assignee: Ankit Jhalaria
>            Priority: Minor
>             Fix For: 2.14.0
>
>          Time Spent: 10h 20m
>  Remaining Estimate: 0h
>
> # Current version of HcatalogIO is a bounded source.
>  # While migrating our jobs to aws, we realized that it would be helpful to 
> have an unbounded hcat reader that can behave as an unbounded source and 
> polls for new partitions as and when they become available.
>  # I have used splittable pardo(s) to do this. There is a flag that can be 
> set to treat this as a bounded source which will terminate if that flag is 
> set.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to