nifi-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From qfdk <...@git.apache.org>
Subject [GitHub] nifi pull request #1376: NIFI-3268 Add AUTO_INCREMENT column in GenerateTabl...
Date Tue, 14 Feb 2017 23:41:11 GMT
Github user qfdk commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/1376#discussion_r101172356
  
    --- Diff: nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/GenerateTableFetch.java
---
    @@ -223,19 +237,34 @@ public void onTrigger(final ProcessContext context, final ProcessSessionFactory
                 }
                 final int numberOfFetches = (partitionSize == 0) ? rowCount : (rowCount /
partitionSize) + (rowCount % partitionSize == 0 ? 0 : 1);
     
    +            if("null".equals(indexValue)) {
    +                // Generate SQL statements to read "pages" of data
    +                for (int i = 0; i < numberOfFetches; i++) {
    +                    FlowFile sqlFlowFile;
     
    -            // Generate SQL statements to read "pages" of data
    -            for (int i = 0; i < numberOfFetches; i++) {
    -                FlowFile sqlFlowFile;
    +                    Integer limit = partitionSize == 0 ? null : partitionSize;
    +                    Integer offset = partitionSize == 0 ? null : i * partitionSize;
    +                    final String query = dbAdapter.getSelectStatement(tableName, columnNames,
whereClause, StringUtils.join(maxValueColumnNameList, ", "), limit, offset);
    +                    sqlFlowFile = session.create();
    +                    sqlFlowFile = session.write(sqlFlowFile, out -> {
    +                        out.write(query.getBytes());
    +                    });
    +                    session.transfer(sqlFlowFile, REL_SUCCESS);
    +                }
    +            }else {
    +                for (int i = 0; i < numberOfFetches; i++) {
    +                    FlowFile sqlFlowFile;
     
    -                Integer limit = partitionSize == 0 ? null : partitionSize;
    -                Integer offset = partitionSize == 0 ? null : i * partitionSize;
    -                final String query = dbAdapter.getSelectStatement(tableName, columnNames,
whereClause, StringUtils.join(maxValueColumnNameList, ", "), limit, offset);
    -                sqlFlowFile = session.create();
    -                sqlFlowFile = session.write(sqlFlowFile, out -> {
    -                    out.write(query.getBytes());
    -                });
    -                session.transfer(sqlFlowFile, REL_SUCCESS);
    +                    Integer limit = partitionSize;
    +                    whereClause = indexValue + " >= " + limit * i;
    --- End diff --
    
    i will take a look for that, thank you for your advice :)


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