geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From u..@apache.org
Subject [09/13] incubator-geode git commit: GEODE-1985 Removing some string comparisons in the AttributesDescriptor
Date Mon, 07 Nov 2016 18:41:00 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/fdf63290
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/fdf63290
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/fdf63290

Branch: refs/heads/feature/GEODE-2017
Commit: fdf632901e15c40a5c5510e24d57e0ecfa0ba32e
Parents: 9ca9d75
Author: Dan Smith <upthewaterspout@apache.org>
Authored: Mon Oct 24 17:23:35 2016 -0700
Committer: Udo Kohlmeyer <ukohlmeyer@pivotal.io>
Committed: Tue Nov 8 05:39:39 2016 +1100

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


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/fdf63290/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