Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id F31E4200D17 for ; Wed, 30 Aug 2017 16:53:07 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id F02CC169234; Wed, 30 Aug 2017 14:53:07 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 44EFB169236 for ; Wed, 30 Aug 2017 16:53:07 +0200 (CEST) Received: (qmail 60168 invoked by uid 500); 30 Aug 2017 14:53:06 -0000 Mailing-List: contact commits-help@flink.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@flink.apache.org Delivered-To: mailing list commits@flink.apache.org Received: (qmail 59998 invoked by uid 99); 30 Aug 2017 14:53:06 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 30 Aug 2017 14:53:06 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 179FFF32FA; Wed, 30 Aug 2017 14:53:06 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: chesnay@apache.org To: commits@flink.apache.org Date: Wed, 30 Aug 2017 14:53:07 -0000 Message-Id: <8173f98f84214831874c0fe2ae968389@git.apache.org> In-Reply-To: <84402dab212a46cfa89d40a9a9e953b8@git.apache.org> References: <84402dab212a46cfa89d40a9a9e953b8@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [2/2] flink git commit: [FLINK-7556] Allow Integer.MIN_VALUE for fetch size in JDBCInputFormat archived-at: Wed, 30 Aug 2017 14:53:08 -0000 [FLINK-7556] Allow Integer.MIN_VALUE for fetch size in JDBCInputFormat Allow Integer.MIN_VALUE to be accepted as a parameter for setFetchSize for MySQL Driver. The combination of a forward-only, read-only result set, with a fetch size of Integer.MIN_VALUE serves as a signal to the driver to stream result sets row-by-row. After this, any result sets created with the statement will be retrieved row-by-row. This closes #4617. Project: http://git-wip-us.apache.org/repos/asf/flink/repo Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/e753db84 Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/e753db84 Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/e753db84 Branch: refs/heads/master Commit: e753db8411debfc573ffc330355a0f24c0afbfb5 Parents: 1b7f8bd Author: Nycholas de Oliveira e Oliveira Authored: Tue Aug 29 14:21:03 2017 -0300 Committer: zentol Committed: Wed Aug 30 16:51:32 2017 +0200 ---------------------------------------------------------------------- .../apache/flink/api/java/io/jdbc/JDBCInputFormat.java | 5 +++-- .../flink/api/java/io/jdbc/JDBCInputFormatTest.java | 11 +++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flink/blob/e753db84/flink-connectors/flink-jdbc/src/main/java/org/apache/flink/api/java/io/jdbc/JDBCInputFormat.java ---------------------------------------------------------------------- diff --git a/flink-connectors/flink-jdbc/src/main/java/org/apache/flink/api/java/io/jdbc/JDBCInputFormat.java b/flink-connectors/flink-jdbc/src/main/java/org/apache/flink/api/java/io/jdbc/JDBCInputFormat.java index b7ac744..7d08814 100644 --- a/flink-connectors/flink-jdbc/src/main/java/org/apache/flink/api/java/io/jdbc/JDBCInputFormat.java +++ b/flink-connectors/flink-jdbc/src/main/java/org/apache/flink/api/java/io/jdbc/JDBCInputFormat.java @@ -144,7 +144,7 @@ public class JDBCInputFormat extends RichInputFormat implements dbConn = DriverManager.getConnection(dbURL, username, password); } statement = dbConn.prepareStatement(queryTemplate, resultSetType, resultSetConcurrency); - if (fetchSize > 0) { + if (fetchSize == Integer.MIN_VALUE || fetchSize > 0) { statement.setFetchSize(fetchSize); } } catch (SQLException se) { @@ -390,7 +390,8 @@ public class JDBCInputFormat extends RichInputFormat implements } public JDBCInputFormatBuilder setFetchSize(int fetchSize) { - Preconditions.checkArgument(fetchSize > 0, "Illegal value %s for fetchSize, has to be positive.", fetchSize); + Preconditions.checkArgument(fetchSize == Integer.MIN_VALUE || fetchSize > 0, + "Illegal value %s for fetchSize, has to be positive or Integer.MIN_VALUE.", fetchSize); format.fetchSize = fetchSize; return this; } http://git-wip-us.apache.org/repos/asf/flink/blob/e753db84/flink-connectors/flink-jdbc/src/test/java/org/apache/flink/api/java/io/jdbc/JDBCInputFormatTest.java ---------------------------------------------------------------------- diff --git a/flink-connectors/flink-jdbc/src/test/java/org/apache/flink/api/java/io/jdbc/JDBCInputFormatTest.java b/flink-connectors/flink-jdbc/src/test/java/org/apache/flink/api/java/io/jdbc/JDBCInputFormatTest.java index f7a86e5..10e8c66 100644 --- a/flink-connectors/flink-jdbc/src/test/java/org/apache/flink/api/java/io/jdbc/JDBCInputFormatTest.java +++ b/flink-connectors/flink-jdbc/src/test/java/org/apache/flink/api/java/io/jdbc/JDBCInputFormatTest.java @@ -114,6 +114,17 @@ public class JDBCInputFormatTest extends JDBCTestBase { } @Test + public void testValidFetchSizeIntegerMin() { + jdbcInputFormat = JDBCInputFormat.buildJDBCInputFormat() + .setDrivername(DRIVER_CLASS) + .setDBUrl(DB_URL) + .setQuery(SELECT_ALL_BOOKS) + .setRowTypeInfo(ROW_TYPE_INFO) + .setFetchSize(Integer.MIN_VALUE) + .finish(); + } + + @Test public void testDefaultFetchSizeIsUsedIfNotConfiguredOtherwise() throws SQLException, ClassNotFoundException { jdbcInputFormat = JDBCInputFormat.buildJDBCInputFormat() .setDrivername(DRIVER_CLASS)