[
https://issues.apache.org/jira/browse/BEAM-6350?focusedWorklogId=182343&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-182343
]
ASF GitHub Bot logged work on BEAM-6350:
----------------------------------------
Author: ASF GitHub Bot
Created on: 08/Jan/19 11:41
Start Date: 08/Jan/19 11:41
Worklog Time Spent: 10m
Work Description: dmvk commented on pull request #7399: [BEAM-6350] Reuse
PCollectionView when created in translators
URL: https://github.com/apache/beam/pull/7399#discussion_r245960574
##########
File path:
sdks/java/extensions/euphoria/src/main/java/org/apache/beam/sdk/extensions/euphoria/core/translate/PViewsStore.java
##########
@@ -0,0 +1,53 @@
+/*
+ * 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.extensions.euphoria.core.translate;
+
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.beam.sdk.transforms.View;
+import org.apache.beam.sdk.values.KV;
+import org.apache.beam.sdk.values.PCollection;
+import org.apache.beam.sdk.values.PCollectionView;
+
+/**
+ * PViewsStore keeps track of {@link PCollection} to {@link PCollectionView}
mappings created during
+ * translation of Euphoria API into Beam java SDK. To prevent creating several
{@link
+ * PCollectionView PCollectionViews} to one {@link PCollection}.
+ */
+public class PViewsStore {
+
+ private Map<Object, PCollectionView<?>> pViewsMap = new HashMap<>();
+
+ /**
+ * Creates new {@link PCollectionView} of given {@code pCollectionToView}
iff there is no {@link
+ * PCollectionView} already associated with {@code Key}.
+ *
+ * @param key mapping key
+ * @param pCollectionToView a {@link PCollection} view will be created from
by applying {@link
+ * View#asMultimap()}
+ * @param <K> element key type
+ * @param <V> value key type
+ * @return the current (already existing or computed) value associated with
the specified key
+ */
+ @SuppressWarnings("unchecked")
+ public <K, V> PCollectionView<Map<K, Iterable<V>>>
computeViewAsMultimapIfAbsent(
Review comment:
can we have a more readable name? eg.: `asMultimap`
----------------------------------------------------------------
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:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 182343)
Time Spent: 40m (was: 0.5h)
> Reuse same PCollectionView when created in translators
> -------------------------------------------------------
>
> Key: BEAM-6350
> URL: https://issues.apache.org/jira/browse/BEAM-6350
> Project: Beam
> Issue Type: Improvement
> Components: dsl-euphoria
> Affects Versions: 2.11.0
> Reporter: Marek Simunek
> Assignee: David Moravek
> Priority: Major
> Time Spent: 40m
> Remaining Estimate: 0h
>
> If for LeftJoin is used BroadcastHashJoinTranslator then from right side is
> created PCollectionView (as sideInput).
> If we use right side in multiple joins then PCollectionView is created
> multiple times which is not optimal behavior.
> Eg.
> {code:java}
> LeftJoin.of(left, right)..
> LeftJoin.of(anotherLeftPcollection, right)..
> {code}
> For example it will happen when we want to solve skew Join.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)