我想使用已经使用bzip2压缩的boost来解压缩文件
我尝试了以下操作,导致无法解释的错误
std::stringstream readData(const std::string path) {
std::stringstream myStream;
std::ifstream input(path,std::ios_base::in);
boost::iostreams::filtering_streambuf<boost::iostreams::input>in;
in.push(input);
in.push(boost::iostreams::bzip2_decompressor());
boost::iostreams::copy(in,myStream);
return myStream;
}
我使用c ++ 17,boost 1.58和gcc 8.0来编译上面的代码
并出现以下错误:
terminate called after throwing an instance of 'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injectorstd::logic_error >'
what(): chain complete
将感谢您提供有关如何解决此问题的帮助/提示
答案 0 :(得分:1)
设备必须是您推送到CASE..WHEN
中的最后一项,在您推送设备之后,您将不能再推送其他任何东西,这就是您得到错误的原因。参见https://www.boost.org/doc/libs/1_68_0/libs/iostreams/doc/classes/filtering_streambuf.html#policy_push
您的代码应为:
SELECT
dt.id,
dt.Start,
dt.Stop,
@rn := CASE WHEN dt.itemId = @itm THEN @rn + 1
ELSE 1
END AS Count,
@itm := dt.itemId AS itemId
FROM
(
SELECT
id,
itemId,
started_at AS Start,
stopped_at AS Stop
FROM events
ORDER BY itemID, id
) AS dt
CROSS JOIN (SELECT @itm := 0, @rn := 0) AS user_init_vars