hadoop - 打开 IgnitePath 时如何获取 InputStream(返回 HadoopIgfsSecondaryFileSystemPositionedReadable)?
问题描述
通常,在使用 Hadoop 和 Flink 时,从分布式文件系统打开/读取文件将返回扩展 java.io.InputStream 的 Source(Sink 的对应物)对象。
但是,在 Apache Ignite 中,IgfsSecondaryFileSystem,更具体地说是 IgniteHadoopIgfsSecondaryFileSystem,在调用其“ open ”方法(通过传递 IgfsPath)时返回 HadoopIgfsSecondaryFileSystemPositionedReadable 类型的对象。
HadoopIgfsSecondaryFileSystemPositionedReadable提供了一种“读取”方法,但需要了解有关要读取的数据所在位置的详细信息,例如输入流位置。
/**
* Read up to the specified number of bytes, from a given position within a file, and return the number of bytes
* read.
*
* @param pos Position in the input stream to seek.
* @param buf Buffer into which data is read.
* @param off Offset in the buffer from which stream data should be written.
* @param len The number of bytes to read.
* @return Total number of bytes read into the buffer, or -1 if there is no more data (EOF).
* @throws IOException In case of any exception.
*/
public int read(long pos, byte[] buf, int off, int len) throws IOException;
如何在调用read方法之前确定这些细节?
我对这些框架很陌生,也许存在一种不同的方法来获取基于指向存储在 Hadoop 文件系统中的文件的 IgfsPath 的 InputStream?
我正在尝试实现此处描述的内容:https ://apacheignite-fs.readme.io/docs/secondary-file-system
提前感谢您的任何提示!
解决方案
不应直接使用IgfsSecondaryFileSystem接口。您可以将 Hadoop 集群配置为用作读取和写入操作的辅助 FS。
IgfsSecondaryFileSystem只能在配置中指定为FileSystemConfiguration#secondaryFileSystem属性。
您应该改用IgniteFileSystem接口。您可以通过调用Ignite#fileSystem(...)方法获取它的实例。要通过 IGFS 获取InputStream
路径,可以使用IgniteFileSystem#open(...)方法。
推荐阅读
- python - 从 .asp 文件中获取数据
- strapi - 保存 CurrentUser.id 最安全的方法是什么?
- ruby-on-rails - 如何在 Rails 表单中设置默认 url
- angularjs - Angularjs:自定义双向绑定属性指令
- python - 无法发送包含西里尔字母的电子邮件
- ruby - 关于类和方法继承的问题
- r - 无法在ggplot中绘制图形
- stored-procedures - 如何使用 .NET Core 中的 EF Core 在 foreach 循环中执行存储过程?
- azure - 通过 azure 数据工厂进行 upsert 活动期间的延迟
- javascript - 数组以错误的顺序出现