-
Notifications
You must be signed in to change notification settings - Fork 819
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: optimized binary numeric support #1940
Conversation
checkstyle
missed unit test class
@vlsi or @davecramer this test is failing. It passes if I comment out |
Have you tried to activate logging and verify what SQL the driver sends to the DB? AFAIK queryMode=simple means it inlines the SQL value, so it might result in producing an invalid SQL. The test code looks valid to me. |
@vlsi that was it. I needed to make changes in If that value has been configured to "simple", should we just disable the binary encoding to begin with? It seems kind of strange to go from "primitive" to binary, back to "primitive" so that we can then go to String. |
simple query mode support for binary value back to String
checkstyle
checkstyle
pgjdbc/src/main/java/org/postgresql/core/v3/SimpleParameterList.java
Outdated
Show resolved
Hide resolved
Codecov Report
@@ Coverage Diff @@
## master #1940 +/- ##
============================================
+ Coverage 69.39% 69.80% +0.40%
- Complexity 4228 4289 +61
============================================
Files 197 197
Lines 18006 18184 +178
Branches 2919 2971 +52
============================================
+ Hits 12496 12693 +197
+ Misses 4158 4136 -22
- Partials 1352 1355 +3 |
@bokken , I see you have quite complicated logic in ByteConverter. For instance, the following loop is shown as uncovered: https://codecov.io/gh/pgjdbc/pgjdbc/pull/1940/diff#D7-175 + | int i = 1;
-- | --
| 175 | + | for ( ; i < len && d == 0; ++i) {
| 176 | + | effectiveScale -= 4;
| 177 | + | idx += 2;
| 178 | + | d = ByteConverter.int2(bytes, idx);
| 179 | + | } + | if (sign == NUMERIC_NEG) {
-- | --
| 227 | + | unscaledBI = unscaledBI.negate();
| 228 | + | } + | if (mod != 0) {
-- | --
| 341 | + | scale += mod;
| 342 | + | unscaled = unscaled.multiply(tenPower(mod));
| 343 | + | } .... Can you please add tests to increase the coverage? |
more unit tests
@bokken I haven't had time to look at this in detail, but it looks quite intricate. I hope we can get some comments in here that would attempt to explain how this works without having to look at the server code to see how everything works. |
more unit tests and comments
@davecramer I have attempted to place comments within the I think some of the complexity is due to the very different way BigDecimal represents data internally. |
Ok, let me read these and see if they make sense. thx |
more comments
@davecramer I have added some more comments explaining the format. |
@vlsi @davecramer any ideas why the logical replication status test fails in one of the appveyor executions:
It appears this same test occasionally fails in the github actions test execution, but a re-run will pass. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you run any performance tests on this? Is it slower or faster than running in text mode?
For simple value such as 42
or for a long value such as -123456789.123456780
.
pgjdbc/src/main/java/org/postgresql/core/v3/SimpleParameterList.java
Outdated
Show resolved
Hide resolved
This is just for decoding/parsing. This is run with 64 bit jdk11 on windows.
binaryConversion is this PR. |
NaN comparison in assert
# Conflicts: # pgjdbc/src/test/java/org/postgresql/test/jdbc2/Jdbc2TestSuite.java
Provides optimized binary numeric support to go directly to a BigDecimal rather than from postgresql binary format to String and then to BigDecimal.
All Submissions:
New Feature Submissions:
./gradlew autostyleCheck checkstyleAll
pass ?Changes to Existing Features: