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

[Java] Support thread-safe fury in graalvm native image #1155

Closed
chaokunyang opened this issue Nov 28, 2023 · 0 comments · Fixed by #1164
Closed

[Java] Support thread-safe fury in graalvm native image #1155

chaokunyang opened this issue Nov 28, 2023 · 0 comments · Fixed by #1164
Labels
enhancement New feature or request java

Comments

@chaokunyang
Copy link
Collaborator

chaokunyang commented Nov 28, 2023

Is your feature request related to a problem? Please describe.

We support fury in graalvm native image in #1143, but didn't add support for ThreadSafeFury.

We need to support ThreadSafeFury in graalvm native image.

Expected Thread Safe Example:

import io.fury.Fury;
import io.fury.ThreadLocalFury;
import io.fury.ThreadSafeFury;
import io.fury.collection.Collections;
import io.fury.util.Preconditions;

import java.util.List;
import java.util.Map;

public class ThreadSafeExample {
  static ThreadSafeFury fury;

  static {
    fury = new ThreadLocalFury(classLoader -> {
      Fury f = Fury.builder().requireClassRegistration(true).build();
      // register and generate serializer code.
      f.register(Foo.class, true);
      return f;
    });
  }

  public static void main(String[] args) throws Throwable {
    Preconditions.checkArgument("abc".equals(fury.deserialize(fury.serialize("abc"))));
    Preconditions.checkArgument(List.of(1,2,3).equals(fury.deserialize(fury.serialize(List.of(1,2,3)))));
    List<String> list = Collections.ofArrayList("a", "b", "c");
    Preconditions.checkArgument(list.equals(fury.deserialize(fury.serialize(list))));
    Map<String, Integer> map = Collections.ofHashMap("k1", 1, "k2", 2);
    Preconditions.checkArgument(map.equals(fury.deserialize(fury.serialize(map))));
    map = Map.of("k1", 1, "k2", 2);
    Preconditions.checkArgument(map.equals(fury.deserialize(fury.serialize(map))));
    Foo foo = new Foo(10, "abc", List.of("str1", "str2"), Map.of("k1", 10L, "k2", 20L));
    Object o = fury.deserialize(fury.serialize(foo));
    Preconditions.checkArgument(foo.equals(o));
}

Describe the solution you'd like

Add ThreadSafeFury support for graalvm native image

Additional context

#1115 #678

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request java
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant