You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@iotdb.apache.org by "GaoYang (Jira)" <ji...@apache.org> on 2021/08/18 01:28:00 UTC

[jira] [Created] (IOTDB-1572) Should not change object's state in toString()

GaoYang created IOTDB-1572:
------------------------------

             Summary: 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: StorageEngine
            Reporter: GaoYang


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.

 
!image-2021-08-18-09-26-23-520.png!



--
This message was sent by Atlassian Jira
(v8.3.4#803005)