* Decompress the log file that was open()-ed and print the message out in * an arbitrary order (i.e. dependent on runtime implementation and not * necessarily in chronological order). * * \param outputFd * The file descriptor to print the log messages to * \param aggregationTargetId * Target logId to run the aggregation function on * \param aggregationFn * Aggregation funct
| 1700 | * outputted to outputFd; |
| 1701 | */ |
| 1702 | bool |
| 1703 | Log::Decoder::internalDecompressUnordered(FILE* outputFd, |
| 1704 | uint32_t aggregationTargetId, |
| 1705 | void(*aggregationFn)(const char*,...)) |
| 1706 | { |
| 1707 | if (filename.empty() || !inputFd) |
| 1708 | return false; |
| 1709 | |
| 1710 | LogMessage logArguments; |
| 1711 | BufferFragment *bf = allocateBufferFragment(); |
| 1712 | while(!feof(inputFd) && good) { |
| 1713 | bool wrapAround = false; |
| 1714 | |
| 1715 | EntryType entry = peekEntryType(inputFd); |
| 1716 | switch (entry) { |
| 1717 | case EntryType::BUFFER_EXTENT: |
| 1718 | { |
| 1719 | if (!bf->readBufferExtent(inputFd, &wrapAround)){ |
| 1720 | fprintf(stderr, |
| 1721 | "Internal Error: Corrupted BufferExtent\r\n"); |
| 1722 | break; |
| 1723 | } |
| 1724 | |
| 1725 | ++numBufferFragmentsRead; |
| 1726 | while (bf->hasNext()) { |
| 1727 | bf->decompressNextLogStatement(outputFd, |
| 1728 | logMsgsPrinted, |
| 1729 | logArguments, |
| 1730 | checkpoint, |
| 1731 | fmtId2metadata, |
| 1732 | aggregationTargetId, |
| 1733 | aggregationFn); |
| 1734 | } |
| 1735 | break; |
| 1736 | } |
| 1737 | case EntryType::CHECKPOINT: |
| 1738 | if (!readDictionary(inputFd, true)) |
| 1739 | good = false; |
| 1740 | else if (outputFd) |
| 1741 | fprintf(outputFd, "\r\n# New execution started\r\n"); |
| 1742 | |
| 1743 | break; |
| 1744 | case EntryType::LOG_MSGS_OR_DIC: |
| 1745 | good = readDictionaryFragment(inputFd); |
| 1746 | break; |
| 1747 | case EntryType::INVALID: |
| 1748 | // Consume whitespace |
| 1749 | while (!feof(inputFd) && peekEntryType(inputFd) == INVALID) |
| 1750 | fgetc(inputFd); |
| 1751 | break; |
| 1752 | } |
| 1753 | } |
| 1754 | |
| 1755 | if (outputFd) |
| 1756 | fprintf(outputFd, "\r\n\r\n# Decompression Complete after printing " |
| 1757 | "%lu log messages\r\n", logMsgsPrinted); |
| 1758 | |
| 1759 | freeBufferFragment(bf); |