Yaml到数据库(Yaml to database)

编程入门 行业动态 更新时间:2024-10-27 16:30:39
Yaml到数据库(Yaml to database)

对于我的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.0

Then 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.

更多推荐

本文发布于:2023-07-15 19:09:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1117630.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数据库   Yaml   database

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!