Repository navigation
Split buffers by target type capacity when cloning primitive columns - #7819
ShryukGrandhi wants to merge 1 commit into
Conversation
The CloneAs*Container methods mapped each source buffer to one target buffer, which fails when the target element type is larger than the source (e.g. a full int buffer cannot fit in a single double buffer) and leaves non-full buffers when it is smaller, breaking row index lookups. Fixes dotnet#7381
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #7819 +/- ##
==========================================
- Coverage 70.77% 70.77% -0.01%
==========================================
Files 1420 1420
Lines 279877 279775 -102
Branches 27604 27587 -17
==========================================
- Hits 198077 198000 -77
+ Misses 73620 73600 -20
+ Partials 8180 8175 -5
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
@ShryukGrandhi, could you please confirm you agree with the CLA? |
|
@ShryukGrandhi please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement ( “Agreement” ) is agreed to by the party signing below ( “You” ), 1. Definitions. “Code” means the computer software code, whether in human-readable or machine-executable form, “Project” means any of the projects owned or managed by .NET Foundation and offered under a license “Submit” is the act of uploading, submitting, transmitting, or distributing code or other content to any “Submission” means the Code and any other copyrightable material Submitted by You, including any 2. Your Submission. You must agree to the terms of this Agreement before making a Submission to any 3. Originality of Work. You represent that each of Your Submissions is entirely Your 4. Your Employer. References to “employer” in this Agreement include Your employer or anyone else 5. Licenses. a. Copyright License. You grant .NET Foundation, and those who receive the Submission directly b. Patent License. You grant .NET Foundation, and those who receive the Submission directly or c. Other Rights Reserved. Each party reserves all rights not expressly granted in this Agreement. 6. Representations and Warranties. You represent that You are legally entitled to grant the above 7. Notice to .NET Foundation. You agree to notify .NET Foundation in writing of any facts or 8. Information about Submissions. You agree that contributions to Projects and information about 9. Governing Law/Jurisdiction. This Agreement is governed by the laws of the State of Washington, and 10. Entire Agreement/Assignment. This Agreement is the entire agreement between the parties, and .NET Foundation dedicates this Contribution License Agreement to the public domain according to the Creative Commons CC0 1. |
Fixes #7381
PrimitiveColumnContainer<T>.CloneAs*Containermapped every source buffer to exactly one buffer of the target type. Buffer capacity isArrayUtility.ArrayMaxSize / sizeof(T), so this breaks in two ways:int->double), a full source buffer holds more values than a target buffer can. Cloning anInt32DataFrameColumnwith more than ~268M values as double threwArgumentException: ... exceeds buffer capacity. This is reachable from public APIs likeInt32DataFrameColumn.Add(double).long->int), the result contains buffers that aren't full. Row lookups assume every buffer except the last holds exactlyMaxCapacityvalues (rowIndex / MaxCapacity), so indexing into that result returns the wrong values.Fix
The per-type copy loops are replaced with one private
CloneAs<U>(Func<T, U> convert)helper. It fills target buffers up toReadOnlyDataFrameBuffer<U>.MaxCapacityand starts a new buffer and null bitmap when one is full. Validity bits are copied into the matching new bitmap. When the column has no nulls they are set in bulk. EachCloneAs*Containermethod now just passes its converter to this helper. Forbool, values from a non-bool column still becomefalseand the validity bits are kept, as before.Testing
PrimitiveDataFrameColumn_Int32_CloneAsDouble_AcrossMultipleBuffers. It builds anInt32DataFrameColumnthat spans two buffers, callsAdd(0.5)(which clones as double) and checks values and nulls around the double and int buffer boundaries. It is markedX64Factlike the other large-allocation tests next to it. For local runs on arm64 I temporarily switched it to[Fact]: it failed before the change with theexceeds buffer capacityexception and passes after it.dotnet test test/Microsoft.Data.Analysis.Testspasses: 1765 passed, 6 skipped, 0 failed.dotnet format --verify-no-changesreports no changes for the touched files.