[
https://issues.apache.org/jira/browse/GEODE-2936?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16049667#comment-16049667
]
ASF GitHub Bot commented on GEODE-2936:
---------------------------------------
Github user YehEmily commented on a diff in the pull request:
https://github.com/apache/geode/pull/580#discussion_r122067285
--- Diff:
geode-core/src/main/java/org/apache/geode/cache/query/internal/OrderByComparator.java
---
@@ -228,4 +139,55 @@ void addEvaluatedSortCriteria(Object row,
ExecutionContext context)
// No op
}
+ private int compareHelperMethod(Object obj1, Object obj2) {
+ if (obj1 == null || obj2 == null) {
+ return compareIfOneOrMoreNull(obj1, obj2);
+ } else if (obj1 == QueryService.UNDEFINED || obj2 ==
QueryService.UNDEFINED) {
+ return compareIfOneOrMoreQueryServiceUndefined(obj1, obj2);
+ } else {
+ return compareTwoObjects(obj1, obj2);
+ }
+ }
+
+ private int compareIfOneOrMoreNull(Object obj1, Object obj2) {
+ if (obj1 == null) {
+ return obj2 == null ? 0 : -1;
+ } else {
+ return 1;
+ }
+ }
+
+ private int compareIfOneOrMoreQueryServiceUndefined(Object obj1, Object
obj2) {
+ if (obj1 == QueryService.UNDEFINED) {
+ return obj2 == QueryService.UNDEFINED ? 0 : -1;
+ } else {
+ return 1;
+ }
+ }
+
+ private int compareTwoObjects(Object obj1, Object obj2) {
+ if (obj1 instanceof Number && obj2 instanceof Number) {
+ return compareTwoNumbers(obj1, obj2);
+ } else {
+ return compareTwoStrings(obj1, obj2);
+ }
+ }
+
+ private int compareTwoNumbers(Object obj1, Object obj2) {
--- End diff --
Oh no, that's very true! I'll fix this and update the PR!
> Refactor OrderByComparator's compare method to reduce redundant code
> --------------------------------------------------------------------
>
> Key: GEODE-2936
> URL: https://issues.apache.org/jira/browse/GEODE-2936
> Project: Geode
> Issue Type: Bug
> Components: querying
> Reporter: nabarun
> Assignee: Emily Yeh
>
> Issue:
> OrderByComparator's compare method has a lot of redundant code.
> Solution:
> These code sections can be modified to have one method call
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)