You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@iotdb.apache.org by "Haonan Hou (Jira)" <ji...@apache.org> on 2021/08/25 09:41:00 UTC
[jira] [Commented] (IOTDB-1572) Should not change object's state in
toString()
[ https://issues.apache.org/jira/browse/IOTDB-1572?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17404319#comment-17404319 ]
Haonan Hou commented on IOTDB-1572:
-----------------------------------
It makes sense!
Would you like to submit a PR to fix it?
> Should not change object's state in toString()
> ----------------------------------------------
>
> Key: IOTDB-1572
> URL: https://issues.apache.org/jira/browse/IOTDB-1572
> Project: Apache IoTDB
> Issue Type: Bug
> Components: Core/Engine
> Reporter: GaoYang
> Priority: Minor
>
> I meet a strange problem.
> When I debug memtable flushing, I do as follows:
> 1. insert into root.a.c(time,s1) values (207,2)
> 2. insert into root.a.c(time,s1) values (203,2)
> According to the code logic, after the second insertion complete, the "sorted" in TVList should be false.
> But, every time when I look into the value of "sorted" in TVList from memChunk, where the debug breakpoint in, it's always true!
> I am sure there is no flush or query be triggered between the insertion and breakpoint.
> After several hours' efforts, I found the cause:
> 1. When debuging, IDEA will invoke Object's toString() method by default.
> 2. This kind of invoke cannot be suspended by breakpoint
> 3. In WritableMemChunk's toString() method, getSortedTVListForQuery() has been invoked, which will trigger a sorting in TVList, has been invoked. And after sorting, "sorted" will be set to true...
> Certainly, it's not a bug and can be bypassed by disable IDEA's auto invoking.
> In my opinion, it's better not to change object's state in toString method, after all, toString is a representation of object's current state, it should be a method sth like read-only.
> At last, WritableMemChunk's toString() method only want to print the min and max point, which can be found with a simple traversal.
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)