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 2020/11/04 02:25:30 UTC

[GitHub] [flink] JingsongLi opened a new pull request #13914: [FLINK-19890][table][fs-connector] Introduce LimitableBulkFormat to wrap BulkFormat when limit pushed down

JingsongLi opened a new pull request #13914:
URL: https://github.com/apache/flink/pull/13914


   
   ## What is the purpose of the change
   
   User requirement:
   Users need to look at a few random pieces of data in a table to see what the data looks like. So users often use the SQL:
   "select * from table limit 10"
   For a large table, expect to end soon because only a few pieces of data are queried.
   For DataStream or BoundedStream, they are push based execution models, so the downstream cannot control the end of source operator.
   We need push down limit to source operator, so that source operator can end early.
   
   Implement a LimitableBulkFormat wrapper to limit output record number in the file source.
   
   ## Brief change log
   
   - Introduce `LimitableBulkFormat`
   - Integrate to `FileSystemTableSource`
   
   ## Verifying this change
   
   This change is already covered by existing tests, such as `FileSystemITCaseBase.testLimitPushDown`.
   
   ## Does this pull request potentially affect one of the following parts:
   
     - Dependencies (does it add or upgrade a dependency): no
     - The public API, i.e., is any changed class annotated with `@Public(Evolving)`: no
     - The serializers: no
     - The runtime per-record code paths (performance sensitive): no
     - Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn/Mesos, ZooKeeper: no
     - The S3 file system connector: no
   
   ## Documentation
   
     - Does this pull request introduce a new feature? yes
     - If yes, how is the feature documented? JavaDocs
   


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



[GitHub] [flink] flinkbot edited a comment on pull request #13914: [FLINK-19890][table][fs-connector] Introduce LimitableBulkFormat to wrap BulkFormat when limit pushed down

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #13914:
URL: https://github.com/apache/flink/pull/13914#issuecomment-721482737


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "62ca1a0f667a10d006193f43171ea7c482f204c5",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=8939",
       "triggerID" : "62ca1a0f667a10d006193f43171ea7c482f204c5",
       "triggerType" : "PUSH"
     }, {
       "hash" : "800a929258db1d388bbb1ea4d7ebc21551aad5f8",
       "status" : "CANCELED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=8947",
       "triggerID" : "800a929258db1d388bbb1ea4d7ebc21551aad5f8",
       "triggerType" : "PUSH"
     }, {
       "hash" : "88a254243687687de1b626aeed306f4c622150a6",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=8950",
       "triggerID" : "88a254243687687de1b626aeed306f4c622150a6",
       "triggerType" : "PUSH"
     }, {
       "hash" : "1e19b0f249789ddc7995ba0f9da816b1283dbd6c",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=8964",
       "triggerID" : "1e19b0f249789ddc7995ba0f9da816b1283dbd6c",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 800a929258db1d388bbb1ea4d7ebc21551aad5f8 Azure: [CANCELED](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=8947) 
   * 88a254243687687de1b626aeed306f4c622150a6 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=8950) 
   * 1e19b0f249789ddc7995ba0f9da816b1283dbd6c Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=8964) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


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



[GitHub] [flink] flinkbot edited a comment on pull request #13914: [FLINK-19890][table][fs-connector] Introduce LimitableBulkFormat to wrap BulkFormat when limit pushed down

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #13914:
URL: https://github.com/apache/flink/pull/13914#issuecomment-721482737


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "62ca1a0f667a10d006193f43171ea7c482f204c5",
       "status" : "CANCELED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=8939",
       "triggerID" : "62ca1a0f667a10d006193f43171ea7c482f204c5",
       "triggerType" : "PUSH"
     }, {
       "hash" : "800a929258db1d388bbb1ea4d7ebc21551aad5f8",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=8947",
       "triggerID" : "800a929258db1d388bbb1ea4d7ebc21551aad5f8",
       "triggerType" : "PUSH"
     }, {
       "hash" : "88a254243687687de1b626aeed306f4c622150a6",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=8950",
       "triggerID" : "88a254243687687de1b626aeed306f4c622150a6",
       "triggerType" : "PUSH"
     }, {
       "hash" : "1e19b0f249789ddc7995ba0f9da816b1283dbd6c",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "1e19b0f249789ddc7995ba0f9da816b1283dbd6c",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 62ca1a0f667a10d006193f43171ea7c482f204c5 Azure: [CANCELED](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=8939) 
   * 800a929258db1d388bbb1ea4d7ebc21551aad5f8 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=8947) 
   * 88a254243687687de1b626aeed306f4c622150a6 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=8950) 
   * 1e19b0f249789ddc7995ba0f9da816b1283dbd6c UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


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



[GitHub] [flink] JingsongLi commented on a change in pull request #13914: [FLINK-19890][table][fs-connector] Introduce LimitableBulkFormat to wrap BulkFormat when limit pushed down

Posted by GitBox <gi...@apache.org>.
JingsongLi commented on a change in pull request #13914:
URL: https://github.com/apache/flink/pull/13914#discussion_r517126873



##########
File path: flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/filesystem/LimitableBulkFormat.java
##########
@@ -0,0 +1,133 @@
+/*
+ * 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.filesystem;
+
+import org.apache.flink.api.common.typeinfo.TypeInformation;
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.connector.file.src.FileSourceSplit;
+import org.apache.flink.connector.file.src.reader.BulkFormat;
+import org.apache.flink.connector.file.src.util.RecordAndPosition;
+
+import javax.annotation.Nullable;
+
+import java.io.IOException;
+import java.util.concurrent.atomic.AtomicLong;
+
+/**
+ * A {@link BulkFormat} that can limit output record number.
+ */
+public class LimitableBulkFormat<T, SplitT extends FileSourceSplit> implements BulkFormat<T, SplitT> {
+
+	private static final long serialVersionUID = 1L;
+
+	private final BulkFormat<T, SplitT> format;
+	private final long limit;
+
+	private transient AtomicLong numRead;
+
+	private LimitableBulkFormat(BulkFormat<T, SplitT> format, long limit) {
+		this.format = format;
+		this.limit = limit;
+	}
+
+	@Override
+	public Reader<T> createReader(Configuration config, SplitT split) throws IOException {
+		return new LimitableReader(format.createReader(config, split));
+	}
+
+	@Override
+	public Reader<T> restoreReader(Configuration config, SplitT split) throws IOException {
+		return new LimitableReader(format.restoreReader(config, split));
+	}
+
+	@Override
+	public boolean isSplittable() {
+		return format.isSplittable();
+	}
+
+	@Override
+	public TypeInformation<T> getProducedType() {
+		return format.getProducedType();
+	}
+
+	private class LimitableReader implements Reader<T> {
+
+		private final Reader<T> reader;
+
+		private LimitableReader(Reader<T> reader) {
+			this.reader = reader;
+		}
+
+		@Nullable
+		@Override
+		public RecordIterator<T> readBatch() throws IOException {
+			if (reachLimit()) {
+				return null;
+			}
+
+			RecordIterator<T> batch = reader.readBatch();
+			return batch == null ? null : new LimitableIterator(batch);
+		}
+
+		@Override
+		public void close() throws IOException {
+			reader.close();
+		}
+	}
+
+	private class LimitableIterator implements RecordIterator<T> {
+
+		private final RecordIterator<T> iterator;
+
+		private LimitableIterator(RecordIterator<T> iterator) {
+			this.iterator = iterator;
+		}
+
+		@Nullable
+		@Override
+		public RecordAndPosition<T> next() {
+			if (reachLimit()) {
+				return null;
+			}
+			getNumRead().incrementAndGet();
+			return iterator.next();
+		}
+
+		@Override
+		public void releaseBatch() {
+			iterator.releaseBatch();
+		}
+	}
+
+	private AtomicLong getNumRead() {
+		if (numRead == null) {
+			numRead = new AtomicLong(0);

Review comment:
       `readBatch` will init this variable. in a single thread.




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



[GitHub] [flink] JingsongLi commented on a change in pull request #13914: [FLINK-19890][table][fs-connector] Introduce LimitableBulkFormat to wrap BulkFormat when limit pushed down

Posted by GitBox <gi...@apache.org>.
JingsongLi commented on a change in pull request #13914:
URL: https://github.com/apache/flink/pull/13914#discussion_r517134332



##########
File path: flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/filesystem/LimitableBulkFormat.java
##########
@@ -0,0 +1,133 @@
+/*
+ * 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.filesystem;
+
+import org.apache.flink.api.common.typeinfo.TypeInformation;
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.connector.file.src.FileSourceSplit;
+import org.apache.flink.connector.file.src.reader.BulkFormat;
+import org.apache.flink.connector.file.src.util.RecordAndPosition;
+
+import javax.annotation.Nullable;
+
+import java.io.IOException;
+import java.util.concurrent.atomic.AtomicLong;
+
+/**
+ * A {@link BulkFormat} that can limit output record number.
+ */
+public class LimitableBulkFormat<T, SplitT extends FileSourceSplit> implements BulkFormat<T, SplitT> {
+
+	private static final long serialVersionUID = 1L;
+
+	private final BulkFormat<T, SplitT> format;
+	private final long limit;
+
+	private transient AtomicLong numRead;
+
+	private LimitableBulkFormat(BulkFormat<T, SplitT> format, long limit) {
+		this.format = format;
+		this.limit = limit;
+	}
+
+	@Override
+	public Reader<T> createReader(Configuration config, SplitT split) throws IOException {
+		return new LimitableReader(format.createReader(config, split));
+	}
+
+	@Override
+	public Reader<T> restoreReader(Configuration config, SplitT split) throws IOException {
+		return new LimitableReader(format.restoreReader(config, split));
+	}
+
+	@Override
+	public boolean isSplittable() {
+		return format.isSplittable();
+	}
+
+	@Override
+	public TypeInformation<T> getProducedType() {
+		return format.getProducedType();
+	}
+
+	private class LimitableReader implements Reader<T> {
+
+		private final Reader<T> reader;
+
+		private LimitableReader(Reader<T> reader) {
+			this.reader = reader;
+		}
+
+		@Nullable
+		@Override
+		public RecordIterator<T> readBatch() throws IOException {
+			if (reachLimit()) {
+				return null;
+			}
+
+			RecordIterator<T> batch = reader.readBatch();
+			return batch == null ? null : new LimitableIterator(batch);
+		}
+
+		@Override
+		public void close() throws IOException {
+			reader.close();
+		}
+	}
+
+	private class LimitableIterator implements RecordIterator<T> {
+
+		private final RecordIterator<T> iterator;
+
+		private LimitableIterator(RecordIterator<T> iterator) {
+			this.iterator = iterator;
+		}
+
+		@Nullable
+		@Override
+		public RecordAndPosition<T> next() {
+			if (reachLimit()) {
+				return null;
+			}
+			getNumRead().incrementAndGet();
+			return iterator.next();
+		}
+
+		@Override
+		public void releaseBatch() {
+			iterator.releaseBatch();
+		}
+	}
+
+	private AtomicLong getNumRead() {
+		if (numRead == null) {
+			numRead = new AtomicLong(0);

Review comment:
       I made `LimitableReader` as a static class, then make the logic more clear.




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



[GitHub] [flink] lirui-apache commented on a change in pull request #13914: [FLINK-19890][table][fs-connector] Introduce LimitableBulkFormat to wrap BulkFormat when limit pushed down

Posted by GitBox <gi...@apache.org>.
lirui-apache commented on a change in pull request #13914:
URL: https://github.com/apache/flink/pull/13914#discussion_r517123736



##########
File path: flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/filesystem/LimitableBulkFormat.java
##########
@@ -0,0 +1,133 @@
+/*
+ * 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.filesystem;
+
+import org.apache.flink.api.common.typeinfo.TypeInformation;
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.connector.file.src.FileSourceSplit;
+import org.apache.flink.connector.file.src.reader.BulkFormat;
+import org.apache.flink.connector.file.src.util.RecordAndPosition;
+
+import javax.annotation.Nullable;
+
+import java.io.IOException;
+import java.util.concurrent.atomic.AtomicLong;
+
+/**
+ * A {@link BulkFormat} that can limit output record number.
+ */
+public class LimitableBulkFormat<T, SplitT extends FileSourceSplit> implements BulkFormat<T, SplitT> {
+
+	private static final long serialVersionUID = 1L;
+
+	private final BulkFormat<T, SplitT> format;
+	private final long limit;
+
+	private transient AtomicLong numRead;
+
+	private LimitableBulkFormat(BulkFormat<T, SplitT> format, long limit) {
+		this.format = format;
+		this.limit = limit;
+	}
+
+	@Override
+	public Reader<T> createReader(Configuration config, SplitT split) throws IOException {
+		return new LimitableReader(format.createReader(config, split));
+	}
+
+	@Override
+	public Reader<T> restoreReader(Configuration config, SplitT split) throws IOException {
+		return new LimitableReader(format.restoreReader(config, split));
+	}
+
+	@Override
+	public boolean isSplittable() {
+		return format.isSplittable();
+	}
+
+	@Override
+	public TypeInformation<T> getProducedType() {
+		return format.getProducedType();
+	}
+
+	private class LimitableReader implements Reader<T> {
+
+		private final Reader<T> reader;
+
+		private LimitableReader(Reader<T> reader) {
+			this.reader = reader;
+		}
+
+		@Nullable
+		@Override
+		public RecordIterator<T> readBatch() throws IOException {
+			if (reachLimit()) {
+				return null;
+			}
+
+			RecordIterator<T> batch = reader.readBatch();
+			return batch == null ? null : new LimitableIterator(batch);
+		}
+
+		@Override
+		public void close() throws IOException {
+			reader.close();
+		}
+	}
+
+	private class LimitableIterator implements RecordIterator<T> {
+
+		private final RecordIterator<T> iterator;
+
+		private LimitableIterator(RecordIterator<T> iterator) {
+			this.iterator = iterator;
+		}
+
+		@Nullable
+		@Override
+		public RecordAndPosition<T> next() {
+			if (reachLimit()) {
+				return null;
+			}
+			getNumRead().incrementAndGet();
+			return iterator.next();
+		}
+
+		@Override
+		public void releaseBatch() {
+			iterator.releaseBatch();
+		}
+	}
+
+	private AtomicLong getNumRead() {
+		if (numRead == null) {
+			numRead = new AtomicLong(0);

Review comment:
       Don't we need to synchronize on the initialization here, if `numRead` can be accessed concurrently?




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



[GitHub] [flink] flinkbot edited a comment on pull request #13914: [FLINK-19890][table][fs-connector] Introduce LimitableBulkFormat to wrap BulkFormat when limit pushed down

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #13914:
URL: https://github.com/apache/flink/pull/13914#issuecomment-721482737


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "62ca1a0f667a10d006193f43171ea7c482f204c5",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=8939",
       "triggerID" : "62ca1a0f667a10d006193f43171ea7c482f204c5",
       "triggerType" : "PUSH"
     }, {
       "hash" : "800a929258db1d388bbb1ea4d7ebc21551aad5f8",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=8947",
       "triggerID" : "800a929258db1d388bbb1ea4d7ebc21551aad5f8",
       "triggerType" : "PUSH"
     }, {
       "hash" : "88a254243687687de1b626aeed306f4c622150a6",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "88a254243687687de1b626aeed306f4c622150a6",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 62ca1a0f667a10d006193f43171ea7c482f204c5 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=8939) 
   * 800a929258db1d388bbb1ea4d7ebc21551aad5f8 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=8947) 
   * 88a254243687687de1b626aeed306f4c622150a6 UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


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



[GitHub] [flink] flinkbot commented on pull request #13914: [FLINK-19890][table][fs-connector] Introduce LimitableBulkFormat to wrap BulkFormat when limit pushed down

Posted by GitBox <gi...@apache.org>.
flinkbot commented on pull request #13914:
URL: https://github.com/apache/flink/pull/13914#issuecomment-721482737


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "62ca1a0f667a10d006193f43171ea7c482f204c5",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "62ca1a0f667a10d006193f43171ea7c482f204c5",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 62ca1a0f667a10d006193f43171ea7c482f204c5 UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


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



[GitHub] [flink] flinkbot edited a comment on pull request #13914: [FLINK-19890][table][fs-connector] Introduce LimitableBulkFormat to wrap BulkFormat when limit pushed down

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #13914:
URL: https://github.com/apache/flink/pull/13914#issuecomment-721482737


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "62ca1a0f667a10d006193f43171ea7c482f204c5",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=8939",
       "triggerID" : "62ca1a0f667a10d006193f43171ea7c482f204c5",
       "triggerType" : "PUSH"
     }, {
       "hash" : "800a929258db1d388bbb1ea4d7ebc21551aad5f8",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "800a929258db1d388bbb1ea4d7ebc21551aad5f8",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 62ca1a0f667a10d006193f43171ea7c482f204c5 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=8939) 
   * 800a929258db1d388bbb1ea4d7ebc21551aad5f8 UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


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



[GitHub] [flink] flinkbot edited a comment on pull request #13914: [FLINK-19890][table][fs-connector] Introduce LimitableBulkFormat to wrap BulkFormat when limit pushed down

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #13914:
URL: https://github.com/apache/flink/pull/13914#issuecomment-721482737


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "62ca1a0f667a10d006193f43171ea7c482f204c5",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=8939",
       "triggerID" : "62ca1a0f667a10d006193f43171ea7c482f204c5",
       "triggerType" : "PUSH"
     }, {
       "hash" : "800a929258db1d388bbb1ea4d7ebc21551aad5f8",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=8947",
       "triggerID" : "800a929258db1d388bbb1ea4d7ebc21551aad5f8",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 62ca1a0f667a10d006193f43171ea7c482f204c5 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=8939) 
   * 800a929258db1d388bbb1ea4d7ebc21551aad5f8 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=8947) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


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



[GitHub] [flink] flinkbot commented on pull request #13914: [FLINK-19890][table][fs-connector] Introduce LimitableBulkFormat to wrap BulkFormat when limit pushed down

Posted by GitBox <gi...@apache.org>.
flinkbot commented on pull request #13914:
URL: https://github.com/apache/flink/pull/13914#issuecomment-721476381


   Thanks a lot for your contribution to the Apache Flink project. I'm the @flinkbot. I help the community
   to review your pull request. We will use this comment to track the progress of the review.
   
   
   ## Automated Checks
   Last check on commit 241cccab53984e13bcaeb09c08899af893f83985 (Wed Nov 04 02:27:23 UTC 2020)
   
   **Warnings:**
    * No documentation files were touched! Remember to keep the Flink docs up to date!
   
   
   <sub>Mention the bot in a comment to re-run the automated checks.</sub>
   ## Review Progress
   
   * ❓ 1. The [description] looks good.
   * ❓ 2. There is [consensus] that the contribution should go into to Flink.
   * ❓ 3. Needs [attention] from.
   * ❓ 4. The change fits into the overall [architecture].
   * ❓ 5. Overall code [quality] is good.
   
   Please see the [Pull Request Review Guide](https://flink.apache.org/contributing/reviewing-prs.html) for a full explanation of the review process.<details>
    The Bot is tracking the review progress through labels. Labels are applied according to the order of the review items. For consensus, approval by a Flink committer of PMC member is required <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot approve description` to approve one or more aspects (aspects: `description`, `consensus`, `architecture` and `quality`)
    - `@flinkbot approve all` to approve all aspects
    - `@flinkbot approve-until architecture` to approve everything until `architecture`
    - `@flinkbot attention @username1 [@username2 ..]` to require somebody's attention
    - `@flinkbot disapprove architecture` to remove an approval you gave earlier
   </details>


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



[GitHub] [flink] JingsongLi merged pull request #13914: [FLINK-19890][table][fs-connector] Introduce LimitableBulkFormat to wrap BulkFormat when limit pushed down

Posted by GitBox <gi...@apache.org>.
JingsongLi merged pull request #13914:
URL: https://github.com/apache/flink/pull/13914


   


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



[GitHub] [flink] flinkbot edited a comment on pull request #13914: [FLINK-19890][table][fs-connector] Introduce LimitableBulkFormat to wrap BulkFormat when limit pushed down

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #13914:
URL: https://github.com/apache/flink/pull/13914#issuecomment-721482737


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "62ca1a0f667a10d006193f43171ea7c482f204c5",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=8939",
       "triggerID" : "62ca1a0f667a10d006193f43171ea7c482f204c5",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 62ca1a0f667a10d006193f43171ea7c482f204c5 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=8939) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


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



[GitHub] [flink] lirui-apache commented on a change in pull request #13914: [FLINK-19890][table][fs-connector] Introduce LimitableBulkFormat to wrap BulkFormat when limit pushed down

Posted by GitBox <gi...@apache.org>.
lirui-apache commented on a change in pull request #13914:
URL: https://github.com/apache/flink/pull/13914#discussion_r517130765



##########
File path: flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/filesystem/LimitableBulkFormat.java
##########
@@ -0,0 +1,133 @@
+/*
+ * 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.filesystem;
+
+import org.apache.flink.api.common.typeinfo.TypeInformation;
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.connector.file.src.FileSourceSplit;
+import org.apache.flink.connector.file.src.reader.BulkFormat;
+import org.apache.flink.connector.file.src.util.RecordAndPosition;
+
+import javax.annotation.Nullable;
+
+import java.io.IOException;
+import java.util.concurrent.atomic.AtomicLong;
+
+/**
+ * A {@link BulkFormat} that can limit output record number.
+ */
+public class LimitableBulkFormat<T, SplitT extends FileSourceSplit> implements BulkFormat<T, SplitT> {
+
+	private static final long serialVersionUID = 1L;
+
+	private final BulkFormat<T, SplitT> format;
+	private final long limit;
+
+	private transient AtomicLong numRead;
+
+	private LimitableBulkFormat(BulkFormat<T, SplitT> format, long limit) {
+		this.format = format;
+		this.limit = limit;
+	}
+
+	@Override
+	public Reader<T> createReader(Configuration config, SplitT split) throws IOException {
+		return new LimitableReader(format.createReader(config, split));
+	}
+
+	@Override
+	public Reader<T> restoreReader(Configuration config, SplitT split) throws IOException {
+		return new LimitableReader(format.restoreReader(config, split));
+	}
+
+	@Override
+	public boolean isSplittable() {
+		return format.isSplittable();
+	}
+
+	@Override
+	public TypeInformation<T> getProducedType() {
+		return format.getProducedType();
+	}
+
+	private class LimitableReader implements Reader<T> {
+
+		private final Reader<T> reader;
+
+		private LimitableReader(Reader<T> reader) {
+			this.reader = reader;
+		}
+
+		@Nullable
+		@Override
+		public RecordIterator<T> readBatch() throws IOException {
+			if (reachLimit()) {
+				return null;
+			}
+
+			RecordIterator<T> batch = reader.readBatch();
+			return batch == null ? null : new LimitableIterator(batch);
+		}
+
+		@Override
+		public void close() throws IOException {
+			reader.close();
+		}
+	}
+
+	private class LimitableIterator implements RecordIterator<T> {
+
+		private final RecordIterator<T> iterator;
+
+		private LimitableIterator(RecordIterator<T> iterator) {
+			this.iterator = iterator;
+		}
+
+		@Nullable
+		@Override
+		public RecordAndPosition<T> next() {
+			if (reachLimit()) {
+				return null;
+			}
+			getNumRead().incrementAndGet();
+			return iterator.next();
+		}
+
+		@Override
+		public void releaseBatch() {
+			iterator.releaseBatch();
+		}
+	}
+
+	private AtomicLong getNumRead() {
+		if (numRead == null) {
+			numRead = new AtomicLong(0);

Review comment:
       If the init can only happen in `readBatch`, I think it's better to move it to `readBatch`. And other code can directly use `numRead`.




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



[GitHub] [flink] flinkbot edited a comment on pull request #13914: [FLINK-19890][table][fs-connector] Introduce LimitableBulkFormat to wrap BulkFormat when limit pushed down

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #13914:
URL: https://github.com/apache/flink/pull/13914#issuecomment-721482737


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "62ca1a0f667a10d006193f43171ea7c482f204c5",
       "status" : "CANCELED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=8939",
       "triggerID" : "62ca1a0f667a10d006193f43171ea7c482f204c5",
       "triggerType" : "PUSH"
     }, {
       "hash" : "800a929258db1d388bbb1ea4d7ebc21551aad5f8",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=8947",
       "triggerID" : "800a929258db1d388bbb1ea4d7ebc21551aad5f8",
       "triggerType" : "PUSH"
     }, {
       "hash" : "88a254243687687de1b626aeed306f4c622150a6",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=8950",
       "triggerID" : "88a254243687687de1b626aeed306f4c622150a6",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 62ca1a0f667a10d006193f43171ea7c482f204c5 Azure: [CANCELED](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=8939) 
   * 800a929258db1d388bbb1ea4d7ebc21551aad5f8 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=8947) 
   * 88a254243687687de1b626aeed306f4c622150a6 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=8950) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


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