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
refactor: use TypeInfo getPGArrayType instead of munging type name #913
Conversation
@grzm , Is it something that can be tested? |
@vlsi There's already coverage of this functionality elsewhere in the code base. Anywhere that tests exercises |
Codecov Report
@@ Coverage Diff @@
## master #913 +/- ##
============================================
+ Coverage 65.91% 65.94% +0.03%
- Complexity 3579 3582 +3
============================================
Files 167 167
Lines 15316 15316
Branches 2480 2480
============================================
+ Hits 10095 10100 +5
+ Misses 4044 4041 -3
+ Partials 1177 1175 -2 |
What I mean is: can a new test be created to test this change? |
I'm all for tests supporting code changes. In this case I don't see what a test would look like other than call what is already in the test suite. What would you like to see such a test do other than call |
@grzm , do you know if there are performance implications and/or performance improvements? |
The main difference I can tell, is that it additionally looks for an alias, then it use the same getPGType method: public int getPGArrayType(String elementTypeName) throws SQLException {
elementTypeName = getTypeForAlias(elementTypeName);
return getPGType(elementTypeName + "[]");
} |
I haven't run the benchmark test suite, so I really can't say. I wouldn't expect any significant change. As @jorsol points out, it does do an additional alias check, but that list is fixed and small. I'm more than happy to run them to confirm. If you could point me to documentation on how to set up and run the benchmarks, I'd appreciate it. I'm using IntelliJ if that makes a difference. |
@grzm there is a subproject called ubenchmark which has the benchmarks in it. |
d014e56
to
435c8fc
Compare
@davecramer Looking at the existing ubenchmark tests, I didn't see anything that would exercise this specifically, so I added some. Here's how I ran the benchmarks (from the root of the pgjdbc checkout):
If there's a better way to run these, please let me know. The documentation I referred to was in a comment in the FinalizeConnection class. mvn clean package -DskipTests && java -classpath pgjdbc/target/postgresql-42.1.5-SNAPSHOT.jar:ubenchmark/target/benchmarks.jar -Duser=grzm -Dport=5496 org.postgresql.benchmark.statement.BindArray I'm not well-versed in reading the output of the test results, but looking at the ns/op numbers, they look comparable. Here's the output for HEAD (9813c68)
With this patch:
|
@@ -0,0 +1,89 @@ | |||
/* | |||
* Copyright (c) 2003, PostgreSQL Global Development Group |
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.
(c) 2017
import java.util.Properties; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
@Fork(value = 0, jvmArgsPrepend = "-Xmx128m") |
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.
Fork value = 1
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.
Thanks, @jorsol ! I copied this straight from BindBoolean. I see that some of the other tests have Fork value = 1 as well. Should BindBoolean be updated (in some other patch)?
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.
Yes, it should, and also the Measurement and Warmup should be at least 10 iterations
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.
I'll do that as well. Would it make sense to extract these and have them set as parameters somewhere? Should they be the same across the board?
4e04a29
to
b17b085
Compare
Updated benchmarks with Fork=1, and warmup and measurement set to 10. I'm just including the ns/op result summary. Happy to include the full results upon request. HEAD
patched
|
The purpose of the getPGArrayType method is to get the array type for a given element type. Let the TypeInfo implementation figure out how to do that rather than appending "[]" to the element type name in PgPreparedStatement setArray.
b17b085
to
92e2328
Compare
Thanks! |
The purpose of the getPGArrayType method is to get the array type for
a given element type. Let the TypeInfo implementation figure out how
to do that rather than appending "[]" to the element type name in
PgPreparedStatement setArray.