You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apex.apache.org by DT-Priyanka <gi...@git.apache.org> on 2016/03/11 13:51:37 UTC

[GitHub] incubator-apex-malhar pull request: APEXMALHAR-1985: Using startRo...

Github user DT-Priyanka commented on a diff in the pull request:

    https://github.com/apache/incubator-apex-malhar/pull/182#discussion_r55825355
  
    --- 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 --
    
    This logic is going to be removed by next pull request for cassandra scan, so not changing it.


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