pitrou commented on a change in pull request #11067:
URL: https://github.com/apache/arrow/pull/11067#discussion_r704665277



##########
File path: java/ffi/src/main/java/org/apache/arrow/ffi/ArrowSchema.java
##########
@@ -0,0 +1,170 @@
+/*
+ * 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.
+ */
+
+package org.apache.arrow.ffi;
+
+import static org.apache.arrow.ffi.NativeUtil.NULL;
+import static org.apache.arrow.util.Preconditions.checkNotNull;
+
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+
+import org.apache.arrow.ffi.jni.JniWrapper;
+import org.apache.arrow.memory.ArrowBuf;
+import org.apache.arrow.memory.BufferAllocator;
+import org.apache.arrow.memory.ReferenceManager;
+import org.apache.arrow.memory.util.MemoryUtil;
+
+/**
+ * C Data Interface ArrowSchema.
+ * <p>
+ * Represents a wrapper for the following C structure:
+ * 
+ * <pre>
+ * 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; 
+ * };
+ * </pre>
+ */
+public class ArrowSchema implements BaseStruct {
+  private static final int SIZE_OF = 72;
+
+  private ArrowBuf data;
+
+  /**
+   * Snapshot of the ArrowSchema raw data.
+   */
+  public static class Snapshot {
+    public long format;
+    public long name;
+    public long metadata;
+    public long flags;
+    public long n_children;
+    public long children;
+    public long dictionary;
+    public long release;
+    public long private_data;
+
+    /**
+    * Initialize empty ArrowSchema snapshot.
+    */
+    public Snapshot() {
+      format = NULL;
+      name = NULL;
+      metadata = NULL;
+      flags = NULL;
+      n_children = NULL;
+      children = NULL;
+      dictionary = NULL;
+      release = NULL;
+      private_data = NULL;
+    }
+  }
+
+  /**
+   * Create ArrowSchema from an existing memory address.
+   * <p>
+   * The resulting ArrowSchema does not own the memory.
+   * 
+   * @param memoryAddress Memory address to wrap
+   * @return A new ArrowSchema instance
+   */
+  public static ArrowSchema wrap(long memoryAddress) {
+    return new ArrowSchema(new ArrowBuf(ReferenceManager.NO_OP, null, 
ArrowSchema.SIZE_OF, memoryAddress));
+  }
+
+  /**
+   * Create ArrowSchema by allocating memory.
+   * <p>
+   * The resulting ArrowSchema owns the memory.
+   * 
+   * @param allocator Allocator for memory allocations
+   * @return A new ArrowSchema instance
+   */
+  public static ArrowSchema allocateNew(BufferAllocator allocator) {
+    return new ArrowSchema(allocator.buffer(ArrowSchema.SIZE_OF));

Review comment:
       I don't understand. Is there a finalizer here?




-- 
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-unsubscr...@arrow.apache.org

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


Reply via email to