Comments (1)
I can run this successfully locally:
Here is my code:
package org.apache.fury;
import lombok.Data;
import org.apache.fury.config.CompatibleMode;
import org.apache.fury.logging.LoggerFactory;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.file.Files;
public class Test {
@Data
public static class AssignDetailInfoLog {
String id;
AssignType type;
}
public enum AssignType {
DEFAULT;
}
public static class FuryUtils {
private static final ThreadSafeFury fury;
public FuryUtils() {
}
public static <T> byte[] serialize(T t) {
return fury.serialize(t);
}
public static Object zeroCopyDeserialize(byte[] byteBuffer) {
return fury.deserialize(byteBuffer);
}
public static Object zeroCopyDeserialize(ByteBuffer byteBuffer) {
return fury.deserialize(byteBuffer);
}
static {
fury = Fury.builder().withRefTracking(true).requireClassRegistration(false).withCompatibleMode(CompatibleMode.COMPATIBLE).buildThreadSafeFury();
LoggerFactory.disableLogging();
}
}
public static void main(String[] args) throws IOException {
// read
read();
// write();
}
public static void write() throws IOException {
AssignDetailInfoLog assignDetailInfoLog = new AssignDetailInfoLog();
assignDetailInfoLog.setType(AssignType.DEFAULT);
assignDetailInfoLog.setId("dsa");
byte[] data = FuryUtils.serialize(assignDetailInfoLog);
saveToFile("test_file", data);
}
public static void read() throws IOException {
write();
// read
byte[] data = readFileToBytes("test_file");
FuryUtils.zeroCopyDeserialize(data);
}
public static void saveToFile(String fileName, byte[] data) {
try (FileOutputStream outputStream = new FileOutputStream(fileName)) {
outputStream.write(data); // 写入byte[]
System.out.println("Data has been written to " + fileName);
} catch (IOException e) {
e.printStackTrace();
}
}
public static byte[] readFileToBytes(String filePath) {
try {
return Files.readAllBytes(new File(filePath).toPath());
} catch (Exception e) {
return null;
}
}
}
from incubator-fury.
Related Issues (20)
- NullPointerException when serializing a custom type HOT 11
- Concerning license in the javadoc jar HOT 2
- it's a bit troublesome to install on apple systems. error: externally-managed-environment...... HOT 2
- [java] jit code of collection with abstract class deserialize error HOT 4
- Enum equality does not work across serialization-deserialization HOT 5
- Mac install using “conda install -c conda-forge pyarrow” command is completed, how to set pyarrow of environment variables?
- [Doc] Use a script to update documentation when code is modified
- [Rust] Please publish fury for rust to crates.io HOT 1
- dubbo-serialization-fury allowList/allowListPrefix doesn't take affect
- Fury 0.5.1 is not backward compatible with 0.5.0 HOT 2
- Fury 0.5.1 Deserialize Error HOT 1
- Scala object type field serialization failure
- [Java] Implement zstd based compressor for type metadata HOT 2
- [scala]Can furry support serializing Seq collections and case classes in Scala, and then deserializing the resulting objects into corresponding Java objects in Java? HOT 1
- [JavaScript] Type Forward/Backward compatible object serialization for Fury JavaScript
- [JavaScript] Implement the object metadata compression protocol
- [JavaScript] Support generating deserializers based on the type metadata parsed during deserialization
- [JavaScript] Implement metadatascoped share mode
- [JavaScript] Support encoding field names with varint in type metadata
- [Rust] About Enum Naming HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from incubator-fury.