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-1985: Using startRo...
Date Sat, 26 Mar 2016 02:49:18 GMT
Github user bhupeshchawda commented on a diff in the pull request:

    https://github.com/apache/incubator-apex-malhar/pull/182#discussion_r57507869
  
    --- Diff: contrib/src/main/java/com/datatorrent/contrib/cassandra/CassandraPOJOInputOperator.java
---
    @@ -359,24 +373,43 @@ public void emitTuples()
       {
         super.emitTuples();
         if (lastRowInBatch != null) {
    -      switch (primaryKeyColumnType.getName()) {
    -        case INT:
    -          startRow = lastRowInBatch.getInt(primaryKeyColumn);
    -          break;
    -        case COUNTER:
    -          startRow = lastRowInBatch.getLong(primaryKeyColumn);
    -          break;
    -        case FLOAT:
    -          startRow = lastRowInBatch.getFloat(primaryKeyColumn);
    -          break;
    -        case DOUBLE:
    -          startRow = lastRowInBatch.getDouble(primaryKeyColumn);
    -          break;
    -        default:
    -          throw new RuntimeException("unsupported data type " + primaryKeyColumnType.getName());
    -      }
    +      startRowToken = getPrimaryKeyToken(primaryKeyColumnType.getName());
         }
    +  }
     
    +  private Long getPrimaryKeyToken(DataType.Name primaryKeyDataType)
    +  {
    +    Object keyValue;
    +    switch (primaryKeyDataType) {
    +    case UUID:
    +      keyValue = lastRowInBatch.getUUID(primaryKeyColumn);
    +      break;
    +    case INT:
    +      keyValue = lastRowInBatch.getInt(primaryKeyColumn);
    +      break;
    +    case COUNTER:
    +      keyValue = lastRowInBatch.getLong(primaryKeyColumn);
    +      break;
    +    case FLOAT:
    +      keyValue = lastRowInBatch.getFloat(primaryKeyColumn);
    +      break;
    +    case DOUBLE:
    +      keyValue = lastRowInBatch.getDouble(primaryKeyColumn);
    +      break;
    +    default:
    +      throw new RuntimeException("unsupported data type " + primaryKeyColumnType.getName());
    +    }
    +    return fetchKeyTokenFromDB(keyValue);
    +  }
    +
    +  private Long fetchKeyTokenFromDB(Object keyValue)
    +  {
    +    PreparedStatement statement = store.getSession().prepare(TOKEN_QUERY);
    --- End diff --
    
    Can you move the relevant changes from #186 to this one? In case this is ever cherry-picked,
it may leave these changes as is, which might not be very efficient. 


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