Skip to content

Commit

Permalink
[Java] enable int compression by default (#935)
Browse files Browse the repository at this point in the history
* enable int compression by default

* Fix crash

* refine buffer varint tests

* fix test
  • Loading branch information
chaokunyang authored Oct 4, 2023
1 parent e081d47 commit af99ec6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
8 changes: 6 additions & 2 deletions docs/guide/java_object_graph_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,12 @@ ThreadSafeFury fury=Fury.builder()

### Smaller size
`FuryBuilder#withIntCompressed`/`FuryBuilder#withLongCompressed` can be used to compress int/long for smaller size.
Normally compress int is enough. If a number use long, it can't be represented by smaller bytes mostly. In such cases,
compressing
Normally compress int is enough. If a number are `long` type, it can't be represented by smaller bytes mostly,
the compression won't get good enough result, not worthy compared to performance cost.

Both compression are enabled by default, if the serialized is not important, for example, you use flatbuffers for
serialization before, which doesn't compress anything, then you should disable compression. If your data are all numbers,
the compression can bring 80% performance regression.

### Implement a customized serializer
In some cases, you may want to implement a serializer for your type, especially some class customize serialization by JDK
Expand Down
2 changes: 1 addition & 1 deletion java/fury-core/src/main/java/io/fury/Fury.java
Original file line number Diff line number Diff line change
Expand Up @@ -1300,7 +1300,7 @@ public static final class FuryBuilder {
boolean stringRefIgnored = true;
boolean timeRefIgnored = true;
ClassLoader classLoader;
boolean compressInt = false;
boolean compressInt = true;
boolean compressLong = false;
boolean compressString = true;
CompatibleMode compatibleMode = CompatibleMode.SCHEMA_CONSISTENT;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ public void testCompressInt() {
Fury fury1 =
Fury.builder()
.withLanguage(Language.JAVA)
.withIntCompressed(false)
.withLongCompressed(true)
.withCompatibleMode(CompatibleMode.SCHEMA_CONSISTENT)
.requireClassRegistration(false)
Expand Down

0 comments on commit af99ec6

Please sign in to comment.