Skip to content

Commit

Permalink
support varint/varuint in xlang java
Browse files Browse the repository at this point in the history
  • Loading branch information
chaokunyang committed Dec 24, 2024
1 parent 09b88b6 commit d304d88
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 17 deletions.
20 changes: 8 additions & 12 deletions java/fury-core/src/main/java/org/apache/fury/Fury.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

Expand Down Expand Up @@ -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();
}
}

Expand Down

0 comments on commit d304d88

Please sign in to comment.