[
https://issues.apache.org/jira/browse/BEAM-6054?focusedWorklogId=165407&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-165407
]
ASF GitHub Bot logged work on BEAM-6054:
----------------------------------------
Author: ASF GitHub Bot
Created on: 13/Nov/18 12:44
Start Date: 13/Nov/18 12:44
Worklog Time Spent: 10m
Work Description: VaclavPlajt commented on a change in pull request
#7019: [BEAM-6054] Euphoria translation providers refactored.
URL: https://github.com/apache/beam/pull/7019#discussion_r233021810
##########
File path:
sdks/java/extensions/euphoria/src/main/java/org/apache/beam/sdk/extensions/euphoria/core/translate/provider/CompositeProvider.java
##########
@@ -0,0 +1,83 @@
+/*
+ * 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.provider;
+
+import static java.util.Objects.requireNonNull;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Optional;
+import
org.apache.beam.sdk.extensions.euphoria.core.annotation.stability.Experimental;
+import
org.apache.beam.sdk.extensions.euphoria.core.client.operator.base.Operator;
+import
org.apache.beam.sdk.extensions.euphoria.core.translate.OperatorTranslator;
+import
org.apache.beam.sdk.extensions.euphoria.core.translate.TranslatorProvider;
+
+/**
+ * An implementation of {@link TranslatorProvider} which allows to stack other
{@link
+ * TranslatorProvider TranslatorProviders} in order given on construction time.
+ */
+@Experimental
+public class CompositeProvider implements TranslatorProvider {
+
+ private final List<TranslatorProvider> orderedTranslatorsChain;
+
+ private CompositeProvider(List<TranslatorProvider> orderedTranslatorsChain) {
+ requireNonNull(orderedTranslatorsChain);
+ this.orderedTranslatorsChain = orderedTranslatorsChain;
+ }
+
+ public static CompositeProvider of(List<TranslatorProvider>
orderedTranslatorsChain) {
+ return new CompositeProvider(orderedTranslatorsChain);
+ }
+
+ public static CompositeProvider of(TranslatorProvider...
orderedTranslatorsChain) {
+ requireNonNull(orderedTranslatorsChain);
+ return new CompositeProvider(Arrays.asList(orderedTranslatorsChain));
+ }
+
+ /**
+ * Returns first {@code Optional<OperatorTranslator<InputT, OutputT,
OperatorT>>} which {@link
+ * OperatorTranslator#canTranslate(Operator) can translate} given operator.
+ *
+ * <p>Translators are acquired by calling {@link
TranslatorProvider#findTranslator(Operator)} on
+ * {@link TranslatorProvider TranslatorProviders} from list given at
construction time in given
+ * order.
+ *
+ * @param operator operator to translate
+ * @param <InputT> the type of input elements
+ * @param <OutputT> the type of output elements
+ * @param <OperatorT> the type of the euphoria operator
+ * @return first {@code Optional<OperatorTranslator<InputT, OutputT,
OperatorT>>} which {@link
+ * OperatorTranslator#canTranslate(Operator) can translate} given
operator.
+ */
+ @Override
+ public <InputT, OutputT, OperatorT extends Operator<OutputT>>
+ Optional<OperatorTranslator<InputT, OutputT, OperatorT>>
findTranslator(OperatorT operator) {
+
+ for (int i = 0; i < orderedTranslatorsChain.size(); i++) {
Review comment:
shure
----------------------------------------------------------------
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: 165407)
Time Spent: 1.5h (was: 1h 20m)
> Refactor traslator providers
> -----------------------------
>
> Key: BEAM-6054
> URL: https://issues.apache.org/jira/browse/BEAM-6054
> Project: Beam
> Issue Type: Sub-task
> Components: dsl-euphoria
> Reporter: Vaclav Plajt
> Assignee: Vaclav Plajt
> Priority: Major
> Time Spent: 1.5h
> Remaining Estimate: 0h
>
> We need following functionality:
> 1. Way of registering translator providers for operator type with optional
> user-defined predicate
> 1. Way of registering translator providers for any operator based on
> predicate. (e.g `CompositeOperatorTranslator`)
> 1. Way of chaining translator providers
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)