You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@geode.apache.org by "Jason Huynh (JIRA)" <ji...@apache.org> on 2016/01/18 21:13:42 UTC
[jira] [Created] (GEODE-785) Refactor repetitive comparison/loop
code in CompiledIn.evaluate
Jason Huynh created GEODE-785:
---------------------------------
Summary: 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
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)