You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "westonpace (via GitHub)" <gi...@apache.org> on 2023/03/01 01:41:24 UTC

[GitHub] [arrow] westonpace commented on a diff in pull request #34133: GH-33856: [C#] C Data interface for schemas and types

westonpace commented on code in PR #34133:
URL: https://github.com/apache/arrow/pull/34133#discussion_r1121013836


##########
csharp/src/Apache.Arrow/C/CArrowSchema.cs:
##########
@@ -0,0 +1,339 @@
+// 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.
+
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Runtime.InteropServices;
+using Apache.Arrow.Types;
+
+[UnmanagedFunctionPointer(CallingConvention.StdCall)]
+public delegate void ReleaseCArrowSchema(IntPtr schema);
+
+namespace Apache.Arrow.C
+{
+    /// <summary>
+    /// An Arrow C Data Interface Schema, which represents a type, field, or schema.
+    /// </summary>
+    /// 
+    /// <remarks>
+    /// This is used to export <see cref="ArrowType"/>, <see cref="Field"/>, or
+    /// <see cref="Schema"/> to other languages. It matches the layout of the
+    /// ArrowSchema struct described in https://github.com/apache/arrow/blob/main/cpp/src/arrow/c/abi.h.
+    /// </remarks>
+    [StructLayout(LayoutKind.Sequential)]
+    unsafe public struct CArrowSchema
+    {
+        [MarshalAs(UnmanagedType.LPStr)]
+        public string format;
+        [MarshalAs(UnmanagedType.LPStr)]
+        public string name;
+        [MarshalAs(UnmanagedType.LPStr)]
+        public string metadata;
+        public long flags;
+        public long n_children;
+        public IntPtr* children;

Review Comment:
   What about [`IntPtr.Size`](https://learn.microsoft.com/en-us/dotnet/api/system.intptr.size?view=net-7.0#system-intptr-size)?
   
   ```
   Marshal.AllocHGlobal(numFields * IntPtr.Size);
   ```



##########
csharp/src/Apache.Arrow/C/CArrowSchema.cs:
##########
@@ -0,0 +1,559 @@
+// 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.
+
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Runtime.InteropServices;
+using Apache.Arrow.Types;
+
+[UnmanagedFunctionPointer(CallingConvention.StdCall)]

Review Comment:
   Why `StdCall`?



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org