| 54 | } |
| 55 | |
| 56 | Status FindFirst(std::string_view partial, std::string_view block, |
| 57 | int64_t* out_pos) override { |
| 58 | ARROW_ASSIGN_OR_RAISE(auto input, GetPaddedStringView(partial, block)); |
| 59 | ARROW_ASSIGN_OR_RAISE(auto consumed_length, FindDocument(input, /*find_last=*/false)); |
| 60 | |
| 61 | DCHECK_NE(consumed_length, std::string_view::npos); |
| 62 | if (consumed_length == 0) { |
| 63 | *out_pos = kNoDelimiterFound; |
| 64 | } else if (ARROW_PREDICT_FALSE(consumed_length <= partial.size())) { |
| 65 | // Something bad happened: partial wasn't supposed to be a full document |
| 66 | return Status::Invalid("JSON parse error: invalid data at end of document"); |
| 67 | } else { |
| 68 | consumed_length -= partial.size(); |
| 69 | DCHECK_LE(consumed_length, block.size()); |
| 70 | *out_pos = static_cast<int64_t>(consumed_length); |
| 71 | } |
| 72 | return Status::OK(); |
| 73 | } |
| 74 | |
| 75 | Status FindLast(std::string_view block, int64_t* out_pos) override { |
| 76 | ARROW_ASSIGN_OR_RAISE(auto input, GetPaddedStringView(/*partial=*/"", block)); |