geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From upthewatersp...@apache.org
Subject [2/3] incubator-geode git commit: GEODE-1985 Removing some string comparisons in the AttributesDescriptor
Date Mon, 07 Nov 2016 18:02:41 GMT
GEODE-1985 Removing some string comparisons in the AttributesDescriptor

Optimizing the attributes descriptor by removing some string
comparisons.


Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/4c0d302f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/4c0d302f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/4c0d302f

Branch: refs/heads/develop
Commit: 4c0d302fcacdc338d967c2fb873c05d0a52f109f
Parents: 1000f0b
Author: Dan Smith <upthewaterspout@apache.org>
Authored: Mon Oct 24 17:23:35 2016 -0700
Committer: Dan Smith <upthewaterspout@apache.org>
Committed: Mon Nov 7 09:57:32 2016 -0800

----------------------------------------------------------------------
 .../query/internal/AttributeDescriptor.java     | 27 ++++++++------------
 1 file changed, 10 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/4c0d302f/geode-core/src/main/java/org/apache/geode/cache/query/internal/AttributeDescriptor.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/cache/query/internal/AttributeDescriptor.java
b/geode-core/src/main/java/org/apache/geode/cache/query/internal/AttributeDescriptor.java
index a11bea0..f40ab3e 100644
--- a/geode-core/src/main/java/org/apache/geode/cache/query/internal/AttributeDescriptor.java
+++ b/geode-core/src/main/java/org/apache/geode/cache/query/internal/AttributeDescriptor.java
@@ -33,6 +33,7 @@ import org.apache.geode.cache.query.NameNotFoundException;
 import org.apache.geode.cache.query.QueryInvocationTargetException;
 import org.apache.geode.cache.query.QueryService;
 import org.apache.geode.cache.query.types.ObjectType;
+import org.apache.geode.internal.cache.Token;
 import org.apache.geode.internal.i18n.LocalizedStrings;
 import org.apache.geode.pdx.PdxInstance;
 import org.apache.geode.pdx.PdxSerializationException;
@@ -78,29 +79,25 @@ public class AttributeDescriptor {
       return readPdx((PdxInstance) target);
     }
     // for non pdx objects
-    return read(target, target.getClass());
+    return readReflection(target);
   }
 
   // used when the resolution of an attribute must be on a superclass
   // instead of the runtime class
-  private Object read(Object target, Class resolutionClass)
+  private Object readReflection(Object target)
       throws NameNotFoundException, QueryInvocationTargetException {
     Support.Assert(target != null);
     Support.Assert(target != QueryService.UNDEFINED);
-    Member m;
-    if (target.getClass().getName().startsWith("org.apache.geode.internal.cache.Token$"))
{
+    if (target instanceof Token) {
       return QueryService.UNDEFINED;
-    } else {
-      m = getReadMember(resolutionClass);
     }
+
+    Class resolutionClass = target.getClass();
+    Member m = getReadMember(resolutionClass);
     try {
       if (m instanceof Method) {
         try {
-          if (target.getClass().getName().startsWith("org.apache.geode.internal.cache.Token$"))
{
-            return QueryService.UNDEFINED;
-          } else {
-            return ((Method) m).invoke(target, (Object[]) null);
-          }
+          return ((Method) m).invoke(target, (Object[]) null);
         } catch (EntryDestroyedException e) {
           // eat the Exception
           return QueryService.UNDEFINED;
@@ -123,11 +120,7 @@ public class AttributeDescriptor {
         }
       } else {
         try {
-          if (target.getClass().getName().startsWith("org.apache.geode.internal.cache.Token$"))
{
-            return QueryService.UNDEFINED;
-          } else {
-            return ((Field) m).get(target);
-          }
+          return ((Field) m).get(target);
         } catch (IllegalAccessException e) {
           throw new NameNotFoundException(
               LocalizedStrings.AttributeDescriptor_FIELD_0_IN_CLASS_1_IS_NOT_ACCESSIBLE_TO_THE_QUERY_PROCESSOR
@@ -315,7 +308,7 @@ public class AttributeDescriptor {
       throws NameNotFoundException, QueryInvocationTargetException {
     try {
       Object obj = pdxInstance.getCachedObject();
-      return read(obj, obj.getClass());
+      return readReflection(obj);
     } catch (PdxSerializationException e) {
       throw new NameNotFoundException( // the domain object is not available
           LocalizedStrings.AttributeDescriptor_FIELD_0_IN_CLASS_1_IS_NOT_ACCESSIBLE_TO_THE_QUERY_PROCESSOR


Mime
View raw message