Javascript - 从 AWS s3 存储桶读取镶木地板数据(使用快速压缩)

2024-05-02

In nodeJS,我正在尝试读取镶木地板文件(压缩='snappy')但没有成功。

I used https://github.com/ironSource/parquetjs https://github.com/ironSource/parquetjsnpm 模块打开本地文件并读取它,但 reader.cursor() 抛出神秘错误'尚未实现'。无论使用哪种压缩(plain、rle 或 snappy)来创建输入文件,都会引发相同的错误。

这是我的代码:

const readParquet = async (fileKey) => {

  const filePath = 'parquet-test-file.plain'; // 'snappy';

  console.log('----- reading file : ', filePath);
  let reader = await parquet.ParquetReader.openFile(filePath);
  console.log('---- ParquetReader initialized....');

  // create a new cursor
  let cursor = reader.getCursor();

  // read all records from the file and print them
  if (cursor) {
    console.log('---- cursor initialized....');

    let record = await cursor.next() ; // this line throws exception
    while (record) {
      console.log(record);
      record = await cursor.next();
    }
  }

  await reader.close();
  console.log('----- done with reading parquet file....');

  return;
};

致电阅读:

let dt = readParquet(fileKeys.dataFileKey);
dt
  .then((value) => console.log('--------SUCCESS', value))
  .catch((error) => {
    console.log('-------FAILURE ', error); // Random error
    console.log(error.stack);
  })

更多信息: 1.我已经使用 pyarrow.parquet 在 python 中生成了 parquet 文件 2.我在写入文件时使用了“SNAPPY”压缩 3.我可以在python中读取这些文件,没有任何问题 4. 每次编写镶木地板文件时,我的架构都不是固定的(未知)。我在写作时不创建模式。 5. error.stack 打印不明确的在控制台中 6. console.log('--------失败', 错误);打印“尚未实施”

我想知道是否有人遇到过类似的问题并有想法/解决方案可以分享。顺便说一句,我的镶木地板文件存储在 AWS S3 位置(与此测试代码不同)。我仍然需要找到从 S3 存储桶读取镶木地板文件的解决方案。

任何帮助、建议、代码示例将不胜感激。


Use var AWS = require('aws-sdk');从S3获取数据。

然后使用node-parquet将镶木地板文件读入变量。

import np = require('node-parquet');

// Read from a file:
var reader = new np.ParquetReader(`file.parquet`);
var parquet_info = reader.info();
var parquet_rows = reader.rows();
reader.close();
parquet_rows = parquet_rows + "\n";
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Javascript - 从 AWS s3 存储桶读取镶木地板数据(使用快速压缩) 的相关文章

随机推荐