lib/connection/result/result.js
function(chunk)
  {
    // get all the rows in the current chunk that overlap with the requested
    // window
    var chunkStart = chunk.getStartIndex();
    var chunkEnd   = chunk.getEndIndex();
    var rows       = chunk.getRows().slice(
        Math.max(chunkStart, start) - chunkStart,
        Math.min(chunkEnd, end) + 1 - chunkStart);

    var rowIndex = 0;
    var rowsLength = rows.length;

    // create a function that can be called to batch-process rows
    var processRows = function()
    {
      // get the start position and start time
      var startIndex = rowIndex;
      var startTime  = Date.now();

      var each = options.each;
      while (rowIndex < rowsLength)
      {
        // invoke the each() callback on the current row
        var ret = each(rows[rowIndex++]);

        context.numRowsProcessed++;

        // if the callback returned false, stop processing rows
        if (ret === false)
        {
          var stoppedProcessingRows = true;
          break;
        }

        // use the current position and current time to check if we've been
        // processing rows for too long; if so, leave the rest for the next
        // tick of the event loop
        if ((rowIndex - startIndex) >= context.rowBatchSize &&
            (Date.now() - startTime) > context.rowBatchDuration)
        {
          process.nextTick(processRows);
          break;
        }
      }

      // if there are no more rows for us to process in this chunk
      if (!(rowIndex < rowsLength) || stoppedProcessingRows)
      {
        // if we exhausted all the rows in this chunk and we haven't yet
        // processed all the rows we want to process, ask the result stream to
        // do another read
        if (!(rowIndex < rowsLength) &&
            context.numRowsProcessed !== context.maxNumRowsToProcess)
        {
          resultStream.read();
        }
        else
        {
          // we've either processed all the rows we wanted to process or we
          // were told to stop processing rows by the each() callback; either
          // way, close the result stream to complete the operation
          resultStream.asyncClose();
        }
      }
    };

    // start processing rows
    processRows();
  }
function(chunk)
  {
    // get all the rows in the current chunk that overlap with the requested
    // window
    var chunkStart = chunk.getStartIndex();
    var chunkEnd   = chunk.getEndIndex();
    var rows       = chunk.getRows().slice(
        Math.max(chunkStart, start) - chunkStart,
        Math.min(chunkEnd, end) + 1 - chunkStart);

    var rowIndex = 0;
    var rowsLength = rows.length;

    // create a function that can be called to batch-process rows
    var processRows = function()
    {
      // get the start position and start time
      var startIndex = rowIndex;
      var startTime  = Date.now();

      var each = options.each;
      while (rowIndex < rowsLength)
      {
        // invoke the each() callback on the current row
        var ret = each(rows[rowIndex++]);

        context.numRowsProcessed++;

        // if the callback returned false, stop processing rows
        if (ret === false)
        {
          var stoppedProcessingRows = true;
          break;
        }

        // use the current position and current time to check if we've been
        // processing rows for too long; if so, leave the rest for the next
        // tick of the event loop
        if ((rowIndex - startIndex) >= context.rowBatchSize &&
            (Date.now() - startTime) > context.rowBatchDuration)
        {
          process.nextTick(processRows);
          break;
        }
      }

      // if there are no more rows for us to process in this chunk
      if (!(rowIndex < rowsLength) || stoppedProcessingRows)
      {
        // if we exhausted all the rows in this chunk and we haven't yet
        // processed all the rows we want to process, ask the result stream to
        // do another read
        if (!(rowIndex < rowsLength) &&
            context.numRowsProcessed !== context.maxNumRowsToProcess)
        {
          resultStream.read();
        }
        else
        {
          // we've either processed all the rows we wanted to process or we
          // were told to stop processing rows by the each() callback; either
          // way, close the result stream to complete the operation
          resultStream.asyncClose();
        }
      }
    };

    // start processing rows
    processRows();
  }
function ( chunk ) { // get all the rows in the current chunk that overlap with the requested // window var chunkStart = chunk . getStartIndex ( ) ; var chunkEnd = chunk . getEndIndex ( ) ; var rows = chunk . getRows ( ) . slice ( Math . max ( chunkStart , start ) - chunkStart , Math . min ( chunkEnd , end ) + 1 - chunkStart ) ; var rowIndex = 0 ; var rowsLength = rows . length ; // create a function that can be called to batch-process rows var processRows = function ( ) { // get the start position and start time var startIndex = rowIndex ; var startTime = Date . now ( ) ; var each = options . each ; while ( rowIndex < rowsLength ) { // invoke the each() callback on the current row var ret = each ( rows [ rowIndex ++ ] ) ; context . numRowsProcessed ++ ; // if the callback returned false, stop processing rows if ( ret === false ) { var stoppedProcessingRows = true ; break ; } // use the current position and current time to check if we've been // processing rows for too long; if so, leave the rest for the next // tick of the event loop if ( ( rowIndex - startIndex ) >= context . rowBatchSize && ( Date . now ( ) - startTime ) > context . rowBatchDuration ) { process . nextTick ( processRows ) ; break ; } } // if there are no more rows for us to process in this chunk if ( ! ( rowIndex < rowsLength ) || stoppedProcessingRows ) { // if we exhausted all the rows in this chunk and we haven't yet // processed all the rows we want to process, ask the result stream to // do another read if ( ! ( rowIndex < rowsLength ) && context . numRowsProcessed !== context . maxNumRowsToProcess ) { resultStream . read ( ) ; } else { // we've either processed all the rows we wanted to process or we // were told to stop processing rows by the each() callback; either // way, close the result stream to complete the operation resultStream . asyncClose ( ) ; } } } ; // start processing rows processRows ( ) ; }
Processes the rows in a given chunk.

@param {Object} chunk
Processes the rows in a given chunk .