Yaml到数据库 [英] Yaml to database

查看:409
本文介绍了Yaml到数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于我的c ++程序,我使用jobs.yml,其中包含有关Yaml格式的作业的信息,例如:

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

然后,我使用 yaml-cpp 库来解析文件并将作业转换为c ++ 对象.由于jobs.yml的大小(〜900Mb),我无法在程序开始时一次读取所有文件并将其存储在RAM中.

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.

我如何克服这一障碍? 我想我应该将jobs.yml转换为数据库,并在程序中通过sql请求获得所需的数据?在这种情况下,我该怎么办?

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.

这篇关于Yaml到数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆