Skip to content

Clean up PrimitiveColumnContainer #6656

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
More clean up
  • Loading branch information
JakeRadMSFT committed May 6, 2023
commit 1fac8ab1637c5de1e177a19970aaeeae30449f81
17 changes: 8 additions & 9 deletions src/Microsoft.Data.Analysis/PrimitiveColumnContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,33 +182,32 @@ public void AppendMany(T? value, long count)


DataFrameBuffer<T> mutableLastBuffer = Buffers.GetMutable(Buffers.Count - 1);

int allocatable = (int)Math.Min(remaining, ReadOnlyDataFrameBuffer<T>.MaxCapacity);

mutableLastBuffer.EnsureCapacity(allocatable);
mutableLastBuffer.Length = allocatable;

DataFrameBuffer<byte> lastNullBitMapBuffer = NullBitMapBuffers.GetMutable(NullBitMapBuffers.Count - 1);
int nullBufferAllocatable = (allocatable + 7) / 8;
lastNullBitMapBuffer.EnsureCapacity(nullBufferAllocatable);
lastNullBitMapBuffer.Length = nullBufferAllocatable;

remaining -= allocatable;
Length += mutableLastBuffer.Length;

// PR Question: Does this need to be called if it's value is null/doesn't have value?
mutableLastBuffer.Length += allocatable;
lastNullBitMapBuffer.Length += nullBufferAllocatable;
Length += allocatable;

if (value.HasValue)
{
mutableLastBuffer.RawSpan.Slice(mutableLastBuffer.Length, allocatable).Fill(value ?? default);
mutableLastBuffer.RawSpan.Slice(mutableLastBuffer.Length - allocatable - 1, allocatable).Fill(value ?? default);

_modifyNullCountWhileIndexing = false;
for (long i = Length - remaining; i < Length; i++)
for (long i = Length - allocatable; i < Length; i++)
{
SetValidityBit(i, value.HasValue);
}
_modifyNullCountWhileIndexing = true;
}


remaining -= allocatable;
}
}

Expand Down