From commits-return-89625-archive-asf-public=cust-asf.ponee.io@beam.apache.org Fri Aug 24 15:22:11 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 2F3D2180629 for ; Fri, 24 Aug 2018 15:22:11 +0200 (CEST) Received: (qmail 65436 invoked by uid 500); 24 Aug 2018 13:22:05 -0000 Mailing-List: contact commits-help@beam.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@beam.apache.org Delivered-To: mailing list commits@beam.apache.org Received: (qmail 65311 invoked by uid 99); 24 Aug 2018 13:22:05 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 24 Aug 2018 13:22:05 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id B05AB1807F9 for ; Fri, 24 Aug 2018 13:22:04 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -109.501 X-Spam-Level: X-Spam-Status: No, score=-109.501 tagged_above=-999 required=6.31 tests=[ENV_AND_HDR_SPF_MATCH=-0.5, KAM_ASCII_DIVIDERS=0.8, RCVD_IN_DNSWL_MED=-2.3, SPF_PASS=-0.001, USER_IN_DEF_SPF_WL=-7.5, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id twH0IokziGtA for ; Fri, 24 Aug 2018 13:22:03 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id 191F55F242 for ; Fri, 24 Aug 2018 13:22:03 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id F33E5E263B for ; Fri, 24 Aug 2018 13:22:01 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 07BC426B73 for ; Fri, 24 Aug 2018 13:22:01 +0000 (UTC) Date: Fri, 24 Aug 2018 13:22:01 +0000 (UTC) From: "ASF GitHub Bot (JIRA)" To: commits@beam.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Work logged] (BEAM-2930) Flink support for portable side input MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/BEAM-2930?focusedWorklogId=137806&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-137806 ] ASF GitHub Bot logged work on BEAM-2930: ---------------------------------------- Author: ASF GitHub Bot Created on: 24/Aug/18 13:21 Start Date: 24/Aug/18 13:21 Worklog Time Spent: 10m Work Description: mxm commented on a change in pull request #6208: [BEAM-2930] Side input support for Flink portable streaming. URL: https://github.com/apache/beam/pull/6208#discussion_r212337222 ########## File path: runners/flink/src/main/java/org/apache/beam/runners/flink/translation/functions/FlinkStreamingSideInputHandlerFactory.java ########## @@ -0,0 +1,167 @@ +/* + * 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.runners.flink.translation.functions; + +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkNotNull; + +import com.google.common.collect.ImmutableMap; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Map; +import org.apache.beam.model.pipeline.v1.RunnerApi; +import org.apache.beam.model.pipeline.v1.RunnerApi.ExecutableStagePayload.SideInputId; +import org.apache.beam.runners.core.construction.PTransformTranslation; +import org.apache.beam.runners.core.construction.graph.ExecutableStage; +import org.apache.beam.runners.core.construction.graph.SideInputReference; +import org.apache.beam.runners.fnexecution.state.StateRequestHandler; +import org.apache.beam.runners.fnexecution.state.StateRequestHandlers.SideInputHandler; +import org.apache.beam.runners.fnexecution.state.StateRequestHandlers.SideInputHandlerFactory; +import org.apache.beam.sdk.coders.Coder; +import org.apache.beam.sdk.coders.KvCoder; +import org.apache.beam.sdk.transforms.Materializations; +import org.apache.beam.sdk.transforms.windowing.BoundedWindow; +import org.apache.beam.sdk.values.KV; +import org.apache.beam.sdk.values.PCollectionView; + +/** + * {@link StateRequestHandler} that uses {@link org.apache.beam.runners.core.SideInputHandler} to + * access the Flink broadcast state that represents side inputs. + */ +public class FlinkStreamingSideInputHandlerFactory implements SideInputHandlerFactory { + + // Map from side input id to global PCollection id. + private final Map> sideInputToCollection; + private final org.apache.beam.runners.core.SideInputHandler runnerHandler; + + /** + * Creates a new state handler for the given stage. Note that this requires a traversal of the + * stage itself, so this should only be called once per stage rather than once per bundle. + */ + public static FlinkStreamingSideInputHandlerFactory forStage( + ExecutableStage stage, + Map> viewMapping, + org.apache.beam.runners.core.SideInputHandler runnerHandler) { + ImmutableMap.Builder> sideInputBuilder = ImmutableMap.builder(); + for (SideInputReference sideInput : stage.getSideInputs()) { + SideInputId sideInputId = + SideInputId.newBuilder() + .setTransformId(sideInput.transform().getId()) + .setLocalName(sideInput.localName()) + .build(); + sideInputBuilder.put( + sideInputId, + checkNotNull( + viewMapping.get(sideInputId), + "No side input for %s/%s", + sideInputId.getTransformId(), + sideInputId.getLocalName())); + } + + FlinkStreamingSideInputHandlerFactory factory = + new FlinkStreamingSideInputHandlerFactory(sideInputBuilder.build(), runnerHandler); + return factory; + } + + private FlinkStreamingSideInputHandlerFactory( + Map> sideInputToCollection, + org.apache.beam.runners.core.SideInputHandler runnerHandler) { + this.sideInputToCollection = sideInputToCollection; + this.runnerHandler = runnerHandler; + } + + @Override + public SideInputHandler forSideInput( + String transformId, + String sideInputId, + RunnerApi.FunctionSpec accessPattern, + Coder elementCoder, + Coder windowCoder) { + + PCollectionView collectionNode = + sideInputToCollection.get( + SideInputId.newBuilder().setTransformId(transformId).setLocalName(sideInputId).build()); + checkArgument(collectionNode != null, "No side input for %s/%s", transformId, sideInputId); + + if (PTransformTranslation.ITERABLE_SIDE_INPUT.equals(accessPattern.getUrn())) { + @SuppressWarnings("unchecked") // T == V + Coder outputCoder = (Coder) elementCoder; + return forIterableSideInput(collectionNode, outputCoder, windowCoder); + } else if (PTransformTranslation.MULTIMAP_SIDE_INPUT.equals(accessPattern.getUrn()) + || Materializations.MULTIMAP_MATERIALIZATION_URN.equals(accessPattern.getUrn())) { + // TODO: Remove non standard URN. + // Using non standard version of multimap urn as dataflow uses the non standard urn. + @SuppressWarnings("unchecked") // T == KV + KvCoder kvCoder = (KvCoder) elementCoder; + return forMultimapSideInput( + collectionNode, kvCoder.getKeyCoder(), kvCoder.getValueCoder(), windowCoder); + } else { + throw new IllegalArgumentException( + String.format("Unknown side input access pattern: %s", accessPattern)); + } + } + + private SideInputHandler forIterableSideInput( + PCollectionView collection, Coder elementCoder, Coder windowCoder) { Review comment: Unused parameter: `windowCoder` ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: users@infra.apache.org Issue Time Tracking ------------------- Worklog Id: (was: 137806) > Flink support for portable side input > ------------------------------------- > > Key: BEAM-2930 > URL: https://issues.apache.org/jira/browse/BEAM-2930 > Project: Beam > Issue Type: Sub-task > Components: runner-flink > Reporter: Henning Rohde > Assignee: Thomas Weise > Priority: Major > Labels: portability > Time Spent: 5h 20m > Remaining Estimate: 0h > -- This message was sent by Atlassian JIRA (v7.6.3#76005)