ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [16/50] [abbrv] ignite git commit: IGNITE-1282 - Fixed queries.
Date Tue, 24 Nov 2015 09:18:27 GMT
IGNITE-1282 - Fixed queries.


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/80abb061
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/80abb061
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/80abb061

Branch: refs/heads/master
Commit: 80abb061b8a19b14a3d6e16f3c15de017d7df09a
Parents: f17dfd0
Author: Alexey Goncharuk <alexey.goncharuk@gmail.com>
Authored: Fri Nov 20 20:28:14 2015 +0300
Committer: Alexey Goncharuk <alexey.goncharuk@gmail.com>
Committed: Fri Nov 20 20:28:14 2015 +0300

----------------------------------------------------------------------
 .../processors/query/GridQueryProcessor.java    | 37 ++++++++++++++++----
 1 file changed, 31 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/80abb061/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
index 4d1145d..fbe54e0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
@@ -45,6 +45,7 @@ import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteException;
 import org.apache.ignite.IgniteLogger;
 import org.apache.ignite.binary.BinaryField;
+import org.apache.ignite.binary.BinaryType;
 import org.apache.ignite.cache.CacheTypeMetadata;
 import org.apache.ignite.cache.QueryEntity;
 import org.apache.ignite.cache.QueryIndex;
@@ -1808,6 +1809,9 @@ public class GridQueryProcessor extends GridProcessorAdapter {
         /** Binary field to speed-up deserialization. */
         private volatile BinaryField field;
 
+        /** Flag indicating that we already tried to take a field. */
+        private volatile boolean fieldTaken;
+
         /**
          * Constructor.
          *
@@ -1861,7 +1865,7 @@ public class GridQueryProcessor extends GridProcessorAdapter {
 
             BinaryObject obj0 = (BinaryObject)obj;
 
-            return binaryField(obj0).value(obj0);
+            return fieldValue(obj0);
         }
 
         /**
@@ -1873,18 +1877,39 @@ public class GridQueryProcessor extends GridProcessorAdapter {
         private BinaryField binaryField(BinaryObject obj) {
             BinaryField field0 = field;
 
-            if (field0 == null)
-            {
-                field0 = obj.type().field(propName);
+            if (field0 == null && !fieldTaken) {
+                BinaryType type = obj.type();
+
+                if (type != null) {
+                    field0 = type.field(propName);
+
+                    assert field0 != null;
 
-                assert field0 != null;
+                    field = field0;
+                }
 
-                field = field0;
+                fieldTaken = true;
             }
 
             return field0;
         }
 
+        /**
+         * Gets field value for the given binary object.
+         *
+         * @param obj Binary object.
+         * @return Field value.
+         */
+        @SuppressWarnings("IfMayBeConditional")
+        private Object fieldValue(BinaryObject obj) {
+            BinaryField field = binaryField(obj);
+
+            if (field != null)
+                return field.value(obj);
+            else
+                return obj.field(propName);
+        }
+
         /** {@inheritDoc} */
         @Override public String name() {
             return alias;


Mime
View raw message