LiangliangSui commented on code in PR #1472:
URL: https://github.com/apache/incubator-fury/pull/1472#discussion_r1554623191


##########
java/fury-core/src/test/java/org/apache/fury/serializer/PrimitiveSerializersTest.java:
##########
@@ -54,4 +59,62 @@ public void testUint16Serializer() {
     assertThrows(IllegalArgumentException.class, () -> 
serializer.xwrite(buffer, -1));
     assertThrows(IllegalArgumentException.class, () -> 
serializer.xwrite(buffer, 65536));
   }
+
+  @Data
+  @AllArgsConstructor
+  public static class PrimitiveStruct {
+    byte byte1;
+    byte byte2;
+    char char1;
+    char char2;
+    short short1;
+    short short2;
+    int int1;
+    int int2;
+    long long1;
+    long long2;
+    float float1;
+    float float2;
+    double double1;
+    double double2;
+  }
+
+  @Test(dataProvider = "compressNumberAndCodeGen")
+  public void testPrimitiveStruct(boolean compressNumber, boolean codegen) {
+    PrimitiveStruct struct =
+        new PrimitiveStruct(
+            Byte.MIN_VALUE,
+            Byte.MIN_VALUE,
+            Character.MIN_VALUE,
+            Character.MIN_VALUE,
+            Short.MIN_VALUE,
+            Short.MIN_VALUE,
+            Integer.MIN_VALUE,
+            Integer.MIN_VALUE,
+            Long.MIN_VALUE,
+            Long.MIN_VALUE,
+            Float.MIN_VALUE,
+            Float.MIN_VALUE,
+            Double.MIN_VALUE,
+            Double.MIN_VALUE);
+    if (compressNumber) {
+      FuryBuilder builder =

Review Comment:
   Nit: We can move the common part of FuryBuilder before the if branch, so 
that if and else can share this part



##########
java/fury-core/src/test/java/org/apache/fury/serializer/PrimitiveSerializersTest.java:
##########
@@ -54,4 +59,62 @@ public void testUint16Serializer() {
     assertThrows(IllegalArgumentException.class, () -> 
serializer.xwrite(buffer, -1));
     assertThrows(IllegalArgumentException.class, () -> 
serializer.xwrite(buffer, 65536));
   }
+
+  @Data
+  @AllArgsConstructor
+  public static class PrimitiveStruct {

Review Comment:
   Should be private.
   ```java
   private static class PrimitiveStruct
   ```



##########
java/fury-core/src/main/java/org/apache/fury/memory/MemoryBuffer.java:
##########
@@ -2318,6 +2205,37 @@ public float readFloat() {
     }
   }
 
+  // Reduce method body for better inline in the caller.
+  @CodegenInvoke
+  public float readFloatOnLE() {
+    int readerIdx = readerIndex;
+    // use subtract to avoid overflow
+    int remaining = size - readerIdx;
+    if (remaining < 4) {
+      throw new IndexOutOfBoundsException(

Review Comment:
   Nit: we can reuse 
[`throwIndexOutOfBoundsException`](https://github.com/apache/incubator-fury/blob/main/java/fury-core/src/main/java/org/apache/fury/memory/MemoryBuffer.java#L1853-L1857).
 `throwIndexOutOfBoundsException` is not executed frequently and should have no 
impact on inlining.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@fury.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@fury.apache.org
For additional commands, e-mail: commits-h...@fury.apache.org

Reply via email to