gaoyunhaii commented on a change in pull request #7:
URL: https://github.com/apache/flink-ml/pull/7#discussion_r731015173



##########
File path: 
flink-ml-iteration/src/main/java/org/apache/flink/ml/iteration/operator/HeadOperatorFactory.java
##########
@@ -0,0 +1,135 @@
+/*
+ * 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.flink.ml.iteration.operator;
+
+import org.apache.flink.annotation.VisibleForTesting;
+import org.apache.flink.ml.iteration.IterationID;
+import org.apache.flink.ml.iteration.IterationRecord;
+import 
org.apache.flink.ml.iteration.operator.coordinator.HeadOperatorCoordinator;
+import org.apache.flink.runtime.jobgraph.OperatorID;
+import org.apache.flink.runtime.operators.coordination.OperatorCoordinator;
+import org.apache.flink.runtime.operators.coordination.OperatorEventGateway;
+import org.apache.flink.streaming.api.operators.AbstractStreamOperatorFactory;
+import org.apache.flink.streaming.api.operators.CoordinatedOperatorFactory;
+import org.apache.flink.streaming.api.operators.MailboxExecutor;
+import org.apache.flink.streaming.api.operators.OneInputStreamOperatorFactory;
+import org.apache.flink.streaming.api.operators.StreamOperator;
+import org.apache.flink.streaming.api.operators.StreamOperatorParameters;
+import org.apache.flink.streaming.api.operators.YieldingOperatorFactory;
+import org.apache.flink.streaming.runtime.tasks.mailbox.TaskMailbox;
+
+import static org.apache.flink.util.Preconditions.checkArgument;
+
+/** The Factory for the {@link HeadOperator}. */
+public class HeadOperatorFactory extends 
AbstractStreamOperatorFactory<IterationRecord<?>>
+        implements OneInputStreamOperatorFactory<IterationRecord<?>, 
IterationRecord<?>>,
+                CoordinatedOperatorFactory<IterationRecord<?>>,
+                YieldingOperatorFactory<IterationRecord<?>> {
+
+    private final IterationID iterationId;
+
+    private final int feedbackIndex;
+
+    private final boolean isCriteriaStream;
+
+    private final int totalInitialVariableParallelism;
+
+    private int criteriaStreamParallelism;
+
+    public HeadOperatorFactory(
+            IterationID iterationId,
+            int feedbackIndex,
+            boolean isCriteriaStream,
+            int totalInitialVariableParallelism) {
+        this.iterationId = iterationId;
+        this.feedbackIndex = feedbackIndex;
+        this.isCriteriaStream = isCriteriaStream;
+
+        checkArgument(
+                totalInitialVariableParallelism > 0,
+                "totalInitialVariableParallelism should be positive");
+        this.totalInitialVariableParallelism = totalInitialVariableParallelism;
+    }
+
+    public void setCriteriaStreamParallelism(int criteriaStreamParallelism) {
+        checkArgument(
+                criteriaStreamParallelism > 0,
+                "totalInitialVariableParallelism should be positive");
+        this.criteriaStreamParallelism = criteriaStreamParallelism;
+    }
+
+    @Override
+    public <T extends StreamOperator<IterationRecord<?>>> T 
createStreamOperator(
+            StreamOperatorParameters<IterationRecord<?>> 
streamOperatorParameters) {
+
+        // TODO: We would have to create a new mailboxExecutor since the given 
one
+        // is created with getChainedIndex as the priority, which seems to be 
a bug.

Review comment:
       There is not such jira ticket yet and the issue is still under 
confirming, I'll update the comment after the issue is opened. 




-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to