Yaml to database

三世轮回 提交于 2020-01-15 12:23:29

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/42859942/yaml-to-database

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!