flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [flink] KurtYoung commented on a change in pull request #8066: [FLINK-12041][table-runtime-blink] Introduce ResettableExternalBuffer to blink batch
Date Thu, 28 Mar 2019 09:55:13 GMT
KurtYoung commented on a change in pull request #8066: [FLINK-12041][table-runtime-blink] Introduce
ResettableExternalBuffer to blink batch
URL: https://github.com/apache/flink/pull/8066#discussion_r269925872
 
 

 ##########
 File path: flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/runtime/util/ResettableExternalBuffer.java
 ##########
 @@ -0,0 +1,699 @@
+/*
+ * 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.runtime.util;
+
+import org.apache.flink.annotation.VisibleForTesting;
+import org.apache.flink.core.memory.MemorySegment;
+import org.apache.flink.core.memory.MemorySegmentFactory;
+import org.apache.flink.runtime.io.disk.RandomAccessInputView;
+import org.apache.flink.runtime.io.disk.SimpleCollectingOutputView;
+import org.apache.flink.runtime.io.disk.iomanager.BlockChannelReader;
+import org.apache.flink.runtime.io.disk.iomanager.BlockChannelWriter;
+import org.apache.flink.runtime.io.disk.iomanager.ChannelReaderInputView;
+import org.apache.flink.runtime.io.disk.iomanager.FileIOChannel;
+import org.apache.flink.runtime.io.disk.iomanager.HeaderlessChannelReaderInputView;
+import org.apache.flink.runtime.io.disk.iomanager.IOManager;
+import org.apache.flink.runtime.memory.ListMemorySegmentSource;
+import org.apache.flink.runtime.memory.MemoryManager;
+import org.apache.flink.table.dataformat.BaseRow;
+import org.apache.flink.table.dataformat.BinaryRow;
+import org.apache.flink.table.runtime.io.BinaryRowChannelInputViewIterator;
+import org.apache.flink.table.runtime.io.ChannelWithMeta;
+import org.apache.flink.table.typeutils.AbstractRowSerializer;
+import org.apache.flink.table.typeutils.BinaryRowSerializer;
+import org.apache.flink.util.MutableObjectIterator;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.Closeable;
+import java.io.EOFException;
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.LinkedList;
+import java.util.List;
+
+import static org.apache.flink.util.Preconditions.checkArgument;
+
+/**
+ * A resettable external buffer for binary row. It stores records in memory and spill to
disk
+ * when memory is not enough. When the spill is completed, the records are written to memory
again.
+ * The returned iterator reads the data in write order (read spilled records first).
+ *
+ * <p>1.It supports infinite length.
+ * 2.It can open multiple Iterators.
+ * 3.It support new iterator with beginRow.
+ */
+public class ResettableExternalBuffer implements Closeable {
+
+	private static final Logger LOG = LoggerFactory.getLogger(ResettableExternalBuffer.class);
+
+	// We will only read one spilled file at the same time.
+	private static final int READ_BUFFER = 2;
+
+	private final MemoryManager memoryManager;
+	private final IOManager ioManager;
+	private final List<MemorySegment> memory;
+	private final BinaryRowSerializer binaryRowSerializer;
+	private final InMemoryBuffer inMemoryBuffer;
+	private long spillSize;
+
+	// The size of each segment
+	private int segmentSize;
+
+	// The length of each row, if each row is of fixed length
+	private long rowFixedPartLength;
+	// If each row is of fixed length
+	private boolean isRowAllInFixedPart;
 
 Review comment:
   what's the differences between "row all in fixed part" and "the row is fixed length"?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message