Skip to content

Commit

Permalink
Add GLib API (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Jun 9, 2022
1 parent 4e44852 commit ac74977
Show file tree
Hide file tree
Showing 37 changed files with 1,799 additions and 66 deletions.
31 changes: 31 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# 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.

root = true

[{meson.build,meson_options.txt,*.sh}]
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.{vala,rust}]
indent_style = space
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
92 changes: 68 additions & 24 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,49 +93,93 @@ jobs:
runs-on: ${{ matrix.runs-on }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
if: |
matrix.runs-on != 'windows-latest'
with:
python-version: '3.x'
- uses: ruby/setup-ruby@v1
if: |
matrix.runs-on != 'windows-latest'
with:
ruby-version: "3.1"
bundler-cache: true
- uses: actions-rs/toolchain@v1
id: rust-toolchain
with:
toolchain: stable
# For cargo's --out-dir option
# toolchain: stable
toolchain: nightly
override: true
- name: Cache Cargo
uses: actions/cache@v2
with:
path: ~/.cargo
key: cargo-test-${{ matrix.runs-on }}-${{ steps.rust-toolchain.outputs.rustc_hash }}-${{ hashFiles('Cargo.lock') }}
- name: Build
- name: Prepare on Ubuntu
if: |
matrix.runs-on == 'ubuntu-latest'
run: |
pip install meson
sudo apt update
sudo apt install -y -V \
gtk-doc-tools \
libgirepository1.0-dev \
ninja-build \
valac
echo "LD_LIBRARY_PATH=${PWD}/build:${LD_LIBRARY_PATH}" >> ${GITHUB_ENV}
- name: Prepare on macOS
if: |
matrix.runs-on == 'macos-latest'
run: |
brew update --preinstall
brew bundle --file=Brewfile
# - name: Prepare on Windows
# if: |
# matrix.runs-on == 'windows-latest'
# run: |
# pip install meson
- name: Setup on non-Windows
if: |
matrix.runs-on != 'windows-latest'
run: |
meson setup -Ddoc=true -Dvala=true -Dwerror=true build .
- name: Build on non-Windows
if: |
matrix.runs-on != 'windows-latest'
run: |
ninja -C build
- name: Build on Windows
if: |
matrix.runs-on == 'windows-latest'
uses: actions-rs/cargo@v1
with:
command: build
- name: Test
if: |
matrix.runs-on != 'windows-latest'
run: |
cd build
bundle exec ../test/run.sh
- name: Run C example
if: |
matrix.runs-on == 'ubuntu-latest'
matrix.runs-on != 'windows-latest'
run: |
cc \
-o target/debug/sql \
examples/sql.c \
-Iinclude \
-Ltarget/debug \
-Wl,--rpath=target/debug \
-ldatafusion
target/debug/sql
- uses: actions/setup-python@v3
build/examples/sql-c
- name: Run Vala example
if: |
matrix.runs-on == 'ubuntu-latest'
with:
python-version: "3.x"
matrix.runs-on != 'windows-latest'
run: |
build/examples/sql-vala
- name: Run Python example
if: |
matrix.runs-on == 'ubuntu-latest'
matrix.runs-on != 'windows-latest'
run: |
LD_LIBRARY_PATH=$PWD/target/debug examples/sql.py
- uses: ruby/setup-ruby@v1
if: |
matrix.runs-on == 'ubuntu-latest'
with:
ruby-version: "3.1"
cd build
../examples/sql.py
- name: Run Ruby example
if: |
matrix.runs-on == 'ubuntu-latest'
matrix.runs-on != 'windows-latest'
run: |
LD_LIBRARY_PATH=$PWD/target/debug examples/sql.rb
cd build
../examples/sql.rb
23 changes: 23 additions & 0 deletions Brewfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# -*- ruby -*-
#
# 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.

brew "gobject-introspection"
brew "gtk-doc"
brew "meson"
brew "vala"
23 changes: 23 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# -*- ruby -*-
#
# 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.

source "https://rubygems.org/"

gem "gobject-introspection"
gem "test-unit"
53 changes: 26 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,64 +21,63 @@

C language bindings for DataFusion.

## Examples
## How to build

### How to run

Build `libdatafusion.so`:
### Without GLib API

```bash
cargo build
```

C example:
### With GLib API

```bash
cc \
-o target/debug/sql \
-I datafusion/c/include \
datafusion/c/examples/sql.c \
-L target/debug \
-Wl,--rpath=target/debug \
-ldatafusion
target/debug/sql
meson setup build .
meson install -C build
```

Output:
#### Examples

See `examples/sql.c` for C.

```text
```console
$ build/examples/sql-c
+----------+
| Int64(1) |
+----------+
| 1 |
+----------+
```

Python example:
See `examples/sql.py` for Python.

```bash
LD_LIBRARY_PATH=$PWD/target/debug datafusion/c/examples/sql.py
```console
$ LD_LIBRARY_PATH=$PWD/build examples/sql.py
+----------+
| Int64(1) |
+----------+
| 1 |
+----------+
```

Output:
See `examples/sql.rb` for Ruby.

```text
```console
$ LD_LIBRARY_PATH=$PWD/build examples/sql.rb
+----------+
| Int64(1) |
+----------+
| 1 |
+----------+
```

Ruby example:

```bash
LD_LIBRARY_PATH=$PWD/target/debug datafusion/c/examples/sql.rb
```
See `examples/sql.vala` for Vala.

Output:
You need to add `-Dvala=true` option to `meson setup` to enable Vala
support.

```text
```console
$ build/examples/sql-vala
+----------+
| Int64(1) |
+----------+
Expand Down
19 changes: 19 additions & 0 deletions datafusion-glib/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# 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.

/.cache
/compile_commands.json
32 changes: 32 additions & 0 deletions datafusion-glib/data-frame-raw.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* 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.
*/

#pragma once

#include <datafusion-glib/data-frame.h>

#include <datafusion.h>

G_BEGIN_DECLS

GDF_AVAILABLE_IN_8_0
GDFDataFrame *
gdf_data_frame_new_raw(DFDataFrame *raw_data_frame);

G_END_DECLS
Loading

0 comments on commit ac74977

Please sign in to comment.