* Read the file's postscript from the given buffer. * @param stream the file stream * @param buffer the buffer with the tail of the file. * @param postscriptSize the length of postscript in bytes */
| 1515 | * @param postscriptSize the length of postscript in bytes |
| 1516 | */ |
| 1517 | std::unique_ptr<proto::PostScript> readPostscript(InputStream* stream, DataBuffer<char>* buffer, |
| 1518 | uint64_t postscriptSize) { |
| 1519 | char* ptr = buffer->data(); |
| 1520 | uint64_t readSize = buffer->size(); |
| 1521 | |
| 1522 | ensureOrcFooter(stream, buffer, postscriptSize); |
| 1523 | |
| 1524 | auto postscript = std::make_unique<proto::PostScript>(); |
| 1525 | if (readSize < 1 + postscriptSize) { |
| 1526 | std::stringstream msg; |
| 1527 | msg << "Invalid ORC postscript length: " << postscriptSize |
| 1528 | << ", file length = " << stream->getLength(); |
| 1529 | throw ParseError(msg.str()); |
| 1530 | } |
| 1531 | if (!postscript->ParseFromArray(ptr + readSize - 1 - postscriptSize, |
| 1532 | static_cast<int>(postscriptSize))) { |
| 1533 | throw ParseError("Failed to parse the postscript from " + stream->getName()); |
| 1534 | } |
| 1535 | return postscript; |
| 1536 | } |
| 1537 | |
| 1538 | /** |
| 1539 | * Check that proto Types are valid. Indices in the type tree should be valid, |
no test coverage detected