()
| 373 | } |
| 374 | |
| 375 | private void spill() throws IOException { |
| 376 | // if there isn't anything in the current buffer, don't spill |
| 377 | if (current == null || |
| 378 | current.position() == (codec == null ? 0 : HEADER_SIZE)) { |
| 379 | return; |
| 380 | } |
| 381 | flip(); |
| 382 | if (codec == null) { |
| 383 | outputBuffer(current); |
| 384 | getNewInputBuffer(); |
| 385 | } else { |
| 386 | compressedBuffer.init(); |
| 387 | int currentPosn = compressedBuffer.getCurrentPosn(); |
| 388 | compressedBuffer.advanceTo(currentPosn + HEADER_SIZE); |
| 389 | |
| 390 | // Worth compression |
| 391 | if (codec.compress(current, compressedBuffer.compressed, |
| 392 | compressedBuffer.overflow, options)) { |
| 393 | // move position back to after the header |
| 394 | uncompressedBytes = 0; |
| 395 | |
| 396 | current.position(HEADER_SIZE); |
| 397 | current.limit(current.capacity()); |
| 398 | |
| 399 | compressedBytes += compressedBuffer.commitCompress(currentPosn); |
| 400 | } else { |
| 401 | compressedBytes += uncompressedBytes + HEADER_SIZE; |
| 402 | uncompressedBytes = 0; |
| 403 | |
| 404 | compressedBuffer.abortCompress(currentPosn); |
| 405 | |
| 406 | // now add the current buffer into the done list and get a new one. |
| 407 | current.position(0); |
| 408 | // update the header with the current length |
| 409 | writeHeader(current, 0, current.limit() - HEADER_SIZE, true); |
| 410 | outputBuffer(current); |
| 411 | getNewInputBuffer(); |
| 412 | } |
| 413 | } |
| 414 | } |
| 415 | |
| 416 | @Override |
| 417 | public void getPosition(PositionRecorder recorder) { |
no test coverage detected