@ipld/car -carreader用于大文件(内容地址为存档)

发布于 2025-02-12 16:58:35 字数 1016 浏览 1 评论 0原文

我正在尝试使用@ipld/car从.car文件(内容地址存档)创建读者。该文档显示了如何创建carreader当文件较小时,如下所示:

import { CarReader } from '@ipld/car'

const inStream = fs.createReadStream('example.car');
// read and parse the entire stream in one go, this will cache the contents of
// the car in memory so is not suitable for large files.
const reader = await CarReader.fromIterable(inStream);

问题:如果我有一个文件c:\ output.car,则说10GB并且比我可用的RAM更大,如何为此大型.car文件创建读者?

我认为这应该是这些方法之一,但是没有关于如何使用它的示例代码...

import { CarBlockIterator } from '@ipld/car/iterator';
// or
import { CarCIDIterator } from '@ipld/car/iterator';

source

I'm trying to create a reader from a .car file (Content Addressed Archive) using @ipld/car. The documentation shows how to create a carReader when files are small as per below:

import { CarReader } from '@ipld/car'

const inStream = fs.createReadStream('example.car');
// read and parse the entire stream in one go, this will cache the contents of
// the car in memory so is not suitable for large files.
const reader = await CarReader.fromIterable(inStream);

Source

Question: If I have a file at C:\output.car, and it's say 10GB and larger than my available RAM, how can I create a reader for this large .car file?

I think it should be one of these methods, but there's no sample code on how to use it...

import { CarBlockIterator } from '@ipld/car/iterator';
// or
import { CarCIDIterator } from '@ipld/car/iterator';

Source

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

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

发布评论

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

评论(1

逆光下的微笑 2025-02-19 16:58:35

弄清楚了。这有效:

import { CarIndexedReader } from '@ipld/car';

const filename = "C:\output.car"
const carReader = await CarIndexedReader.fromFile(filename);

Figured it out. This works:

import { CarIndexedReader } from '@ipld/car';

const filename = "C:\output.car"
const carReader = await CarIndexedReader.fromFile(filename);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文