Github user mattyb149 commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/3051#discussion_r228332165
  
    --- Diff: 
nifi-nar-bundles/nifi-cassandra-bundle/nifi-cassandra-processors/src/main/java/org/apache/nifi/processors/cassandra/QueryCassandra.java
 ---
    @@ -400,77 +478,87 @@ public static long convertToJsonStream(final 
ResultSet rs, final OutputStream ou
                 outStream.write("{\"results\":[".getBytes(charset));
                 final ColumnDefinitions columnDefinitions = 
rs.getColumnDefinitions();
                 long nrOfRows = 0;
    +            long rowsAvailableWithoutFetching = 
rs.getAvailableWithoutFetching();
    +
                 if (columnDefinitions != null) {
    -                do {
    -
    -                    // Grab the ones we have
    -                    int rowsAvailableWithoutFetching = 
rs.getAvailableWithoutFetching();
    -                    if (rowsAvailableWithoutFetching == 0) {
    -                        // Get more
    -                        if (timeout <= 0 || timeUnit == null) {
    -                            rs.fetchMoreResults().get();
    -                        } else {
    -                            rs.fetchMoreResults().get(timeout, timeUnit);
    -                        }
    +
    +                // Grab the ones we have
    +                if (rowsAvailableWithoutFetching == 0) {
    +                    // Get more
    +                    if (timeout <= 0 || timeUnit == null) {
    +                        rs.fetchMoreResults().get();
    +                    } else {
    +                        rs.fetchMoreResults().get(timeout, timeUnit);
                         }
    +                    rowsAvailableWithoutFetching = 
rs.getAvailableWithoutFetching();
    +                }
     
    -                    for (Row row : rs) {
    -                        if (nrOfRows != 0) {
    +                if(maxRowsPerFlowFile == 0){
    +                    maxRowsPerFlowFile = rowsAvailableWithoutFetching;
    +                }
    +                Row row;
    +                while(nrOfRows < maxRowsPerFlowFile){
    +                    try {
    +                        row = rs.iterator().next();
    +                    }catch (NoSuchElementException nsee){
    +                        //nrOfRows -= 1;
    --- End diff --
    
    This is commented out here but active in the Avro version above, I assume 
they need to be the same?


---

Reply via email to