Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

`ListViewVector#copyFrom` Throws `IndexOutOfBoundsException` on Non-Empty Elements

Đang mở
#471 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
52/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
java
Lĩnh vực
data-engineering

Hướng nghiên cứu

Bắt đầu với ListViewVector#copyFrom và bài kiểm thử được cung cấp, sau đó kiểm tra UnionListViewReader#next cùng với UnionListReader và ComplexCopier#writeValue. Xác minh rằng việc lặp kết thúc đối với một danh sách không rỗng, chạy bài kiểm thử và xác nhận rằng vector đã sao chép trả về các phần tử giống nhau mà không xảy ra IndexOutOfBoundsException.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

help wanted Type: bug

ListViewVector's #copyFrom is broken. Here is a test (that otherwise works for List):

    @Test
    public void testListViewCopy() {
        final Field childField = new Field("testChild",
                new FieldType(false, new ArrowType.Int(32, true), null), null);
        final Field listField = new Field("test",
                new FieldType(false, ArrowType.ListView.INSTANCE, null), Collections.singletonList(childField));
        try (final ListViewVector src = (ListViewVector) listField.createVector(allocator);
             final ListViewVector dst = (ListViewVector) listField.createVector(allocator)) {
            // init child vector
            final int numValues = 10;
            final IntVector childSrc = (IntVector) src.getDataVector();
            childSrc.setValueCount(numValues);
            for (int ii = 0; ii < numValues; ++ii) {
                childSrc.set(ii, ii);
            }

            // init source vector
            src.setValueCount(1);
            src.startNewValue(0);
            src.endValue(0, numValues);

            assertEquals(List.of(0, 1, 2, 3, 4, 5, 6, 7, 8, 9), src.getObject(0));

            dst.setValueCount(src.getValueCount());
            dst.getDataVector().setValueCount(numValues);
            dst.copyFrom(0, 0, src);
            assertEquals(src.getObject(0), dst.getObject(0));
        }
    }

ComplexCopier#writeValue has impl:

      case LIST:
      case LISTVIEW:
      case LARGELIST:
      case LARGELISTVIEW:
      case FIXED_SIZE_LIST:
        if (reader.isSet()) {
          writer.startList();
          while (reader.next()) {
            FieldReader childReader = reader.reader();
            FieldWriter childWriter = getListWriterForReader(childReader, writer);
            if (childReader.isSet()) {
              writeValue(childReader, childWriter);
            } else {
              childWriter.writeNull();
            }
          }
          writer.endList();
        } else {
          writer.writeNull();
        }
        break;

Note that the implementation of UnionListViewReader#next will never ever return false:

  @Override
  public boolean next() {
    // Here, the currentOffSet keeps track of the current position in the vector inside the list at
    // set position.
    // And, size keeps track of the elements count in the list, so to make sure we traverse
    // the full list, we need to check if the currentOffset is less than the currentOffset + size
    if (currentOffset < currentOffset + size) {
      data.getReader().setPosition(currentOffset++);
      return true;
    } else {
      return false;
    }
  }

Notice how currentOffset < currentOffset + size can only ever be false if size <= 0 -- but size is never modified.

I suspect the desired conditional is:

    if (currentOffset < size) {

Please note that the embedded comment is also nonsense. It's not clear why the approach differs from UnionListReader, keeping a consistent approach would have prevented introducing a bug.

This issue exists in main as of 480e1be.

Ngôn ngữ chính
Java
Star
95
Fork
154
Merge trung bình
2 ngày 10 giờ
Pull request đã merge (30 ngày)
11

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của apache/arrow-java

Tất cả issue của apache/arrow-java

Issue tương tự

Thêm issue về Java

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.