对于我的c ++程序,我使用jobs.yml ,其中包含有关yaml格式的作业的信息,如:
141647523: JobType: Turbo LocalJobID: 16773779.0 Status: Done SystemPriority: 0.0 UserPriority: 8.0然后我使用yaml-cpp库来解析文件并将作业转换为c ++ Job对象。 由于jobs.yml (~900Mb)的大小,我无法在程序开头一次读取所有文件并存储在RAM 。
我怎样才能克服这个障碍? 我想我应该将jobs.yml转换为数据库并在程序中通过sql请求获取所需的数据? 在这种情况下我该怎么办?
或者可能有更简单的解决方案?
For my c++ program, I use jobs.yml which contains information about jobs in yaml format like:
141647523: JobType: Turbo LocalJobID: 16773779.0 Status: Done SystemPriority: 0.0 UserPriority: 8.0Then I use yaml-cpp library for parsing file and casting jobs to c++ Job objects. Due to the big size of jobs.yml (~900Mb) I can't read all file at once at the beginning of the program and store in RAM.
How can I overcome this obstacle? I guess that I should convert jobs.yml to database and in the program get desired data through sql requests? In this case what I should do?
Or maybe there are available more simple solutions?
最满意答案
yaml-cpp有一个基于事件的API。 只是派生自YAML::EventHandler并使用YAML::Parser.HandleNextDocument 。 然后逐个处理事件处理程序中的事件。 这样可以避免将整个文件加载到RAM中。
yaml-cpp has an event-based API. Just derive from YAML::EventHandler and use YAML::Parser.HandleNextDocument. Then process the events in your event handler one-by-one. This should save you from loading the whole file into RAM.
更多推荐
发布评论