Skip to content
Snippets Groups Projects
Commit 37b18801 authored by Daniel Hornung's avatar Daniel Hornung
Browse files

ENH: Always apply POV to ints and doubles alike.

parent 0c329e01
No related branches found
No related tags found
2 merge requests!66REL: prepare release 0.8.0,!62Fix large integer queries
...@@ -128,10 +128,8 @@ public class POV implements EntityFilterInterface { ...@@ -128,10 +128,8 @@ public class POV implements EntityFilterInterface {
this.vInt = null; this.vInt = null;
} }
// try and parse as double // Try and parse as double, if integer parsing was unsuccessful.
if (this.vInt != null) { if (this.vInt == null) {
this.vDouble = (double) this.vInt;
} else {
try { try {
// Doubles are allowed without dots, for example when the integer overflows. // Doubles are allowed without dots, for example when the integer overflows.
final Pattern dp = Pattern.compile("^(-?[0-9]+(?:\\.)?(?:[0-9]+))\\s*([^-]*)$"); final Pattern dp = Pattern.compile("^(-?[0-9]+(?:\\.)?(?:[0-9]+))\\s*([^-]*)$");
...@@ -217,6 +215,11 @@ public class POV implements EntityFilterInterface { ...@@ -217,6 +215,11 @@ public class POV implements EntityFilterInterface {
"Versioned queries are not supported for subqueries yet. Please file a feature request."); "Versioned queries are not supported for subqueries yet. Please file a feature request.");
} }
final long t1 = System.currentTimeMillis(); final long t1 = System.currentTimeMillis();
// Add type-converted substitutes for ints/doubles.
final Integer vIntSubst = (this.vDouble != null && this.vDouble % 1 == 0)
? (int) Math.rint(this.vDouble) : null;
final Double vDoubleSubst = (this.vInt != null) ? (double) this.vInt : null;
try { try {
this.connection = query.getConnection(); this.connection = query.getConnection();
this.targetSet = query.getTargetSet(); this.targetSet = query.getTargetSet();
...@@ -270,15 +273,14 @@ public class POV implements EntityFilterInterface { ...@@ -270,15 +273,14 @@ public class POV implements EntityFilterInterface {
} else { } else {
callPOV.setNull(6, VARCHAR); callPOV.setNull(6, VARCHAR);
} }
if (this.vInt != null) { // vInt if (this.vInt != null || this.vDouble != null) { // Some numeric
callPOV.setInt(7, this.vInt); if (this.vInt != null) {
} else { callPOV.setInt(7, this.vInt);
callPOV.setNull(7, INTEGER); callPOV.setDouble(8, vDoubleSubst);
} } else {
if (this.vDouble != null) { // vDouble callPOV.setInt(7, vIntSubst);
callPOV.setDouble(8, this.vDouble); callPOV.setDouble(8, this.vDouble);
} else { }
callPOV.setNull(8, DOUBLE);
} }
if (this.unit != null) { if (this.unit != null) {
final long unitSig = this.unit.getSignature(); final long unitSig = this.unit.getSignature();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment