[
https://issues.apache.org/jira/browse/GEODE-2936?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16049614#comment-16049614
]
ASF GitHub Bot commented on GEODE-2936:
---------------------------------------
Github user PurelyApplied commented on a diff in the pull request:
https://github.com/apache/geode/pull/580#discussion_r122053903
--- Diff:
geode-core/src/main/java/org/apache/geode/cache/query/internal/OrderByComparator.java
---
@@ -45,78 +44,50 @@ public OrderByComparator(List<CompiledSortCriterion>
orderByAttrs, ObjectType ob
}
/**
- * Yogesh : This methods evaluates sort criteria and returns a ArrayList
of Object[] arrays of
- * evaluated criteria
+ * This method evaluates sort criteria and returns an ArrayList of
Object[] arrays of the
+ * evaluated criteria.
*
- * @param value
- * @return Object[]
+ * @param value the criteria to be evaluated.
+ * @return an Object array of Object arrays of the evaluated criteria.
*/
protected Object[] evaluateSortCriteria(Object value) {
-
CompiledSortCriterion csc;
Object[] array = null;
if (orderByAttrs != null) {
array = new Object[orderByAttrs.size()];
- Iterator orderiter = orderByAttrs.iterator();
+ Iterator orderIter = orderByAttrs.iterator();
int i = 0;
- while (orderiter.hasNext()) {
- csc = (CompiledSortCriterion) orderiter.next();
- Object[] arr = new Object[2];
- arr[0] = csc.evaluate(value, context);
- arr[1] = Boolean.valueOf(csc.getCriterion());
+ while (orderIter.hasNext()) {
--- End diff --
This loop and the one below could read better with a "for each" loop.
```
for (CompiledSortCriterion csc: orderByAttrs){
```
Good refactoring overall.
+1 with or without the loop edit.
> 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)