paleolimbot commented on code in PR #406: URL: https://github.com/apache/arrow-nanoarrow/pull/406#discussion_r1533130121
########## examples/cmake-scenarios/src/library.cpp: ########## @@ -0,0 +1,39 @@ +// 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. + +#include "nanoarrow/nanoarrow.h" +#include "nanoarrow/nanoarrow.hpp" + +#include "library.hpp" + +std::optional<std::pair<std::unique_ptr<ArrowArray>, std::unique_ptr<ArrowSchema>>> +make_simple_array() { + nanoarrow::UniqueArray tmp_array; + nanoarrow::UniqueSchema tmp_schema; + auto result = make_simple_array(tmp_array.get(), tmp_schema.get()); + if (result != 0) { + if (tmp_array.get()->release) tmp_array.get()->release(tmp_array.get()); + if (tmp_schema.get()->release) tmp_schema.get()->release(tmp_schema.get()); + return std::nullopt; + } + auto ret_array = std::make_unique<ArrowArray>(); Review Comment: If you were going to do this in real life you would need to set a custom deleter to ensure that `array->release` was called for a non-null `array` and non-null `array->release`, and I would generally reccomend using the `UniqueArray` (but I think just a simpler example is the way to go here). ########## examples/cmake-scenarios/CMakeLists.txt: ########## @@ -0,0 +1,73 @@ +# 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. + +message(STATUS "Building using CMake version: ${CMAKE_VERSION}") +cmake_minimum_required(VERSION 3.12) + +project(NanoArrowExampleCMakeMinimal LANGUAGES C CXX) + Review Comment: I had to add ``` set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) ``` ...to get `build.sh` to run successfully (although `nanoarrow.hpp` only requires C++11) -- 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