From d304d88733c9a1274f0aa6dbb94d818e91fe929e Mon Sep 17 00:00:00 2001 From: chaokunyang Date: Tue, 24 Dec 2024 22:55:15 +0800 Subject: [PATCH] support varint/varuint in xlang java --- .../src/main/java/org/apache/fury/Fury.java | 20 ++++++++----------- .../fury/serializer/PrimitiveSerializers.java | 10 +++++----- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/java/fury-core/src/main/java/org/apache/fury/Fury.java b/java/fury-core/src/main/java/org/apache/fury/Fury.java index 6f5e7cbee6..2980c60bf4 100644 --- a/java/fury-core/src/main/java/org/apache/fury/Fury.java +++ b/java/fury-core/src/main/java/org/apache/fury/Fury.java @@ -516,19 +516,16 @@ public void xwriteRef(MemoryBuffer buffer, Object obj) { buffer.writeInt16((Short) obj); break; case Types.INT32: - buffer.writeInt32((Integer) obj); - break; case Types.VAR_INT32: + // TODO(chaokunyang) support other encoding buffer.writeVarInt32((Integer) obj); break; case Types.INT64: - buffer.writeInt64((Long) obj); - break; case Types.VAR_INT64: - buffer.writeVarInt64((Long) obj); - break; + // TODO(chaokunyang) support other encoding case Types.SLI_INT64: - buffer.writeSliInt64((Long) obj); + // TODO(chaokunyang) support varint encoding + buffer.writeVarInt64((Long) obj); break; case Types.FLOAT32: buffer.writeFloat32((Float) obj); @@ -1024,15 +1021,14 @@ public Object xreadNonRef(MemoryBuffer buffer, ClassInfo classInfo) { case Types.INT16: return buffer.readInt16(); case Types.INT32: - return buffer.readInt32(); case Types.VAR_INT32: - return buffer.readVarUint32(); + // TODO(chaokunyang) support other encoding + return buffer.readVarInt32(); case Types.INT64: - return buffer.readInt64(); case Types.VAR_INT64: - return buffer.readVarInt64(); + // TODO(chaokunyang) support other encoding case Types.SLI_INT64: - return buffer.readSliInt64(); + return buffer.readVarInt64(); case Types.FLOAT32: return buffer.readFloat32(); case Types.FLOAT64: diff --git a/java/fury-core/src/main/java/org/apache/fury/serializer/PrimitiveSerializers.java b/java/fury-core/src/main/java/org/apache/fury/serializer/PrimitiveSerializers.java index 1a5c974142..71954f19de 100644 --- a/java/fury-core/src/main/java/org/apache/fury/serializer/PrimitiveSerializers.java +++ b/java/fury-core/src/main/java/org/apache/fury/serializer/PrimitiveSerializers.java @@ -166,12 +166,12 @@ public Integer read(MemoryBuffer buffer) { @Override public void xwrite(MemoryBuffer buffer, Integer value) { // TODO support varint in cross-language serialization - buffer.writeInt32(value); + buffer.writeVarInt32(value); } @Override public Integer xread(MemoryBuffer buffer) { - return buffer.readInt32(); + return buffer.readVarInt32(); } } @@ -247,13 +247,13 @@ public static String readLongFunc(LongEncoding longEncoding) { @Override public void xwrite(MemoryBuffer buffer, Long value) { - // TODO support var long in cross-language serialization - buffer.writeInt64(value); + // TODO(chaokunyang) support var long in cross-language serialization + buffer.writeVarInt64(value); } @Override public Long xread(MemoryBuffer buffer) { - return buffer.readInt64(); + return buffer.readVarInt64(); } }