C++ C++;文件备份的树状数据结构

C++ C++;文件备份的树状数据结构,c++,database,file,random-access,C++,Database,File,Random Access,我目前正在使用google的protobuffer库来存储和加载磁盘上的数据。 它非常方便,因为它速度快,提供了一种很好的定义数据结构的方法,允许在写入/读取文件时压缩/解压缩数据 到目前为止,这对我很有帮助。现在的问题是,我必须处理一个几百GB大的数据结构,而protobuf只能写入和加载整个文件 数据结构看起来是这样的 struct Layer { std::vector<float> weights_; std::vector<size_t> indices

我目前正在使用google的protobuffer库来存储和加载磁盘上的数据。 它非常方便,因为它速度快,提供了一种很好的定义数据结构的方法,允许在写入/读取文件时压缩/解压缩数据

到目前为止,这对我很有帮助。现在的问题是,我必须处理一个几百GB大的数据结构,而protobuf只能写入和加载整个文件

数据结构看起来是这样的

struct Layer {
  std::vector<float> weights_;
  std::vector<size_t> indices_;
};

struct Cell {
  std::vector<Layer> layers_;
};

struct Data {
  int some_header_fields;
  ...
  std::vector<Cell> cells_;
};
此时,权重数组/列表和索引数组/列表会将其当前数据写入磁盘(并释放相关内存),但保留其索引,以便我可以在运行时向其中添加更多数据

稍后在算法的第二部分,我可以做如下的事情

Data.cells_[i].populate(); //now all data for cell i has been loaded into ram from the file
... process cell i...
Data.cells_[i].dispose();  //now all data for cell i is removed from memory but remains in the file
此外,为了将数据存储到磁盘,我希望它还支持数据压缩。它还应该允许多线程访问

什么图书馆能让我做到这一点?或者我还能以某种方式使用protobuf吗?(我想不会,因为我不会以序列化方式将数据写入磁盘)

//编辑:
性能非常重要。因此,当我填充单元格时,我需要将数据放在主存和连续数组中

对不起,stackoverflow.com的软件建议是离题的。我不是在找软件,我正在寻找一种库或编程方法。您是否考虑过使用NoSQL数据库(如MongoDB)?我见过一位客户使用ObjectStore进行类似的操作(如果您同意使用专有产品)。
Data.cells_[i].populate(); //now all data for cell i has been loaded into ram from the file
... process cell i...
Data.cells_[i].dispose();  //now all data for cell i is removed from memory but remains in the file