[
https://issues.apache.org/jira/browse/GEODE-785?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Jason Huynh resolved GEODE-785.
-------------------------------
Resolution: Fixed
> Refactor repetitive comparison/loop code in CompiledIn.evaluate
> ---------------------------------------------------------------
>
> Key: GEODE-785
> URL: https://issues.apache.org/jira/browse/GEODE-785
> Project: Geode
> Issue Type: Improvement
> Components: querying
> Reporter: Jason Huynh
> Assignee: Jason Huynh
>
> In CompiledIn.evaluate we can see repetitive loops, each one differing only
> in the cast to a specific array type. For example:
> // handle each type of primitive array
> if (evalColln instanceof long[]) {
> long[] a = (long[])evalColln;
> for (int i = 0; i < a.length; i++) {
> Object e = Long.valueOf(a[i]);
> if (TypeUtils.compare(evalElm, e, TOK_EQ).equals(Boolean.TRUE)) {
> return Boolean.TRUE;
> }
> }
> return Boolean.FALSE;
> }
>
> if (evalColln instanceof double[]) {
> double[] a = (double[])evalColln;
> for (int i = 0; i < a.length; i++) {
> Object e = Double.valueOf(a[i]);
> if (TypeUtils.compare(evalElm, e, TOK_EQ).equals(Boolean.TRUE)) {
> return Boolean.TRUE;
> }
> }
> return Boolean.FALSE;
> }
> We should be able to write a test to exercise this code and then write a
> single loop that handles all object thypes as the comparison is actually done
> by the TypeUtils.compare() method.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)