fury
fury copied to clipboard
Integer values inside arrays are not compressed
Search before asking
- [X] I had searched in the issues and found no similar issues.
Version
fury 0.9.0 Temurin 21.0.5 (x64) Windows 11
Component(s)
Java
Minimal reproduce step
import org.apache.fury.*;
import org.apache.fury.config.*;
public class FuryRepro
{
public static class RecordA
{
private int int32 = 1;
}
public static class RecordB
{
private int int32 = Integer.MAX_VALUE;
}
public static class RecordC
{
private int[] intArray = { 1 };
}
public static class RecordD
{
private int[] intArray = { Integer.MAX_VALUE };
}
public static void main(String[] args)
{
Fury fury = Fury.builder()
.withLanguage(Language.JAVA)
.withIntCompressed(true)
.withCompatibleMode(CompatibleMode.SCHEMA_CONSISTENT)
.requireClassRegistration(true)
.build();
fury.register(RecordA.class);
fury.register(RecordB.class);
fury.register(RecordC.class);
fury.register(RecordD.class);
System.out.printf("A: %d%n", fury.serialize(new RecordA()).length);
System.out.printf("B: %d%n", fury.serialize(new RecordB()).length);
System.out.printf("C: %d%n", fury.serialize(new RecordC()).length);
System.out.printf("D: %d%n", fury.serialize(new RecordD()).length);
}
}
What did you expect to see?
The values inside int[] arrays compressed, just like the values of int fields.
What did you see instead?
A: 5 B: 9 C: 10 D: 10
The values of int fields are compressed as expected, but the values inside int[] arrays are not.
Anything Else?
No response
Are you willing to submit a PR?
- [ ] I'm willing to submit a PR!
same issue for long:
import org.apache.fury.*;
import org.apache.fury.config.*;
public class FuryReproLong {
public static class RecordA {
private long long64 = 1L;
}
public static class RecordB {
private long long64 = Long.MAX_VALUE;
}
public static class RecordC {
private long[] longArray = {1L};
}
public static class RecordD {
private long[] longArray = {Long.MAX_VALUE};
}
public static void main(String[] args) {
Fury fury =
Fury.builder()
.withLanguage(Language.JAVA)
.withLongCompressed(true)
.withCompatibleMode(CompatibleMode.SCHEMA_CONSISTENT)
.requireClassRegistration(true)
.build();
fury.register(RecordA.class);
fury.register(RecordB.class);
fury.register(RecordC.class);
fury.register(RecordD.class);
System.out.printf("A: %d%n", fury.serialize(new RecordA()).length);
System.out.printf("B: %d%n", fury.serialize(new RecordB()).length);
System.out.printf("C: %d%n", fury.serialize(new RecordC()).length);
System.out.printf("D: %d%n", fury.serialize(new RecordD()).length);
}
}
results in:
A: 8
B: 13
C: 14 // would have expected this value to be lower
D: 14
I've poked around the code base to see if I can fix it myself, but this is higher magic :) Fixing this issue would be a major storage saver for my use case
int array compression has be supported in #2485