Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add feature request tpl #6

Closed
wants to merge 11 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ build:linux --force_pic
build:macos --force_pic
build:clang-cl --compiler=clang-cl
build:msvc --compiler=msvc-cl
build:windows --compiler=msvc-cl

# test config
test --build_tests_only
Expand All @@ -38,4 +39,5 @@ test --test_output=all
build:linux --cxxopt="-std=c++17" --linkopt="-pthread"
build:macos --cxxopt="-std=c++17" --linkopt="-pthread"
build:clang-cl --cxxopt="-std=c++17"
build:windows --cxxopt="/std:c++17"
build:windows --cxxopt="/std:c++17" --cxxopt="/Zc:preprocessor" --cxxopt="/utf-8"
build:msvc --cxxopt="/std:c++17" --cxxopt="/Zc:preprocessor" --cxxopt="/utf-8"
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/feature_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
name: 🚀 Feature Request
description: I have a suggestion (and may want to implement it 🙂)!
title: "[<Fury component: Protocol|Java|Python|C++|JavaScript|etc...>] "
assignees: ""
labels: ["new feature"]

body:
Expand Down Expand Up @@ -55,4 +54,5 @@ body:
validations:
required: false
- type: markdown
value: "Please read the [Contribution Guideline](https://fury.apache.org/docs/community/how_to_join_community) before submitting the PR"
attributes:
value: "Please read the [Contribution Guideline](https://fury.apache.org/docs/community/how_to_join_community) before submitting the PR"
28 changes: 26 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@
with:
java-version: ${{ matrix.java-version }}
distribution: "temurin"
- name: Set up Python3.8
uses: actions/setup-python@v5
with:
python-version: 3.8
- name: Install bazel
run: ./ci/run_ci.sh install_bazel
- name: Install python
Expand All @@ -78,6 +82,10 @@
with:
java-version: ${{ matrix.java-version }}
distribution: "adopt-openj9"
- name: Set up Python3.8
uses: actions/setup-python@v5
with:
python-version: 3.8
- name: Install bazel
run: ./ci/run_ci.sh install_bazel
- name: Install python
Expand All @@ -100,6 +108,10 @@
distribution: "graalvm"
github-token: ${{ secrets.GITHUB_TOKEN }}
native-image-job-reports: "true"
- name: Set up Python3.8
uses: actions/setup-python@v5
with:
python-version: 3.8
- name: Build native image and run
run: ./ci/run_ci.sh graalvm_test

Expand All @@ -111,12 +123,20 @@
- name: Set up JDK8
uses: actions/setup-java@v4
with:
java-version: 8
java-version: 11
distribution: "temurin"
- name: Install fury java
run: cd java && mvn -T10 --no-transfer-progress clean install -DskipTests && cd -
- name: Test
run: |
sudo apt-get update
sudo apt-get install apt-transport-https curl gnupg -yqq
echo "deb https://repo.scala-sbt.org/scalasbt/debian all main" | sudo tee /etc/apt/sources.list.d/sbt.list
echo "deb https://repo.scala-sbt.org/scalasbt/debian /" | sudo tee /etc/apt/sources.list.d/sbt_old.list
curl -sL "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x2EE0EA64E40A89B84B2DF73499E82A75642AC823" | sudo -H gpg --no-default-keyring --keyring gnupg-ring:/etc/apt/trusted.gpg.d/scalasbt-release.gpg --import
sudo chmod 644 /etc/apt/trusted.gpg.d/scalasbt-release.gpg
sudo apt-get update
sudo apt-get install sbt
# Avoid sbt download jackson-databind error
rm -rf /home/runner/.m2/repository/com/fasterxml/jackson/
cd scala && sbt +test && cd -
Expand Down Expand Up @@ -165,7 +185,7 @@
name: Rust CI
strategy:
matrix:
os: [ubuntu-latest, macos-12, macos-14] # macos-12: x86, macos-14: arm64

Check warning on line 188 in .github/workflows/ci.yml

View workflow job for this annotation

GitHub Actions / 🍏 YAML

188:49 [comments] too few spaces before comment

Check warning on line 188 in .github/workflows/ci.yml

View workflow job for this annotation

GitHub Actions / 🍏 YAML

188:49 [comments] too few spaces before comment
runs-on: ${{ matrix.os }}
timeout-minutes: 45
steps:
Expand All @@ -181,7 +201,7 @@
name: C++ CI
strategy:
matrix:
os: [ubuntu-latest, macos-12, macos-14] # macos-12: x86, macos-14: arm64
os: [ubuntu-latest, macos-12, macos-14, windows-2022] # macos-12: x86, macos-14: arm64

Check warning on line 204 in .github/workflows/ci.yml

View workflow job for this annotation

GitHub Actions / 🍏 YAML

204:63 [comments] too few spaces before comment

Check warning on line 204 in .github/workflows/ci.yml

View workflow job for this annotation

GitHub Actions / 🍏 YAML

204:63 [comments] too few spaces before comment
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -224,6 +244,10 @@
go-version: ${{ matrix.go-version }}
- name: Display Go version
run: go version
- name: Set up Python3.8
uses: actions/setup-python@v5
with:
python-version: 3.8
- name: Install bazel
run: ./ci/run_ci.sh install_bazel
- name: Install python
Expand Down
62 changes: 62 additions & 0 deletions bazel/arrow/BUILD.windows.bzl
Original file line number Diff line number Diff line change
@@ -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.

package(default_visibility = ["//visibility:public"])

load("@rules_cc//cc:defs.bzl", "cc_library", "cc_import")

cc_library(
name = "arrow",
hdrs = [":arrow_header_include"],
includes = ["include"],
deps = [":arrow_shared_library"],
visibility = ["//visibility:public"],
)

cc_import(
name = "arrow_shared_library",
interface_library = ":libarrow_interface",
shared_library = ":libarrow",
visibility = ["//visibility:public"],
)

cc_import(
name = "arrow_python_shared_library",
interface_library = ":libarrow_python_interface",
shared_library = ":libarrow_python",
visibility = ["//visibility:public"],
)

cc_library(
name = "arrow_header_lib",
hdrs = [":arrow_header_include"],
includes = ["include"],
visibility = ["//visibility:public"],
)

cc_library(
name="python_numpy_headers",
hdrs=[":python_numpy_include"],
includes=["python_numpy_include"],
)

%{ARROW_HEADER_GENRULE}
%{ARROW_LIBRARY_GENRULE}
%{ARROW_ITF_LIBRARY_GENRULE}
%{ARROW_PYTHON_LIBRARY_GENRULE}
%{ARROW_PYTHON_ITF_LIB_GENRULE}
%{PYTHON_NUMPY_INCLUDE_GENRULE}
58 changes: 43 additions & 15 deletions bazel/arrow/pyarrow_configure.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,12 @@ def _get_pyarrow_include(repository_ctx, python_bin="python3"):
error_details=(
"Is the Python binary path set up right? " + "(See ./configure or "
+ python_bin + ".) " + "Is distutils installed?"))
return result.stdout.splitlines()[0]
return result.stdout.splitlines()[0].replace('\\', '/')

def _get_pyarrow_shared_library(repository_ctx, library_name, python_bin="python3"):
"""Gets the pyarrow shared library path."""
code = """import pyarrow, os, glob;print(glob.glob(os.path.join(""" +\
"""os.path.dirname(pyarrow.__file__), 'lib{}.*'))[0])""".format(library_name)
"""os.path.dirname(pyarrow.__file__), '{}'))[0])""".format(library_name)
result = _execute(
repository_ctx, [
python_bin, "-c", code
Expand All @@ -186,7 +186,7 @@ def _get_pyarrow_shared_library(repository_ctx, library_name, python_bin="python
error_details=(
"Is the Python binary path set up right? " + "(See ./configure or "
+ python_bin + ".) " + "Is distutils installed?"))
return result.stdout.splitlines()[0]
return result.stdout.splitlines()[0].replace('\\', '/')

#python numpy include
def _get_python_numpy_include(repository_ctx, python_bin="python3"):
Expand All @@ -199,39 +199,67 @@ def _get_python_numpy_include(repository_ctx, python_bin="python3"):
error_details=(
"Is the Python binary path set up right? " + "(See ./configure or "
+ python_bin + ".) " + "Is distutils installed?"))
return result.stdout.splitlines()[0]
return result.stdout.splitlines()[0].replace('\\', '/')

def _pyarrow_pip_impl(repository_ctx):
arrow_header_dir = _get_pyarrow_include(repository_ctx)
python_bin = "python3"

# python 3.x is usually named as `python` by default on windows.
if _is_windows(repository_ctx):
python_bin = "python"

arrow_header_dir = _get_pyarrow_include(repository_ctx, python_bin)
arrow_header_rule = _symlink_genrule_for_dir(
repository_ctx,
arrow_header_dir,
"include",
"arrow_header_include",
)

arrow_library_path = _get_pyarrow_shared_library(repository_ctx, "arrow")
arrow_library_path = _get_pyarrow_shared_library(repository_ctx, "arrow.dll" if _is_windows(repository_ctx) else "libarrow.*", python_bin)
arrow_library = arrow_library_path.rsplit("/",1 )[-1]
arrow_library_rule = _symlink_genrule_for_dir(
repository_ctx, None, "", "libarrow", [arrow_library_path], [arrow_library])

arrow_python_library_path = _get_pyarrow_shared_library(repository_ctx, "arrow_python")
arrow_python_library_path = _get_pyarrow_shared_library(repository_ctx, "arrow_python.dll" if _is_windows(repository_ctx) else "libarrow_python.*", python_bin)
arrow_python_library = arrow_python_library_path.rsplit("/",1 )[-1]
arrow_python_library_rule = _symlink_genrule_for_dir(
repository_ctx, None, "", "libarrow_python",
[arrow_python_library_path], [arrow_python_library])

python_numpy_include = _get_python_numpy_include(repository_ctx)
python_numpy_include = _get_python_numpy_include(repository_ctx, python_bin)
python_numpy_include_rule = _symlink_genrule_for_dir(
repository_ctx, python_numpy_include, 'python_numpy_include', 'python_numpy_include')

build_tpl = repository_ctx.path(Label("//bazel/arrow:BUILD.tpl.bzl"))
repository_ctx.template("BUILD", build_tpl, {
"%{ARROW_HEADER_GENRULE}": arrow_header_rule,
"%{ARROW_LIBRARY_GENRULE}": arrow_library_rule,
"%{ARROW_PYTHON_LIBRARY_GENRULE}": arrow_python_library_rule,
"%{PYTHON_NUMPY_INCLUDE_GENRULE}": python_numpy_include_rule,
})
if _is_windows(repository_ctx):
arrow_interface_library_path = _get_pyarrow_shared_library(repository_ctx, "arrow.lib", python_bin)
arrow_interface_library = arrow_interface_library_path.rsplit("/",1 )[-1]
arrow_interface_library_rule = _symlink_genrule_for_dir(
repository_ctx, None, "", "libarrow_interface", [arrow_interface_library_path], [arrow_interface_library])

arrow_python_interface_library_path = _get_pyarrow_shared_library(repository_ctx, "arrow_python.lib", python_bin)
arrow_python_interface_library = arrow_python_interface_library_path.rsplit("/",1 )[-1]
arrow_python_interface_library_rule = _symlink_genrule_for_dir(
repository_ctx, None, "", "libarrow_python_interface",
[arrow_python_interface_library_path], [arrow_python_interface_library])

build_tpl = repository_ctx.path(Label("//bazel/arrow:BUILD.windows.bzl"))
repository_ctx.template("BUILD", build_tpl, {
"%{ARROW_HEADER_GENRULE}": arrow_header_rule,
"%{ARROW_LIBRARY_GENRULE}": arrow_library_rule,
"%{ARROW_ITF_LIBRARY_GENRULE}": arrow_interface_library_rule,
"%{ARROW_PYTHON_LIBRARY_GENRULE}": arrow_python_library_rule,
"%{ARROW_PYTHON_ITF_LIB_GENRULE}": arrow_python_interface_library_rule,
"%{PYTHON_NUMPY_INCLUDE_GENRULE}": python_numpy_include_rule,
})
else:
build_tpl = repository_ctx.path(Label("//bazel/arrow:BUILD.tpl.bzl"))
repository_ctx.template("BUILD", build_tpl, {
"%{ARROW_HEADER_GENRULE}": arrow_header_rule,
"%{ARROW_LIBRARY_GENRULE}": arrow_library_rule,
"%{ARROW_PYTHON_LIBRARY_GENRULE}": arrow_python_library_rule,
"%{PYTHON_NUMPY_INCLUDE_GENRULE}": python_numpy_include_rule,
})

pyarrow_configure = repository_rule(
implementation = _pyarrow_pip_impl,
Expand Down
4 changes: 3 additions & 1 deletion ci/run_ci.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@

PYARROW_VERSION = "14.0.0"

NUMPY_VERSION = "1.26.4"

PROJECT_ROOT_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), "../")

logging.basicConfig(
Expand Down Expand Up @@ -115,7 +117,7 @@ def _run_js():
def _install_cpp_deps():
_exec_cmd(f"pip install pyarrow=={PYARROW_VERSION}")
_exec_cmd("pip install psutil")
_exec_cmd("pip install 'numpy<2.0.0'")
_exec_cmd(f"pip install numpy=={NUMPY_VERSION}")
_install_bazel()


Expand Down
1 change: 1 addition & 0 deletions ci/run_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ ROOT="$(git rev-parse --show-toplevel)"
echo "Root path: $ROOT, home path: $HOME"
cd "$ROOT"


install_python() {
wget -q https://repo.anaconda.com/miniconda/Miniconda3-py38_23.5.2-0-Linux-x86_64.sh -O Miniconda3.sh
bash Miniconda3.sh -b -p $HOME/miniconda && rm -f miniconda.*
Expand Down
4 changes: 2 additions & 2 deletions cpp/fury/row/row.cc
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,8 @@ int *ArrayData::GetDimensions(ArrayData &array, int num_dims) {
// use deep-first search to search to numDimensions-1 layer to get dimensions.
int depth = 0;
auto dimensions = new int[num_dims];
int start_from_lefts[num_dims];
ArrayData *arrs[num_dims]; // root to current node
std::vector<int> start_from_lefts(num_dims);
std::vector<const ArrayData *> arrs(num_dims); // root to current node
ArrayData &arr = array;
while (depth < num_dims) {
arrs[depth] = &arr;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,55 +21,57 @@

import java.util.function.Consumer;
import java.util.function.Function;
import org.apache.fury.annotation.Internal;
import org.apache.fury.resolver.ClassChecker;
import org.apache.fury.serializer.Serializer;
import org.apache.fury.serializer.SerializerFactory;

public abstract class AbstractThreadSafeFury implements ThreadSafeFury {
@Override
public void register(Class<?> clz) {
processCallback(fury -> fury.register(clz));
registerCallback(fury -> fury.register(clz));
}

@Override
public void register(Class<?> cls, boolean createSerializer) {
processCallback(fury -> fury.register(cls, createSerializer));
registerCallback(fury -> fury.register(cls, createSerializer));
}

@Override
public void register(Class<?> cls, Short id) {
processCallback(fury -> fury.register(cls, id));
registerCallback(fury -> fury.register(cls, id));
}

@Override
public void register(Class<?> cls, Short id, boolean createSerializer) {
processCallback(fury -> fury.register(cls, id, createSerializer));
registerCallback(fury -> fury.register(cls, id, createSerializer));
}

@Override
public <T> void registerSerializer(Class<T> type, Class<? extends Serializer> serializerClass) {
processCallback(fury -> fury.registerSerializer(type, serializerClass));
registerCallback(fury -> fury.registerSerializer(type, serializerClass));
}

@Override
public void registerSerializer(Class<?> type, Serializer<?> serializer) {
processCallback(fury -> fury.registerSerializer(type, serializer));
registerCallback(fury -> fury.registerSerializer(type, serializer));
}

@Override
public void registerSerializer(Class<?> type, Function<Fury, Serializer<?>> serializerCreator) {
processCallback(fury -> fury.registerSerializer(type, serializerCreator.apply(fury)));
registerCallback(fury -> fury.registerSerializer(type, serializerCreator.apply(fury)));
}

@Override
public void setSerializerFactory(SerializerFactory serializerFactory) {
processCallback(fury -> fury.setSerializerFactory(serializerFactory));
registerCallback(fury -> fury.setSerializerFactory(serializerFactory));
}

@Override
public void setClassChecker(ClassChecker classChecker) {
processCallback(fury -> fury.getClassResolver().setClassChecker(classChecker));
registerCallback(fury -> fury.getClassResolver().setClassChecker(classChecker));
}

protected abstract void processCallback(Consumer<Fury> callback);
@Internal
public abstract void registerCallback(Consumer<Fury> callback);
}
Loading
Loading