You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2022/07/11 08:32:41 UTC

[GitHub] [flink] reswqa commented on a diff in pull request #20100: [FLINK-27905][runtime] Introduce HsSpillingStrategy and HsSelectiveSpillingStrategy implementation

reswqa commented on code in PR #20100:
URL: https://github.com/apache/flink/pull/20100#discussion_r917675487


##########
flink-runtime/src/main/java/org/apache/flink/runtime/io/network/partition/hybrid/HsSpillingStrategy.java:
##########
@@ -0,0 +1,97 @@
+/*
+ * 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.runtime.io.network.partition.hybrid;
+
+import org.apache.flink.runtime.io.network.buffer.Buffer;
+
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * Component which encapsulates the spilling logic. It is responsible for deciding when and which
+ * buffers will be spilled to disk and released from memory.
+ */
+public interface HsSpillingStrategy {
+    /**
+     * Callback for {@link Buffer} instances when it becomes finished.
+     *
+     * @param spillingInfoProvider to compute which buffers need to be spilled into disk and which
+     *     buffers need be released from memory.
+     * @param finishedBuffer info of finished buffer.
+     * @return Which buffers need to be spilled and which buffers need to be released.
+     */
+    Action onBufferFinished(
+            HsSpillingInfoProvider spillingInfoProvider, BufferWithIdentity finishedBuffer);
+
+    /**
+     * Callback for {@link Buffer} instances when it is consumed by downstream task.
+     *
+     * <p>Note that only this method is called by downstream thread, everything else is the current
+     * task main thread.
+     *
+     * @param spillingInfoProvider to compute which buffers need to be spilled into disk and which
+     *     buffers need be released from memory.
+     * @param consumedBuffer info of consumed buffer.
+     * @return Which buffers need to be spilled and which buffers need to be released.
+     */
+    Action onBufferConsumed(
+            HsSpillingInfoProvider spillingInfoProvider, BufferWithIdentity consumedBuffer);
+
+    /**
+     * Decide whether the current situation will trigger an {@link Action} and return it.
+     *
+     * @param spillInfoProvider to compute which buffers need to be spilled into disk and which
+     *     buffers need be released from memory.
+     * @return Which buffers need to be spilled and which buffers need to be released.
+     */
+    Action maybeSpill(HsSpillingInfoProvider spillInfoProvider);

Review Comment:
   renamed



-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org