Called when the result stream reads a new chunk.

@param {Chunk} chunk
321486
function onResultStreamData(chunk)
  {
    // unsubscribe from the result stream's 'data' and 'close' events
    resultStream.removeListener('data', onResultStreamData);
    resultStream.removeListener('close', onResultStreamClose);

    // get all the rows in the chunk that overlap with the requested window,
    // and use the resulting array as the new row buffer
    var chunkStart = chunk.getStartIndex();
    var chunkEnd = chunk.getEndIndex();
    rowBuffer = chunk.getRows().slice(
        Math.max(chunkStart, start) - chunkStart,
        Math.min(chunkEnd, end) + 1 - chunkStart);

    // reset the row index
    rowIndex = 0;

    // process the row buffer
    processRowBuffer();
  }
26371
function(chunk){
            if(printOutput){
                if (chunk.indexOf(options.matchString) !== -1) {
                    child_process.stdout.removeListener('data', detachIfStarted);
                    printOutput = false;
                    done();
                }
            }
        }
1260979
function(base_url, callback, cors) {
    var recv = new XhrReceiver(base_url + '/chunking_test', {cors: cors});
    var result = 0;
    recv.onmessage = function(e) {
        // Now a cool hack: we can stop receiving after we got at least
        // one chunk, contains some data, but not everyting.
        var l = e.responsetext.split('h\n').length;
        if(e.readystate === 3 && l > 0 && l < 6 ) {
            result = l;
            recv.abort();
        }
    };
    recv.onclose = function(e) {
        recv = recv.onmessage = recv.onclose = null;
        utils.log('Chunking test: ' + (result ? 'passed' : 'failed')
                  + ' (' + result + ' chunk received)');
        callback(!!result);
    };
}
1115260
function(viewers, req) {
  var stream = bl();

  req.on('data', function(chunk) {
    stream.append(chunk);
  });

  req.on('end', function() {
    var data = stream.toString('ascii');
    console.log('Dispatching: ' + data);
  })
}
83251
public final void setDataSegment (final IDataSegmentChunk chunk) {

        if (chunk == null) { throw new NullPointerException(); }

        dataSegment = ByteBuffer.allocate(chunk.getTotalLength());
        dataSegment.put(chunk.getData());
        basicHeaderSegment.setDataSegmentLength(chunk.getLength());
    }
375997
def _stream_helper(self, response, decode=False):
        """"""

        if response.raw._fp.chunked:
            if decode:
                for chunk in json_stream(self._stream_helper(response, False)):
                    yield chunk
            else:
                reader = response.raw
                while not reader.closed:
                    # this read call will block until we get a chunk
                    data = reader.read(1)
                    if not data:
                        break
                    if reader._fp.chunk_left:
                        data += reader.read(reader._fp.chunk_left)
                    yield data
        else:
            # Response isn't chunked, meaning we probably
            # encountered an error immediately
            yield self._result(response, json=decode)
1265156
private void writeChunk(String spaceId, ChunkInputStream chunk)
        throws NotFoundException {
        // Write chunk as a temp file
        String chunkId = chunk.getChunkId();
        File chunkFile = IOUtil.writeStreamToFile(chunk);

        try {
            String chunkChecksum = getChunkChecksum(chunkFile);

            // Write chunk if it is not already in storage (or jumpstart is enabled)
            if (jumpStart || !chunkInStorage(spaceId, chunkId, chunkChecksum)) {
                try {
                    createRetrier().execute(new Retriable() {
                        private int attempt = 0;

                        @Override
                        public Object retry() throws Exception {
                            attempt++;
                            try (InputStream chunkStream = new FileInputStream(chunkFile)) {
                                ChunkInputStream chunkFileStream =
                                    new ChunkInputStream(chunkId,
                                                         chunkStream,
                                                         chunkFile.length(),
                                                         chunk.md5Preserved());
                                writeSingle(spaceId, chunkChecksum, chunkFileStream, attempt == getMaxRetries() + 1);
                            }
                            return "";
                        }
                    });

                } catch (Exception e) {
                    String err = "Failed to store chunk with ID " + chunkId +
                                 " in space " + spaceId + " after " + getMaxRetries() +
                                 " attempts. Last error: " + e.getMessage();
                    throw new DuraCloudRuntimeException(err, e);
                }
            }
        } finally {
            if (null != chunkFile && chunkFile.exists()) {
                FileUtils.deleteQuietly(chunkFile);
            }
        }
    }
148122
private void addCoord(Chunk chunk, BlockPos pos)
	{
		chunks(chunk).add(chunk, pos);
	}
527139
function (chunks) {
	var groupedChunks = [];
	var inCommentBlock = false;
	chunks.forEach(function (chunk) {
		var isComment = helpers.isComment(chunk);
		var isNewline = helpers.isNewline(chunk);
		if (isComment) {
			inCommentBlock = true;
		} else if (inCommentBlock && !isNewline) {
			inCommentBlock = false;
		}

		var previous = groupedChunks[groupedChunks.length - 1];
		var previousIsComment = helpers.isComment(previous);
		var previousIsArray = Array.isArray(previous);
		if (groupedChunks.length > 0 && inCommentBlock && (previousIsComment || previousIsArray)) {
			if (previousIsArray) {
				previous.push(chunk);
			} else if (previousIsComment) {
				groupedChunks[groupedChunks.length - 1] = [].concat(previous, chunk);
			}
		} else {
			groupedChunks.push(chunk);
		}
	});
	return groupedChunks;
}
1301623
function ChunkedStreamManager_groupChunks(chunks) {
      var groupedChunks = [];
      var beginChunk = -1;
      var prevChunk = -1;
      for (var i = 0; i < chunks.length; ++i) {
        var chunk = chunks[i];

        if (beginChunk < 0) {
          beginChunk = chunk;
        }

        if (prevChunk >= 0 && prevChunk + 1 !== chunk) {
          groupedChunks.push({ beginChunk: beginChunk,
                               endChunk: prevChunk + 1 });
          beginChunk = chunk;
        }
        if (i + 1 === chunks.length) {
          groupedChunks.push({ beginChunk: beginChunk,
                               endChunk: chunk + 1 });
        }

        prevChunk = chunk;
      }
      return groupedChunks;
    }
852793
@Override
    public Chunk<byte[], BytesReference> readChunk() throws IOException {
        Chunk<byte[], BytesReference> chunk = internalReadChunk();
        if (chunk != null) {
            processChunk(chunk);
        }
        return chunk;
    }
325928
private void nextChunk() throws IOException {
        if (!bof) {
            readCRLF();
        }
        chunkSize = getChunkSizeFromInputStream(in);
        bof = false;
        pos = 0;
        if (chunkSize == 0) {
            eof = true;
            parseTrailerHeaders();
        }
    }
1140451
function ChunkStreamWithStream(stream, options) {
  ChunkStream.call(this, options);

  stream.pause(); // Pause stream and wait for data listener. It's useful for node v0.8
  this._stream = stream;
  this._stream.on('end', this.end.bind(this)); // Should catch the end event for node v0.8
}
645741
def _handle_read_chunk(self):
        """"""
        new_data = b''
        buffer_length = len(self.read_buffer)
        try:
            while buffer_length < self.MAX_BUFFER_SIZE:
                try:
                    piece = self.recv(4096)
                except OSError as e:
                    if e.errno == errno.EAGAIN:
                        # End of the available data
                        break
                    elif e.errno == errno.EIO and new_data:
                        # Hopefully we could read an error message before the
                        # actual termination
                        break
                    else:
                        raise

                if not piece:
                    # A closed connection is indicated by signaling a read
                    # condition, and having recv() return 0.
                    break

                new_data += piece
                buffer_length += len(piece)

        finally:
            new_data = new_data.replace(b'\r', b'\n')
            self.read_buffer += new_data
        return new_data
700352
function chunk(start, end) {
                // Slice, unescape and push onto result array.
                res.push(str.slice(start, end).replace(/\\\\/g, '\\').replace(/\\\./g, '.'));
                // Set starting position of next chunk.
                pos = end + 1;
            }
1114836
@Override
  public int read(byte []buf, int offset, int len) throws IOException
  {
    int available = _available;
    
    // The chunk still has more data left
    if (available > 0) {
      len = Math.min(len, available);

      len = _next.read(buf, offset, len);

      if (len > 0) {
        _available -= len;
      }
    }
    // The chunk is done, so read the next chunk
    else if (available == 0) {
      _available = readChunkLength();

      // the new chunk has data
      if (_available > 0) {
        len = Math.min(len, _available);

        len = _next.read(buf, offset, len);

        if (len > 0)
          _available -= len;
      }
      // the new chunk is the last
      else {
        _available = -1;
        len = -1;
      }
    }
    else {
      len = -1;
    }
    
    return len;
  }
6814
function push (chunk) {
		if (!isAudioBuffer(chunk)) {
			chunk = util.create(chunk, channels)
		}

		data.append(chunk)

		isEmpty = false;
	}