You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@geode.apache.org by "ASF subversion and git services (JIRA)" <ji...@apache.org> on 2016/01/20 19:08:39 UTC
[jira] [Commented] (GEODE-785) Refactor repetitive comparison/loop
code in CompiledIn.evaluate
[ https://issues.apache.org/jira/browse/GEODE-785?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15109048#comment-15109048 ]
ASF subversion and git services commented on GEODE-785:
-------------------------------------------------------
Commit 06a7dbd3888cfa706efbd5ce255c7b83d7720e57 in incubator-geode's branch refs/heads/develop from [~huynhja]
[ https://git-wip-us.apache.org/repos/asf?p=incubator-geode.git;h=06a7dbd ]
GEODE-785: Refactor repetitive comparison/loop code in CompiledIn.evaluate
Collapsed multiple primitive array loops into a single one
Added CompiledInJUnitTest
> 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)