Skip to content

ArrowBuffer allocates a multiple of 64 plus 8 bytes. #106

@willtemperley

Description

@willtemperley

Describe the enhancement requested

In ArrowBuffer, alignTo64 always aligns to a multiple of 64 plus 8. I just can't think of a reason for this. The naming alignTo64 seems to point ot this being an oversight.

private static func alignTo64(_ length: UInt) -> UInt {
    let bufAlignment = length % 64
    if bufAlignment != 0 {
        return length + (64 - bufAlignment) + 8
    }

    return length + 8
}

Oddly this behaviour is tested for which indicates it might have been intentional but I really can't see a reason.

    func testPrimitiveArray() throws {
.
        let arrayBuilder: NumberArrayBuilder<UInt8> = try ArrowArrayBuilders.loadNumberArrayBuilder()
        for index in 0..<100 {
            arrayBuilder.append(UInt8(index))
        }

        XCTAssertEqual(arrayBuilder.nullCount, 0)
        arrayBuilder.append(nil)
        XCTAssertEqual(arrayBuilder.length, 101)
        XCTAssertEqual(arrayBuilder.capacity, 136) // Why not 128??
   }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions