apex-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bhupeshchawda <...@git.apache.org>
Subject [GitHub] incubator-apex-malhar pull request: APEXMALHAR-1966: Update casand...
Date Wed, 06 Apr 2016 13:37:15 GMT
Github user bhupeshchawda commented on a diff in the pull request:

    https://github.com/apache/incubator-apex-malhar/pull/227#discussion_r58705296
  
    --- Diff: contrib/src/main/java/com/datatorrent/contrib/cassandra/CassandraPOJOOutputOperator.java
---
    @@ -172,25 +197,32 @@ public void deactivate()
       @Override
       protected PreparedStatement getUpdateCommand()
       {
    +    PreparedStatement statement;
    +    if (query == null) {
    +      statement = prepareStatementFromFieldsAndTableName();
    +    } else {
    +      statement = store.getSession().prepare(query);
    +    }
    +    LOG.debug("Statement is: " + statement.getQueryString());
    +    return statement;
    +  }
    +
    +  private PreparedStatement prepareStatementFromFieldsAndTableName()
    +  {
         StringBuilder queryfields = new StringBuilder();
         StringBuilder values = new StringBuilder();
    -    for (FieldInfo fieldInfo: fieldInfos) {
    +    for (FieldInfo fieldInfo : fieldInfos) {
           if (queryfields.length() == 0) {
             queryfields.append(fieldInfo.getColumnName());
             values.append("?");
    -      }
    -      else {
    +      } else {
             queryfields.append(",").append(fieldInfo.getColumnName());
             values.append(",").append("?");
           }
         }
    -    String statement
    -            = "INSERT INTO " + store.keyspace + "."
    -            + tablename
    -            + " (" + queryfields.toString() + ") "
    -            + "VALUES (" + values.toString() + ");";
    -    LOG.debug("statement is {}", statement);
    +    String statement = "INSERT INTO " + store.keyspace + "." + tablename + " (" + queryfields.toString()
+ ") " + "VALUES (" + values.toString() + ");";
    --- End diff --
    
    have a check for null tablename, since ```@NotNull``` is now removed


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message