JackieTien97 opened a new pull request, #16186:
URL: https://github.com/apache/iotdb/pull/16186

   This pull request refactors the IoTDB Java session examples to improve code 
reuse and consistency in how query results are printed. The main enhancement is 
the introduction of a shared `printDataSet` utility method, which standardizes 
the output of query results across multiple example classes. Additionally, some 
redundant or outdated query methods are removed for clarity.
   
   Key changes:
   
   **Code reuse and consistency improvements:**
   
   * Introduced a new `printDataSet(SessionDataSet dataSet)` method in 
`SessionExample.java` to handle printing of query results, including column 
names, types, and handling of null values. This method is now used throughout 
the example code to ensure consistent output formatting. (Fc9e8d42L812R812)
   * Updated `TableModelSessionExample.java` and 
`TableModelSessionPoolExample.java` to use the shared `printDataSet` method for 
displaying query results, replacing previous ad-hoc printing logic. 
[[1]](diffhunk://#diff-2149ed73aebb9dd2786837799d1eb00b887c6d65d71e08e1b0e8f9fdbd695bc7R37-R38)
 
[[2]](diffhunk://#diff-2149ed73aebb9dd2786837799d1eb00b887c6d65d71e08e1b0e8f9fdbd695bc7L74-R76)
 
[[3]](diffhunk://#diff-2149ed73aebb9dd2786837799d1eb00b887c6d65d71e08e1b0e8f9fdbd695bc7L125-R124)
 
[[4]](diffhunk://#diff-2149ed73aebb9dd2786837799d1eb00b887c6d65d71e08e1b0e8f9fdbd695bc7L149-R144)
 
[[5]](diffhunk://#diff-2149ed73aebb9dd2786837799d1eb00b887c6d65d71e08e1b0e8f9fdbd695bc7L161-R153)
 
[[6]](diffhunk://#diff-73c1a845a4b1bf00559d67b35dd7cbcf1538ce371b4ce486cb1a6202d2e891a6R38-R39)
 
[[7]](diffhunk://#diff-73c1a845a4b1bf00559d67b35dd7cbcf1538ce371b4ce486cb1a6202d2e891a6L80-R88)
 
[[8]](diffhunk://#diff-73c1a845a4b1bf00559d67b35dd7cbcf1538ce371b4ce486cb1a6202d2e891a6L142-R136)
   
   **Code cleanup and simplification:**
   
   * Removed the `queryByRowRecord` method from `SessionPoolExample.java`, as 
well as its invocation, to streamline the example and focus on the 
iterator-based approach. 
[[1]](diffhunk://#diff-f3e4f5e22236cf146d0639080651dfba76236a97cab0f0aca490f457c3d81c3fL77)
 
[[2]](diffhunk://#diff-f3e4f5e22236cf146d0639080651dfba76236a97cab0f0aca490f457c3d81c3fL105-L126)
   * Replaced multiple manual loops for printing `SessionDataSet` results in 
`SessionExample.java` with calls to `printDataSet`, including in methods like 
`query4Redirect`, `queryWithTimeout`, `rawDataQuery`, `lastDataQuery`, 
`fastLastDataQueryForOneDevice`, `fastLastDataQueryForOnePrefix`, 
`aggregationQuery`, and `groupByQuery`. 
[[1]](diffhunk://#diff-3a3fa624df531223227483a40128d766ef46cfdc7c3199e054763f9366bfb315L693-R699)
 
[[2]](diffhunk://#diff-3a3fa624df531223227483a40128d766ef46cfdc7c3199e054763f9366bfb315L723-R708)
 
[[3]](diffhunk://#diff-3a3fa624df531223227483a40128d766ef46cfdc7c3199e054763f9366bfb315L736-R717)
 
[[4]](diffhunk://#diff-3a3fa624df531223227483a40128d766ef46cfdc7c3199e054763f9366bfb315L752-R737)
 
[[5]](diffhunk://#diff-3a3fa624df531223227483a40128d766ef46cfdc7c3199e054763f9366bfb315L782-R751)
 
[[6]](diffhunk://#diff-3a3fa624df531223227483a40128d766ef46cfdc7c3199e054763f9366bfb315L796-R761)
 [[7]](diffhunk://#diff-3a3fa624df531223227483a40128d766ef46cfdc7c3199e054763f9
 366bfb315L812-R785) 
[[8]](diffhunk://#diff-3a3fa624df531223227483a40128d766ef46cfdc7c3199e054763f9366bfb315L848-R801)
 
[[9]](diffhunk://#diff-3a3fa624df531223227483a40128d766ef46cfdc7c3199e054763f9366bfb315L867-R836)
   
   **Minor improvements:**
   
   * Standardized the random number generator by making the `Random` instance 
in `SessionExample.java` static and final, and updating all usages accordingly. 
[[1]](diffhunk://#diff-3a3fa624df531223227483a40128d766ef46cfdc7c3199e054763f9366bfb315L67-R67)
 
[[2]](diffhunk://#diff-3a3fa624df531223227483a40128d766ef46cfdc7c3199e054763f9366bfb315L459-R458)
 
[[3]](diffhunk://#diff-3a3fa624df531223227483a40128d766ef46cfdc7c3199e054763f9366bfb315L500-R499)
 
[[4]](diffhunk://#diff-3a3fa624df531223227483a40128d766ef46cfdc7c3199e054763f9366bfb315L561-R560)
 
[[5]](diffhunk://#diff-3a3fa624df531223227483a40128d766ef46cfdc7c3199e054763f9366bfb315L605-R604)
   * Changed the default query method called in `main` from `query()` to 
`queryByIterator()` in `SessionExample.java`, and removed the now-unused 
`query()` method. 
[[1]](diffhunk://#diff-3a3fa624df531223227483a40128d766ef46cfdc7c3199e054763f9366bfb315L105-L111)
 
[[2]](diffhunk://#diff-3a3fa624df531223227483a40128d766ef46cfdc7c3199e054763f9366bfb315L693-R699)
   * Removed redundant calls to `setFetchSize` where no longer necessary due to 
the new printing logic.
   
   These changes make the example code easier to read, maintain, and extend, 
while ensuring all query outputs are handled in a unified way.


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to