我有一个模拟,其中我需要转储大量数据,通常在大约50GB左右的数量,而代码正在运行,这通常发生在几周的数量级。现在,我将数据导出为legacy ASCII VTK
个文件。
我想知道是否有任何方法来压缩数据,因为它被写入磁盘,所以我可以节省一些空间(我需要同时运行多个版本的代码)。如果可能的话,我更喜欢标准库中的东西。
答案 0 :(得分:3)
如果你可以使用boost,请查看zlib过滤器compressor and decompressor
#include <fstream>
#include <iostream>
#include <boost/iostreams/filtering_streambuf.hpp>
#include <boost/iostreams/copy.hpp>
#include <boost/iostreams/filter/zlib.hpp>
int main()
{
using namespace std;
ifstream file("hello.z", ios_base::in | ios_base::binary);
filtering_streambuf<input> in;
in.push(zlib_decompressor());
in.push(file);
boost::iostreams::copy(in, cout);
}