15 #include <msgpack.hpp>
16 #include <Poco/Random.h>
25 using namespace HCE::exception;
33 return highlightStringGenerator;
38 Poco::SharedPtr<DataBase> ret =
nullptr;
39 Poco::SharedPtr<InDataHighlight> inDataHiglight = inData.cast<
InDataHighlight>();
40 if(!inDataHiglight.isNull())
43 if(!inDataHiglight->getCrossThreadBufPtr().isNull())
45 unsigned int index = 0;
46 unsigned int highlightCounter = 0;
47 unsigned long long id = 0llu;
48 unsigned long long resCrc = 0llu;
49 std::string outPutStr;
51 std::string &incomeContent = inDataHiglight->
getCrossThreadBufPtr()->getIntData(index,
id, resCrc);
52 Poco::SharedPtr<InDataStruct> inDataStructPtr = inDataHiglight->getInDataStructPtr();
53 Poco::SharedPtr<ContentsStorageBase> contentsStoragePtr = inDataHiglight->getContentsStorageBasePtr();
54 Poco::SharedPtr<std::string> contentStringPtr =
nullptr;
55 if(!incomeContent.empty() && !inDataStructPtr.isNull() && !contentsStoragePtr.isNull() && inDataStructPtr->getParamsCount() > 0)
57 wordMapPtr = contentsStoragePtr->wordMapExctract(resCrc, incomeContent);
58 contentStringPtr = Poco::SharedPtr<std::string>(
new std::string(incomeContent));
59 highlightStringGenerator.setHlBegin(inDataStructPtr->getParams(0).beginMarker);
60 highlightStringGenerator.setHlEnd(inDataStructPtr->getParams(0).endMarker);
61 highlightStringGenerator.setWordMapPtr(wordMapPtr);
62 highlightStringGenerator.setContent(contentStringPtr);
63 highlightStringGenerator.setMaxNumber(inDataStructPtr->getParams(0).maxNumber);
64 highlightStringGenerator.highlightStringStickerReinit(inDataStructPtr);
67 outPutStr = highlightStringGenerator.highlightStringGenerate(inDataStructPtr->getSearchStrings());
72 catch(std::length_error &excp)
75 highlightCounter = highlightStringGenerator.getHighlightCounts();
76 if(inDataHiglight->getCrossThreadBufPtr()->getIsSendWordsMapBack())
79 msgpack::sbuffer &localMsgPackBuff = inDataHiglight->getCrossThreadBufPtr()->getElem(index).getMsgPackBuff();
80 msgpack::pack(&localMsgPackBuff, serializeCacheData);
82 contentsStoragePtr->wordMapRelease(resCrc, wordMapPtr);
84 inDataHiglight->getCrossThreadBufPtr()->setOutData(outPutStr, highlightCounter, index);
85 inDataHiglight->getCrossThreadBufPtr()->signal();