| 123 | } |
| 124 | |
| 125 | Status Chunker::ProcessWithPartial(std::shared_ptr<Buffer> partial, |
| 126 | std::shared_ptr<Buffer> block, |
| 127 | std::shared_ptr<Buffer>* completion, |
| 128 | std::shared_ptr<Buffer>* rest) { |
| 129 | if (partial->size() == 0) { |
| 130 | // If partial is empty, don't bother looking for completion |
| 131 | *completion = SliceBuffer(block, 0, 0); |
| 132 | *rest = block; |
| 133 | return Status::OK(); |
| 134 | } |
| 135 | int64_t first_pos = -1; |
| 136 | RETURN_NOT_OK(boundary_finder_->FindFirst(std::string_view(*partial), |
| 137 | std::string_view(*block), &first_pos)); |
| 138 | if (first_pos == BoundaryFinder::kNoDelimiterFound) { |
| 139 | // No delimiter in block => the current object is too large for block size |
| 140 | return StraddlingTooLarge(); |
| 141 | } else { |
| 142 | *completion = SliceBuffer(block, 0, first_pos); |
| 143 | *rest = SliceBuffer(block, first_pos); |
| 144 | return Status::OK(); |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | Status Chunker::ProcessFinal(std::shared_ptr<Buffer> partial, |
| 149 | std::shared_ptr<Buffer> block, |