在HDFS中存储普通的JSON将在MongoDB中使用

发布于 2025-01-18 22:17:05 字数 261 浏览 1 评论 0原文

我正在从不同的 API 获取 JSON 数据。我想将它们存储在 HDFS 中,然后在 MongoDB 中使用它们。

我是否需要将它们转换为 avro、序列文件、parquet 等,或者我可以简单地将它们存储为纯 JSON 并稍后将它们加载到数据库中?

我知道如果我将它们转换为另一种格式,它们将得到更好的分发和压缩,但是我如何才能将 avro 文件上传到 MongoDB? MongoDB 仅接受 JSON。我应该采取另一个步骤从 avro 读取它们并将它们转换为 JSON 吗?

I am fetching JSON data from different API's. I want to store them in HDFS and then use them in MongoDB.

Do I need to convert them to avro, sequence file, parquet, etc., or can I simply store them as plain JSON and load them to the database later?

I know that if i convert them to another format they will get distributed better and compressed, but how will I be able then to upload an avro file to MongoDB? MongoDB only accepts JSON. Should I do another step to read them from avro and convert them to JSON?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

半﹌身腐败 2025-01-25 22:17:05

您获取的数据有多大?如果每个文件小于128MB(或不带压缩),则实际上不应该在HDF中。

要回答这个问题,格式并不重要。您可以使用SparkSQL读取任何Hadoop格式(或JSON),以加载到Mongo(反之亦然)中。

或者,您可以将数据首先写入Kafka,然后使用Kafka Connect等过程同时写入HDFS和Mongo。

How large is the data you're fetching? If it's less than 128MB (with or without compression) per file, it really shouldn't be in HDFS.

To answer the question, format doesn't really matter. You can use SparkSQL to read any Hadoop format (or JSON) to load into Mongo (and vice versa).

Or you can write the data first to Kafka, then use a process such as Kafka Connect to write to both HDFS and Mongo at the same time.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文