Skip to content

feat: stop using regex pattern to escape single quota#275

Merged
sheyanjie-qq merged 2 commits intotaosdata:mainfrom
oneby-wang:escapeSingleQuota_performance
Aug 22, 2025
Merged

feat: stop using regex pattern to escape single quota#275
sheyanjie-qq merged 2 commits intotaosdata:mainfrom
oneby-wang:escapeSingleQuota_performance

Conversation

@oneby-wang
Copy link
Copy Markdown
Contributor

@oneby-wang oneby-wang commented Aug 20, 2025

Description

Using regex pattern to escape single quota has a big performance problem. I followed the previous unit tests, and then refactored Utils.escapeSingleQuota() method, and then added some more unit tests.

Checklist

Please check the items in the checklist if applicable.

  • [√] Is the user manual updated?
  • [√] Are the test cases passed and automated?
  • [√] Is there no significant decrease in test coverage?

@oneby-wang
Copy link
Copy Markdown
Contributor Author

A simple performance test sample code:

int testSize = 10000;
List<String> payloadPool = new ArrayList<>(testSize);
for (int i = 0; i < testSize; i++) {
    payloadPool.add(RandomUtil.randomString(1024));
}

Stopwatch stopwatch = Stopwatch.createStarted();
for (int i = 0; i < testSize; i++) {
    escapeSingleQuota(payloadPool.get(i));
}
System.out.println(stopwatch.elapsed());

Test case: Winodws x64 OpenJDK17 platform, 10000 elemets.
Before refactor it takes PT18.081949S to complete .
After refactor it takes PT0.0197031S to complete.

With 1000000 elements, it takes PT1.0449361S to complete.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Aug 21, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 71.60%. Comparing base (180ba59) to head (1abdcec).
⚠️ Report is 31 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main     #275      +/-   ##
============================================
- Coverage     71.98%   71.60%   -0.38%     
+ Complexity     3658     3652       -6     
============================================
  Files           193      196       +3     
  Lines         12371    12418      +47     
  Branches       1652     1656       +4     
============================================
- Hits           8905     8892      -13     
- Misses         2432     2477      +45     
- Partials       1034     1049      +15     
Flag Coverage Δ
unittests 71.60% <ø> (-0.38%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sheyanjie-qq sheyanjie-qq merged commit c4b41ff into taosdata:main Aug 22, 2025
2 checks passed
sheyanjie-qq added a commit that referenced this pull request Dec 9, 2025
* perf: improve native query performance (#274)

* chore: update changelog (#276)

* feat: stop using regex pattern to escape single quota (#275)

* feat: stop using regex pattern to escape single quota

* feat: escape single quota unit test

---------

Co-authored-by: dywangbh <dywangbh@chint.com>

* feat: supports delete meta subscription (#277)

* feat: supports delete meta subscription

* chore: improve meta enum implementation

* perf: improve writing efficiency in efficient writing mode by serializing data with a separate thread (#278)

* feat: JDBC URL supports multiple endpoints (#279)

* chore: improve tests

* add loadbalance tests

* feat: stmt supports reconnection (#280)

* chore: improve tests

* add loadbalance tests

* perf: improve isValid performace (#281)

* chore: improve tests

* feat: use cache to improve isValid perf

* chore: update deploy pom (#282)

* chore: update change log (#283)

* feat: improve stmt setObject and loadbalance (#284)

* feat: improve stmt setObject and loadbalance

* Update src/main/java/com/taosdata/jdbc/ws/AbsWSPreparedStatement.java

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

---------

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

* chore: update changelog (#285)

* fix: load properties issue in windows (#289)

* fix: WebSocket statement timeout setting resets transport's timeout (#290)

* fix: WebSocket statement timeout setting resets transport's timeout

Closes TD-38565

* --amend

* fix: fix getTables need identifier quote string bug. (#292)

Closes TD-38643.

* feat: Optimize the load balancing logic to achieve rebalancing after node failure recovery. (#291)

* fix: load properties issue in windows

* feat: supports rebalance when node down

* fix: WebSocket statement timeout setting resets transport's timeout

Closes TD-38565

* --amend

* --amend

* chore: fix unit test issues

* chore: add unit tests

* fix: websocket reconnect null point error (#296)

Closes: TD-38690

* fix: fix sonar error and security issues (#295)

* fix: load properties issue in windows

* feat: supports rebalance when node down

* fix: WebSocket statement timeout setting resets transport's timeout

Closes TD-38565

* --amend

* --amend

* chore: fix unit test issues

* chore: add unit tests

* chore: fix sonar error and security issues
Closes 6482039483

* chore: add unit tests

---------

Co-authored-by: Oneby <44369297+oneby-wang@users.noreply.github.com>
Co-authored-by: dywangbh <dywangbh@chint.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants