ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From se...@apache.org
Subject [1/6] incubator-ignite git commit: ignite-gg-9933 - portable queries fix
Date Fri, 20 Mar 2015 23:17:48 GMT
Repository: incubator-ignite
Updated Branches:
  refs/heads/sprint-2 38faddaeb -> 62f93c206


ignite-gg-9933 - portable queries fix


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

Branch: refs/heads/sprint-2
Commit: 06324b1bc6f0b0cda8a724a5dc0191e694efce8d
Parents: fe649a4
Author: S.Vladykin <svladykin@gridgain.com>
Authored: Thu Mar 19 04:03:40 2015 +0300
Committer: S.Vladykin <svladykin@gridgain.com>
Committed: Thu Mar 19 04:03:40 2015 +0300

----------------------------------------------------------------------
 .../org/apache/ignite/cache/CacheTypeMetadata.java  |  6 ++++++
 .../apache/ignite/cache/query/SqlFieldsQuery.java   |  7 -------
 .../org/apache/ignite/cache/query/TextQuery.java    | 14 ++++----------
 .../processors/query/GridQueryProcessor.java        | 14 +++++++++++---
 .../apache/ignite/internal/util/IgniteUtils.java    | 16 ++++++++++++++++
 5 files changed, 37 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/06324b1b/modules/core/src/main/java/org/apache/ignite/cache/CacheTypeMetadata.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/CacheTypeMetadata.java b/modules/core/src/main/java/org/apache/ignite/cache/CacheTypeMetadata.java
index f25d9f4..e97e3b8 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/CacheTypeMetadata.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/CacheTypeMetadata.java
@@ -18,6 +18,7 @@
 package org.apache.ignite.cache;
 
 import org.apache.ignite.internal.util.tostring.*;
+import org.apache.ignite.internal.util.typedef.internal.*;
 import org.apache.ignite.lang.*;
 
 import java.util.*;
@@ -327,4 +328,9 @@ public class CacheTypeMetadata {
     public void setGroups(Map<String, LinkedHashMap<String, IgniteBiTuple<Class<?>,
Boolean>>> grps) {
         this.grps = grps;
     }
+
+    /** {@inheritDoc} */
+    @Override public String toString() {
+        return S.toString(CacheTypeMetadata.class, this);
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/06324b1b/modules/core/src/main/java/org/apache/ignite/cache/query/SqlFieldsQuery.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/query/SqlFieldsQuery.java
b/modules/core/src/main/java/org/apache/ignite/cache/query/SqlFieldsQuery.java
index 65e7a29..c0733e6 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/query/SqlFieldsQuery.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/query/SqlFieldsQuery.java
@@ -39,13 +39,6 @@ public final class SqlFieldsQuery extends Query<SqlFieldsQuery>{
     private Object[] args;
 
     /**
-     * Default constructor.
-     */
-    public SqlFieldsQuery() {
-        // No-op.
-    }
-
-    /**
      * Constructs sql fields query.
      *
      * @param sql SQL Query.

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/06324b1b/modules/core/src/main/java/org/apache/ignite/cache/query/TextQuery.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/query/TextQuery.java b/modules/core/src/main/java/org/apache/ignite/cache/query/TextQuery.java
index dbb9183..c48331b 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/query/TextQuery.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/query/TextQuery.java
@@ -38,18 +38,13 @@ public final class TextQuery extends Query<TextQuery> {
     private String txt;
 
     /**
-     * Default constructor.
-     */
-    public TextQuery() {
-        // No-op.
-    }
-
-    /**
      * Constructs query for the given search string.
      *
+     * @param type Type.
      * @param txt Search string.
      */
-    public TextQuery(String txt) {
+    public TextQuery(String type, String txt) {
+        setType(type);
         setText(txt);
     }
 
@@ -60,9 +55,8 @@ public final class TextQuery extends Query<TextQuery> {
      * @param txt Search string.
      */
     public TextQuery(Class<?> type, String txt) {
-        this(txt);
-
         setType(type);
+        setText(txt);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/06324b1b/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 aa924c4..068ebe5 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
@@ -368,7 +368,7 @@ public class GridQueryProcessor extends GridProcessorAdapter {
             if (desc == null || !desc.registered())
                 return;
 
-            if (!desc.valueClass().equals(valCls))
+            if (!desc.valueClass().isAssignableFrom(valCls))
                 throw new IgniteCheckedException("Failed to update index due to class name
conflict" +
                     "(multiple classes with same simple name are stored in the same cache)
" +
                     "[expCls=" + desc.valueClass().getName() + ", actualCls=" + valCls.getName()
+ ']');
@@ -1057,6 +1057,14 @@ public class GridQueryProcessor extends GridProcessorAdapter {
                 d.addProperty(prop, false);
         }
 
+        if (F.isEmpty(meta.getValueType()))
+            throw new IgniteCheckedException("Value type is not set: " + meta);
+
+        d.name(meta.getValueType());
+
+        d.valueClass(U.classForName(meta.getValueType(), Object.class));
+        d.keyClass(meta.getKeyType() == null ? Object.class : U.classForName(meta.getKeyType(),
Object.class));
+
         return d;
     }
 
@@ -1364,8 +1372,8 @@ public class GridQueryProcessor extends GridProcessorAdapter {
             else {
                 int isKeyProp0 = isKeyProp;
 
-                if (isKeyProp0 == 0) {
-                    if (ctx.cacheObjects().hasField(key, propName))
+                if (isKeyProp0 == 0) { // Key is allowed to be a non-portable object here.
+                    if (ctx.cacheObjects().isPortableObject(key) && ctx.cacheObjects().hasField(key,
propName))
                         isKeyProp = isKeyProp0 = 1;
                     else if (ctx.cacheObjects().hasField(val, propName))
                         isKeyProp = isKeyProp0 = -1;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/06324b1b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
index 7804c9d..521cdc1 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
@@ -1068,6 +1068,22 @@ public abstract class IgniteUtils {
     }
 
     /**
+     * Gets class for the given name if it can be loaded or default given class.
+     *
+     * @param cls Class.
+     * @param dflt Default class to return.
+     * @return Class or default given class if it can't be found.
+     */
+    @Nullable public static Class<?> classForName(String cls, @Nullable Class<?>
dflt) {
+        try {
+            return Class.forName(cls);
+        }
+        catch (ClassNotFoundException e) {
+            return dflt;
+        }
+    }
+
+    /**
      * Creates new instance of a class only if it has an empty constructor (can be non-public).
      *
      * @param cls Class name.


Mime
View raw message