Memory usage of jq's --slurp option

对着背影说爱祢 提交于 2021-01-28 03:42:24

问题


Does the --slurp option load the entire input in memory before processing it or has it been optimized somehow in order to avoid that?


回答1:


The answer to the question is essentially "yes". Commands such as "jq --slurp . FILE ...." store the parsed input as an array in memory. This will often require more memory than the size of the input itself -- consider for example that JSON objects are stored as hash tables.

With jq 1.5 there are often better alternatives than "slurping" the input. Most notably, perhaps, the inputs filter works very nicely with reduce and foreach. (If you do use inputs then don't forget you will probably want to invoke jq with the "-n" option.)



来源:https://stackoverflow.com/questions/34778425/memory-usage-of-jqs-slurp-option

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