부스트 스피릿 QI로 TPCH 파일을 구문 분석하려고합니다. 내 구현은 Spirit QI (http://www.boost.org/doc/libs/1_52_0/libs/spirit/example/qi/employee.cpp)의 직원 예제에서 영감을 받았습니다. 데이터는 CSV 형식이며 토큰은 '|'로 구분됩니다. 캐릭터.부스트 스피릿 QI 느림
매우 느립니다 (1GB의 경우 20 초).
이struct lineitem {
int l_orderkey;
int l_partkey;
int l_suppkey;
int l_linenumber;
std::string l_quantity;
std::string l_extendedprice;
std::string l_discount;
std::string l_tax;
std::string l_returnflag;
std::string l_linestatus;
std::string l_shipdate;
std::string l_commitdate;
std::string l_recepitdate;
std::string l_shipinstruct;
std::string l_shipmode;
std::string l_comment;
};
BOOST_FUSION_ADAPT_STRUCT(lineitem,
(int, l_orderkey)
(int, l_partkey)
(int, l_suppkey)
(int, l_linenumber)
(std::string, l_quantity)
(std::string, l_extendedprice)
(std::string, l_discount)
(std::string, l_tax)
(std::string, l_returnflag)
(std::string, l_linestatus)
(std::string, l_shipdate)
(std::string, l_commitdate)
(std::string, l_recepitdate)
(std::string, l_shipinstruct)
(std::string, l_shipmode)
(std::string, l_comment))
vector<lineitem>* lineitems=new vector<lineitem>();
phrase_parse(state->dataPointer,
state->dataEndPointer,
(*(int_ >> "|" >>
int_ >> "|" >>
int_ >> "|" >>
int_ >> "|" >>
+(char_ - '|') >> "|" >>
+(char_ - '|') >> "|" >>
+(char_ - '|') >> "|" >>
+(char_ - '|') >> "|" >>
+(char_ - '|') >> '|' >>
+(char_ - '|') >> '|' >>
+(char_ - '|') >> '|' >>
+(char_ - '|') >> '|' >>
+(char_ - '|') >> '|' >>
+(char_ - '|') >> '|' >>
+(char_ - '|') >> '|' >>
+(char_ - '|') >> '|'
)), space, *lineitems
);
문제는 문자 구문 분석 것 같다 :
여기에 광고 항목이 파일에 대한 내 제나라 문법이다. 그것은 다른 전환보다 훨씬 느립니다. 가변 길이 토큰을 문자열로 구문 분석하는 더 좋은 방법이 있습니까?
한 번 같은 경험이 있습니다. Spirit qi는 가변 길이 문자열을 효율적으로 처리하지 못하는 것 같습니다. 누구든지 해결책이 있습니까? – muehlbau