beam-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbono...@apache.org
Subject [1/2] beam git commit: [BEAM-1660] Update JdbcIO JavaDoc about withCoder() use to ensure the examples runnable
Date Wed, 15 Mar 2017 13:11:25 GMT
Repository: beam
Updated Branches:
  refs/heads/master 806c53c18 -> bb9ae7350


[BEAM-1660] Update JdbcIO JavaDoc about withCoder() use to ensure the examples runnable


Project: http://git-wip-us.apache.org/repos/asf/beam/repo
Commit: http://git-wip-us.apache.org/repos/asf/beam/commit/ffd777d1
Tree: http://git-wip-us.apache.org/repos/asf/beam/tree/ffd777d1
Diff: http://git-wip-us.apache.org/repos/asf/beam/diff/ffd777d1

Branch: refs/heads/master
Commit: ffd777d15eba358bd5b14ec299a17d96399312a0
Parents: 806c53c
Author: mingmxu <mingmxu@ebay.com>
Authored: Wed Mar 8 15:42:46 2017 -0800
Committer: Jean-Baptiste Onofré <jbonofre@apache.org>
Committed: Wed Mar 15 10:01:53 2017 +0800

----------------------------------------------------------------------
 .../src/main/java/org/apache/beam/sdk/io/jdbc/JdbcIO.java | 10 ++++++++--
 .../test/java/org/apache/beam/sdk/io/jdbc/JdbcIOTest.java |  2 +-
 2 files changed, 9 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/beam/blob/ffd777d1/sdks/java/io/jdbc/src/main/java/org/apache/beam/sdk/io/jdbc/JdbcIO.java
----------------------------------------------------------------------
diff --git a/sdks/java/io/jdbc/src/main/java/org/apache/beam/sdk/io/jdbc/JdbcIO.java b/sdks/java/io/jdbc/src/main/java/org/apache/beam/sdk/io/jdbc/JdbcIO.java
index c625287..1b83fe9 100644
--- a/sdks/java/io/jdbc/src/main/java/org/apache/beam/sdk/io/jdbc/JdbcIO.java
+++ b/sdks/java/io/jdbc/src/main/java/org/apache/beam/sdk/io/jdbc/JdbcIO.java
@@ -70,11 +70,13 @@ import org.apache.commons.dbcp2.BasicDataSource;
  *        .withUsername("username")
  *        .withPassword("password"))
  *   .withQuery("select id,name from Person")
+ *   .withCoder(KvCoder.of(BigEndianIntegerCoder.of(), StringUtf8Coder.of()))
  *   .withRowMapper(new JdbcIO.RowMapper<KV<Integer, String>>() {
  *     public KV<Integer, String> mapRow(ResultSet resultSet) throws Exception {
  *       return KV.of(resultSet.getInt(1), resultSet.getString(2));
  *     }
  *   })
+ * );
  * }</pre>
  *
  * <p>Query parameters can be configured using a user-provided {@link StatementPreparator}.
@@ -86,6 +88,7 @@ import org.apache.commons.dbcp2.BasicDataSource;
  *       "com.mysql.jdbc.Driver", "jdbc:mysql://hostname:3306/mydb",
  *       "username", "password"))
  *   .withQuery("select id,name from Person where name = ?")
+ *   .withCoder(KvCoder.of(BigEndianIntegerCoder.of(), StringUtf8Coder.of()))
  *   .withStatementPreparator(new JdbcIO.StatementPreparator() {
  *     public void setParameters(PreparedStatement preparedStatement) throws Exception {
  *       preparedStatement.setString(1, "Darwin");
@@ -96,6 +99,7 @@ import org.apache.commons.dbcp2.BasicDataSource;
  *       return KV.of(resultSet.getInt(1), resultSet.getString(2));
  *     }
  *   })
+ * );
  * }</pre>
  *
  * <h3>Writing to JDBC datasource</h3>
@@ -116,11 +120,13 @@ import org.apache.commons.dbcp2.BasicDataSource;
  *          .withPassword("password"))
  *      .withStatement("insert into Person values(?, ?)")
  *      .withPreparedStatementSetter(new JdbcIO.PreparedStatementSetter<KV<Integer,
String>>() {
- *        public void setParameters(KV<Integer, String> element, PreparedStatement
query) {
+ *        public void setParameters(KV<Integer, String> element, PreparedStatement
query)
+ *          throws SQLException {
  *          query.setInt(1, kv.getKey());
  *          query.setString(2, kv.getValue());
  *        }
  *      })
+ *    );
  * }</pre>
  *
  * <p>NB: in case of transient failures, Beam runners may execute parts of JdbcIO.Write
multiple
@@ -277,7 +283,7 @@ public class JdbcIO {
       return toBuilder().setQuery(query).build();
     }
 
-    public Read<T> withStatementPrepator(StatementPreparator statementPreparator) {
+    public Read<T> withStatementPreparator(StatementPreparator statementPreparator)
{
       checkArgument(statementPreparator != null,
           "JdbcIO.read().withStatementPreparator(statementPreparator) called "
               + "with null statementPreparator");

http://git-wip-us.apache.org/repos/asf/beam/blob/ffd777d1/sdks/java/io/jdbc/src/test/java/org/apache/beam/sdk/io/jdbc/JdbcIOTest.java
----------------------------------------------------------------------
diff --git a/sdks/java/io/jdbc/src/test/java/org/apache/beam/sdk/io/jdbc/JdbcIOTest.java b/sdks/java/io/jdbc/src/test/java/org/apache/beam/sdk/io/jdbc/JdbcIOTest.java
index 32573ea..4e82338 100644
--- a/sdks/java/io/jdbc/src/test/java/org/apache/beam/sdk/io/jdbc/JdbcIOTest.java
+++ b/sdks/java/io/jdbc/src/test/java/org/apache/beam/sdk/io/jdbc/JdbcIOTest.java
@@ -223,7 +223,7 @@ public class JdbcIOTest implements Serializable {
                      .withDataSourceConfiguration(JdbcIO.DataSourceConfiguration.create(dataSource))
                      .withQuery(String.format("select name,id from %s where name = ?",
                          JdbcTestDataSet.READ_TABLE_NAME))
-                     .withStatementPrepator(new JdbcIO.StatementPreparator() {
+                     .withStatementPreparator(new JdbcIO.StatementPreparator() {
                        @Override
                        public void setParameters(PreparedStatement preparedStatement)
                                throws Exception {


Mime
View raw message