You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ja...@apache.org on 2025/03/13 06:25:09 UTC
(iotdb) branch master updated: Compatibility modification for LikeViewExpression deserialization
This is an automated email from the ASF dual-hosted git repository.
jackietien pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new 3f9778a6004 Compatibility modification for LikeViewExpression deserialization
3f9778a6004 is described below
commit 3f9778a6004e1995a24855bfca7da0ad64c17d45
Author: Lin Xintao <lx...@163.com>
AuthorDate: Thu Mar 13 14:25:03 2025 +0800
Compatibility modification for LikeViewExpression deserialization
---
.../viewExpression/unary/LikeViewExpression.java | 53 ++++++++++++++++++----
1 file changed, 43 insertions(+), 10 deletions(-)
diff --git a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/schema/view/viewExpression/unary/LikeViewExpression.java b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/schema/view/viewExpression/unary/LikeViewExpression.java
index e52f436f23e..1c195727d5e 100644
--- a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/schema/view/viewExpression/unary/LikeViewExpression.java
+++ b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/schema/view/viewExpression/unary/LikeViewExpression.java
@@ -56,24 +56,55 @@ public class LikeViewExpression extends UnaryViewExpression {
public LikeViewExpression(ByteBuffer byteBuffer) {
super(ViewExpression.deserialize(byteBuffer));
pattern = ReadWriteIOUtils.readString(byteBuffer);
- if (ReadWriteIOUtils.readBool(byteBuffer)) {
- escape = Optional.of(ReadWriteIOUtils.readString(byteBuffer).charAt(0));
- } else {
- escape = Optional.empty();
+ byte judge = ReadWriteIOUtils.readByte(byteBuffer);
+ switch (judge) {
+ case -1:
+ case 0:
+ isNot = false;
+ escape = Optional.empty();
+ break;
+ case 1:
+ isNot = true;
+ escape = Optional.empty();
+ break;
+ case 2:
+ if (ReadWriteIOUtils.readBool(byteBuffer)) {
+ escape = Optional.of(ReadWriteIOUtils.readString(byteBuffer).charAt(0));
+ } else {
+ escape = Optional.empty();
+ }
+ isNot = ReadWriteIOUtils.readBool(byteBuffer);
+ default:
+ throw new IllegalStateException("Unexpected value in LikeViewExpression: " + judge);
}
- isNot = ReadWriteIOUtils.readBool(byteBuffer);
}
public LikeViewExpression(InputStream inputStream) {
super(ViewExpression.deserialize(inputStream));
try {
pattern = ReadWriteIOUtils.readString(inputStream);
- if (ReadWriteIOUtils.readBool(inputStream)) {
- escape = Optional.of(ReadWriteIOUtils.readString(inputStream).charAt(0));
- } else {
- escape = Optional.empty();
+ byte judge = ReadWriteIOUtils.readByte(inputStream);
+ switch (judge) {
+ case -1:
+ case 0:
+ escape = Optional.empty();
+ isNot = false;
+ break;
+ case 1:
+ escape = Optional.empty();
+ isNot = true;
+ break;
+ case 2:
+ if (ReadWriteIOUtils.readBool(inputStream)) {
+ escape = Optional.of(ReadWriteIOUtils.readString(inputStream).charAt(0));
+ } else {
+ escape = Optional.empty();
+ }
+ isNot = ReadWriteIOUtils.readBool(inputStream);
+ break;
+ default:
+ throw new IllegalStateException("Unexpected value in LikeViewExpression: " + judge);
}
- isNot = ReadWriteIOUtils.readBool(inputStream);
} catch (IOException e) {
throw new RuntimeException(e);
}
@@ -113,6 +144,7 @@ public class LikeViewExpression extends UnaryViewExpression {
protected void serialize(ByteBuffer byteBuffer) {
super.serialize(byteBuffer);
ReadWriteIOUtils.write(pattern, byteBuffer);
+ ReadWriteIOUtils.write(2, byteBuffer);
ReadWriteIOUtils.write(escape.isPresent(), byteBuffer);
if (escape.isPresent()) {
ReadWriteIOUtils.write(escape.get().toString(), byteBuffer);
@@ -124,6 +156,7 @@ public class LikeViewExpression extends UnaryViewExpression {
protected void serialize(OutputStream stream) throws IOException {
super.serialize(stream);
ReadWriteIOUtils.write(pattern, stream);
+ ReadWriteIOUtils.write(2, stream);
ReadWriteIOUtils.write(escape.isPresent(), stream);
if (escape.isPresent()) {
ReadWriteIOUtils.write(escape.get().toString(), stream);