This is an automated email from the ASF dual-hosted git repository.

raulcd pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-swift.git

commit 722b8cdaf5de895ccbe48004a5452e0372fe95fc
Author: abandy <[email protected]>
AuthorDate: Mon Jul 1 21:15:03 2024 -0400

    GH-43092: [Swift] Update ArrowData for Nested Types (allow children) 
(#43086)
    
    ### Rationale for this change
    Struct (Nested Types) need children property on ArrowData
    
    ### What changes are included in this PR?
    children property added to ArrowData an constructor updated (original 
constructor moved to convenience constructor so it must call the updated 
constructor but keeps the original behavior for existing types)
    
    * GitHub Issue: #43092
    
    Authored-by: Alva Bandy <[email protected]>
    Signed-off-by: Sutou Kouhei <[email protected]>
---
 Arrow/Sources/Arrow/ArrowData.swift | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/Arrow/Sources/Arrow/ArrowData.swift 
b/Arrow/Sources/Arrow/ArrowData.swift
index 5e23e60..2728b9f 100644
--- a/Arrow/Sources/Arrow/ArrowData.swift
+++ b/Arrow/Sources/Arrow/ArrowData.swift
@@ -20,11 +20,18 @@ import Foundation
 public class ArrowData {
     public let type: ArrowType
     public let buffers: [ArrowBuffer]
+    public let children: [ArrowData]
     public let nullCount: UInt
     public let length: UInt
     public let stride: Int
 
-    init(_ arrowType: ArrowType, buffers: [ArrowBuffer], nullCount: UInt) 
throws {
+    convenience init(_ arrowType: ArrowType, buffers: [ArrowBuffer], 
nullCount: UInt) throws {
+        try self.init(arrowType, buffers: buffers,
+                      children: [ArrowData](), nullCount: nullCount,
+                      length: buffers[1].length)
+    }
+
+    init(_ arrowType: ArrowType, buffers: [ArrowBuffer], children: 
[ArrowData], nullCount: UInt, length: UInt) throws {
         let infoType = arrowType.info
         switch infoType {
         case let .primitiveInfo(typeId):
@@ -47,8 +54,9 @@ public class ArrowData {
 
         self.type = arrowType
         self.buffers = buffers
+        self.children = children
         self.nullCount = nullCount
-        self.length = buffers[1].length
+        self.length = length
         self.stride = arrowType.getStride()
     }
 

Reply via email to