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

ToArrowRecordBatches accumulates arrays from previous batches, producing invalid record batches

Đang mở Phù hợp với người mới
#7,799 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 2 ngày

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

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
62/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
csharp, machine-learning
Lĩnh vực
data

Hướng nghiên cứu

Lỗi nằm ở ToArrowRecordBatches() trong src/Microsoft.Data.Analysis/DataFrame.Arrow.cs, nơi danh sách arrays được khai báo bên ngoài vòng lặp chia lô và không bao giờ được đặt lại. Hãy đọc vòng lặp đó, sau đó đối chiếu bản tái hiện với DataFrame.FromArrowRecordBatch. Hoàn thành khi mỗi lô chỉ chứa các mảng cột của chính nó và lô 1 của bản tái hiện được nhập lại thành một frame một hàng, một cột chứa 42. Bài kiểm tra cần mở rộng nằm trong các bài kiểm tra Microsoft.Data.Analysis cho các vòng round-trip Arrow.

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

Mô tả

area-DataFrame bug untriaged

Description

DataFrame.ToArrowRecordBatches() accumulates arrays from previous batches. A one-column DataFrame exports its second record batch with one schema field but two arrays, including the first batch's stale array.

This invalid batch cannot be imported using DataFrame.FromArrowRecordBatch(), which throws ArgumentOutOfRangeException.

Reproduced on Microsoft.Data.Analysis 0.23.0, Apache.Arrow 14.0.2, Windows x64, .NET 10. The reproduction uses only public, high-level DataFrame APIs and is independent of Arrow string null-count bugs (https://github.com/dotnet/machinelearning/issues/7800 and https://github.com/dotnet/machinelearning/issues/7801).

Reproduction

Create a console app, add Microsoft.Data.Analysis version 0.23.0, and run:

using System;
using System.Linq;
using Microsoft.Data.Analysis;

var numbers = new Int64DataFrameColumn("numbers");
numbers.AppendMany(42, 268_304_384);
var frame = new DataFrame(numbers);
var batches = frame.ToArrowRecordBatches();

foreach (var (i, batch) in batches.Index())
{
    Console.WriteLine(
        $"Batch {i}: rows={batch.Length}; fields={batch.Schema.FieldsList.Count}; arrays={batch.Arrays.Count()}; array lengths=[{string.Join(", ", batch.Arrays.Select(array => array.Length))}]");

    try
    {
        var roundTrip = DataFrame.FromArrowRecordBatch(batch);
        Console.WriteLine($"Reimported batch {i}: rows={roundTrip.Rows.Count}; columns={roundTrip.Columns.Count}");
    }
    catch (ArgumentOutOfRangeException e)
    {
        Console.WriteLine($"Reimporting batch {i}: {e.GetType().Name}: {e.Message}");
    }
}

Requires slightly over 2 GB for the numeric buffers and validity bitmaps. The row count naturally creates two numeric buffers and forces two record batches.

Actual output
Batch 0: rows=268304383; fields=1; arrays=1; array lengths=[268304383]
Reimported batch 0: rows=268304383; columns=1
Batch 1: rows=1; fields=1; arrays=2; array lengths=[268304383, 1]
Reimporting batch 1: ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')
Expected behavior

Each batch should contain exactly one array matching its single schema field. Batch 1 should contain only its one-row array, and reimport should produce a one-row, one-column DataFrame containing 42.

Cause

DataFrame.ToArrowRecordBatches() creates the arrays list outside its batching loop and continually appends each batch's arrays without resetting that list.

Each record batch should receive a fresh per-batch collection containing only the current batch's column arrays. Also ensure that continuing enumeration cannot mutate an already yielded batch.

Ngôn ngữ chính
C#
Star
9.4k
Fork
2k
Merge trung bình
3 ngày 8 giờ
Pull request đã merge (30 ngày)
41

Chuẩn bị môi trường

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 dotnet/machinelearning

Tất cả issue của dotnet/machinelearning

Issue tương tự

Thêm issue về C#

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.