paleolimbot commented on code in PR #39:
URL: https://github.com/apache/arrow-nanoarrow/pull/39#discussion_r960618138


##########
r/R/array.R:
##########
@@ -0,0 +1,68 @@
+# 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.
+
+#' Convert an object to a nanoarrow array
+#'
+#' @param x An object to convert to a array
+#' @param schema An optional schema used to enforce conversion to a particular
+#'   type. Defaults to [infer_nanoarrow_schema()].
+#' @param to A target prototype object describing the type to which `array`
+#'   should be converted.
+#' @param array An object of class 'nanoarrow_array'
+#' @param ... Passed to S3 methods
+#'
+#' @return An object of class 'nanoarrow_array'
+#' @export
+as_nanoarrow_array <- function(x, ..., schema = NULL) {
+  UseMethod("as_nanoarrow_array")
+}
+
+#' @rdname as_nanoarrow_array
+#' @export
+from_nanoarrow_array <- function(array, to = NULL, ...) {
+  stopifnot(inherits(array, "nanoarrow_array"))
+  UseMethod("from_nanoarrow_array", to)
+}
+
+#' @export
+as_nanoarrow_array.default <- function(x, ..., schema = NULL) {
+  # For now, use arrow's conversion for everything

Review Comment:
   Yes, it's temporary. When did narrow the first time, I started from the 
"let's assemble C structs from R vectors first" side of things and it was a 
long road to anything useful. Here I'm trying it from the other side...let's 
let Arrow create valid C structs for us and implement conversions one at a time.



-- 
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]

Reply via email to