diff --git a/.github/workflows/d.yml b/.github/workflows/d.yml new file mode 100644 index 0000000000000..1471c0ca4865e --- /dev/null +++ b/.github/workflows/d.yml @@ -0,0 +1,104 @@ +# 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. + +name: D + +on: + push: + branches: + - '**' + - '!dependabot/**' + tags: + - '**' + paths: + - '.dockerignore' + - '.github/workflows/d.yml' + - 'ci/docker/*d*' + - 'ci/scripts/c_glib_*' + - 'ci/scripts/cpp_*' + - 'ci/scripts/d_*' + - 'c_glib/**' + - 'cpp/**' + - 'docker-compose.yml' + - 'd/**' + pull_request: + paths: + - '.dockerignore' + - '.github/workflows/d.yml' + - 'ci/docker/*d*' + - 'ci/scripts/c_glib_*' + - 'ci/scripts/cpp_*' + - 'ci/scripts/d_*' + - 'c_glib/**' + - 'cpp/**' + - 'docker-compose.yml' + - 'd/**' + +concurrency: + group: ${{ github.repository }}-${{ github.head_ref || github.sha }}-${{ github.workflow }} + cancel-in-progress: true + +permissions: + contents: read + +env: + ARCHERY_DEBUG: 1 + DOCKER_VOLUME_PREFIX: ".docker/" + +jobs: + docker: + name: AMD64 Ubuntu ${{ matrix.ubuntu }} Glib & D + runs-on: ubuntu-latest + if: ${{ !contains(github.event.pull_request.title, 'WIP') }} + timeout-minutes: 60 + strategy: + fail-fast: false + matrix: + ubuntu: + - 22.04 + env: + UBUNTU: ${{ matrix.ubuntu }} + steps: + - name: Checkout Arrow + uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 + with: + fetch-depth: 0 + submodules: recursive + - name: Setup Python on hosted runner + uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0 + with: + python-version: 3 + - name: Setup Archery + run: pip install -e dev/archery[docker] + - name: Execute Docker Build + env: + ARCHERY_DOCKER_USER: ${{ secrets.DOCKERHUB_USER }} + ARCHERY_DOCKER_PASSWORD: ${{ secrets.DOCKERHUB_TOKEN }} + run: | + source ci/scripts/util_enable_core_dumps.sh + archery docker run ubuntu-d + - name: Docker Push + if: >- + success() && + github.event_name == 'push' && + github.repository == 'apache/arrow' && + github.ref_name == 'main' + env: + ARCHERY_DOCKER_USER: ${{ secrets.DOCKERHUB_USER }} + ARCHERY_DOCKER_PASSWORD: ${{ secrets.DOCKERHUB_TOKEN }} + continue-on-error: true + run: archery docker push ubuntu-d diff --git a/ci/docker/ubuntu-d.dockerfile b/ci/docker/ubuntu-d.dockerfile new file mode 100644 index 0000000000000..4ee1cccc86ed5 --- /dev/null +++ b/ci/docker/ubuntu-d.dockerfile @@ -0,0 +1,34 @@ +# 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. + +ARG base +FROM ${base} + +SHELL ["/bin/bash", "-o", "pipefail", "-c"] + +RUN echo "debconf debconf/frontend select Noninteractive" | + debconf-set-selections + +# Install ldc2 toolchain (dmd-frontend + llvm-backend), dub package manager & meson build system +RUN apt-get update -y -q && + apt-get install -y -q --no-install-recommends \ + dub \ + ldc \ + meson \ + pkg-config && + apt-get clean && \ + rm -rf /var/lib/apt/lists/* diff --git a/ci/scripts/d_test.sh b/ci/scripts/d_test.sh new file mode 100755 index 0000000000000..9e2dd74e519fa --- /dev/null +++ b/ci/scripts/d_test.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash +# +# 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. + +set -ex + +source_dir=${1}/d + +export DYLD_LIBRARY_PATH=${ARROW_HOME}/lib:${DYLD_LIBRARY_PATH} +export LD_LIBRARY_PATH=${ARROW_HOME}/lib:${LD_LIBRARY_PATH} +export PKG_CONFIG_PATH=${ARROW_HOME}/lib/pkgconfig +export GI_TYPELIB_PATH=${ARROW_HOME}/lib/girepository-1.0 + +# Enable memory debug checks if the env is not set already +if [ -z "${ARROW_DEBUG_MEMORY_POOL}" ]; then + export ARROW_DEBUG_MEMORY_POOL=trap +fi + +dub test --root=${source_dir} diff --git a/d/.gitignore b/d/.gitignore new file mode 100644 index 0000000000000..6900592817fa0 --- /dev/null +++ b/d/.gitignore @@ -0,0 +1,21 @@ +# 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. + +# unittest executable +arrow-d-test-unittest* +# generated files +source/arrow*/ diff --git a/d/README.md b/d/README.md new file mode 100644 index 0000000000000..aa2e148bcd5d2 --- /dev/null +++ b/d/README.md @@ -0,0 +1,43 @@ + + +# Apache Arrow D + +An implementation of Arrow targeting D programming language. + +See our current [feature matrix](https://github.com/apache/arrow/blob/main/docs/source/status.rst) +for currently available features. + +## Requirements + +- [dmd/gdc/ldc2](https://dlang.org/download) with druntime-frontend 2.105.0 or later + +## Building + +- build Apache Arrow C++ +- build Apache Arrow GLib +- build D bindings + +```console +$ git clone https://github.com/apache/arrow.git +$ cd arrow/d +$ dub build -b release +# Test +$ dub test +``` diff --git a/d/dub.json b/d/dub.json new file mode 100644 index 0000000000000..d245671e77c4a --- /dev/null +++ b/d/dub.json @@ -0,0 +1,50 @@ +{ + "name": "arrow-d", + "description": "Apache Arrow - D bindings", + "license": "Apache-2.0", + "toolchainRequirements": { + "frontend": ">=2.105.3" + }, + "buildTypes": { + "debug": { + "buildOptions": [ + "debugMode", + "debugInfo" + ] + }, + "release": { + "buildOptions": [ + "releaseMode", + "inline", + "optimize" + ] + } + }, + "preBuildCommands": [ + "\"$DUB\" run girtod -- -i source -o source --use-runtime-linker" + ], + "dependencies": { + "girtod": { + "repository": "git+https://github.com/gtkd-developers/gir-to-d.git", + "version": "098475152340cbac072824af5136b9151a983ca4" + }, + "glibd": { + "repository": "git+https://github.com/gtkd-developers/GlibD.git", + "version": "1546823185334c4727d378baf890fa13d9fa4cbd" + } + }, + "configurations": [ + { + "name": "unittest", + "sourceFiles": [ + "source/package.d" + ], + "libs": [ + "arrow-glib" + ], + "dflags-dmd": ["-verrors=context"], + "dflags-ldc": ["--verrors-context"] + } + ] + +} \ No newline at end of file diff --git a/d/source/APILookup.txt b/d/source/APILookup.txt new file mode 100644 index 0000000000000..3c60a77dd28f4 --- /dev/null +++ b/d/source/APILookup.txt @@ -0,0 +1,20 @@ +# 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. + +includeComments: y + +lookup: APILookupArrow.txt diff --git a/d/source/APILookupArrow.txt b/d/source/APILookupArrow.txt new file mode 100644 index 0000000000000..26ccd4db7e842 --- /dev/null +++ b/d/source/APILookupArrow.txt @@ -0,0 +1,55 @@ +# 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. + +# add apache license in wrapped modules + +license: start +/* +* 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. +*/ + +// generated automatically - do not change +// find conversion definition on APILookup.txt +// implement new conversion functionalities the gir-to-d package + + +license: end + +############################################# +### Definitions for wrapping Arrow ########## +############################################# + +wrap: arrow +file: Arrow-1.0.gir + +# rename +alias: import import_ diff --git a/d/source/package.d b/d/source/package.d new file mode 100644 index 0000000000000..9d5ad09adcba0 --- /dev/null +++ b/d/source/package.d @@ -0,0 +1,62 @@ +/* +* 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. +*/ + +module arrow; + +version (unittest) +{ + import arrow.Array; + import arrow.DataType; + import arrow.BooleanArray; + import arrow.CastOptions; + import arrow.FilterOptions; + import arrow.TakeOptions; + import arrow.c.types; + + @("Arrow Array") + unittest + { + // Test array creation and basic properties + auto array = new Array(null); + assert(array.getLength() == 0); + assert(array.getNNulls() == 0); + assert(array.getOffset() == 0); + + // Test null checks + auto nullBitmap = array.getNullBitmap(); + assert(nullBitmap is null); + + // Test value type + auto valueType = array.getValueType(); + assert(valueType >= GArrowType.NA); + + // Test equality + auto otherArray = new Array(null); + assert(array.equal(otherArray)); + assert(array.equalApprox(otherArray)); + + // Test slicing + auto slice = array.slice(0, 0); + assert(slice !is null); + + // Test data type + auto dataType = array.getValueDataType(); + assert(dataType is null || dataType !is null); + } +} diff --git a/docker-compose.yml b/docker-compose.yml index 0882121d598bb..8193959187181 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -157,6 +157,7 @@ x-hierarchy: - ubuntu-cpp-sanitizer - ubuntu-cpp-thread-sanitizer - ubuntu-cpp-emscripten + - ubuntu-d - ubuntu-r-sanitizer - ubuntu-r-valgrind - ubuntu-swift @@ -955,6 +956,23 @@ services: /arrow/ci/scripts/python_build.sh /arrow /build && /arrow/ci/scripts/python_test.sh /arrow" + ubuntu-d: + # Usage: + # docker-compose build ubuntu-d + # docker-compose run --rm ubuntu-d + # Parameters: + image: ubuntu-d + build: + context: . + dockerfile: ci/docker/ubuntu-d.dockerfile + shm_size: *shm-size + volumes: *ubuntu-volumes + command: &d-command > + /bin/bash -c " + /arrow/ci/scripts/cpp_build.sh /arrow /build && + /arrow/ci/scripts/c_glib_build.sh /arrow /build && + /arrow/ci/scripts/d_test.sh /arrow /build" + debian-python: # Usage: # docker-compose build debian-cpp