Skip to content
Draft
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
2 changes: 1 addition & 1 deletion .github/actions/mlt-setup-java/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ runs:
uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: '21'
java-version: '22'

- name: Setup Java Gradle
uses: gradle/actions/setup-gradle@v4
8 changes: 2 additions & 6 deletions .github/workflows/java-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,11 @@ jobs:
- name: Checkout code
uses: actions/checkout@v5

- name: Set up JDK
uses: actions/setup-java@v5
with:
java-version: '21'
distribution: 'temurin'

- uses: taiki-e/install-action@v2
with: { tool: 'just,cargo-binstall' }

- uses: ./.github/actions/mlt-setup-java

- name: Get version from tag
id: get_version
run: |
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/java.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
test-java:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
Expand Down
2 changes: 1 addition & 1 deletion java/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jacocoTestReport {

java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
languageVersion = JavaLanguageVersion.of(22)
}
}

Expand Down
3 changes: 2 additions & 1 deletion java/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#Thu Nov 06 08:19:40 PST 2025
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
2 changes: 1 addition & 1 deletion java/mlt-cli/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jacocoTestReport {

java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
languageVersion = JavaLanguageVersion.of(22)
}
}

Expand Down
29 changes: 18 additions & 11 deletions java/mlt-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,16 @@ dependencies {
implementation 'com.google.guava:guava:33.5.0-jre'
implementation 'com.google.protobuf:protobuf-java:4.32.1'
implementation 'io.github.earcut4j:earcut4j:2.2.2'
testImplementation 'io.github.sebasbaumh:mapbox-vector-tile-java:25.1.0'
implementation 'me.lemire.integercompression:JavaFastPFOR:0.2.1'
implementation 'no.ecc.vectortile:java-vector-tile:1.3.23'
implementation 'org.apache.orc:orc-core:1.8.1'
implementation 'org.locationtech.jts:jts-core:1.20.0'
implementation 'org.slf4j:slf4j-simple:2.0.17'
implementation 'jakarta.annotation:jakarta.annotation-api:3.0.0'
implementation 'org.jetbrains:annotations:15.0'
implementation 'nl.bartlouwers:fsst4j:0.0.4'

testImplementation 'io.github.sebasbaumh:mapbox-vector-tile-java:25.1.0'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.3'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.11.4'
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.10.3'
Expand All @@ -54,7 +55,7 @@ jacocoTestReport {

java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
languageVersion = JavaLanguageVersion.of(22)
}
}

Expand All @@ -67,19 +68,24 @@ spotless {
}
}

tasks.register('compileWrapper', Exec) {
workingDir = project.projectDir
doFirst {
if (System.properties['os.name'].toLowerCase().contains('windows')) {
executable "../resources/compile-windows.bat"
} else {
executable "./compile-wrapper.sh"
tasks.register('compileWrapper') {
description = 'Builds the native FSST wrapper'
group = 'build'
outputs.files layout.projectDirectory.dir('../resources/build/FsstWrapper.so')

doLast {
def baseDir = file(layout.projectDirectory.dir('..'))
exec {
workingDir baseDir
if (System.properties['os.name'].toLowerCase().contains('windows')) {
commandLine "resources\\compile-windows.bat"
} else {
commandLine './resources/compile'
}
}
}
}

// compileJava.dependsOn compileWrapper // Disabled due to CMake compatibility issues

gradle.projectsEvaluated {
tasks.withType(JavaCompile).tap {
configureEach {
Expand All @@ -92,6 +98,7 @@ gradle.projectsEvaluated {

tasks.withType(Test).configureEach {
useJUnitPlatform()
//dependsOn(tasks.named('compileWrapper'))
}

tasks.register('validateSemver') {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.maplibre.mlt.converter.encodings.fsst;

import java.io.ByteArrayOutputStream;
import nl.bartlouwers.fsst.SymbolTable;

public interface Fsst {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import nl.bartlouwers.fsst.SymbolTable;

class FsstDebug implements Fsst {
private final Fsst java = new FsstJava();
Expand All @@ -21,20 +22,24 @@ class FsstDebug implements Fsst {
Runtime.getRuntime().addShutdownHook(new Thread(FsstDebug::printStats));
}

public static int weight(SymbolTable table) {
return table.symbols().length + table.symbolLengths().length + table.compressedData().length;
}

@Override
public SymbolTable encode(byte[] data) {
new LongSummaryStatistics();

long a = System.currentTimeMillis();
var fromJni = jni.encode(data);
long b = System.currentTimeMillis();
var fromJava = java.encode(data);
long c = System.currentTimeMillis();
jniTime.addAndGet(b - a);
javaTime.addAndGet(c - b);
jniSize.addAndGet(fromJni.weight());
javaSize.addAndGet(fromJava.weight());
(fromJava.weight() <= fromJni.weight() ? javaSmaller : jniSmaller).incrementAndGet();
final long a = System.currentTimeMillis();
final var fromJni = FsstJni.isLoaded() ? jni.encode(data) : null;
final long b = System.currentTimeMillis();
final var fromJava = java.encode(data);
final long c = System.currentTimeMillis();
if (fromJni != null) {
jniTime.addAndGet(b - a);
javaTime.addAndGet(c - b);
jniSize.addAndGet(weight(fromJni));
javaSize.addAndGet(weight(fromJava));
(weight(fromJava) <= weight(fromJni) ? javaSmaller : jniSmaller).incrementAndGet();
}
return fromJava;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.maplibre.mlt.converter.encodings.fsst;

import nl.bartlouwers.fsst.SymbolTable;

public class FsstEncoder {
public static Fsst INSTANCE;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.maplibre.mlt.converter.encodings.fsst;

import nl.bartlouwers.fsst.SymbolTable;

class FsstJava implements Fsst {

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,41 +1,39 @@
package org.maplibre.mlt.converter.encodings.fsst;

import java.nio.file.FileSystems;
import nl.bartlouwers.fsst.*;

public class FsstJni implements Fsst {

private static boolean isLoaded = false;
private static UnsatisfiedLinkError loadError;
private static nl.bartlouwers.fsst.Fsst impl = null;
private static Error loadError;

static {
String os = System.getProperty("os.name").toLowerCase();
boolean isWindows = os.contains("win");
String moduleDir = "build/FsstWrapper.so";
if (isWindows) {
// TODO: figure out how to get cmake to put in common directory
moduleDir = "build/Release/FsstWrapper.so";
}
String modulePath =
FileSystems.getDefault().getPath(moduleDir).normalize().toAbsolutePath().toString();
try {
System.load(modulePath);
isLoaded = true;
} catch (UnsatisfiedLinkError e) {
var impl = new FsstImpl();
impl.encode(new byte[] {});
FsstJni.impl = impl;
} catch (UnsatisfiedLinkError | ExceptionInInitializerError e) {
loadError = e;
}
}

public SymbolTable encode(byte[] data) {
return FsstJni.compress(data);
return impl.encode(data);
}

public byte[] decode(SymbolTable table) {
return impl.decode(table);
}

public byte[] decode(
byte[] symbols, int[] symbolLengths, byte[] compressedData, int decompressedLength) {
return impl.decode(symbols, symbolLengths, compressedData, decompressedLength);
}

public static boolean isLoaded() {
return isLoaded;
return (impl != null);
}

public static UnsatisfiedLinkError getLoadError() {
public static Error getLoadError() {
return loadError;
}

public static native SymbolTable compress(byte[] inputBytes);
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ of this software and associated documentation files (the "Software"), to deal
import java.nio.ByteBuffer;
import java.util.*;
import java.util.stream.IntStream;
import nl.bartlouwers.fsst.SymbolTable;
import org.jetbrains.annotations.NotNull;

/**
Expand Down
Loading
Loading