kou commented on code in PR #39091:
URL: https://github.com/apache/arrow/pull/39091#discussion_r1525664022
##########
swift/Arrow/Package.swift:
##########
@@ -36,18 +36,27 @@ let package = Package(
// and therefore doesn't include the unaligned buffer swift changes.
// This can be changed back to using the tag once a new version of
// flatbuffers has been released.
- .package(url: "https://github.com/google/flatbuffers.git", branch:
"master")
+ .package(url: "https://github.com/google/flatbuffers.git", branch:
"master"),
+ .package(
+ url: "https://github.com/apple/swift-atomics.git",
+ .upToNextMajor(from: "1.2.0") // or `.upToNextMinor
+ )
],
targets: [
// Targets are the basic building blocks of a package. A target can
define a module or a test suite.
// Targets can depend on other targets in this package, and on
products in packages this package depends on.
+ .target(
+ name: "ArrowC", //your C/C++ library's name
+ path: "Sources/ArrowC" //your path to the C/C++ library
Review Comment:
```suggestion
name: "ArrowC", // your C/C++ library's name
path: "Sources/ArrowC" // your path to the C/C++ library
```
##########
swift/Arrow/Sources/Arrow/ArrowCExporter.swift:
##########
@@ -0,0 +1,134 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+import Foundation
+import ArrowC
+import Atomics
+
+extension String {
+ var cstring: UnsafePointer<CChar> {
+ (self as NSString).cString(using: String.Encoding.utf8.rawValue)!
+ }
+}
+
+// The memory used by UnsafeAtomic is not automatically
+// reclaimed. Since this value is initialized once
+// and used until the program/app is closed it's
+// memory will be released on program/app exit
+let exportDataCounter: UnsafeAtomic<Int> = .create(0)
+
+public class ArrowCExporter {
+ private class ExportData {
+ let id: Int
+ init() {
+ id = exportDataCounter.loadThenWrappingIncrement(ordering:
.relaxed)
+ ArrowCExporter.exportedData[id] = self
+ }
+ }
+
+ private class ExportSchema: ExportData {
+ public let arrowTypeName: UnsafePointer<CChar>
+ public let name: UnsafePointer<CChar>
+ private let arrowType: ArrowType
+ init(_ arrowType: ArrowType, name: String = "") throws {
+ self.arrowType = arrowType
+ self.arrowTypeName = try arrowType.cDataFormatId.cstring
+ self.name = name.cstring
+ super.init()
+ }
+ }
+
+ private class ExportArray: ExportData {
+ private let arrowData: ArrowData
+ private(set) var data = [UnsafeRawPointer?]()
+ private(set) var buffers: UnsafeMutablePointer<UnsafeRawPointer?>
+ init(_ arrowData: ArrowData) {
+ // keep a reference to the ArrowData
+ // obj so the memory doesn't get
+ // deallocated
+ self.arrowData = arrowData
+ for arrowBuffer in arrowData.buffers {
+ data.append(arrowBuffer.rawPointer)
+ }
+
+ self.buffers = UnsafeMutablePointer(mutating: data)
+ super.init()
+ }
+ }
+
+ private static var exportedData = [Int: ExportData]()
+ public init() {}
+
+ public func exportType(_ cSchema: inout ArrowC.ArrowSchema, arrowType:
ArrowType, name: String = "") ->
+ Result<Bool, ArrowError> {
+ do {
+ let exportSchema = try ExportSchema(arrowType, name: name)
+ cSchema.format = exportSchema.arrowTypeName
+ cSchema.name = exportSchema.name
+ cSchema.private_data =
+ UnsafeMutableRawPointer(mutating: UnsafeRawPointer(bitPattern:
exportSchema.id))
+ cSchema.release = {(data:
UnsafeMutablePointer<ArrowC.ArrowSchema>?) in
+ let arraySchema = data!.pointee
+ let exportId = Int(bitPattern: arraySchema.private_data)
+ guard ArrowCExporter.exportedData[exportId] != nil else {
+ fatalError("Export schema not found with id \(exportId)")
+ }
+
+ // the data associated with this exportschema object
+ // which includes the c strings for the format and name
+ // be deallocated upon removal
+ ArrowCExporter.exportedData.removeValue(forKey: exportId)
+ ArrowC.ClearReleaseSchema(data)
+ }
+ } catch {
+ return .failure(.unknownError("\(error)"))
+ }
+ return .success(true)
+ }
+
+ public func exportField(_ schema: inout ArrowC.ArrowSchema, field:
ArrowField) ->
+ Result<Bool, ArrowError> {
+ return exportType(&schema, arrowType: field.type, name: field.name)
+ }
+
+ public func exportArray(_ cArray: inout ArrowC.ArrowArray, arrowData:
ArrowData) {
+ let exportArray = ExportArray(arrowData)
+ cArray.buffers = exportArray.buffers
+ cArray.length = Int64(arrowData.length)
+ cArray.null_count = Int64(arrowData.nullCount)
+ cArray.n_buffers = Int64(arrowData.buffers.count)
+ cArray.n_children = 0
+ cArray.children = nil
+ cArray.dictionary = nil
+ cArray.private_data =
+ UnsafeMutableRawPointer(mutating: UnsafeRawPointer(bitPattern:
exportArray.id))
+ cArray.release = {(data: UnsafeMutablePointer<ArrowC.ArrowArray>?) in
+ let arrayData = data!.pointee
+ let exportId = Int(bitPattern: arrayData.private_data)
+ guard ArrowCExporter.exportedData[exportId] != nil else {
+ fatalError("Export data not found with id \(exportId)")
+ }
+
+ // the data associated with this exportdata object
+ // which includes the entire arrowdata object
Review Comment:
```suggestion
// which includes the entire arrowData object
```
##########
swift/Arrow/Sources/ArrowC/include/ArrowCData.h:
##########
@@ -0,0 +1,85 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#ifndef ARROW_C_DATA_INTERFACE
+#define ARROW_C_DATA_INTERFACE
+
+#define ARROW_FLAG_DICTIONARY_ORDERED 1
+#define ARROW_FLAG_NULLABLE 2
+#define ARROW_FLAG_MAP_KEYS_SORTED 4
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h> // Must have this!
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct ArrowSchema {
+ // Array type description
+ const char* format;
+ const char* name;
+ const char* metadata;
+ int64_t flags;
+ int64_t n_children;
+ struct ArrowSchema** children;
+ struct ArrowSchema* dictionary;
+
+ // Release callback
+ void (*release)(struct ArrowSchema*);
+ // Opaque producer-specific data
+ void* private_data;
+};
+
+struct ArrowArray {
+ // Array data description
+ int64_t length;
+ int64_t null_count;
+ int64_t offset;
+ int64_t n_buffers;
+ int64_t n_children;
+ const void** buffers;
+ struct ArrowArray** children;
+ struct ArrowArray* dictionary;
+
+ // Release callback
+ void (*release)(struct ArrowArray*);
+ // Opaque producer-specific data
+ void* private_data;
+};
+
+// Not able to set the release on the schema
+// to NULL in swift. nil in swift is not
+// equivalent to NULL.
+void ClearReleaseSchema(struct ArrowSchema*);
+
+// Not able to set the release on the array
+// to NULL in swift. nil in swift is not
+// equivalent to NULL.
+void ClearReleaseArray(struct ArrowArray*);
+
+int ArrowSchemaIsReleased(struct ArrowSchema*);
+
+int ArrowArrayIsReleased(struct ArrowArray*);
Review Comment:
How about using a prefix to avoid naming conflict as much as possible?
`ArrowSwiftXXX()`?
(If symbols in `ArrowC` are loaded with `RTLD_LOCAL`, we don't need prefix.)
##########
swift/Arrow/Sources/Arrow/ArrowCExporter.swift:
##########
@@ -0,0 +1,134 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+import Foundation
+import ArrowC
+import Atomics
+
+extension String {
+ var cstring: UnsafePointer<CChar> {
+ (self as NSString).cString(using: String.Encoding.utf8.rawValue)!
+ }
+}
+
+// The memory used by UnsafeAtomic is not automatically
+// reclaimed. Since this value is initialized once
+// and used until the program/app is closed it's
+// memory will be released on program/app exit
+let exportDataCounter: UnsafeAtomic<Int> = .create(0)
+
+public class ArrowCExporter {
+ private class ExportData {
+ let id: Int
+ init() {
+ id = exportDataCounter.loadThenWrappingIncrement(ordering:
.relaxed)
+ ArrowCExporter.exportedData[id] = self
+ }
+ }
+
+ private class ExportSchema: ExportData {
+ public let arrowTypeName: UnsafePointer<CChar>
+ public let name: UnsafePointer<CChar>
+ private let arrowType: ArrowType
+ init(_ arrowType: ArrowType, name: String = "") throws {
+ self.arrowType = arrowType
+ self.arrowTypeName = try arrowType.cDataFormatId.cstring
+ self.name = name.cstring
+ super.init()
+ }
+ }
+
+ private class ExportArray: ExportData {
+ private let arrowData: ArrowData
+ private(set) var data = [UnsafeRawPointer?]()
+ private(set) var buffers: UnsafeMutablePointer<UnsafeRawPointer?>
+ init(_ arrowData: ArrowData) {
+ // keep a reference to the ArrowData
+ // obj so the memory doesn't get
+ // deallocated
+ self.arrowData = arrowData
+ for arrowBuffer in arrowData.buffers {
+ data.append(arrowBuffer.rawPointer)
+ }
+
+ self.buffers = UnsafeMutablePointer(mutating: data)
+ super.init()
+ }
+ }
+
+ private static var exportedData = [Int: ExportData]()
+ public init() {}
+
+ public func exportType(_ cSchema: inout ArrowC.ArrowSchema, arrowType:
ArrowType, name: String = "") ->
+ Result<Bool, ArrowError> {
+ do {
+ let exportSchema = try ExportSchema(arrowType, name: name)
+ cSchema.format = exportSchema.arrowTypeName
+ cSchema.name = exportSchema.name
+ cSchema.private_data =
+ UnsafeMutableRawPointer(mutating: UnsafeRawPointer(bitPattern:
exportSchema.id))
+ cSchema.release = {(data:
UnsafeMutablePointer<ArrowC.ArrowSchema>?) in
+ let arraySchema = data!.pointee
+ let exportId = Int(bitPattern: arraySchema.private_data)
+ guard ArrowCExporter.exportedData[exportId] != nil else {
+ fatalError("Export schema not found with id \(exportId)")
+ }
+
+ // the data associated with this exportschema object
Review Comment:
```suggestion
// the data associated with this exportSchema object
```
##########
swift/Arrow/Sources/Arrow/ArrowCExporter.swift:
##########
@@ -0,0 +1,134 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+import Foundation
+import ArrowC
+import Atomics
+
+extension String {
+ var cstring: UnsafePointer<CChar> {
+ (self as NSString).cString(using: String.Encoding.utf8.rawValue)!
+ }
+}
+
+// The memory used by UnsafeAtomic is not automatically
+// reclaimed. Since this value is initialized once
+// and used until the program/app is closed it's
+// memory will be released on program/app exit
+let exportDataCounter: UnsafeAtomic<Int> = .create(0)
+
+public class ArrowCExporter {
+ private class ExportData {
+ let id: Int
+ init() {
+ id = exportDataCounter.loadThenWrappingIncrement(ordering:
.relaxed)
+ ArrowCExporter.exportedData[id] = self
+ }
+ }
+
+ private class ExportSchema: ExportData {
+ public let arrowTypeName: UnsafePointer<CChar>
+ public let name: UnsafePointer<CChar>
+ private let arrowType: ArrowType
+ init(_ arrowType: ArrowType, name: String = "") throws {
+ self.arrowType = arrowType
+ self.arrowTypeName = try arrowType.cDataFormatId.cstring
+ self.name = name.cstring
+ super.init()
+ }
+ }
+
+ private class ExportArray: ExportData {
+ private let arrowData: ArrowData
+ private(set) var data = [UnsafeRawPointer?]()
+ private(set) var buffers: UnsafeMutablePointer<UnsafeRawPointer?>
+ init(_ arrowData: ArrowData) {
+ // keep a reference to the ArrowData
+ // obj so the memory doesn't get
+ // deallocated
+ self.arrowData = arrowData
+ for arrowBuffer in arrowData.buffers {
+ data.append(arrowBuffer.rawPointer)
+ }
+
+ self.buffers = UnsafeMutablePointer(mutating: data)
+ super.init()
+ }
+ }
+
+ private static var exportedData = [Int: ExportData]()
+ public init() {}
+
+ public func exportType(_ cSchema: inout ArrowC.ArrowSchema, arrowType:
ArrowType, name: String = "") ->
+ Result<Bool, ArrowError> {
+ do {
+ let exportSchema = try ExportSchema(arrowType, name: name)
+ cSchema.format = exportSchema.arrowTypeName
+ cSchema.name = exportSchema.name
+ cSchema.private_data =
+ UnsafeMutableRawPointer(mutating: UnsafeRawPointer(bitPattern:
exportSchema.id))
+ cSchema.release = {(data:
UnsafeMutablePointer<ArrowC.ArrowSchema>?) in
+ let arraySchema = data!.pointee
+ let exportId = Int(bitPattern: arraySchema.private_data)
+ guard ArrowCExporter.exportedData[exportId] != nil else {
+ fatalError("Export schema not found with id \(exportId)")
+ }
+
+ // the data associated with this exportschema object
+ // which includes the c strings for the format and name
Review Comment:
```suggestion
// which includes the C strings for the format and name
```
##########
swift/Arrow/Sources/ArrowC/include/ArrowCData.h:
##########
@@ -0,0 +1,85 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#ifndef ARROW_C_DATA_INTERFACE
+#define ARROW_C_DATA_INTERFACE
+
+#define ARROW_FLAG_DICTIONARY_ORDERED 1
+#define ARROW_FLAG_NULLABLE 2
+#define ARROW_FLAG_MAP_KEYS_SORTED 4
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h> // Must have this!
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct ArrowSchema {
+ // Array type description
+ const char* format;
+ const char* name;
+ const char* metadata;
+ int64_t flags;
+ int64_t n_children;
+ struct ArrowSchema** children;
+ struct ArrowSchema* dictionary;
+
+ // Release callback
+ void (*release)(struct ArrowSchema*);
+ // Opaque producer-specific data
+ void* private_data;
+};
+
+struct ArrowArray {
+ // Array data description
+ int64_t length;
+ int64_t null_count;
+ int64_t offset;
+ int64_t n_buffers;
+ int64_t n_children;
+ const void** buffers;
+ struct ArrowArray** children;
+ struct ArrowArray* dictionary;
+
+ // Release callback
+ void (*release)(struct ArrowArray*);
+ // Opaque producer-specific data
+ void* private_data;
+};
+
+// Not able to set the release on the schema
+// to NULL in swift. nil in swift is not
+// equivalent to NULL.
+void ClearReleaseSchema(struct ArrowSchema*);
+
+// Not able to set the release on the array
+// to NULL in swift. nil in swift is not
Review Comment:
```suggestion
// to NULL in Swift. nil in Swift is not
```
##########
swift/Arrow/Sources/Arrow/ArrowCExporter.swift:
##########
@@ -0,0 +1,134 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+import Foundation
+import ArrowC
+import Atomics
+
+extension String {
+ var cstring: UnsafePointer<CChar> {
+ (self as NSString).cString(using: String.Encoding.utf8.rawValue)!
+ }
+}
+
+// The memory used by UnsafeAtomic is not automatically
+// reclaimed. Since this value is initialized once
+// and used until the program/app is closed it's
+// memory will be released on program/app exit
+let exportDataCounter: UnsafeAtomic<Int> = .create(0)
+
+public class ArrowCExporter {
+ private class ExportData {
+ let id: Int
+ init() {
+ id = exportDataCounter.loadThenWrappingIncrement(ordering:
.relaxed)
+ ArrowCExporter.exportedData[id] = self
+ }
+ }
+
+ private class ExportSchema: ExportData {
+ public let arrowTypeName: UnsafePointer<CChar>
+ public let name: UnsafePointer<CChar>
+ private let arrowType: ArrowType
+ init(_ arrowType: ArrowType, name: String = "") throws {
+ self.arrowType = arrowType
+ self.arrowTypeName = try arrowType.cDataFormatId.cstring
+ self.name = name.cstring
+ super.init()
+ }
+ }
+
+ private class ExportArray: ExportData {
+ private let arrowData: ArrowData
+ private(set) var data = [UnsafeRawPointer?]()
+ private(set) var buffers: UnsafeMutablePointer<UnsafeRawPointer?>
+ init(_ arrowData: ArrowData) {
+ // keep a reference to the ArrowData
+ // obj so the memory doesn't get
+ // deallocated
+ self.arrowData = arrowData
+ for arrowBuffer in arrowData.buffers {
+ data.append(arrowBuffer.rawPointer)
+ }
+
+ self.buffers = UnsafeMutablePointer(mutating: data)
+ super.init()
+ }
+ }
+
+ private static var exportedData = [Int: ExportData]()
+ public init() {}
+
+ public func exportType(_ cSchema: inout ArrowC.ArrowSchema, arrowType:
ArrowType, name: String = "") ->
+ Result<Bool, ArrowError> {
+ do {
+ let exportSchema = try ExportSchema(arrowType, name: name)
+ cSchema.format = exportSchema.arrowTypeName
+ cSchema.name = exportSchema.name
+ cSchema.private_data =
+ UnsafeMutableRawPointer(mutating: UnsafeRawPointer(bitPattern:
exportSchema.id))
+ cSchema.release = {(data:
UnsafeMutablePointer<ArrowC.ArrowSchema>?) in
+ let arraySchema = data!.pointee
+ let exportId = Int(bitPattern: arraySchema.private_data)
+ guard ArrowCExporter.exportedData[exportId] != nil else {
+ fatalError("Export schema not found with id \(exportId)")
+ }
+
+ // the data associated with this exportschema object
+ // which includes the c strings for the format and name
+ // be deallocated upon removal
+ ArrowCExporter.exportedData.removeValue(forKey: exportId)
+ ArrowC.ClearReleaseSchema(data)
+ }
+ } catch {
+ return .failure(.unknownError("\(error)"))
+ }
+ return .success(true)
+ }
+
+ public func exportField(_ schema: inout ArrowC.ArrowSchema, field:
ArrowField) ->
+ Result<Bool, ArrowError> {
+ return exportType(&schema, arrowType: field.type, name: field.name)
+ }
+
+ public func exportArray(_ cArray: inout ArrowC.ArrowArray, arrowData:
ArrowData) {
+ let exportArray = ExportArray(arrowData)
+ cArray.buffers = exportArray.buffers
+ cArray.length = Int64(arrowData.length)
+ cArray.null_count = Int64(arrowData.nullCount)
+ cArray.n_buffers = Int64(arrowData.buffers.count)
+ cArray.n_children = 0
+ cArray.children = nil
+ cArray.dictionary = nil
+ cArray.private_data =
+ UnsafeMutableRawPointer(mutating: UnsafeRawPointer(bitPattern:
exportArray.id))
+ cArray.release = {(data: UnsafeMutablePointer<ArrowC.ArrowArray>?) in
+ let arrayData = data!.pointee
+ let exportId = Int(bitPattern: arrayData.private_data)
+ guard ArrowCExporter.exportedData[exportId] != nil else {
+ fatalError("Export data not found with id \(exportId)")
+ }
+
+ // the data associated with this exportdata object
Review Comment:
```suggestion
// the data associated with this exportArray object
```
##########
swift/Arrow/Sources/ArrowC/include/ArrowCData.h:
##########
@@ -0,0 +1,85 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#ifndef ARROW_C_DATA_INTERFACE
+#define ARROW_C_DATA_INTERFACE
+
+#define ARROW_FLAG_DICTIONARY_ORDERED 1
+#define ARROW_FLAG_NULLABLE 2
+#define ARROW_FLAG_MAP_KEYS_SORTED 4
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h> // Must have this!
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct ArrowSchema {
+ // Array type description
+ const char* format;
+ const char* name;
+ const char* metadata;
+ int64_t flags;
+ int64_t n_children;
+ struct ArrowSchema** children;
+ struct ArrowSchema* dictionary;
+
+ // Release callback
+ void (*release)(struct ArrowSchema*);
+ // Opaque producer-specific data
+ void* private_data;
+};
+
+struct ArrowArray {
+ // Array data description
+ int64_t length;
+ int64_t null_count;
+ int64_t offset;
+ int64_t n_buffers;
+ int64_t n_children;
+ const void** buffers;
+ struct ArrowArray** children;
+ struct ArrowArray* dictionary;
+
+ // Release callback
+ void (*release)(struct ArrowArray*);
+ // Opaque producer-specific data
+ void* private_data;
+};
+
+// Not able to set the release on the schema
+// to NULL in swift. nil in swift is not
+// equivalent to NULL.
+void ClearReleaseSchema(struct ArrowSchema*);
+
+// Not able to set the release on the array
+// to NULL in swift. nil in swift is not
+// equivalent to NULL.
+void ClearReleaseArray(struct ArrowArray*);
+
+int ArrowSchemaIsReleased(struct ArrowSchema*);
+
+int ArrowArrayIsReleased(struct ArrowArray*);
Review Comment:
It seems that they aren't used. Can we remove them?
##########
swift/Arrow/Sources/ArrowC/include/ArrowCData.h:
##########
@@ -0,0 +1,85 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#ifndef ARROW_C_DATA_INTERFACE
+#define ARROW_C_DATA_INTERFACE
+
+#define ARROW_FLAG_DICTIONARY_ORDERED 1
+#define ARROW_FLAG_NULLABLE 2
+#define ARROW_FLAG_MAP_KEYS_SORTED 4
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h> // Must have this!
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct ArrowSchema {
+ // Array type description
+ const char* format;
+ const char* name;
+ const char* metadata;
+ int64_t flags;
+ int64_t n_children;
+ struct ArrowSchema** children;
+ struct ArrowSchema* dictionary;
+
+ // Release callback
+ void (*release)(struct ArrowSchema*);
+ // Opaque producer-specific data
+ void* private_data;
+};
+
+struct ArrowArray {
+ // Array data description
+ int64_t length;
+ int64_t null_count;
+ int64_t offset;
+ int64_t n_buffers;
+ int64_t n_children;
+ const void** buffers;
+ struct ArrowArray** children;
+ struct ArrowArray* dictionary;
+
+ // Release callback
+ void (*release)(struct ArrowArray*);
+ // Opaque producer-specific data
+ void* private_data;
+};
+
+// Not able to set the release on the schema
+// to NULL in swift. nil in swift is not
Review Comment:
```suggestion
// to NULL in Swift. nil in Swift is not
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]