Mike Kolesnik has uploaded a new change for review. Change subject: core: Fixed lexo-numeric comparator for big numbers ......................................................................
core: Fixed lexo-numeric comparator for big numbers The lexo-numeric comparator was using Integer class which is very limited to parse numbers, and would cause an exception if the sequence of numbers if too long. Change to BigInteger which is unlimited in size, and has the required functionality. There doesn't seem to be any adverse effect on the performance of the comparison. Change-Id: I52ec8c73e85b2505314a4043206d5883e2a43e37 Bug-Url: https://bugzilla.redhat.com/?????? Signed-off-by: Mike Kolesnik <[email protected]> --- M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/comparators/LexoNumericComparator.java 1 file changed, 2 insertions(+), 1 deletion(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/38/17238/1 diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/comparators/LexoNumericComparator.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/comparators/LexoNumericComparator.java index 9b58c62..dbd9f6a 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/comparators/LexoNumericComparator.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/comparators/LexoNumericComparator.java @@ -1,6 +1,7 @@ package org.ovirt.engine.core.common.businessentities.comparators; import java.io.Serializable; +import java.math.BigInteger; import java.util.Comparator; /** @@ -86,7 +87,7 @@ } private static int compDigitSequence(String seq1, String seq2, boolean caseSensitive) { - int compRes = ((Integer) Integer.parseInt(seq1)).compareTo(Integer.parseInt(seq2)); + int compRes = new BigInteger(seq1).compareTo(new BigInteger(seq2)); return compRes == 0 ? compNonDigitSequence(seq1, seq2, caseSensitive) : compRes; } -- To view, visit http://gerrit.ovirt.org/17238 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I52ec8c73e85b2505314a4043206d5883e2a43e37 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Mike Kolesnik <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
