yuzelin commented on code in PR #472:
URL: https://github.com/apache/flink-table-store/pull/472#discussion_r1065532487


##########
flink-table-store-core/src/main/java/org/apache/flink/table/store/file/memory/BufferRecycler.java:
##########
@@ -0,0 +1,32 @@
+/*
+ * 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.table.store.file.memory;
+
+import org.apache.flink.core.memory.MemorySegment;
+
+/** Interface for recycling {@link MemorySegment}s. */
+public interface BufferRecycler {
+
+    /**
+     * Recycles the {@link MemorySegment} to its original pool instance.
+     *
+     * @param memorySegment The memory segment to be recycled.
+     */
+    void recycle(MemorySegment memorySegment);
+}

Review Comment:
   Seems this interface is not used.



##########
flink-table-store-core/src/main/java/org/apache/flink/table/store/file/sort/PartialOrderPriorityQueue.java:
##########
@@ -0,0 +1,195 @@
+/*
+ * 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.table.store.file.sort;
+
+import java.util.AbstractQueue;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.Queue;
+
+/**
+ * This class implements a priority-queue, which maintains a partial ordering 
of its elements such
+ * that the least element can always be found in constant time. Put()'s and 
pop()'s require
+ * log(size) time.
+ */
+public class PartialOrderPriorityQueue<T> extends AbstractQueue<T> implements 
Queue<T> {
+    /** The heap, organized as an array. */
+    private final T[] heap;
+
+    /** The comparator used to establish the order between the streams. */
+    private final Comparator<T> comparator;
+
+    /** The maximum size of the heap. */
+    private final int capacity;
+
+    /** The current number of elements in the queue. */
+    private int size;
+
+    @SuppressWarnings("unchecked")
+    public PartialOrderPriorityQueue(Comparator<T> comparator, int capacity) {
+        this.comparator = comparator;
+        this.capacity = capacity + 1;
+        this.size = 0;
+        this.heap = (T[]) new Object[this.capacity];
+    }
+
+    /**
+     * Determines the ordering of objects in this priority queue.
+     *
+     * @param a The first element.
+     * @param b The second element.
+     * @return True, if a &lt; b, false otherwise.
+     */
+    private final boolean lessThan(T a, T b) {
+        return comparator.compare(a, b) < 0;

Review Comment:
   `final` is redundant



##########
flink-table-store-core/src/main/java/org/apache/flink/table/store/file/sort/QuickSort.java:
##########
@@ -0,0 +1,330 @@
+/*
+ * 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.table.store.file.sort;
+
+/** Quick sort {@link IndexedSorter}. */
+public final class QuickSort implements IndexedSorter {
+
+    private static final IndexedSorter alt = new HeapSort();
+
+    public QuickSort() {}
+
+    /**
+     * Fix the records into sorted order, swapping when the first record is 
greater than the second
+     * record.
+     *
+     * @param s paged sortable
+     * @param pN page number of first record
+     * @param pO page offset of first record
+     * @param rN page number of second record
+     * @param rO page offset of second record
+     */
+    private static void fix(IndexedSortable s, int pN, int pO, int rN, int rO) 
{
+        if (s.compare(pN, pO, rN, rO) > 0) {
+            s.swap(pN, pO, rN, rO);
+        }
+    }
+
+    /** Deepest recursion before giving up and doing a heapsort. Returns 2 * 
ceil(log(n)). */
+    protected static int getMaxDepth(int x) {
+        if (x <= 0) {

Review Comment:
   Seems here it can be private.



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