You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by se...@apache.org on 2015/07/01 21:52:43 UTC
[1/4] incubator-ignite git commit: ignite-959-x - wip
Repository: incubator-ignite
Updated Branches:
refs/heads/ignite-959-x [created] 7df4f8cb0
ignite-959-x - wip
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/781f0d5f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/781f0d5f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/781f0d5f
Branch: refs/heads/ignite-959-x
Commit: 781f0d5ff32ea034d67260469a595cdb64048655
Parents: 285d790
Author: S.Vladykin <sv...@gridgain.com>
Authored: Thu Jun 25 12:46:25 2015 +0300
Committer: S.Vladykin <sv...@gridgain.com>
Committed: Thu Jun 25 12:46:25 2015 +0300
----------------------------------------------------------------------
.../configuration/CacheConfiguration.java | 602 ++++++++++++++++++-
.../processors/query/GridQueryProcessor.java | 44 ++
.../processors/query/h2/IgniteH2Indexing.java | 2 -
3 files changed, 632 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/781f0d5f/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
index 7af4974..50ba040 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
@@ -25,6 +25,9 @@ import org.apache.ignite.cache.eviction.*;
import org.apache.ignite.cache.query.annotations.*;
import org.apache.ignite.cache.store.*;
import org.apache.ignite.cluster.*;
+import org.apache.ignite.internal.processors.query.*;
+import org.apache.ignite.internal.util.tostring.*;
+import org.apache.ignite.internal.util.typedef.*;
import org.apache.ignite.internal.util.typedef.internal.*;
import org.apache.ignite.lang.*;
import org.apache.ignite.plugin.*;
@@ -33,8 +36,11 @@ import org.jetbrains.annotations.*;
import javax.cache.*;
import javax.cache.configuration.*;
import javax.cache.expiry.*;
+import java.lang.reflect.*;
import java.util.*;
+import static org.apache.ignite.internal.processors.query.GridQueryIndexType.*;
+
/**
* This class defines grid cache configuration. This configuration is passed to
* grid via {@link IgniteConfiguration#getCacheConfiguration()} method. It defines all configuration
@@ -298,7 +304,7 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
private boolean sqlEscapeAll;
/** */
- private Class<?>[] indexedTypes;
+ private transient Class<?>[] indexedTypes;
/** */
private int sqlOnheapRowCacheSize = DFLT_SQL_ONHEAP_ROW_CACHE_SIZE;
@@ -1506,7 +1512,12 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
* @return {@code this} for chaining.
*/
public CacheConfiguration setTypeMetadata(Collection<CacheTypeMetadata> typeMeta) {
- this.typeMeta = typeMeta;
+ if (this.typeMeta == null)
+ this.typeMeta = new ArrayList<>(typeMeta);
+ else if (indexedTypes != null)
+ this.typeMeta.addAll(typeMeta);
+ else
+ throw new CacheException("Type metadata can be set only once.");
return this;
}
@@ -1661,21 +1672,31 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
* @return {@code this} for chaining.
*/
public CacheConfiguration setIndexedTypes(Class<?>... indexedTypes) {
- A.ensure(indexedTypes == null || (indexedTypes.length & 1) == 0,
+ int len = indexedTypes.length;
+
+ A.ensure(len > 0, "Array of indexed types can not be empty.");
+ A.ensure((len & 1) == 0,
"Number of indexed types is expected to be even. Refer to method javadoc for details.");
- if (indexedTypes != null) {
- int len = indexedTypes.length;
+ if (this.indexedTypes != null)
+ throw new CacheException("Indexed types can be set only once.");
+
+ Class<?>[] newIndexedTypes = new Class<?>[len];
- Class<?>[] newIndexedTypes = new Class<?>[len];
+ for (int i = 0; i < len; i++)
+ newIndexedTypes[i] = U.box(indexedTypes[i]);
- for (int i = 0; i < len; i++)
- newIndexedTypes[i] = U.box(indexedTypes[i]);
+ if (typeMeta == null)
+ typeMeta = new ArrayList<>();
- this.indexedTypes = newIndexedTypes;
+ for (int i = 0; i < len; i += 2) {
+ Class<?> keyCls = newIndexedTypes[i];
+ Class<?> valCls = newIndexedTypes[i + 1];
+
+ TypeDescriptor desc = processKeyAndValueClasses(keyCls, valCls);
+
+ typeMeta.add(convert(desc));
}
- else
- this.indexedTypes = null;
return this;
}
@@ -1773,6 +1794,165 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
return this;
}
+ /**
+ * @param desc Type descriptor.
+ * @return Type metadata.
+ */
+ private CacheTypeMetadata convert(TypeDescriptor desc) {
+ CacheTypeMetadata meta = new CacheTypeMetadata();
+
+ // TODO
+
+ return meta;
+ }
+
+ /**
+ * @param keyCls Key class.
+ * @param valCls Value class.
+ * @return Type descriptor.
+ */
+ private static TypeDescriptor processKeyAndValueClasses(
+ Class<?> keyCls,
+ Class<?> valCls
+ ) {
+ TypeDescriptor d = new TypeDescriptor();
+
+ d.keyClass(keyCls);
+ d.valueClass(valCls);
+
+ processAnnotationsInClass(true, d.keyCls, d, null);
+
+ String valTypeName = GridQueryProcessor.typeName(valCls);
+
+ d.name(valTypeName);
+
+ processAnnotationsInClass(false, d.valCls, d, null);
+
+ return d;
+ }
+
+ /**
+ * Process annotations for class.
+ *
+ * @param key If given class relates to key.
+ * @param cls Class.
+ * @param type Type descriptor.
+ * @param parent Parent in case of embeddable.
+ */
+ private static void processAnnotationsInClass(boolean key, Class<?> cls, TypeDescriptor type,
+ @Nullable ClassProperty parent) {
+ if (U.isJdk(cls) || GridQueryProcessor.isGeometryClass(cls)) {
+ if (parent == null && !key && GridQueryProcessor.isSqlType(cls) ) { // We have to index primitive _val.
+ String idxName = "_val_idx";
+
+ type.addIndex(idxName, GridQueryProcessor.isGeometryClass(cls) ? GEO_SPATIAL : SORTED);
+
+ type.addFieldToIndex(idxName, "_VAL", 0, false);
+ }
+
+ return;
+ }
+
+ if (parent != null && parent.knowsClass(cls))
+ throw new CacheException("Recursive reference found in type: " + cls.getName());
+
+ if (parent == null) { // Check class annotation at top level only.
+ QueryTextField txtAnnCls = cls.getAnnotation(QueryTextField.class);
+
+ if (txtAnnCls != null)
+ type.valueTextIndex(true);
+
+ QueryGroupIndex grpIdx = cls.getAnnotation(QueryGroupIndex.class);
+
+ if (grpIdx != null)
+ type.addIndex(grpIdx.name(), SORTED);
+
+ QueryGroupIndex.List grpIdxList = cls.getAnnotation(QueryGroupIndex.List.class);
+
+ if (grpIdxList != null && !F.isEmpty(grpIdxList.value())) {
+ for (QueryGroupIndex idx : grpIdxList.value())
+ type.addIndex(idx.name(), SORTED);
+ }
+ }
+
+ for (Class<?> c = cls; c != null && !c.equals(Object.class); c = c.getSuperclass()) {
+ for (Field field : c.getDeclaredFields()) {
+ QuerySqlField sqlAnn = field.getAnnotation(QuerySqlField.class);
+ QueryTextField txtAnn = field.getAnnotation(QueryTextField.class);
+
+ if (sqlAnn != null || txtAnn != null) {
+ ClassProperty prop = new ClassProperty(field, key);
+
+ prop.parent(parent);
+
+ processAnnotation(key, sqlAnn, txtAnn, field.getType(), prop, type);
+
+ type.addProperty(prop, true);
+ }
+ }
+
+ for (Method mtd : c.getDeclaredMethods()) {
+ QuerySqlField sqlAnn = mtd.getAnnotation(QuerySqlField.class);
+ QueryTextField txtAnn = mtd.getAnnotation(QueryTextField.class);
+
+ if (sqlAnn != null || txtAnn != null) {
+ if (mtd.getParameterTypes().length != 0)
+ throw new CacheException("Getter with QuerySqlField " +
+ "annotation cannot have parameters: " + mtd);
+
+ ClassProperty prop = new ClassProperty(mtd, key);
+
+ prop.parent(parent);
+
+ processAnnotation(key, sqlAnn, txtAnn, mtd.getReturnType(), prop, type);
+
+ type.addProperty(prop, true);
+ }
+ }
+ }
+ }
+
+ /**
+ * Processes annotation at field or method.
+ *
+ * @param key If given class relates to key.
+ * @param sqlAnn SQL annotation, can be {@code null}.
+ * @param txtAnn H2 text annotation, can be {@code null}.
+ * @param cls Class of field or return type for method.
+ * @param prop Current property.
+ * @param desc Class description.
+ */
+ private static void processAnnotation(boolean key, QuerySqlField sqlAnn, QueryTextField txtAnn,
+ Class<?> cls, ClassProperty prop, TypeDescriptor desc) {
+ if (sqlAnn != null) {
+ processAnnotationsInClass(key, cls, desc, prop);
+
+ if (!sqlAnn.name().isEmpty())
+ prop.name(sqlAnn.name());
+
+ if (sqlAnn.index()) {
+ String idxName = prop.name() + "_idx";
+
+ desc.addIndex(idxName, GridQueryProcessor.isGeometryClass(prop.type()) ? GEO_SPATIAL : SORTED);
+
+ desc.addFieldToIndex(idxName, prop.name(), 0, sqlAnn.descending());
+ }
+
+ if (!F.isEmpty(sqlAnn.groups())) {
+ for (String group : sqlAnn.groups())
+ desc.addFieldToIndex(group, prop.name(), 0, false);
+ }
+
+ if (!F.isEmpty(sqlAnn.orderedGroups())) {
+ for (QuerySqlField.Group idx : sqlAnn.orderedGroups())
+ desc.addFieldToIndex(idx.name(), prop.name(), idx.order(), idx.descending());
+ }
+ }
+
+ if (txtAnn != null)
+ desc.addFieldToTextIndex(prop.name());
+ }
+
/** {@inheritDoc} */
@Override public String toString() {
return S.toString(CacheConfiguration.class, this);
@@ -1792,10 +1972,404 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
/** {@inheritDoc} */
@Override public boolean equals(Object obj) {
- if (obj == null)
- return false;
+ return obj != null && obj.getClass().equals(this.getClass());
+ }
+ }
+
+ /**
+ * Descriptor of type.
+ */
+ private static class TypeDescriptor implements GridQueryTypeDescriptor {
+ /** */
+ private String name;
+
+ /** Value field names and types with preserved order. */
+ @GridToStringInclude
+ private final Map<String, Class<?>> fields = new LinkedHashMap<>();
+
+ /** */
+ @GridToStringExclude
+ private final Map<String, Property> props = new HashMap<>();
+
+ /** */
+ @GridToStringInclude
+ private final Map<String, IndexDescriptor> indexes = new HashMap<>();
+
+ /** */
+ private IndexDescriptor fullTextIdx;
+
+ /** */
+ private Class<?> keyCls;
+
+ /** */
+ private Class<?> valCls;
+
+ /** */
+ private boolean valTextIdx;
+
+ /** SPI can decide not to register this type. */
+ private boolean registered;
+
+ /**
+ * @return {@code True} if type registration in SPI was finished and type was not rejected.
+ */
+ boolean registered() {
+ return registered;
+ }
+
+ /**
+ * @param registered Sets registered flag.
+ */
+ void registered(boolean registered) {
+ this.registered = registered;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String name() {
+ return name;
+ }
+
+ /**
+ * Sets type name.
+ *
+ * @param name Name.
+ */
+ void name(String name) {
+ this.name = name;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Map<String, Class<?>> fields() {
+ return fields;
+ }
+
+ /** {@inheritDoc} */
+ @SuppressWarnings("unchecked")
+ @Override public <T> T value(String field, Object key, Object val) throws IgniteCheckedException {
+ assert field != null;
+
+ Property prop = props.get(field);
+
+ if (prop == null)
+ throw new IgniteCheckedException("Failed to find field '" + field + "' in type '" + name + "'.");
+
+ return (T)prop.value(key, val);
+ }
+
+ /** {@inheritDoc} */
+ @Override public Map<String, GridQueryIndexDescriptor> indexes() {
+ return Collections.<String, GridQueryIndexDescriptor>unmodifiableMap(indexes);
+ }
+
+ /**
+ * Adds index.
+ *
+ * @param idxName Index name.
+ * @param type Index type.
+ * @return Index descriptor.
+ */
+ public IndexDescriptor addIndex(String idxName, GridQueryIndexType type) {
+ IndexDescriptor idx = new IndexDescriptor(type);
+
+ if (indexes.put(idxName, idx) != null)
+ throw new CacheException("Index with name '" + idxName + "' already exists.");
+
+ return idx;
+ }
- return obj.getClass().equals(this.getClass());
+ /**
+ * Adds field to index.
+ *
+ * @param idxName Index name.
+ * @param field Field name.
+ * @param orderNum Fields order number in index.
+ * @param descending Sorting order.
+ */
+ public void addFieldToIndex(String idxName, String field, int orderNum,
+ boolean descending) {
+ IndexDescriptor desc = indexes.get(idxName);
+
+ if (desc == null)
+ desc = addIndex(idxName, SORTED);
+
+ desc.addField(field, orderNum, descending);
+ }
+
+ /**
+ * Adds field to text index.
+ *
+ * @param field Field name.
+ */
+ public void addFieldToTextIndex(String field) {
+ if (fullTextIdx == null) {
+ fullTextIdx = new IndexDescriptor(FULLTEXT);
+
+ indexes.put(null, fullTextIdx);
+ }
+
+ fullTextIdx.addField(field, 0, false);
+ }
+
+ /** {@inheritDoc} */
+ @Override public Class<?> valueClass() {
+ return valCls;
+ }
+
+ /**
+ * Sets value class.
+ *
+ * @param valCls Value class.
+ */
+ void valueClass(Class<?> valCls) {
+ this.valCls = valCls;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Class<?> keyClass() {
+ return keyCls;
+ }
+
+ /**
+ * Set key class.
+ *
+ * @param keyCls Key class.
+ */
+ void keyClass(Class<?> keyCls) {
+ this.keyCls = keyCls;
+ }
+
+ /**
+ * Adds property to the type descriptor.
+ *
+ * @param prop Property.
+ * @param failOnDuplicate Fail on duplicate flag.
+ */
+ public void addProperty(Property prop, boolean failOnDuplicate) {
+ String name = prop.name();
+
+ if (props.put(name, prop) != null && failOnDuplicate)
+ throw new CacheException("Property with name '" + name + "' already exists.");
+
+ fields.put(name, prop.type());
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean valueTextIndex() {
+ return valTextIdx;
+ }
+
+ /**
+ * Sets if this value should be text indexed.
+ *
+ * @param valTextIdx Flag value.
+ */
+ public void valueTextIndex(boolean valTextIdx) {
+ this.valTextIdx = valTextIdx;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(TypeDescriptor.class, this);
+ }
+ }
+
+ /**
+ * Index descriptor.
+ */
+ private static class IndexDescriptor implements GridQueryIndexDescriptor {
+ /** Fields sorted by order number. */
+ private final Collection<T2<String, Integer>> fields = new TreeSet<>(
+ new Comparator<T2<String, Integer>>() {
+ @Override public int compare(T2<String, Integer> o1, T2<String, Integer> o2) {
+ if (o1.get2().equals(o2.get2())) // Order is equal, compare field names to avoid replace in Set.
+ return o1.get1().compareTo(o2.get1());
+
+ return o1.get2() < o2.get2() ? -1 : 1;
+ }
+ });
+
+ /** Fields which should be indexed in descending order. */
+ private Collection<String> descendings;
+
+ /** */
+ private final GridQueryIndexType type;
+
+ /**
+ * @param type Type.
+ */
+ private IndexDescriptor(GridQueryIndexType type) {
+ assert type != null;
+
+ this.type = type;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Collection<String> fields() {
+ Collection<String> res = new ArrayList<>(fields.size());
+
+ for (T2<String, Integer> t : fields)
+ res.add(t.get1());
+
+ return res;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean descending(String field) {
+ return descendings != null && descendings.contains(field);
+ }
+
+ /**
+ * Adds field to this index.
+ *
+ * @param field Field name.
+ * @param orderNum Field order number in this index.
+ * @param descending Sort order.
+ */
+ public void addField(String field, int orderNum, boolean descending) {
+ fields.add(new T2<>(field, orderNum));
+
+ if (descending) {
+ if (descendings == null)
+ descendings = new HashSet<>();
+
+ descendings.add(field);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public GridQueryIndexType type() {
+ return type;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(IndexDescriptor.class, this);
+ }
+ }
+
+ /**
+ *
+ */
+ private abstract static class Property {
+ /**
+ * Gets this property value from the given object.
+ *
+ * @param key Key.
+ * @param val Value.
+ * @return Property value.
+ * @throws IgniteCheckedException If failed.
+ */
+ public abstract Object value(Object key, Object val) throws IgniteCheckedException;
+
+ /**
+ * @return Property name.
+ */
+ public abstract String name();
+
+ /**
+ * @return Class member type.
+ */
+ public abstract Class<?> type();
+ }
+
+ /**
+ * Description of type property.
+ */
+ private static class ClassProperty extends Property {
+ /** */
+ private final Member member;
+
+ /** */
+ private ClassProperty parent;
+
+ /** */
+ private String name;
+
+ /** */
+ private boolean field;
+
+ /** */
+ private boolean key;
+
+ /**
+ * Constructor.
+ *
+ * @param member Element.
+ */
+ ClassProperty(Member member, boolean key) {
+ this.member = member;
+ this.key = key;
+
+ name = member instanceof Method && member.getName().startsWith("get") && member.getName().length() > 3 ?
+ member.getName().substring(3) : member.getName();
+
+ ((AccessibleObject) member).setAccessible(true);
+
+ field = member instanceof Field;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Object value(Object key, Object val) throws IgniteCheckedException {
+ Object x = this.key ? key : val;
+
+ if (parent != null)
+ x = parent.value(key, val);
+
+ if (x == null)
+ return null;
+
+ try {
+ if (field) {
+ Field field = (Field)member;
+
+ return field.get(x);
+ }
+ else {
+ Method mtd = (Method)member;
+
+ return mtd.invoke(x);
+ }
+ }
+ catch (Exception e) {
+ throw new IgniteCheckedException(e);
+ }
+ }
+
+ /**
+ * @param name Property name.
+ */
+ public void name(String name) {
+ this.name = name;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String name() {
+ return name;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Class<?> type() {
+ return member instanceof Field ? ((Field)member).getType() : ((Method)member).getReturnType();
+ }
+
+ /**
+ * @param parent Parent property if this is embeddable element.
+ */
+ public void parent(ClassProperty parent) {
+ this.parent = parent;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(ClassProperty.class, this);
+ }
+
+ /**
+ * @param cls Class.
+ * @return {@code true} If this property or some parent relates to member of the given class.
+ */
+ public boolean knowsClass(Class<?> cls) {
+ return member.getDeclaringClass() == cls || (parent != null && parent.knowsClass(cls));
}
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/781f0d5f/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 e080c6d..f6cff33 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
@@ -41,6 +41,8 @@ import org.jsr166.*;
import javax.cache.*;
import java.lang.reflect.*;
+import java.math.*;
+import java.sql.*;
import java.util.*;
import java.util.concurrent.*;
@@ -52,6 +54,28 @@ import static org.apache.ignite.internal.processors.query.GridQueryIndexType.*;
* Indexing processor.
*/
public class GridQueryProcessor extends GridProcessorAdapter {
+ /** */
+ private static final Class<?> GEOMETRY_CLASS = U.classForName("com.vividsolutions.jts.geom.Geometry", null);
+
+ /** */
+ private static Set<Class<?>> SQL_TYPES = new HashSet<>(F.<Class<?>>asList(
+ Integer.class,
+ Boolean.class,
+ Byte.class,
+ Short.class,
+ Long.class,
+ BigDecimal.class,
+ Double.class,
+ Float.class,
+ Time.class,
+ Timestamp.class,
+ java.util.Date.class,
+ java.sql.Date.class,
+ String.class,
+ UUID.class,
+ byte[].class
+ ));
+
/** For tests. */
public static Class<? extends GridQueryIndexing> idxCls;
@@ -801,6 +825,26 @@ public class GridQueryProcessor extends GridProcessorAdapter {
}
/**
+ * Checks if the given class can be mapped to a simple SQL type.
+ *
+ * @param cls Class.
+ * @return {@code true} If can.
+ */
+ public static boolean isSqlType(Class<?> cls) {
+ return SQL_TYPES.contains(cls);
+ }
+
+ /**
+ * Checks if the given class is GEOMETRY.
+ *
+ * @param cls Class.
+ * @return {@code true} If this is geometry.
+ */
+ public static boolean isGeometryClass(Class<?> cls) {
+ return GEOMETRY_CLASS != null && GEOMETRY_CLASS.isAssignableFrom(cls);
+ }
+
+ /**
* Gets type name by class.
*
* @param cls Class.
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/781f0d5f/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
index 06c0961..359341a 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
@@ -1584,8 +1584,6 @@ public class IgniteH2Indexing implements GridQueryIndexing {
map.put(Timestamp.class, TIMESTAMP);
map.put(java.util.Date.class, TIMESTAMP);
map.put(java.sql.Date.class, DATE);
- map.put(char.class, CHAR);
- map.put(Character.class, CHAR);
map.put(String.class, VARCHAR);
map.put(UUID.class, UUID);
map.put(byte[].class, BINARY);
[3/4] incubator-ignite git commit: ignite-959-x - wip
Posted by se...@apache.org.
ignite-959-x - wip
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/3f38513f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/3f38513f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/3f38513f
Branch: refs/heads/ignite-959-x
Commit: 3f38513fb00b472a5b30be4da61a6838154e5e57
Parents: 9379828
Author: S.Vladykin <sv...@gridgain.com>
Authored: Tue Jun 30 18:25:33 2015 -0700
Committer: S.Vladykin <sv...@gridgain.com>
Committed: Tue Jun 30 18:25:33 2015 -0700
----------------------------------------------------------------------
.../apache/ignite/cache/CacheTypeMetadata.java | 66 +++--
.../configuration/CacheConfiguration.java | 260 ++++++++---------
.../processors/query/GridQueryIndexing.java | 16 --
.../processors/query/GridQueryProcessor.java | 283 ++++++-------------
.../ignite/internal/util/IgniteUtils.java | 5 +-
.../processors/query/h2/IgniteH2Indexing.java | 17 --
6 files changed, 254 insertions(+), 393 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3f38513f/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 20129b7..f2b004e 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
@@ -17,10 +17,12 @@
package org.apache.ignite.cache;
+import org.apache.ignite.internal.processors.query.*;
import org.apache.ignite.internal.util.tostring.*;
import org.apache.ignite.internal.util.typedef.internal.*;
import org.apache.ignite.lang.*;
+import javax.cache.*;
import java.io.*;
import java.util.*;
@@ -43,6 +45,9 @@ public class CacheTypeMetadata implements Serializable {
/** Value class used to store value in cache. */
private String valType;
+ /** Simple value type name that will be used as SQL table name.*/
+ private String simpleValType;
+
/** Key fields. */
@GridToStringInclude
private Collection<CacheTypeFieldMetadata> keyFields;
@@ -71,22 +76,20 @@ public class CacheTypeMetadata implements Serializable {
@GridToStringInclude
private Map<String, LinkedHashMap<String, IgniteBiTuple<Class<?>, Boolean>>> grps;
+ /** */
+ @GridToStringInclude
+ private Map<String,String> aliases;
+
/**
* Default constructor.
*/
public CacheTypeMetadata() {
keyFields = new ArrayList<>();
-
valFields = new ArrayList<>();
-
qryFlds = new LinkedHashMap<>();
-
ascFlds = new LinkedHashMap<>();
-
descFlds = new LinkedHashMap<>();
-
txtFlds = new LinkedHashSet<>();
-
grps = new LinkedHashMap<>();
}
@@ -95,25 +98,16 @@ public class CacheTypeMetadata implements Serializable {
*/
public CacheTypeMetadata(CacheTypeMetadata src) {
dbSchema = src.getDatabaseSchema();
-
dbTbl = src.getDatabaseTable();
-
keyType = src.getKeyType();
-
valType = src.getValueType();
-
+ simpleValType = src.simpleValType;
keyFields = new ArrayList<>(src.getKeyFields());
-
valFields = new ArrayList<>(src.getValueFields());
-
qryFlds = new LinkedHashMap<>(src.getQueryFields());
-
ascFlds = new LinkedHashMap<>(src.getAscendingFields());
-
descFlds = new LinkedHashMap<>(src.getDescendingFields());
-
txtFlds = new LinkedHashSet<>(src.getTextFields());
-
grps = new LinkedHashMap<>(src.getGroups());
}
@@ -190,12 +184,28 @@ public class CacheTypeMetadata implements Serializable {
}
/**
+ * Gets simple value type.
+ *
+ * @return Simple value type.
+ */
+ public String getSimpleValueType() {
+ return simpleValType;
+ }
+
+ /**
* Sets value type.
*
* @param valType Value type.
*/
public void setValueType(String valType) {
+ if (this.valType != null)
+ throw new CacheException("Value type can be set only once.");
+
this.valType = valType;
+
+ Class<?> cls = U.classForName(valType, null);
+
+ simpleValType = cls == null ? valType : GridQueryProcessor.typeName(cls);
}
/**
@@ -276,7 +286,10 @@ public class CacheTypeMetadata implements Serializable {
* @param ascFlds Map of ascending-indexed fields.
*/
public void setAscendingFields(Map<String, Class<?>> ascFlds) {
- this.ascFlds = ascFlds;
+ if (ascFlds == null)
+ this.ascFlds = ascFlds;
+ else
+ this.ascFlds.putAll(ascFlds);
}
/**
@@ -333,6 +346,25 @@ public class CacheTypeMetadata implements Serializable {
this.grps = grps;
}
+ /**
+ * Sets mapping from full property name in dot notation to an alias that will be used as SQL column name.
+ * Example: {"parent.name" -> "parentName"}.
+ *
+ * @param aliases Aliases.
+ */
+ public void setAliases(Map<String,String> aliases) {
+ this.aliases = aliases;
+ }
+
+ /**
+ * Gets aliases mapping.
+ *
+ * @return Aliases.
+ */
+ public Map<String,String> getAliases() {
+ return aliases;
+ }
+
/** {@inheritDoc} */
@Override public String toString() {
return S.toString(CacheTypeMetadata.class, this);
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3f38513f/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
index 50ba040..1f32cf3 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
@@ -1798,15 +1798,92 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
* @param desc Type descriptor.
* @return Type metadata.
*/
- private CacheTypeMetadata convert(TypeDescriptor desc) {
+ private static CacheTypeMetadata convert(TypeDescriptor desc) {
CacheTypeMetadata meta = new CacheTypeMetadata();
- // TODO
+ // Key and val types.
+ meta.setKeyType(desc.keyClass());
+ meta.setValueType(desc.valueClass());
+
+ // Query fields.
+ Map<String, Class<?>> qryFields = new HashMap<>();
+
+ for (ClassProperty prop : desc.props.values())
+ qryFields.put(prop.fullName(), mask(prop.type()));
+
+ meta.setQueryFields(qryFields);
+
+ // Indexes.
+ Collection<String> txtFields = new ArrayList<>();
+ Map<String, LinkedHashMap<String, IgniteBiTuple<Class<?>, Boolean>>> grps = new HashMap<>();
+
+ for (Map.Entry<String,GridQueryIndexDescriptor> idxEntry : desc.indexes().entrySet()) {
+ GridQueryIndexDescriptor idx = idxEntry.getValue();
+
+ if (idx.type() == FULLTEXT) {
+ assert txtFields.isEmpty();
+
+ txtFields.addAll(idx.fields());
+ }
+ else {
+ LinkedHashMap<String, IgniteBiTuple<Class<?>, Boolean>> grp = new LinkedHashMap<>();
+
+ for (String fieldName : idx.fields()) {
+ ClassProperty prop = desc.props.get(fieldName);
+
+ Class<?> cls = mask(prop.type());
+
+ grp.put(fieldName, new IgniteBiTuple<Class<?>, Boolean>(cls, idx.descending(fieldName)));
+ }
+
+ grps.put(idxEntry.getKey(), grp);
+ }
+ }
+
+ if (desc.valueTextIndex())
+ txtFields.add("_val");
+
+ if (!txtFields.isEmpty())
+ meta.setTextFields(txtFields);
+
+ meta.setGroups(grps);
+
+ // Index primitive types.
+ if (GridQueryProcessor.isSqlType(desc.valueClass()))
+ meta.setAscendingFields(Collections.<String, Class<?>>singletonMap("_val", desc.valueClass()));
+
+ // Aliases.
+ Map<String,String> aliases = null;
+
+ for (ClassProperty prop : desc.props.values()) {
+ while (prop != null) {
+ if (!F.isEmpty(prop.alias)) {
+ if (aliases == null)
+ aliases = new HashMap<>();
+
+ aliases.put(prop.fullName(), prop.alias);
+ }
+
+ prop = prop.parent;
+ }
+ }
+
+ meta.setAliases(aliases);
return meta;
}
/**
+ * @param cls Class.
+ * @return Masked class.
+ */
+ private static Class<?> mask(Class<?> cls) {
+ assert cls != null;
+
+ return GridQueryProcessor.isSqlType(cls) ? cls : Object.class;
+ }
+
+ /**
* @param keyCls Key class.
* @param valCls Value class.
* @return Type descriptor.
@@ -1821,11 +1898,6 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
d.valueClass(valCls);
processAnnotationsInClass(true, d.keyCls, d, null);
-
- String valTypeName = GridQueryProcessor.typeName(valCls);
-
- d.name(valTypeName);
-
processAnnotationsInClass(false, d.valCls, d, null);
return d;
@@ -1847,7 +1919,7 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
type.addIndex(idxName, GridQueryProcessor.isGeometryClass(cls) ? GEO_SPATIAL : SORTED);
- type.addFieldToIndex(idxName, "_VAL", 0, false);
+ type.addFieldToIndex(idxName, "_val", 0, false);
}
return;
@@ -1928,7 +2000,7 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
processAnnotationsInClass(key, cls, desc, prop);
if (!sqlAnn.name().isEmpty())
- prop.name(sqlAnn.name());
+ prop.alias(sqlAnn.name());
if (sqlAnn.index()) {
String idxName = prop.name() + "_idx";
@@ -1979,17 +2051,14 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
/**
* Descriptor of type.
*/
- private static class TypeDescriptor implements GridQueryTypeDescriptor {
- /** */
- private String name;
-
+ private static class TypeDescriptor {
/** Value field names and types with preserved order. */
@GridToStringInclude
private final Map<String, Class<?>> fields = new LinkedHashMap<>();
/** */
@GridToStringExclude
- private final Map<String, Property> props = new HashMap<>();
+ private final Map<String, ClassProperty> props = new HashMap<>();
/** */
@GridToStringInclude
@@ -2007,57 +2076,10 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
/** */
private boolean valTextIdx;
- /** SPI can decide not to register this type. */
- private boolean registered;
-
- /**
- * @return {@code True} if type registration in SPI was finished and type was not rejected.
- */
- boolean registered() {
- return registered;
- }
-
/**
- * @param registered Sets registered flag.
+ * @return Indexes.
*/
- void registered(boolean registered) {
- this.registered = registered;
- }
-
- /** {@inheritDoc} */
- @Override public String name() {
- return name;
- }
-
- /**
- * Sets type name.
- *
- * @param name Name.
- */
- void name(String name) {
- this.name = name;
- }
-
- /** {@inheritDoc} */
- @Override public Map<String, Class<?>> fields() {
- return fields;
- }
-
- /** {@inheritDoc} */
- @SuppressWarnings("unchecked")
- @Override public <T> T value(String field, Object key, Object val) throws IgniteCheckedException {
- assert field != null;
-
- Property prop = props.get(field);
-
- if (prop == null)
- throw new IgniteCheckedException("Failed to find field '" + field + "' in type '" + name + "'.");
-
- return (T)prop.value(key, val);
- }
-
- /** {@inheritDoc} */
- @Override public Map<String, GridQueryIndexDescriptor> indexes() {
+ public Map<String, GridQueryIndexDescriptor> indexes() {
return Collections.<String, GridQueryIndexDescriptor>unmodifiableMap(indexes);
}
@@ -2110,8 +2132,10 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
fullTextIdx.addField(field, 0, false);
}
- /** {@inheritDoc} */
- @Override public Class<?> valueClass() {
+ /**
+ * @return Value class.
+ */
+ public Class<?> valueClass() {
return valCls;
}
@@ -2124,8 +2148,10 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
this.valCls = valCls;
}
- /** {@inheritDoc} */
- @Override public Class<?> keyClass() {
+ /**
+ * @return Key class.
+ */
+ public Class<?> keyClass() {
return keyCls;
}
@@ -2144,7 +2170,7 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
* @param prop Property.
* @param failOnDuplicate Fail on duplicate flag.
*/
- public void addProperty(Property prop, boolean failOnDuplicate) {
+ public void addProperty(ClassProperty prop, boolean failOnDuplicate) {
String name = prop.name();
if (props.put(name, prop) != null && failOnDuplicate)
@@ -2153,8 +2179,10 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
fields.put(name, prop.type());
}
- /** {@inheritDoc} */
- @Override public boolean valueTextIndex() {
+ /**
+ * @return {@code true} If we need to have a fulltext index on value.
+ */
+ public boolean valueTextIndex() {
return valTextIdx;
}
@@ -2248,34 +2276,9 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
}
/**
- *
- */
- private abstract static class Property {
- /**
- * Gets this property value from the given object.
- *
- * @param key Key.
- * @param val Value.
- * @return Property value.
- * @throws IgniteCheckedException If failed.
- */
- public abstract Object value(Object key, Object val) throws IgniteCheckedException;
-
- /**
- * @return Property name.
- */
- public abstract String name();
-
- /**
- * @return Class member type.
- */
- public abstract Class<?> type();
- }
-
- /**
* Description of type property.
*/
- private static class ClassProperty extends Property {
+ private static class ClassProperty {
/** */
private final Member member;
@@ -2286,10 +2289,7 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
private String name;
/** */
- private boolean field;
-
- /** */
- private boolean key;
+ private String alias;
/**
* Constructor.
@@ -2298,57 +2298,31 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
*/
ClassProperty(Member member, boolean key) {
this.member = member;
- this.key = key;
name = member instanceof Method && member.getName().startsWith("get") && member.getName().length() > 3 ?
member.getName().substring(3) : member.getName();
((AccessibleObject) member).setAccessible(true);
-
- field = member instanceof Field;
- }
-
- /** {@inheritDoc} */
- @Override public Object value(Object key, Object val) throws IgniteCheckedException {
- Object x = this.key ? key : val;
-
- if (parent != null)
- x = parent.value(key, val);
-
- if (x == null)
- return null;
-
- try {
- if (field) {
- Field field = (Field)member;
-
- return field.get(x);
- }
- else {
- Method mtd = (Method)member;
-
- return mtd.invoke(x);
- }
- }
- catch (Exception e) {
- throw new IgniteCheckedException(e);
- }
}
/**
- * @param name Property name.
+ * @param alias Alias.
*/
- public void name(String name) {
- this.name = name;
+ public void alias(String alias) {
+ this.alias = alias;
}
- /** {@inheritDoc} */
- @Override public String name() {
+ /**
+ * @return Name.
+ */
+ public String name() {
return name;
}
- /** {@inheritDoc} */
- @Override public Class<?> type() {
+ /**
+ * @return Type.
+ */
+ public Class<?> type() {
return member instanceof Field ? ((Field)member).getType() : ((Method)member).getReturnType();
}
@@ -2371,5 +2345,17 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
public boolean knowsClass(Class<?> cls) {
return member.getDeclaringClass() == cls || (parent != null && parent.knowsClass(cls));
}
+
+ /**
+ * @return Full name with all parents in dot notation.
+ */
+ public String fullName() {
+ assert name != null;
+
+ if (parent == null)
+ return name;
+
+ return parent.fullName() + '.' + name;
+ }
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3f38513f/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryIndexing.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryIndexing.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryIndexing.java
index 0cbb77a..fd5de66 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryIndexing.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryIndexing.java
@@ -151,22 +151,6 @@ public interface GridQueryIndexing {
public void unregisterCache(CacheConfiguration<?, ?> ccfg) throws IgniteCheckedException;
/**
- * Checks if the given class can be mapped to a simple SQL type.
- *
- * @param cls Class.
- * @return {@code true} If can.
- */
- public boolean isSqlType(Class<?> cls);
-
- /**
- * Checks if the given class is GEOMETRY.
- *
- * @param cls Class.
- * @return {@code true} If this is geometry.
- */
- public boolean isGeometryClass(Class<?> cls);
-
- /**
* Registers type if it was not known before or updates it otherwise.
*
* @param spaceName Space name.
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3f38513f/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 f6cff33..afc90e8 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
@@ -20,7 +20,6 @@ package org.apache.ignite.internal.processors.query;
import org.apache.ignite.*;
import org.apache.ignite.cache.*;
import org.apache.ignite.cache.query.*;
-import org.apache.ignite.cache.query.annotations.*;
import org.apache.ignite.configuration.*;
import org.apache.ignite.events.*;
import org.apache.ignite.internal.*;
@@ -152,9 +151,11 @@ public class GridQueryProcessor extends GridProcessorAdapter {
TypeDescriptor desc = new TypeDescriptor();
+ // Key and value classes still can be available if they are primitive or JDK part.
+ // We need that to set correct types for _key and _val columns.
Class<?> valCls = U.classForName(meta.getValueType(), null);
- desc.name(valCls != null ? typeName(valCls) : meta.getValueType());
+ desc.name(meta.getSimpleValueType());
desc.valueClass(valCls != null ? valCls : Object.class);
desc.keyClass(
@@ -182,21 +183,7 @@ public class GridQueryProcessor extends GridProcessorAdapter {
}
}
- Class<?>[] clss = ccfg.getIndexedTypes();
-
- if (!F.isEmpty(clss)) {
- for (int i = 0; i < clss.length; i += 2) {
- Class<?> keyCls = clss[i];
- Class<?> valCls = clss[i + 1];
-
- TypeDescriptor desc = processKeyAndValueClasses(keyCls, valCls);
-
- addTypeByName(ccfg, desc);
- types.put(new TypeId(ccfg.getName(), valCls), desc);
-
- desc.registered(idx.registerType(ccfg.getName(), desc));
- }
- }
+ // Indexed types must be translated to CacheTypeMetadata in CacheConfiguration.
}
catch (IgniteCheckedException | RuntimeException e) {
idx.unregisterCache(ccfg);
@@ -216,33 +203,6 @@ public class GridQueryProcessor extends GridProcessorAdapter {
"in cache '" + ccfg.getName() + "'.");
}
- /**
- * @param keyCls Key class.
- * @param valCls Value class.
- * @return Type descriptor.
- * @throws IgniteCheckedException If failed.
- */
- private TypeDescriptor processKeyAndValueClasses(
- Class<?> keyCls,
- Class<?> valCls
- )
- throws IgniteCheckedException {
- TypeDescriptor d = new TypeDescriptor();
-
- d.keyClass(keyCls);
- d.valueClass(valCls);
-
- processAnnotationsInClass(true, d.keyCls, d, null);
-
- String valTypeName = typeName(valCls);
-
- d.name(valTypeName);
-
- processAnnotationsInClass(false, d.valCls, d, null);
-
- return d;
- }
-
/** {@inheritDoc} */
@Override public void onKernalStop(boolean cancel) {
super.onKernalStop(cancel);
@@ -831,7 +791,9 @@ public class GridQueryProcessor extends GridProcessorAdapter {
* @return {@code true} If can.
*/
public static boolean isSqlType(Class<?> cls) {
- return SQL_TYPES.contains(cls);
+ cls = U.box(cls);
+
+ return SQL_TYPES.contains(cls) || isGeometryClass(cls);
}
/**
@@ -1050,130 +1012,6 @@ public class GridQueryProcessor extends GridProcessorAdapter {
}
/**
- * Process annotations for class.
- *
- * @param key If given class relates to key.
- * @param cls Class.
- * @param type Type descriptor.
- * @param parent Parent in case of embeddable.
- * @throws IgniteCheckedException In case of error.
- */
- private void processAnnotationsInClass(boolean key, Class<?> cls, TypeDescriptor type,
- @Nullable ClassProperty parent) throws IgniteCheckedException {
- if (U.isJdk(cls) || idx.isGeometryClass(cls)) {
- if (parent == null && !key && idx.isSqlType(cls) ) { // We have to index primitive _val.
- String idxName = "_val_idx";
-
- type.addIndex(idxName, idx.isGeometryClass(cls) ? GEO_SPATIAL : SORTED);
-
- type.addFieldToIndex(idxName, "_VAL", 0, false);
- }
-
- return;
- }
-
- if (parent != null && parent.knowsClass(cls))
- throw new IgniteCheckedException("Recursive reference found in type: " + cls.getName());
-
- if (parent == null) { // Check class annotation at top level only.
- QueryTextField txtAnnCls = cls.getAnnotation(QueryTextField.class);
-
- if (txtAnnCls != null)
- type.valueTextIndex(true);
-
- QueryGroupIndex grpIdx = cls.getAnnotation(QueryGroupIndex.class);
-
- if (grpIdx != null)
- type.addIndex(grpIdx.name(), SORTED);
-
- QueryGroupIndex.List grpIdxList = cls.getAnnotation(QueryGroupIndex.List.class);
-
- if (grpIdxList != null && !F.isEmpty(grpIdxList.value())) {
- for (QueryGroupIndex idx : grpIdxList.value())
- type.addIndex(idx.name(), SORTED);
- }
- }
-
- for (Class<?> c = cls; c != null && !c.equals(Object.class); c = c.getSuperclass()) {
- for (Field field : c.getDeclaredFields()) {
- QuerySqlField sqlAnn = field.getAnnotation(QuerySqlField.class);
- QueryTextField txtAnn = field.getAnnotation(QueryTextField.class);
-
- if (sqlAnn != null || txtAnn != null) {
- ClassProperty prop = new ClassProperty(field, key);
-
- prop.parent(parent);
-
- processAnnotation(key, sqlAnn, txtAnn, field.getType(), prop, type);
-
- type.addProperty(prop, true);
- }
- }
-
- for (Method mtd : c.getDeclaredMethods()) {
- QuerySqlField sqlAnn = mtd.getAnnotation(QuerySqlField.class);
- QueryTextField txtAnn = mtd.getAnnotation(QueryTextField.class);
-
- if (sqlAnn != null || txtAnn != null) {
- if (mtd.getParameterTypes().length != 0)
- throw new IgniteCheckedException("Getter with QuerySqlField " +
- "annotation cannot have parameters: " + mtd);
-
- ClassProperty prop = new ClassProperty(mtd, key);
-
- prop.parent(parent);
-
- processAnnotation(key, sqlAnn, txtAnn, mtd.getReturnType(), prop, type);
-
- type.addProperty(prop, true);
- }
- }
- }
- }
-
- /**
- * Processes annotation at field or method.
- *
- * @param key If given class relates to key.
- * @param sqlAnn SQL annotation, can be {@code null}.
- * @param txtAnn H2 text annotation, can be {@code null}.
- * @param cls Class of field or return type for method.
- * @param prop Current property.
- * @param desc Class description.
- * @throws IgniteCheckedException In case of error.
- */
- private void processAnnotation(boolean key, QuerySqlField sqlAnn, QueryTextField txtAnn,
- Class<?> cls, ClassProperty prop, TypeDescriptor desc) throws IgniteCheckedException {
- if (sqlAnn != null) {
- processAnnotationsInClass(key, cls, desc, prop);
-
- if (!sqlAnn.name().isEmpty())
- prop.name(sqlAnn.name());
-
- if (sqlAnn.index()) {
- String idxName = prop.name() + "_idx";
-
- desc.addIndex(idxName, idx.isGeometryClass(prop.type()) ? GEO_SPATIAL : SORTED);
-
- desc.addFieldToIndex(idxName, prop.name(), 0, sqlAnn.descending());
- }
-
- if (!F.isEmpty(sqlAnn.groups())) {
- for (String group : sqlAnn.groups())
- desc.addFieldToIndex(group, prop.name(), 0, false);
- }
-
- if (!F.isEmpty(sqlAnn.orderedGroups())) {
- for (QuerySqlField.Group idx : sqlAnn.orderedGroups())
- desc.addFieldToIndex(idx.name(), prop.name(), idx.order(), idx.descending());
- }
- }
-
- if (txtAnn != null)
- desc.addFieldToTextIndex(prop.name());
- }
-
- /**
* Processes declarative metadata for class.
*
* @param meta Type metadata.
@@ -1182,6 +1020,11 @@ public class GridQueryProcessor extends GridProcessorAdapter {
*/
private void processClassMeta(CacheTypeMetadata meta, TypeDescriptor d)
throws IgniteCheckedException {
+ Map<String,String> aliases = meta.getAliases();
+
+ if (aliases == null)
+ aliases = Collections.emptyMap();
+
Class<?> keyCls = d.keyClass();
Class<?> valCls = d.valueClass();
@@ -1193,13 +1036,14 @@ public class GridQueryProcessor extends GridProcessorAdapter {
keyCls,
valCls,
entry.getKey(),
- entry.getValue());
+ entry.getValue(),
+ aliases);
d.addProperty(prop, false);
String idxName = prop.name() + "_idx";
- d.addIndex(idxName, idx.isGeometryClass(prop.type()) ? GEO_SPATIAL : SORTED);
+ d.addIndex(idxName, isGeometryClass(prop.type()) ? GEO_SPATIAL : SORTED);
d.addFieldToIndex(idxName, prop.name(), 0, false);
}
@@ -1209,13 +1053,14 @@ public class GridQueryProcessor extends GridProcessorAdapter {
keyCls,
valCls,
entry.getKey(),
- entry.getValue());
+ entry.getValue(),
+ aliases);
d.addProperty(prop, false);
String idxName = prop.name() + "_idx";
- d.addIndex(idxName, idx.isGeometryClass(prop.type()) ? GEO_SPATIAL : SORTED);
+ d.addIndex(idxName, isGeometryClass(prop.type()) ? GEO_SPATIAL : SORTED);
d.addFieldToIndex(idxName, prop.name(), 0, true);
}
@@ -1225,7 +1070,8 @@ public class GridQueryProcessor extends GridProcessorAdapter {
keyCls,
valCls,
txtIdx,
- String.class);
+ String.class,
+ aliases);
d.addProperty(prop, false);
@@ -1247,7 +1093,8 @@ public class GridQueryProcessor extends GridProcessorAdapter {
keyCls,
valCls,
idxField.getKey(),
- idxField.getValue().get1());
+ idxField.getValue().get1(),
+ aliases);
d.addProperty(prop, false);
@@ -1265,7 +1112,8 @@ public class GridQueryProcessor extends GridProcessorAdapter {
keyCls,
valCls,
entry.getKey(),
- entry.getValue());
+ entry.getValue(),
+ aliases);
d.addProperty(prop, false);
}
@@ -1280,32 +1128,37 @@ public class GridQueryProcessor extends GridProcessorAdapter {
*/
private void processPortableMeta(CacheTypeMetadata meta, TypeDescriptor d)
throws IgniteCheckedException {
+ Map<String,String> aliases = meta.getAliases();
+
+ if (aliases == null)
+ aliases = Collections.emptyMap();
+
for (Map.Entry<String, Class<?>> entry : meta.getAscendingFields().entrySet()) {
- PortableProperty prop = buildPortableProperty(entry.getKey(), entry.getValue());
+ PortableProperty prop = buildPortableProperty(entry.getKey(), entry.getValue(), aliases);
d.addProperty(prop, false);
String idxName = prop.name() + "_idx";
- d.addIndex(idxName, idx.isGeometryClass(prop.type()) ? GEO_SPATIAL : SORTED);
+ d.addIndex(idxName, isGeometryClass(prop.type()) ? GEO_SPATIAL : SORTED);
d.addFieldToIndex(idxName, prop.name(), 0, false);
}
for (Map.Entry<String, Class<?>> entry : meta.getDescendingFields().entrySet()) {
- PortableProperty prop = buildPortableProperty(entry.getKey(), entry.getValue());
+ PortableProperty prop = buildPortableProperty(entry.getKey(), entry.getValue(), aliases);
d.addProperty(prop, false);
String idxName = prop.name() + "_idx";
- d.addIndex(idxName, idx.isGeometryClass(prop.type()) ? GEO_SPATIAL : SORTED);
+ d.addIndex(idxName, isGeometryClass(prop.type()) ? GEO_SPATIAL : SORTED);
d.addFieldToIndex(idxName, prop.name(), 0, true);
}
for (String txtIdx : meta.getTextFields()) {
- PortableProperty prop = buildPortableProperty(txtIdx, String.class);
+ PortableProperty prop = buildPortableProperty(txtIdx, String.class, aliases);
d.addProperty(prop, false);
@@ -1323,7 +1176,7 @@ public class GridQueryProcessor extends GridProcessorAdapter {
int order = 0;
for (Map.Entry<String, IgniteBiTuple<Class<?>, Boolean>> idxField : idxFields.entrySet()) {
- PortableProperty prop = buildPortableProperty(idxField.getKey(), idxField.getValue().get1());
+ PortableProperty prop = buildPortableProperty(idxField.getKey(), idxField.getValue().get1(), aliases);
d.addProperty(prop, false);
@@ -1337,7 +1190,7 @@ public class GridQueryProcessor extends GridProcessorAdapter {
}
for (Map.Entry<String, Class<?>> entry : meta.getQueryFields().entrySet()) {
- PortableProperty prop = buildPortableProperty(entry.getKey(), entry.getValue());
+ PortableProperty prop = buildPortableProperty(entry.getKey(), entry.getValue(), aliases);
if (!d.props.containsKey(prop.name()))
d.addProperty(prop, false);
@@ -1350,15 +1203,26 @@ public class GridQueryProcessor extends GridProcessorAdapter {
* @param pathStr String representing path to the property. May contains dots '.' to identify
* nested fields.
* @param resType Result type.
+ * @param aliases Aliases.
* @return Portable property.
*/
- private PortableProperty buildPortableProperty(String pathStr, Class<?> resType) {
+ private PortableProperty buildPortableProperty(String pathStr, Class<?> resType, Map<String,String> aliases) {
String[] path = pathStr.split("\\.");
PortableProperty res = null;
- for (String prop : path)
- res = new PortableProperty(prop, res, resType);
+ StringBuilder fullName = new StringBuilder();
+
+ for (String prop : path) {
+ if (fullName.length() != 0)
+ fullName.append('.');
+
+ fullName.append(prop);
+
+ String alias = aliases.get(fullName.toString());
+
+ res = new PortableProperty(prop, res, resType, alias);
+ }
return res;
}
@@ -1368,19 +1232,21 @@ public class GridQueryProcessor extends GridProcessorAdapter {
* @param valCls Value class.
* @param pathStr Path string.
* @param resType Result type.
+ * @param aliases Aliases.
* @return Class property.
* @throws IgniteCheckedException If failed.
*/
- private static ClassProperty buildClassProperty(Class<?> keyCls, Class<?> valCls, String pathStr, Class<?> resType)
- throws IgniteCheckedException {
+ private static ClassProperty buildClassProperty(Class<?> keyCls, Class<?> valCls, String pathStr, Class<?> resType,
+ Map<String,String> aliases) throws IgniteCheckedException {
ClassProperty res = buildClassProperty(
true,
keyCls,
pathStr,
- resType);
+ resType,
+ aliases);
if (res == null) // We check key before value consistently with PortableProperty.
- res = buildClassProperty(false, valCls, pathStr, resType);
+ res = buildClassProperty(false, valCls, pathStr, resType, aliases);
if (res == null)
throw new IgniteCheckedException("Failed to initialize property '" + pathStr + "' for " +
@@ -1395,16 +1261,27 @@ public class GridQueryProcessor extends GridProcessorAdapter {
* @param cls Source type class.
* @param pathStr String representing path to the property. May contains dots '.' to identify nested fields.
* @param resType Expected result type.
+ * @param aliases Aliases.
* @return Property instance corresponding to the given path.
* @throws IgniteCheckedException If property cannot be created.
*/
- static ClassProperty buildClassProperty(boolean key, Class<?> cls, String pathStr, Class<?> resType)
+ static ClassProperty buildClassProperty(boolean key, Class<?> cls, String pathStr, Class<?> resType,
+ Map<String,String> aliases)
throws IgniteCheckedException {
String[] path = pathStr.split("\\.");
ClassProperty res = null;
+ StringBuilder fullName = new StringBuilder();
+
for (String prop : path) {
+ if (fullName.length() != 0)
+ fullName.append('.');
+
+ fullName.append(prop);
+
+ String alias = aliases.get(fullName.toString());
+
ClassProperty tmp;
try {
@@ -1414,11 +1291,11 @@ public class GridQueryProcessor extends GridProcessorAdapter {
bld.setCharAt(3, Character.toUpperCase(bld.charAt(3)));
- tmp = new ClassProperty(cls.getMethod(bld.toString()), key);
+ tmp = new ClassProperty(cls.getMethod(bld.toString()), key, alias);
}
catch (NoSuchMethodException ignore) {
try {
- tmp = new ClassProperty(cls.getDeclaredField(prop), key);
+ tmp = new ClassProperty(cls.getDeclaredField(prop), key, alias);
}
catch (NoSuchFieldException ignored) {
return null;
@@ -1577,11 +1454,12 @@ public class GridQueryProcessor extends GridProcessorAdapter {
*
* @param member Element.
*/
- ClassProperty(Member member, boolean key) {
+ ClassProperty(Member member, boolean key, String name) {
this.member = member;
this.key = key;
- name = member instanceof Method && member.getName().startsWith("get") && member.getName().length() > 3 ?
+ this.name = !F.isEmpty(name) ? name :
+ member instanceof Method && member.getName().startsWith("get") && member.getName().length() > 3 ?
member.getName().substring(3) : member.getName();
((AccessibleObject) member).setAccessible(true);
@@ -1616,13 +1494,6 @@ public class GridQueryProcessor extends GridProcessorAdapter {
}
}
- /**
- * @param name Property name.
- */
- public void name(String name) {
- this.name = name;
- }
-
/** {@inheritDoc} */
@Override public String name() {
return name;
@@ -1661,6 +1532,9 @@ public class GridQueryProcessor extends GridProcessorAdapter {
/** Property name. */
private String propName;
+ /** */
+ private String alias;
+
/** Parent property. */
private PortableProperty parent;
@@ -1677,8 +1551,9 @@ public class GridQueryProcessor extends GridProcessorAdapter {
* @param parent Parent property.
* @param type Result type.
*/
- private PortableProperty(String propName, PortableProperty parent, Class<?> type) {
+ private PortableProperty(String propName, PortableProperty parent, Class<?> type, String alias) {
this.propName = propName;
+ this.alias = F.isEmpty(alias) ? propName : alias;
this.parent = parent;
this.type = type;
}
@@ -1723,7 +1598,7 @@ public class GridQueryProcessor extends GridProcessorAdapter {
/** {@inheritDoc} */
@Override public String name() {
- return propName;
+ return alias;
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3f38513f/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 6623e85..e5e93c3 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
@@ -7872,9 +7872,10 @@ public abstract class IgniteUtils {
if (cls == null)
return null;
- Class<?> boxed = boxedClsMap.get(cls);
+ if (!cls.isPrimitive())
+ return cls;
- return boxed != null ? boxed : cls;
+ return boxedClsMap.get(cls);
}
/**
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3f38513f/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
index 359341a..dfa1e5d 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
@@ -1483,23 +1483,6 @@ public class IgniteH2Indexing implements GridQueryIndexing {
}
}
- /** {@inheritDoc} */
- @Override public boolean isSqlType(Class<?> cls) {
- switch (DBTypeEnum.fromClass(cls)) {
- case OTHER:
- case ARRAY:
- return false;
-
- default:
- return true;
- }
- }
-
- /** {@inheritDoc} */
- @Override public boolean isGeometryClass(Class<?> cls) {
- return DataType.isGeometryClass(cls);
- }
-
/**
* Enum that helps to map java types to database types.
*/
[2/4] incubator-ignite git commit: Merge branch 'ignite-sprint-7' of
https://git-wip-us.apache.org/repos/asf/incubator-ignite into ignite-959-x
Posted by se...@apache.org.
Merge branch 'ignite-sprint-7' of https://git-wip-us.apache.org/repos/asf/incubator-ignite into ignite-959-x
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/93798283
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/93798283
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/93798283
Branch: refs/heads/ignite-959-x
Commit: 9379828300b3a47e4a08c444a26a261d5ea04a34
Parents: 781f0d5 7fc5595
Author: S.Vladykin <sv...@gridgain.com>
Authored: Thu Jun 25 12:50:35 2015 +0300
Committer: S.Vladykin <sv...@gridgain.com>
Committed: Thu Jun 25 12:50:35 2015 +0300
----------------------------------------------------------------------
examples/pom.xml | 2 +-
modules/aop/pom.xml | 2 +-
modules/aws/pom.xml | 2 +-
modules/clients/pom.xml | 2 +-
modules/cloud/pom.xml | 2 +-
modules/codegen/pom.xml | 2 +-
modules/core/pom.xml | 2 +-
.../configuration/IgniteReflectionFactory.java | 81 +++-
.../ignite/internal/GridKernalContextImpl.java | 3 +
.../processors/cache/GridCacheContext.java | 2 +-
.../distributed/dht/GridDhtLocalPartition.java | 3 +-
.../distributed/dht/GridDhtLockFuture.java | 2 +-
.../dht/atomic/GridDhtAtomicCache.java | 9 +-
.../GridDhtPartitionsExchangeFuture.java | 46 +-
.../datastructures/DataStructuresProcessor.java | 64 +--
.../processors/hadoop/HadoopJobInfo.java | 4 +-
.../hadoop/counter/HadoopCounterWriter.java | 5 +-
.../processors/plugin/CachePluginManager.java | 10 +-
.../processors/task/GridTaskProcessor.java | 23 +-
.../core/src/main/resources/ignite.properties | 2 +-
.../GridTaskFailoverAffinityRunTest.java | 170 +++++++
.../CacheReadThroughAtomicRestartSelfTest.java | 32 ++
...heReadThroughLocalAtomicRestartSelfTest.java | 32 ++
.../CacheReadThroughLocalRestartSelfTest.java | 32 ++
...dThroughReplicatedAtomicRestartSelfTest.java | 32 ++
...cheReadThroughReplicatedRestartSelfTest.java | 32 ++
.../cache/CacheReadThroughRestartSelfTest.java | 133 ++++++
.../cache/GridCacheAbstractSelfTest.java | 2 +-
...eDynamicCacheStartNoExchangeTimeoutTest.java | 466 +++++++++++++++++++
.../cache/IgniteDynamicCacheStartSelfTest.java | 37 ++
...GridCacheQueueMultiNodeAbstractSelfTest.java | 4 +-
.../GridCacheSetAbstractSelfTest.java | 22 +-
.../IgniteDataStructureWithJobTest.java | 111 +++++
...ridCachePartitionNotLoadedEventSelfTest.java | 82 ++++
.../distributed/IgniteCache150ClientsTest.java | 189 ++++++++
...teCacheClientNodePartitionsExchangeTest.java | 1 +
.../distributed/IgniteCacheManyClientsTest.java | 2 +
.../IgniteCacheTxMessageRecoveryTest.java | 5 +
...idCacheNearOnlyMultiNodeFullApiSelfTest.java | 5 -
...achePartitionedMultiNodeFullApiSelfTest.java | 49 +-
.../GridCacheReplicatedFailoverSelfTest.java | 5 +
.../IgniteCacheTxStoreSessionTest.java | 4 +
.../testframework/junits/GridAbstractTest.java | 2 +-
.../IgniteCacheDataStructuresSelfTestSuite.java | 1 +
.../ignite/testsuites/IgniteCacheTestSuite.java | 4 +-
.../testsuites/IgniteCacheTestSuite4.java | 8 +
.../testsuites/IgniteClientTestSuite.java | 38 ++
.../testsuites/IgniteComputeGridTestSuite.java | 1 +
.../ignite/util/TestTcpCommunicationSpi.java | 21 +
modules/extdata/p2p/pom.xml | 2 +-
modules/extdata/uri/pom.xml | 2 +-
modules/gce/pom.xml | 2 +-
modules/geospatial/pom.xml | 2 +-
modules/hadoop/pom.xml | 80 +---
.../fs/IgniteHadoopFileSystemCounterWriter.java | 9 +-
.../processors/hadoop/HadoopClassLoader.java | 29 ++
.../processors/hadoop/HadoopDefaultJobInfo.java | 27 +-
.../internal/processors/hadoop/HadoopUtils.java | 237 ----------
.../hadoop/SecondaryFileSystemProvider.java | 3 +-
.../hadoop/fs/HadoopFileSystemCacheUtils.java | 241 ++++++++++
.../hadoop/fs/HadoopFileSystemsUtils.java | 11 +
.../hadoop/fs/HadoopLazyConcurrentMap.java | 5 +
.../hadoop/jobtracker/HadoopJobTracker.java | 25 +-
.../child/HadoopChildProcessRunner.java | 3 +-
.../processors/hadoop/v2/HadoopV2Job.java | 84 +++-
.../hadoop/v2/HadoopV2JobResourceManager.java | 22 +-
.../hadoop/v2/HadoopV2TaskContext.java | 37 +-
.../apache/ignite/igfs/IgfsEventsTestSuite.java | 5 +-
.../processors/hadoop/HadoopMapReduceTest.java | 2 +-
.../processors/hadoop/HadoopTasksV1Test.java | 7 +-
.../processors/hadoop/HadoopTasksV2Test.java | 7 +-
.../processors/hadoop/HadoopV2JobSelfTest.java | 6 +-
.../collections/HadoopAbstractMapTest.java | 3 +-
.../testsuites/IgniteHadoopTestSuite.java | 2 +-
.../IgniteIgfsLinuxAndMacOSTestSuite.java | 3 +-
modules/hibernate/pom.xml | 2 +-
modules/indexing/pom.xml | 2 +-
...QueryOffheapEvictsMultiThreadedSelfTest.java | 5 +
.../IgniteCacheQuerySelfTestSuite.java | 2 +-
modules/jcl/pom.xml | 2 +-
modules/jta/pom.xml | 2 +-
modules/log4j/pom.xml | 2 +-
modules/mesos/pom.xml | 2 +-
modules/rest-http/pom.xml | 2 +-
modules/scalar-2.10/pom.xml | 2 +-
modules/scalar/pom.xml | 2 +-
modules/schedule/pom.xml | 2 +-
modules/schema-import/pom.xml | 2 +-
modules/slf4j/pom.xml | 2 +-
modules/spark-2.10/pom.xml | 2 +-
modules/spark/pom.xml | 2 +-
modules/spring/pom.xml | 2 +-
modules/ssh/pom.xml | 2 +-
modules/tools/pom.xml | 2 +-
modules/urideploy/pom.xml | 2 +-
modules/visor-console-2.10/pom.xml | 2 +-
modules/visor-console/pom.xml | 2 +-
modules/visor-plugins/pom.xml | 2 +-
modules/web/pom.xml | 2 +-
.../IgniteWebSessionSelfTestSuite.java | 2 +-
modules/yardstick/pom.xml | 2 +-
pom.xml | 2 +-
102 files changed, 2180 insertions(+), 523 deletions(-)
----------------------------------------------------------------------
[4/4] incubator-ignite git commit: Merge branch 'ignite-sprint-7' of
https://git-wip-us.apache.org/repos/asf/incubator-ignite into ignite-959-x
Posted by se...@apache.org.
Merge branch 'ignite-sprint-7' of https://git-wip-us.apache.org/repos/asf/incubator-ignite into ignite-959-x
# Conflicts:
# modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/7df4f8cb
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/7df4f8cb
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/7df4f8cb
Branch: refs/heads/ignite-959-x
Commit: 7df4f8cb063b4491e46cc64368dff5a83a3df200
Parents: 3f38513 d3783a1
Author: S.Vladykin <sv...@gridgain.com>
Authored: Wed Jul 1 12:52:32 2015 -0700
Committer: S.Vladykin <sv...@gridgain.com>
Committed: Wed Jul 1 12:52:32 2015 -0700
----------------------------------------------------------------------
assembly/dependencies-fabric.xml | 1 +
examples/pom.xml | 2 +-
modules/aop/pom.xml | 2 +-
modules/aws/pom.xml | 2 +-
modules/clients/pom.xml | 2 +-
.../ClientAbstractConnectivitySelfTest.java | 4 +-
modules/cloud/pom.xml | 2 +-
modules/codegen/pom.xml | 2 +-
modules/core/pom.xml | 2 +-
.../org/apache/ignite/cluster/ClusterGroup.java | 18 +-
.../org/apache/ignite/cluster/ClusterNode.java | 2 +
.../configuration/CacheConfiguration.java | 105 +--
.../configuration/NearCacheConfiguration.java | 10 +-
.../ignite/internal/GridKernalContextImpl.java | 2 +-
.../internal/cluster/ClusterGroupAdapter.java | 50 +-
.../cluster/IgniteClusterAsyncImpl.java | 12 +-
.../managers/communication/GridIoManager.java | 49 +-
.../discovery/GridDiscoveryManager.java | 32 +-
.../cache/GridCacheDeploymentManager.java | 10 +-
.../GridCachePartitionExchangeManager.java | 6 +-
.../processors/cache/GridCacheProcessor.java | 62 +-
.../processors/cache/IgniteCacheFutureImpl.java | 42 +
.../processors/cache/IgniteCacheProxy.java | 2 +-
.../processors/clock/GridClockServer.java | 21 +-
.../processors/rest/GridRestProcessor.java | 4 +-
.../handlers/task/GridTaskCommandHandler.java | 12 +-
.../processors/task/GridTaskWorker.java | 4 +-
.../internal/util/GridConfigurationFinder.java | 55 +-
.../ignite/internal/util/IgniteUtils.java | 6 +-
.../internal/util/future/IgniteFutureImpl.java | 18 +-
.../shmem/IpcSharedMemoryServerEndpoint.java | 10 +-
.../util/nio/GridNioMessageTracker.java | 23 +-
.../apache/ignite/internal/visor/VisorJob.java | 2 +
.../internal/visor/log/VisorLogSearchTask.java | 2 +-
.../visor/node/VisorNodeDataCollectorJob.java | 4 +
.../visor/query/VisorQueryCleanupTask.java | 14 +
.../util/VisorClusterGroupEmptyException.java | 37 +
.../ignite/spi/discovery/tcp/ClientImpl.java | 151 ++--
.../ignite/spi/discovery/tcp/ServerImpl.java | 105 ++-
.../spi/discovery/tcp/TcpDiscoverySpi.java | 3 +-
.../TcpDiscoveryMulticastIpFinder.java | 74 +-
.../core/src/main/resources/ignite.properties | 2 +-
.../core/src/test/config/spark/spark-config.xml | 46 ++
modules/core/src/test/config/tests.properties | 6 +-
.../internal/ClusterGroupAbstractTest.java | 777 ++++++++++++++++++
.../internal/ClusterGroupHostsSelfTest.java | 141 ++++
.../ignite/internal/ClusterGroupSelfTest.java | 251 ++++++
.../internal/GridDiscoveryEventSelfTest.java | 12 +-
.../internal/GridProjectionAbstractTest.java | 784 -------------------
.../ignite/internal/GridProjectionSelfTest.java | 251 ------
.../apache/ignite/internal/GridSelfTest.java | 2 +-
.../IgniteTopologyPrintFormatSelfTest.java | 289 +++++++
.../cache/GridCacheDaemonNodeStopSelfTest.java | 119 ---
.../IgniteDaemonNodeMarshallerCacheTest.java | 192 +++++
...achePartitionedMultiNodeFullApiSelfTest.java | 4 +-
.../internal/util/IgniteUtilsSelfTest.java | 22 +
.../GridP2PContinuousDeploymentSelfTest.java | 2 -
.../tcp/TcpClientDiscoverySpiSelfTest.java | 265 ++++++-
.../ignite/testsuites/IgniteBasicTestSuite.java | 7 +-
.../testsuites/IgniteCacheTestSuite3.java | 1 -
.../testsuites/IgniteKernalSelfTestSuite.java | 1 +
modules/core/src/test/resources/helloworld.gar | Bin 6092 -> 0 bytes
modules/core/src/test/resources/helloworld1.gar | Bin 6092 -> 0 bytes
modules/core/src/test/resources/readme.txt | 6 -
modules/docker/Dockerfile | 55 ++
modules/docker/README.txt | 11 +
modules/docker/build_users_libs.sh | 39 +
modules/docker/download_ignite.sh | 49 ++
modules/docker/execute.sh | 62 ++
modules/docker/run.sh | 34 +
modules/extdata/p2p/pom.xml | 4 +-
.../p2p/GridP2PContinuousDeploymentTask1.java | 2 +-
modules/extdata/uri/META-INF/ignite.xml | 38 +
.../extdata/uri/modules/uri-dependency/pom.xml | 42 +
.../deployment/uri/tasks/GarHelloWorldBean.java | 60 ++
.../src/main/resources/gar-example.properties | 18 +
modules/extdata/uri/pom.xml | 62 +-
.../deployment/uri/tasks/GarHelloWorldTask.java | 81 ++
.../deployment/uri/tasks/gar-spring-bean.xml | 29 +
modules/gce/pom.xml | 2 +-
modules/geospatial/pom.xml | 2 +-
modules/hadoop/pom.xml | 2 +-
modules/hibernate/pom.xml | 2 +-
modules/indexing/pom.xml | 2 +-
modules/jcl/pom.xml | 2 +-
modules/jta/pom.xml | 2 +-
modules/log4j/pom.xml | 2 +-
modules/mesos/pom.xml | 2 +-
modules/rest-http/pom.xml | 2 +-
modules/scalar-2.10/pom.xml | 2 +-
modules/scalar/pom.xml | 2 +-
modules/schedule/pom.xml | 2 +-
modules/schema-import/pom.xml | 2 +-
.../ignite/schema/model/PojoDescriptor.java | 2 +
.../apache/ignite/schema/model/PojoField.java | 1 +
.../parser/dialect/OracleMetadataDialect.java | 2 +-
modules/slf4j/pom.xml | 2 +-
modules/spark-2.10/pom.xml | 2 +-
modules/spark/pom.xml | 2 +-
.../org/apache/ignite/spark/IgniteContext.scala | 50 +-
.../org/apache/ignite/spark/IgniteRddSpec.scala | 18 +
modules/spring/pom.xml | 2 +-
modules/ssh/pom.xml | 2 +-
modules/tools/pom.xml | 2 +-
modules/urideploy/pom.xml | 16 +-
.../GridTaskUriDeploymentDeadlockSelfTest.java | 13 +-
.../ignite/p2p/GridP2PDisabledSelfTest.java | 2 +-
modules/visor-console-2.10/pom.xml | 2 +-
modules/visor-console/pom.xml | 2 +-
.../commands/cache/VisorCacheCommand.scala | 7 +-
modules/visor-plugins/pom.xml | 2 +-
modules/web/pom.xml | 2 +-
modules/yardstick/pom.xml | 2 +-
pom.xml | 14 +-
scripts/git-patch-prop.sh | 2 +-
115 files changed, 3413 insertions(+), 1496 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7df4f8cb/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
----------------------------------------------------------------------
diff --cc modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
index 1f32cf3,e2308f2..e73f51f
--- a/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
@@@ -1511,13 -1506,8 +1512,13 @@@ public class CacheConfiguration<K, V> e
* @param typeMeta Collection of type metadata.
* @return {@code this} for chaining.
*/
- public CacheConfiguration setTypeMetadata(Collection<CacheTypeMetadata> typeMeta) {
+ public CacheConfiguration<K, V> setTypeMetadata(Collection<CacheTypeMetadata> typeMeta) {
- this.typeMeta = typeMeta;
+ if (this.typeMeta == null)
+ this.typeMeta = new ArrayList<>(typeMeta);
+ else if (indexedTypes != null)
+ this.typeMeta.addAll(typeMeta);
+ else
+ throw new CacheException("Type metadata can be set only once.");
return this;
}
@@@ -1671,32 -1661,22 +1672,32 @@@
* @param indexedTypes Key and value type pairs.
* @return {@code this} for chaining.
*/
- public CacheConfiguration setIndexedTypes(Class<?>... indexedTypes) {
+ public CacheConfiguration<K, V> setIndexedTypes(Class<?>... indexedTypes) {
- A.ensure(indexedTypes == null || (indexedTypes.length & 1) == 0,
+ int len = indexedTypes.length;
+
+ A.ensure(len > 0, "Array of indexed types can not be empty.");
+ A.ensure((len & 1) == 0,
"Number of indexed types is expected to be even. Refer to method javadoc for details.");
- if (indexedTypes != null) {
- int len = indexedTypes.length;
+ if (this.indexedTypes != null)
+ throw new CacheException("Indexed types can be set only once.");
+
+ Class<?>[] newIndexedTypes = new Class<?>[len];
- Class<?>[] newIndexedTypes = new Class<?>[len];
+ for (int i = 0; i < len; i++)
+ newIndexedTypes[i] = U.box(indexedTypes[i]);
- for (int i = 0; i < len; i++)
- newIndexedTypes[i] = U.box(indexedTypes[i]);
+ if (typeMeta == null)
+ typeMeta = new ArrayList<>();
- this.indexedTypes = newIndexedTypes;
+ for (int i = 0; i < len; i += 2) {
+ Class<?> keyCls = newIndexedTypes[i];
+ Class<?> valCls = newIndexedTypes[i + 1];
+
+ TypeDescriptor desc = processKeyAndValueClasses(keyCls, valCls);
+
+ typeMeta.add(convert(desc));
}
- else
- this.indexedTypes = null;
return this;
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7df4f8cb/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
----------------------------------------------------------------------