Skip to content

Commit 4c78c99

Browse files
committed
fix: support java #7
1 parent d8a5656 commit 4c78c99

18 files changed

+2153
-2
lines changed

.github/workflows/test_java.yml

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Test Java
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
env:
10+
CARGO_TERM_COLOR: always
11+
CONDA_PREFIX: /usr/share/miniconda
12+
13+
jobs:
14+
test:
15+
name: Build and test Java
16+
runs-on: ${{ matrix.os }}
17+
strategy:
18+
matrix:
19+
os: [ "macos-latest", "windows-latest", "ubuntu-latest"]
20+
steps:
21+
- uses: actions/checkout@v3
22+
- name: Set up Python
23+
uses: actions/setup-python@v4
24+
with:
25+
python-version: 3.7
26+
- name: Add conda to system path
27+
run: |
28+
# $CONDA is an environment variable pointing to the root of the miniconda directory
29+
echo $CONDA/bin >> $GITHUB_PATH
30+
echo $CONDA
31+
- name: Install python dependencies
32+
run: |
33+
python -m pip install --upgrade pip
34+
pip install -r build.requirements.txt
35+
- name: Maturin develop
36+
uses: PyO3/maturin-action@v1
37+
with:
38+
maturin-version: latest
39+
command: develop
40+
args: --release
41+
- name: save bloom filter to file
42+
run: python py_tests/test_save_file.py
43+
- uses: actions/setup-java@v3
44+
with:
45+
distribution: 'zulu'
46+
java-version: '8'
47+
- run: chmod +x millw
48+
- run: ./millw fastbloomjvm.test

.gitignore

+10
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,13 @@ Cargo.lock
1616
*.pyc
1717

1818
__pychche__
19+
20+
out
21+
fastbloomjvm/native/target
22+
fastbloomjvm/native/Cargo.lock
23+
fastbloomjvm/native/.idea
24+
25+
.pytest_cache
26+
.vscode
27+
py_tests/.pytest_cache
28+
data

.mill-version

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.10.12

Cargo.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "fastbloom_rs"
3-
version = "0.5.4"
3+
version = "0.5.5"
44
edition = "2021"
55
authors = ["Yan Kun <[email protected]>"]
66
description = "Some fast bloom filter implemented by Rust for Python and Rust! 10x faster than pybloom!"
@@ -39,6 +39,7 @@ rand = "0.8"
3939

4040
[workspace]
4141
members = ["fastbloom-rs"]
42+
exclude = ["fastbloomjvm/native"]
4243

4344
[[bench]]
4445
name = "fastbloom"

build.sc

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import mill._, scalalib._, publish._
2+
import mill.define.Sources
3+
import mill.scalalib.JavaModule
4+
import $ivy.`io.github.otavia-projects::mill-rust_mill$MILL_BIN_PLATFORM:0.2.1`
5+
import io.github.otavia.jni.plugin.RustJniModule
6+
7+
object ProjectInfo {
8+
9+
def description: String = "Some fast bloom filter implemented by Rust for Python and Java!"
10+
11+
def organization: String = "io.github.yankun1992"
12+
13+
def organizationUrl: String = ""
14+
15+
def projectUrl: String = ""
16+
17+
def licenses = Seq()
18+
19+
def author = Seq("Yan Kun <[email protected]>")
20+
21+
def version = "0.5.5-SNAPSHOT"
22+
23+
def buildTool = "mill"
24+
25+
def buildToolVersion = mill.BuildInfo.millVersion
26+
27+
}
28+
29+
object fastbloomjvm extends RustJniModule with PublishModule {
30+
31+
override def release: Boolean = true
32+
33+
override def publishVersion: T[String] = ProjectInfo.version
34+
35+
override def pomSettings: T[PomSettings] = PomSettings(
36+
description = ProjectInfo.description,
37+
organization = ProjectInfo.organization,
38+
url = "",
39+
licenses = ProjectInfo.licenses,
40+
versionControl = VersionControl(),
41+
developers = Seq(Developer("yan_kun", "Yan Kun", "", Some("icekredit"), Some("")))
42+
)
43+
44+
override def artifactName = "fastbloomjvm"
45+
46+
override def artifactId = "fastbloom"
47+
48+
override def ivyDeps = Agg(ivy"io.github.otavia-projects:jni-loader:0.2.1")
49+
50+
object test extends Tests with TestModule.Junit4 {
51+
52+
}
53+
54+
}

fastbloom-rs/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "fastbloom-rs"
3-
version = "0.5.4"
3+
version = "0.5.5"
44
edition = "2021"
55
authors = ["Yan Kun <[email protected]>"]
66
description = "Some fast bloom filter implemented by Rust for Python and Rust!"

fastbloomjvm/native/Cargo.toml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[package]
2+
name = "fastbloom" # generated by nativeInit with defaultNativeName
3+
version = "0.5.5"
4+
authors = ["Yan Kun <[email protected]>"]
5+
edition = "2021"
6+
7+
[dependencies]
8+
jni = "0.21"
9+
fastbloom-rs = { path = "../../fastbloom-rs" }
10+
11+
[lib]
12+
crate_type = ["cdylib"]

0 commit comments

Comments
 (0)