You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@iotdb.apache.org by "gongning (Jira)" <ji...@apache.org> on 2022/04/15 14:12:00 UTC

[jira] [Created] (IOTDB-2936) The serialization type uses the enumeration ordinal, which can easily cause deserialization failures if the order of the enumeration objects changes.

gongning created IOTDB-2936:
-------------------------------

             Summary: The serialization type uses the enumeration ordinal, which can easily cause deserialization failures if the order of the enumeration objects changes.
                 Key: IOTDB-2936
                 URL: https://issues.apache.org/jira/browse/IOTDB-2936
             Project: Apache IoTDB
          Issue Type: Improvement
          Components: Core/Engine
            Reporter: gongning


The serialization type uses the enumeration ordinal, which can easily cause deserialization failures if the order of the enumeration objects changes.

Therefore, the constant value int should be used for each type

eg:
@Override
  public void serializeImpl(ByteBuffer buffer) {
    int type = PhysicalPlanType.INSERT.ordinal();
    buffer.put((byte) type);
    subSerialize(buffer);
  }

  @Override
  public void serializeImpl(ByteBuffer buffer) {
    int type = PhysicalPlanType.BATCHINSERT.ordinal();
    buffer.put((byte) type);
    subSerialize(buffer, 0, rowCount);
  }

Improvement:

@Override
  public void serializeImpl(ByteBuffer buffer) {
    int type = PhysicalPlanType.INSERT.type;
    buffer.put((byte) type);
    subSerialize(buffer);
  }

  @Override
  public void serializeImpl(ByteBuffer buffer) {
    int type = PhysicalPlanType.BATCHINSERT.type;
    buffer.put((byte) type);
    subSerialize(buffer, 0, rowCount);
  }




--
This message was sent by Atlassian Jira
(v8.20.1#820001)