source: icGREP/icgrep-devel/icgrep/lz4/grep/lz4_grep_base_generator.h @ 6143

Last change on this file since 6143 was 6143, checked in by xwa163, 10 months ago

lz4_grep: some bug fixing and refactor

File size: 2.6 KB
Line 
1
2#ifndef ICGREP_LZ4GREPGENERATOR_H
3#define ICGREP_LZ4GREPGENERATOR_H
4
5#include "lz4/lz4_base_generator.h"
6
7#include <grep_interface.h>
8#include <kernels/streamset.h>
9#include <cc/multiplex_CCs.h>
10#include <string>
11#include <vector>
12#include <sstream>
13#include <atomic>
14#include <grep/grep_engine.h>
15
16typedef void (*ScanMatchGrepMainFunctionType)(char * byte_data, size_t headerSize, size_t filesize, bool hasBlockChecksum, intptr_t match_accumulator);
17typedef uint64_t (*CountOnlyGrepMainFunctionType)(char * byte_data, size_t headerSize, size_t filesize, bool hasBlockChecksum);
18
19
20
21class LZ4GrepBaseGenerator : public LZ4BaseGenerator {
22public:
23
24    LZ4GrepBaseGenerator();
25
26    void generateScanMatchGrepPipeline(re::RE* regex);
27    void generateCountOnlyGrepPipeline(re::RE* regex, bool enableMultiplexing, bool utf8CC);
28
29
30    void invokeScanMatchGrep(char* fileBuffer, size_t blockStart, size_t blockEnd, bool hasBlockChecksum);
31
32    ScanMatchGrepMainFunctionType getScanMatchGrepMainFunction();
33    CountOnlyGrepMainFunctionType getCountOnlyGrepMainFunction();
34
35
36
37protected:
38    virtual parabix::StreamSetBuffer* generateUncompressedBitStreams() = 0;
39    virtual parabix::StreamSetBuffer* decompressBitStream(parabix::StreamSetBuffer* compressedByteStream, parabix::StreamSetBuffer* compressedBitStream) = 0;
40
41private:
42    grep::GrepRecordBreakKind mGrepRecordBreak;
43    void initREs(re::RE * REs);
44
45
46    re::CC * mBreakCC;
47    re:: RE * mRE;
48    std::set<re::Name *> mUnicodeProperties;
49    bool mMoveMatchesToEOL;
50
51
52    std::vector<std::ostringstream> mResultStrs;
53
54    void generateCountOnlyMainFunc(const std::unique_ptr<kernel::KernelBuilder> & iBuilder);
55    void generateScanMatchMainFunc(const std::unique_ptr<kernel::KernelBuilder> & iBuilder);
56
57
58    llvm::Value * match_accumulator;
59
60
61    parabix::StreamSetBuffer * linefeedStreamFromUncompressedBits(parabix::StreamSetBuffer *uncompressedBasisBits);
62
63
64    void generateFullyDecompressionCountOnlyGrepPipeline(re::RE *regex);
65    void generateMultiplexingCountOnlyGrepPipeline(re::RE *regex, bool utf8CC);
66
67
68    std::pair<parabix::StreamSetBuffer *, parabix::StreamSetBuffer *> grep(re::RE *RE,
69                                                                           parabix::StreamSetBuffer *uncompressedBasisBits, bool ccMultiplexing = false);
70    std::pair<parabix::StreamSetBuffer *, parabix::StreamSetBuffer *> multiplexingGrep(
71            re::RE *RE,
72            parabix::StreamSetBuffer *compressedByteStream,
73            parabix::StreamSetBuffer *compressedBitStream,
74            bool utf8CC
75    );
76    std::unique_ptr<cc::MultiplexedAlphabet> mpx;
77};
78
79
80#endif //ICGREP_LZ4GREPGENERATOR_H
Note: See TracBrowser for help on using the repository browser.