Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

VectorAppender fails with OversizedAllocationException when appending to empty UnionVector

未关闭
#812 0 条评论 3 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
55/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
停滞
技术栈
java
领域
data

调研方向

从 VectorAppender.java 第556行附近的循环开始,检查 UnionVector.getValueCapacity(),包括 NonNullableStructVector.java 第373行附近的代码。运行提供的 testAppendEmptyTargetUnionVector 复现,并比较 reAlloc() 前后的容量。当向空的 UnionVector 追加数据时能够在没有 OversizedAllocationException 的情况下完成,并保留全部五个 float 值,即表示完成。

由索引模型根据 Issue 内容生成。

描述

Type: bug
Describe the bug, including details regarding any error messages, version, and platform.

Description:
When appending a UnionVector to an empty target UnionVector, this while loop runs infinitely until the exception occurs:

org.apache.arrow.vector.util.OversizedAllocationException: Unable to expand the buffer

It seems to be a issue with the UnionVector.getValueCapacity() method. Logging the capacity before and after calling reAlloc() shows that it's always 0.
Debugging further, it seems like the value capacity of the internalStruct in the UnionVector always returns 0 because it has no children so size is 0.

 @Override
  public int getValueCapacity() {
    return Math.min(getTypeBufferValueCapacity(), internalStruct.getValueCapacity());
  }

Steps to reproduce

  @Test
  public void testAppendEmptyTargetUnionVector() {
    final int length = 5;

    try (final UnionVector target = UnionVector.empty("target", allocator);
         final UnionVector delta = UnionVector.empty("delta", allocator)) {

      // populate the delta vector
      delta.setType(0, Types.MinorType.FLOAT4);
      delta.setType(1, Types.MinorType.FLOAT4);
      delta.setType(2, Types.MinorType.FLOAT4);
      delta.setType(3, Types.MinorType.FLOAT4);
      delta.setType(4, Types.MinorType.FLOAT4);

      Float4Vector deltaFloatVector = delta.getFloat4Vector();
      deltaFloatVector.allocateNew();
      ValueVectorDataPopulator.setVector(deltaFloatVector, 1f, 2f, 3f, 4f, 5f);
      assertEquals(length, deltaFloatVector.getValueCount());
      delta.setValueCount(length);

      VectorAppender appender = new VectorAppender(target);
      delta.accept(appender, null);

      assertEquals(length, target.getValueCount());

      for (int i = 0; i < length; i++) {
        Object floatObj = target.getObject(i);
        assertTrue(floatObj instanceof Float);
        assertEquals(i+1, ((Float) floatObj).intValue());
      }
    }
  }

This issue does not occur if any value is set in the target vector before appending.

主要语言
Java
星标
95
派生
154
平均合并
2 天 10 小时
30 天内合并 PR
11

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

apache/arrow-java 的其他 Issue

查看 apache/arrow-java 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。