You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by "JackieTien97 (via GitHub)" <gi...@apache.org> on 2025/08/15 03:22:40 UTC

[PR] Change all query example into iterator style [iotdb]

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: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Change all query example into iterator style [iotdb]

Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #16186:
URL: https://github.com/apache/iotdb/pull/16186#issuecomment-3190556566

   ## [Codecov](https://app.codecov.io/gh/apache/iotdb/pull/16186?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :white_check_mark: All modified and coverable lines are covered by tests.
   :white_check_mark: Project coverage is 38.94%. Comparing base ([`c030c64`](https://app.codecov.io/gh/apache/iotdb/commit/c030c64036eac13c76599ed2d6208cad0358399b?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`8287018`](https://app.codecov.io/gh/apache/iotdb/commit/8287018804b93cfd28d2c0ac7150c6c5a5fe42eb?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   :warning: Report is 4 commits behind head on master.
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@             Coverage Diff              @@
   ##             master   #16186      +/-   ##
   ============================================
   - Coverage     38.95%   38.94%   -0.01%     
     Complexity      198      198              
   ============================================
     Files          4880     4880              
     Lines        318795   318915     +120     
     Branches      40241    40253      +12     
   ============================================
   + Hits         124189   124204      +15     
   - Misses       194606   194711     +105     
   ```
   </details>
   
   [:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/iotdb/pull/16186?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).   
   :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
   </details>


-- 
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: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Change all query example into iterator style [iotdb]

Posted by "JackieTien97 (via GitHub)" <gi...@apache.org>.
JackieTien97 merged PR #16186:
URL: https://github.com/apache/iotdb/pull/16186


-- 
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: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Change all query example into iterator style [iotdb]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #16186:
URL: https://github.com/apache/iotdb/pull/16186#issuecomment-3190504307

   ## [![Quality Gate Failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-failed-20px.png 'Quality Gate Failed')](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=16186) **Quality Gate failed**  
   Failed conditions  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/failed-16px.png '') [11.1% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_iotdb&pullRequest=16186&metric=new_duplicated_lines_density&view=list) (required ≤ 5%)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_iotdb&pullRequest=16186)
   
   


-- 
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: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org