- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想做什么
我正在使用 PyArrow读取一些 CSV 并将它们转换为 Parquet。我阅读的一些文件有很多列并且占用大量内存(足以使运行该作业的机器崩溃),因此我正在分块读取文件。
这就是我用来生成箭头表的函数的样子(为简洁起见的片段):
import pyarrow as pa
import pyarrow.parquet as pq
from pyarrow import csv as arrow_csv
def generate_arrow_tables(
input_buffer: pa.lib.Buffer,
arrow_schema: pa.Schema,
batch_size: int
) -> Generator[pa.Table, None, None]:
"""
Generates an Arrow Table from given data.
:param batch_size: Size of batch streamed from CSV at a time
:param input_buffer: Takes in an Arrow BufferOutputStream
:param arrow_schema: Takes in an Arrow Schema
:return: Returns an Arrow Table
"""
# Preparing convert options
co = arrow_csv.ConvertOptions(column_types=arrow_schema, strings_can_be_null=True)
# Preparing read options
ro = arrow_csv.ReadOptions(block_size=batch_size)
# Streaming contents of CSV into batches
with arrow_csv.open_csv(input_buffer, convert_options=co, read_options=ro) as stream_reader:
for chunk in stream_reader:
if chunk is None:
break
# Emit batches from generator. Arrow schema is inferred unless explicitly specified
yield pa.Table.from_batches(batches=[chunk], schema=arrow_schema)
这就是我使用该函数将批处理写入 S3 的方式(为简洁起见的片段):
GB = 1024 ** 3
# data.size here is the size of the buffer
arrow_tables: Generator[Table, None, None] = generate_arrow_tables(pg_data, arrow_schema, min(data.size, GB ** 10))
# Iterate through generated tables and write to S3
count = 0
for table in arrow_tables:
count += 1 # Count based on batch size
# Write keys to S3
file_name = f'{ARGS.run_id}-{count}.parquet'
write_to_s3(table, output_path=f"s3://{bucket}/{bucket_prefix}/{file_name}")
出了什么问题
我收到以下错误 OverflowError: value too large to convert to int32_t
这里是堆栈跟踪(为简洁起见的片段):
[2021-08-04 11:26:45,479] {pod_launcher.py:156} INFO - b' ro = arrow_csv.ReadOptions(block_size=batch_size)\n'
[2021-08-04 11:26:45,479] {pod_launcher.py:156} INFO - b' File "pyarrow/_csv.pyx", line 87, in pyarrow._csv.ReadOptions.__init__\n'
[2021-08-04 11:26:45,479] {pod_launcher.py:156} INFO - b' File "pyarrow/_csv.pyx", line 119, in pyarrow._csv.ReadOptions.block_size.__set__\n'
[2021-08-04 11:26:45,479] {pod_launcher.py:156} INFO - b'OverflowError: value too large to convert to int32_t\n'
如何调试和/或修复此问题?
如果需要,我很乐意提供更多信息
最佳答案
如果我理解正确,generate_arrow_tables
的第三个参数是 batch_size
,您将其作为 block_size
传递给 CSV 阅读器。我不确定 data.size
的值是多少,但你用 min(data.size, GB ** 10)
来保护它。
10GB 的 block_size
将不起作用。您收到的错误是 block 大小不适合带符号的 32 位整数(最大 ~2GB)。
除此限制外,我不确定使用比默认值 (1MB) 大得多的 block 大小是否是个好主意。我不认为您会看到很多性能优势,并且您最终会使用比您需要的更多的 RAM。
关于python - 如何调试 OverflowError : value too large to convert to int32_t?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68652157/
根据在线文档,这些固定宽度整数类型之间存在差异。对于 int*_t,我们将宽度固定为 * 的值。然而对于其他两种类型,描述中使用形容词最快和最小来请求底层数据模型提供的最快或最小实例。 “最快”或“最
我是 Python 注释的新手(类型提示)。我注意到 pyi 中的许多类定义文件继承到 Generic[_T] , 和 _T = TypeVar('_T') . 我很困惑,_T 是什么意思?这里的意思
这个问题在这里已经有了答案: How to use a variable inside a _T wrapper? (3 个答案) 关闭 7 年前。 我有以下代码: CString port = m
要包含 _T() 宏,我应该包含什么文件?它转换我认为的文本文字。我以为它是 windows.h,但我已经包含了它。 令人惊讶的是,我无法在 Google 上找到答案。 最佳答案 我在主题 Unico
类型的后缀 _t 由 POSIX 保留,但是如果我在自己的命名空间中使用 _t 后缀定义自己的类型怎么办? 最佳答案 我同意 user6366161 的 answer,其中说“C 对 namespac
我知道 size_t 有 _t 后缀,因为它的别名/typedef。但是我不明白为什么 char16_t, char32_t 和 wchar_t 包含 _t 后缀。 最佳答案 对于 wchar_t :
我想让这个字符串的主机名部分可变..目前,它只修复了这个 URL: _T(" --url=http://www.myurl.com/ --out=c:\\current.png"); 我想做这样的东西
这个问题在这里已经有了答案: convert string to _T in cpp (6 个答案) 关闭 7 年前。 string pagexx = "http://website.com/" +
我有一个注册为 COM 对象的 .net 库,当在 C++ 项目中导入 .tlb 文件时,我得到这样的方法声明 virtual HRESULT __stdcall GetBid ( /*[
我现在遇到了很多 Unicode 问题。据我了解,TCHAR 被定义为 wchar_t 或 char,具体取决于 _UNICODE 是否在某处定义,并且还有各种其他功能可以帮助解决这个问题。显然 _T
关闭。这个问题需要details or clarity .它目前不接受答案。 想改进这个问题吗? 通过 editing this post 添加细节并澄清问题. 关闭 9 年前。 Improve t
我正在尝试使用 _t() 方法翻译一个 DataObject。 我一直在 Pages 上使用它没有问题,但它似乎不适用于数据对象。 class SliderItem extends DataObjec
关于保留 _t 结尾名称的规则是否也适用于作用域名称(例如,在 namespace 或类中定义的类型和类型定义),还是仅适用于全局 namespace 中的类型和类型定义?标准 C/C++ 库或 PO
我确定以前有人问过这个问题,但我无法搜索到文本。如果有人可以解释它们,请给我推荐一篇文章,或者给我正确的搜索查询,我将不胜感激。 谢谢。 最佳答案 这只是一种预感,但看看 Wikipedia C++1
我有一个 UNICODE 应用程序,我们使用 _T(x) 定义如下。 #if defined(_UNICODE) #define _T(x) L ##x #else #define _T(x) x #
我一直想知道是否存在任何命名约定,例如何时对类型使用 ALLCAPS 以及何时附加 _t(以及何时不使用任何东西?)。我知道以前 K&R 发布了各种关于如何使用 C 的文档,但我找不到任何相关内容。
这似乎是一个简单的问题,但我无法通过 Stack Overflow 搜索或 Google 找到它。类型后跟 _t 是什么意思?比如 int_t anInt; 我在 C 代码中经常看到它与硬件密切相关—
C++ 有时使用后缀 _type关于类型定义(例如 std::vector::value_type ),有时_t (例如 std::size_t ),或者没有后缀(普通类,还有像 std::strin
字符串中的“T”代表什么。例如 _T("Hello")。我在需要 unicode 支持的项目中看到了这一点。它实际上告诉处理器什么 最佳答案 _T 代表“文本”。当且仅当您使用 Unicode 支持编
我的代码可以根据 C++ 类型识别您需要使用的 GL 类型。我想制作它的 _t 版本(如 std::decay_t 或 std::enable_if_t)但公开 int常量值 template st
我是一名优秀的程序员,十分优秀!