Skip to content

[C#] Need refacto IArrowArrayBuilder for nested types #35285

@Platob

Description

@Platob

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

Hello,

I feel like missing raw memory byte/bits control on buffers

The interface IArrowArrayBuilder<out TArray, out TBuilder> forces the dev to return TBuilder

It makes it harder on nested structures

I don't see how it is necessary since its as the same behavior as void, its just cleaner for one line code if we want do it

Is it possible to move value append methods in IArrowArrayBuilder simply ?

Same as Reserve, Resize and Clear methods

public interface IBufferBuilder
{
    int ValueLength { get; }
    Memory<byte> Memory { get; }
        
    int ValueBitSize { get; }
    int Capacity { get; }

    void AppendBit(bool bit);

    void AppendBits(ReadOnlySpan<bool> bits);
    void AppendBits(ReadOnlySpan<bool> bits, int length);

    void AppendByte(byte byteValue);
    void AppendByte(byte byteValue, int length);

    void AppendBytes(ReadOnlySpan<byte> bytes);
    void AppendBytes(ReadOnlySpan<byte> bytes, int length);
        
    /// <summary>
    /// Reserve a given number of items' additional capacity.
    /// </summary>
    /// <param name="additionalCapacity">Number of items of required additional capacity.</param>
    void Reserve(int additionalCapacity);

    /// <summary>
    /// Resize the buffer to a given size.
    /// </summary>
    /// <remarks>
    /// Note that if the required capacity is larger than the current length of the populated buffer so far,
    /// the buffer's contents in the new, expanded region are undefined.
    /// </remarks>
    /// <remarks>
    /// Note that if the required capacity is smaller than the current length of the populated buffer so far,
    /// the buffer will be truncated and items at the end of the buffer will be lost.
    /// </remarks>
    /// <param name="capacity">Number of items of required capacity.</param>
    void Resize(int capacity);

    /// <summary>
    /// Clear all contents appended so far.
    /// </summary>
    void Clear();

    /// <summary>
    /// Build an Arrow buffer from the appended contents so far.
    /// </summary>
    /// <param name="allocator">Optional memory allocator.</param>
    /// <returns>Returns an <see cref="ArrowBuffer"/> object.</returns>
    ArrowBuffer Build(MemoryAllocator allocator = default);

    /// <summary>
    /// Build an Arrow buffer from the appended contents so far of the specified byte size.
    /// </summary>
    /// <param name="allocator">Optional memory allocator.</param>
    /// <returns>Returns an <see cref="ArrowBuffer"/> object.</returns>
    ArrowBuffer Build(int byteSize, MemoryAllocator allocator = default);
}

public interface IStructBufferBuilder<T> : IBufferBuilder where T : struct
{
    void AppendNull();
    void AppendValue(T value);
    void AppendValues(ReadOnlySpan<T> values);
}

Component(s)

C#

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions