IGNITE-4839: Removed CacheTypeMetadata. This closes #1667.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/1811ede4 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/1811ede4 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/1811ede4 Branch: refs/heads/ignite-1192 Commit: 1811ede439b1273f4904666ecb0a49ac8efd2f11 Parents: c3431e9 Author: tledkov-gridgain <[email protected]> Authored: Wed Apr 5 11:53:33 2017 +0300 Committer: devozerov <[email protected]> Committed: Wed Apr 5 11:53:33 2017 +0300 ---------------------------------------------------------------------- .../src/test/resources/spring-server-node.xml | 71 ++-- .../test/resources/spring-server-ssl-node.xml | 69 ++-- .../java/org/apache/ignite/IgniteBinary.java | 35 +- .../ignite/cache/CacheTypeFieldMetadata.java | 149 -------- .../apache/ignite/cache/CacheTypeMetadata.java | 379 ------------------- .../org/apache/ignite/cache/QueryEntity.java | 3 + .../store/jdbc/CacheAbstractJdbcStore.java | 55 --- .../configuration/CacheConfiguration.java | 27 -- .../processors/query/GridQueryProcessor.java | 10 - .../internal/processors/query/QueryUtils.java | 326 ---------------- .../visor/cache/VisorCacheConfiguration.java | 2 +- .../cache/VisorCacheTypeFieldMetadata.java | 14 +- .../visor/cache/VisorCacheTypeMetadata.java | 91 +---- .../resources/META-INF/classnames.properties | 1 - .../test/config/store/jdbc/ignite-jdbc-type.xml | 279 ++++++++++++++ .../config/store/jdbc/ignite-type-metadata.xml | 276 -------------- ...eJdbcStoreAbstractMultithreadedSelfTest.java | 71 ++-- ...ryDuplicateIndexObjectsAbstractSelfTest.java | 161 -------- ...ateIndexObjectPartitionedAtomicSelfTest.java | 38 -- ...xObjectPartitionedTransactionalSelfTest.java | 41 -- .../cache/BinarySerializationQuerySelfTest.java | 30 +- ...ryDuplicateIndexObjectsAbstractSelfTest.java | 159 ++++++++ .../cache/IncorrectCacheTypeMetadataTest.java | 72 ---- .../cache/IncorrectQueryEntityTest.java | 3 + ...ateIndexObjectPartitionedAtomicSelfTest.java | 38 ++ ...xObjectPartitionedTransactionalSelfTest.java | 41 ++ .../IgniteBinaryCacheQueryTestSuite.java | 4 +- .../IgniteCacheQuerySelfTestSuite.java | 2 - .../cpp/core-test/config/cache-query.xml | 37 +- .../Config/cache-query-continuous.xml | 118 ++++-- modules/schema-import/README.txt | 4 +- modules/spring/pom.xml | 6 + .../IgniteExcludeInConfigurationTest.java | 14 +- .../org/apache/ignite/spring/sprint-exclude.xml | 19 +- modules/web-console/web-agent/README.txt | 2 +- .../IgniteCacheRandomOperationBenchmark.java | 25 +- 36 files changed, 849 insertions(+), 1823 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/1811ede4/modules/clients/src/test/resources/spring-server-node.xml ---------------------------------------------------------------------- diff --git a/modules/clients/src/test/resources/spring-server-node.xml b/modules/clients/src/test/resources/spring-server-node.xml index 093b35d..3211b80 100644 --- a/modules/clients/src/test/resources/spring-server-node.xml +++ b/modules/clients/src/test/resources/spring-server-node.xml @@ -123,52 +123,77 @@ </bean> </property> - <property name="binaryEnabled" value="true"/> + <!--<property name="binaryEnabled" value="true"/>--> - <property name="typeMetadata"> + <property name="queryEntities"> <list> - <bean class="org.apache.ignite.cache.CacheTypeMetadata"> + <bean class="org.apache.ignite.cache.QueryEntity"> <property name="valueType" value="GridBinaryPerson"/> - <property name="ascendingFields"> - <map> - <entry key="age" value="java.lang.Integer"/> - </map> - </property> - <property name="queryFields"> + <property name="fields"> <map> <entry key="name" value="java.lang.String"/> + <entry key="address" value="java.lang.String"/> + <entry key="age" value="java.lang.Integer"/> </map> </property> - <property name="textFields"> + <property name="indexes"> <list> - <value>address</value> + <bean class="org.apache.ignite.cache.QueryIndex"> + <property name="fields"> + <map> + <entry key="age" value="true"/> + </map> + </property> + </bean> + <bean class="org.apache.ignite.cache.QueryIndex"> + <property name="indexType" value="FULLTEXT"/> + <property name="fields"> + <map> + <entry key="address" value="false"/> + </map> + </property> + </bean> </list> </property> </bean> - <bean class="org.apache.ignite.cache.CacheTypeMetadata"> + <bean class="org.apache.ignite.cache.QueryEntity"> <property name="valueType" value="GridImplicitBinaryPerson"/> - <property name="ascendingFields"> + <property name="fields"> <map> + <entry key="name" value="java.lang.String"/> <entry key="age" value="java.lang.Integer"/> </map> </property> - <property name="queryFields"> - <map> - <entry key="name" value="java.lang.String"/> - </map> + <property name="indexes"> + <list> + <bean class="org.apache.ignite.cache.QueryIndex"> + <property name="fields"> + <map> + <entry key="age" value="true"/> + </map> + </property> + </bean> + </list> </property> </bean> - <bean class="org.apache.ignite.cache.CacheTypeMetadata"> + <bean class="org.apache.ignite.cache.QueryEntity"> <property name="valueType" value="GridNoDefBinaryPerson"/> - <property name="ascendingFields"> + <property name="fields"> <map> + <entry key="name" value="java.lang.String"/> <entry key="age" value="java.lang.Integer"/> </map> </property> - <property name="queryFields"> - <map> - <entry key="name" value="java.lang.String"/> - </map> + <property name="indexes"> + <list> + <bean class="org.apache.ignite.cache.QueryIndex"> + <property name="fields"> + <map> + <entry key="age" value="true"/> + </map> + </property> + </bean> + </list> </property> </bean> </list> http://git-wip-us.apache.org/repos/asf/ignite/blob/1811ede4/modules/clients/src/test/resources/spring-server-ssl-node.xml ---------------------------------------------------------------------- diff --git a/modules/clients/src/test/resources/spring-server-ssl-node.xml b/modules/clients/src/test/resources/spring-server-ssl-node.xml index 98b5e1f..05b1d51 100644 --- a/modules/clients/src/test/resources/spring-server-ssl-node.xml +++ b/modules/clients/src/test/resources/spring-server-ssl-node.xml @@ -127,50 +127,75 @@ <property name="binaryEnabled" value="true"/> - <property name="typeMetadata"> + <property name="queryEntities"> <list> - <bean class="org.apache.ignite.cache.CacheTypeMetadata"> + <bean class="org.apache.ignite.cache.QueryEntity"> <property name="valueType" value="GridBinaryPerson"/> - <property name="ascendingFields"> - <map> - <entry key="age" value="java.lang.Integer"/> - </map> - </property> - <property name="queryFields"> + <property name="fields"> <map> <entry key="name" value="java.lang.String"/> + <entry key="address" value="java.lang.String"/> + <entry key="age" value="java.lang.Integer"/> </map> </property> - <property name="textFields"> + <property name="indexes"> <list> - <value>address</value> + <bean class="org.apache.ignite.cache.QueryIndex"> + <property name="fields"> + <map> + <entry key="age" value="true"/> + </map> + </property> + </bean> + <bean class="org.apache.ignite.cache.QueryIndex"> + <property name="indexType" value="FULLTEXT"/> + <property name="fields"> + <map> + <entry key="address" value="false"/> + </map> + </property> + </bean> </list> </property> </bean> - <bean class="org.apache.ignite.cache.CacheTypeMetadata"> + <bean class="org.apache.ignite.cache.QueryEntity"> <property name="valueType" value="GridImplicitBinaryPerson"/> - <property name="ascendingFields"> + <property name="fields"> <map> + <entry key="name" value="java.lang.String"/> <entry key="age" value="java.lang.Integer"/> </map> </property> - <property name="queryFields"> - <map> - <entry key="name" value="java.lang.String"/> - </map> + <property name="indexes"> + <list> + <bean class="org.apache.ignite.cache.QueryIndex"> + <property name="fields"> + <map> + <entry key="age" value="true"/> + </map> + </property> + </bean> + </list> </property> </bean> - <bean class="org.apache.ignite.cache.CacheTypeMetadata"> + <bean class="org.apache.ignite.cache.QueryEntity"> <property name="valueType" value="GridNoDefBinaryPerson"/> - <property name="ascendingFields"> + <property name="fields"> <map> + <entry key="name" value="java.lang.String"/> <entry key="age" value="java.lang.Integer"/> </map> </property> - <property name="queryFields"> - <map> - <entry key="name" value="java.lang.String"/> - </map> + <property name="indexes"> + <list> + <bean class="org.apache.ignite.cache.QueryIndex"> + <property name="fields"> + <map> + <entry key="age" value="true"/> + </map> + </property> + </bean> + </list> </property> </bean> </list> http://git-wip-us.apache.org/repos/asf/ignite/blob/1811ede4/modules/core/src/main/java/org/apache/ignite/IgniteBinary.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteBinary.java b/modules/core/src/main/java/org/apache/ignite/IgniteBinary.java index 450cf70..1d1c0c3 100644 --- a/modules/core/src/main/java/org/apache/ignite/IgniteBinary.java +++ b/modules/core/src/main/java/org/apache/ignite/IgniteBinary.java @@ -256,27 +256,48 @@ import org.jetbrains.annotations.Nullable; * or for a specific type via {@link org.apache.ignite.binary.BinaryTypeConfiguration} instance. * <h1 class="header">Query Indexing</h1> * Binary objects can be indexed for querying by specifying index fields in - * {@link org.apache.ignite.cache.CacheTypeMetadata} inside of specific + * {@link org.apache.ignite.cache.QueryEntity} inside of specific * {@link org.apache.ignite.configuration.CacheConfiguration} instance, * like so: * <pre name=code class=xml> * ... * <bean class="org.apache.ignite.cache.CacheConfiguration"> * ... - * <property name="typeMetadata"> + * <property name="queryEntities"> * <list> - * <bean class="CacheTypeMetadata"> + * <bean class="QueryEntity"> * <property name="type" value="Employee"/> * - * <!-- Fields to index in ascending order. --> - * <property name="ascendingFields"> + * <!-- Fields available from query. --> + * <property name="fields"> * <map> * <entry key="name" value="java.lang.String"/> * - * <!-- Nested binary objects can also be indexed. --> - * <entry key="address.zip" value="java.lang.Integer"/> + * <!-- Nested binary objects can also be indexed. --> + * <entry key="address.zip" value="java.lang.Integer" /> * </map> * </property> + * + * <!-- Aliases for full property name in dot notation. --> + * <property name="fields"> + * <map> + * <entry key="address.zip" value="zip" /> + * </map> + * </property> + * + * <!-- Indexes configuration. --> + * <property name="indexes"> + * <list> + * <bean class="org.apache.ignite.cache.QueryIndex"> + * <property name="fields"> + * <map> + * <!-- The boolean value is the acceding flag. --> + * <entry key="name" value="true"/> + * </map> + * </property> + * </bean> + * </list> + * </property> * </bean> * </list> * </property> http://git-wip-us.apache.org/repos/asf/ignite/blob/1811ede4/modules/core/src/main/java/org/apache/ignite/cache/CacheTypeFieldMetadata.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/cache/CacheTypeFieldMetadata.java b/modules/core/src/main/java/org/apache/ignite/cache/CacheTypeFieldMetadata.java deleted file mode 100644 index 1ec2408..0000000 --- a/modules/core/src/main/java/org/apache/ignite/cache/CacheTypeFieldMetadata.java +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.cache; - -import java.io.Serializable; -import org.apache.ignite.internal.util.typedef.internal.S; - -/** - * Type field metadata. - */ -public class CacheTypeFieldMetadata implements Serializable { - /** */ - private static final long serialVersionUID = 0L; - - /** Column name in database. */ - private String dbName; - - /** Column JDBC type in database. */ - private int dbType; - - /** Field name in java object. */ - private String javaName; - - /** Corresponding java type. */ - private Class<?> javaType; - - /** - * Default constructor. - */ - public CacheTypeFieldMetadata() { - // No-op. - } - - /** - * Full constructor. - * - * @param dbName Column name in database. - * @param dbType Column JDBC type in database. - * @param javaName Field name in java object. - * @param javaType Field java type. - */ - public CacheTypeFieldMetadata(String dbName, int dbType, String javaName, Class<?> javaType) { - this.dbName = dbName; - this.dbType = dbType; - this.javaName = javaName; - this.javaType = javaType; - } - - /** - * @return Column name in database. - */ - public String getDatabaseName() { - return dbName; - } - - /** - * @param dbName Column name in database. - */ - public void setDatabaseName(String dbName) { - this.dbName = dbName; - } - - /** - * @return Column JDBC type in database. - */ - public int getDatabaseType() { - return dbType; - } - - /** - * @param dbType Column JDBC type in database. - */ - public void setDatabaseType(int dbType) { - this.dbType = dbType; - } - - /** - * @return Field name in java object. - */ - public String getJavaName() { - return javaName; - } - - /** - * @param javaName Field name in java object. - */ - public void setJavaName(String javaName) { - this.javaName = javaName; - } - - /** - * @return Field java type. - */ - public Class<?> getJavaType() { - return javaType; - } - - /** - * @param javaType Corresponding java type. - */ - public void setJavaType(Class<?> javaType) { - this.javaType = javaType; - } - - /** {@inheritDoc} */ - @Override public boolean equals(Object o) { - if (this == o) - return true; - - if (!(o instanceof CacheTypeFieldMetadata)) - return false; - - CacheTypeFieldMetadata that = (CacheTypeFieldMetadata)o; - - return javaName.equals(that.javaName) && dbName.equals(that.dbName) && - javaType == that.javaType && dbType == that.dbType; - } - - /** {@inheritDoc} */ - @Override public int hashCode() { - int res = dbName.hashCode(); - - res = 31 * res + dbType; - res = 31 * res + javaName.hashCode(); - res = 31 * res + javaType.hashCode(); - - return res; - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(CacheTypeFieldMetadata.class, this); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/1811ede4/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 deleted file mode 100644 index 0c91394..0000000 --- a/modules/core/src/main/java/org/apache/ignite/cache/CacheTypeMetadata.java +++ /dev/null @@ -1,379 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.cache; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Collection; -import java.util.LinkedHashMap; -import java.util.LinkedHashSet; -import java.util.Map; -import javax.cache.CacheException; -import org.apache.ignite.cache.store.jdbc.CacheJdbcPojoStore; -import org.apache.ignite.internal.processors.query.QueryUtils; -import org.apache.ignite.internal.util.tostring.GridToStringInclude; -import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.lang.IgniteBiTuple; - -/** - * Cache type metadata need for configuration of indexes or automatic persistence. - * @deprecated Use {@link org.apache.ignite.cache.QueryEntity} instead. - */ -@Deprecated -public class CacheTypeMetadata implements Serializable { - /** */ - private static final long serialVersionUID = 0L; - - /** Schema name in database. */ - private String dbSchema; - - /** Table name in database. */ - private String dbTbl; - - /** Key class used to store key in cache. */ - private String keyType; - - /** 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; - - /** Optional persistent key fields (needed only if {@link CacheJdbcPojoStore} is used). */ - @GridToStringInclude - private Collection<CacheTypeFieldMetadata> keyFields; - - /** Optional persistent value fields (needed only if {@link CacheJdbcPojoStore} is used). */ - @GridToStringInclude - private Collection<CacheTypeFieldMetadata> valFields; - - /** Field name-to-type map to be queried, in addition to indexed fields. */ - @GridToStringInclude - private Map<String, Class<?>> qryFlds; - - /** Field name-to-type map to index in ascending order. */ - @GridToStringInclude - private Map<String, Class<?>> ascFlds; - - /** Field name-to-type map to index in descending order. */ - @GridToStringInclude - private Map<String, Class<?>> descFlds; - - /** Fields to index as text. */ - @GridToStringInclude - private Collection<String> txtFlds; - - /** Fields to create group indexes for. */ - @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<>(); - } - - /** - * Copy constructor. - */ - 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()); - } - - /** - * Gets database schema name. - * - * @return Schema name. - */ - public String getDatabaseSchema() { - return dbSchema; - } - - /** - * Sets database schema name. - * - * @param dbSchema Schema name. - */ - public void setDatabaseSchema(String dbSchema) { - this.dbSchema = dbSchema; - } - - /** - * Gets table name in database. - * - * @return Table name in database. - */ - public String getDatabaseTable() { - return dbTbl; - } - - /** - * Table name in database. - * - * @param dbTbl Table name in database. - */ - public void setDatabaseTable(String dbTbl) { - this.dbTbl = dbTbl; - } - - /** - * Gets key type. - * - * @return Key type. - */ - public String getKeyType() { - return keyType; - } - - /** - * Sets key type. - * - * @param keyType Key type. - */ - public void setKeyType(String keyType) { - this.keyType = keyType; - } - - /** - * Sets key type. - * - * @param cls Key type class. - */ - public void setKeyType(Class<?> cls) { - setKeyType(cls.getName()); - } - - /** - * Gets value type. - * - * @return Key type. - */ - public String getValueType() { - return valType; - } - - /** - * 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 : QueryUtils.typeName(cls); - } - - /** - * Sets value type. - * - * @param cls Value type class. - */ - public void setValueType(Class<?> cls) { - setValueType(cls.getName()); - } - - /** - * Gets optional persistent key fields (needed only if {@link CacheJdbcPojoStore} is used). - * - * @return Persistent key fields. - */ - public Collection<CacheTypeFieldMetadata> getKeyFields() { - return keyFields; - } - - /** - * Sets optional persistent key fields (needed only if {@link CacheJdbcPojoStore} is used). - * - * @param keyFields Persistent key fields. - */ - public void setKeyFields(Collection<CacheTypeFieldMetadata> keyFields) { - this.keyFields = keyFields; - } - - /** - * Gets optional persistent value fields (needed only if {@link CacheJdbcPojoStore} is used). - * - * @return Persistent value fields. - */ - public Collection<CacheTypeFieldMetadata> getValueFields() { - return valFields; - } - - /** - * Sets optional persistent value fields (needed only if {@link CacheJdbcPojoStore} is used). - * - * @param valFields Persistent value fields. - */ - public void setValueFields(Collection<CacheTypeFieldMetadata> valFields) { - this.valFields = valFields; - } - - /** - * Gets name-to-type map for query-enabled fields. - * - * @return Name-to-type map for query-enabled fields. - */ - public Map<String, Class<?>> getQueryFields() { - return qryFlds; - } - - /** - * Sets name-to-type map for query-enabled fields. - * - * @param qryFlds Name-to-type map for query-enabled fields. - */ - public void setQueryFields(Map<String, Class<?>> qryFlds) { - this.qryFlds = qryFlds; - } - - /** - * Gets name-to-type map for ascending-indexed fields. - * - * @return Name-to-type map for ascending-indexed fields. - */ - public Map<String, Class<?>> getAscendingFields() { - return ascFlds; - } - - /** - * Sets name-to-type map for ascending-indexed fields. - * - * @param ascFlds Name-to-type map for ascending-indexed fields. - */ - public void setAscendingFields(Map<String, Class<?>> ascFlds) { - if (ascFlds == null) - this.ascFlds = ascFlds; - else - this.ascFlds.putAll(ascFlds); - } - - /** - * Gets name-to-type map for descending-indexed fields. - * - * @return Name-to-type map of descending-indexed fields. - */ - public Map<String, Class<?>> getDescendingFields() { - return descFlds; - } - - /** - * Sets name-to-type map for descending-indexed fields. - * - * @param descFlds Name-to-type map of descending-indexed fields. - */ - public void setDescendingFields(Map<String, Class<?>> descFlds) { - this.descFlds = descFlds; - } - - /** - * Gets text-indexed fields. - * - * @return Collection of text indexed fields. - */ - public Collection<String> getTextFields() { - return txtFlds; - } - - /** - * Sets text-indexed fields. - * - * @param txtFlds Text-indexed fields. - */ - public void setTextFields(Collection<String> txtFlds) { - this.txtFlds = txtFlds; - } - - /** - * Gets group-indexed fields. - * - * @return Map of group-indexed fields. - */ - public Map<String, LinkedHashMap<String, IgniteBiTuple<Class<?>, Boolean>>> getGroups() { - return grps; - } - - /** - * Sets group-indexed fields. - * - * @param grps Map of group-indexed fields from index name to index fields. - */ - public void setGroups(Map<String, LinkedHashMap<String, IgniteBiTuple<Class<?>, Boolean>>> grps) { - 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); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/1811ede4/modules/core/src/main/java/org/apache/ignite/cache/QueryEntity.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/cache/QueryEntity.java b/modules/core/src/main/java/org/apache/ignite/cache/QueryEntity.java index f791c1c..9f4313e 100644 --- a/modules/core/src/main/java/org/apache/ignite/cache/QueryEntity.java +++ b/modules/core/src/main/java/org/apache/ignite/cache/QueryEntity.java @@ -238,6 +238,9 @@ public class QueryEntity implements Serializable { /** * Utility method for building query entities programmatically. + * @param fullName Full name of the field. + * @param type Type of the field. + * @param alias Field alias. * @return {@code this} for chaining. */ public QueryEntity addQueryField(String fullName, String type, String alias) { http://git-wip-us.apache.org/repos/asf/ignite/blob/1811ede4/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheAbstractJdbcStore.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheAbstractJdbcStore.java b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheAbstractJdbcStore.java index 41709a1..c774e65 100644 --- a/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheAbstractJdbcStore.java +++ b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheAbstractJdbcStore.java @@ -49,8 +49,6 @@ import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.IgniteException; import org.apache.ignite.IgniteLogger; import org.apache.ignite.binary.BinaryObject; -import org.apache.ignite.cache.CacheTypeFieldMetadata; -import org.apache.ignite.cache.CacheTypeMetadata; import org.apache.ignite.cache.store.CacheStore; import org.apache.ignite.cache.store.CacheStoreSession; import org.apache.ignite.cache.store.jdbc.dialect.BasicJdbcDialect; @@ -60,7 +58,6 @@ import org.apache.ignite.cache.store.jdbc.dialect.JdbcDialect; import org.apache.ignite.cache.store.jdbc.dialect.MySQLDialect; import org.apache.ignite.cache.store.jdbc.dialect.OracleDialect; import org.apache.ignite.cache.store.jdbc.dialect.SQLServerDialect; -import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.internal.binary.BinaryMarshaller; import org.apache.ignite.internal.util.tostring.GridToStringExclude; import org.apache.ignite.internal.util.typedef.C1; @@ -534,28 +531,6 @@ public abstract class CacheAbstractJdbcStore<K, V> implements CacheStore<K, V>, } /** - * For backward compatibility translate old field type descriptors to new format. - * - * @param oldFlds Fields in old format. - * @return Fields in new format. - */ - @Deprecated - private JdbcTypeField[] translateFields(Collection<CacheTypeFieldMetadata> oldFlds) { - JdbcTypeField[] newFlds = new JdbcTypeField[oldFlds.size()]; - - int idx = 0; - - for (CacheTypeFieldMetadata oldField : oldFlds) { - newFlds[idx] = new JdbcTypeField(oldField.getDatabaseType(), oldField.getDatabaseName(), - oldField.getJavaType(), oldField.getJavaName()); - - idx++; - } - - return newFlds; - } - - /** * @param type Type name to check. * @return {@code True} if class not found. */ @@ -591,36 +566,6 @@ public abstract class CacheAbstractJdbcStore<K, V> implements CacheStore<K, V>, if (entryMappings != null) return entryMappings; - // If no types configured, check CacheTypeMetadata for backward compatibility. - if (types == null) { - CacheConfiguration ccfg = ignite.cache(cacheName).getConfiguration(CacheConfiguration.class); - - Collection<CacheTypeMetadata> oldTypes = ccfg.getTypeMetadata(); - - types = new JdbcType[oldTypes.size()]; - - int idx = 0; - - for (CacheTypeMetadata oldType : oldTypes) { - JdbcType newType = new JdbcType(); - - newType.setCacheName(cacheName); - - newType.setDatabaseSchema(oldType.getDatabaseSchema()); - newType.setDatabaseTable(oldType.getDatabaseTable()); - - newType.setKeyType(oldType.getKeyType()); - newType.setKeyFields(translateFields(oldType.getKeyFields())); - - newType.setValueType(oldType.getValueType()); - newType.setValueFields(translateFields(oldType.getValueFields())); - - types[idx] = newType; - - idx++; - } - } - List<JdbcType> cacheTypes = new ArrayList<>(types.length); for (JdbcType type : types) http://git-wip-us.apache.org/repos/asf/ignite/blob/1811ede4/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 c4fc98b..ab0aff2 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 @@ -51,7 +51,6 @@ import org.apache.ignite.cache.CacheInterceptor; import org.apache.ignite.cache.CacheMemoryMode; import org.apache.ignite.cache.CacheMode; import org.apache.ignite.cache.CacheRebalanceMode; -import org.apache.ignite.cache.CacheTypeMetadata; import org.apache.ignite.cache.CacheWriteSynchronizationMode; import org.apache.ignite.cache.QueryEntity; import org.apache.ignite.cache.QueryIndex; @@ -372,9 +371,6 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> { */ private boolean readFromBackup = DFLT_READ_FROM_BACKUP; - /** Collection of type metadata. */ - private Collection<CacheTypeMetadata> typeMeta; - /** Node filter specifying nodes on which this cache should be deployed. */ private IgnitePredicate<ClusterNode> nodeFilter; @@ -498,7 +494,6 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> { swapEnabled = cc.isSwapEnabled(); tmLookupClsName = cc.getTransactionManagerLookupClassName(); topValidator = cc.getTopologyValidator(); - typeMeta = cc.getTypeMetadata(); writeBehindBatchSize = cc.getWriteBehindBatchSize(); writeBehindEnabled = cc.isWriteBehindEnabled(); writeBehindFlushFreq = cc.getWriteBehindFlushFrequency(); @@ -1724,28 +1719,6 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> { } /** - * Gets collection of type metadata objects. - * - * @return Collection of type metadata. - */ - public Collection<CacheTypeMetadata> getTypeMetadata() { - return typeMeta; - } - - /** - * Sets collection of type metadata objects. - * - * @param typeMeta Collection of type metadata. - * @return {@code this} for chaining. - * @deprecated Use {@link #setQueryEntities(java.util.Collection)} instead. - */ - public CacheConfiguration<K, V> setTypeMetadata(Collection<CacheTypeMetadata> typeMeta) { - this.typeMeta = new ArrayList<>(typeMeta); - - return this; - } - - /** * Gets flag indicating whether data can be read from backup. * If {@code false} always get data from primary node (never from backup). * <p> http://git-wip-us.apache.org/repos/asf/ignite/blob/1811ede4/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 676c836..74a0213 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 @@ -32,7 +32,6 @@ import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.IgniteDataStreamer; import org.apache.ignite.IgniteException; import org.apache.ignite.binary.Binarylizable; -import org.apache.ignite.cache.CacheTypeMetadata; import org.apache.ignite.cache.QueryEntity; import org.apache.ignite.cache.query.QueryCursor; import org.apache.ignite.cache.query.SqlFieldsQuery; @@ -158,15 +157,6 @@ public class GridQueryProcessor extends GridProcessorAdapter { } } - if (!F.isEmpty(ccfg.getTypeMetadata())) { - for (CacheTypeMetadata meta : ccfg.getTypeMetadata()) { - QueryTypeCandidate cand = QueryUtils.typeForCacheMetadata(space, cctx, meta, mustDeserializeClss); - - if (cand != null) - cands.add(cand); - } - } - // Register candidates. idx.registerCache(space, cctx, cctx.config()); http://git-wip-us.apache.org/repos/asf/ignite/blob/1811ede4/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryUtils.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryUtils.java index 19a752a..896c62b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryUtils.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryUtils.java @@ -18,7 +18,6 @@ package org.apache.ignite.internal.processors.query; import org.apache.ignite.IgniteCheckedException; -import org.apache.ignite.cache.CacheTypeMetadata; import org.apache.ignite.cache.QueryEntity; import org.apache.ignite.cache.QueryIndex; import org.apache.ignite.cache.QueryIndexType; @@ -39,7 +38,6 @@ import org.apache.ignite.internal.processors.query.property.QueryReadOnlyMethods import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.A; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.lang.IgniteBiTuple; import org.jetbrains.annotations.Nullable; import java.lang.reflect.Method; @@ -48,7 +46,6 @@ import java.sql.Time; import java.sql.Timestamp; import java.util.Collections; import java.util.HashSet; -import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Set; @@ -200,314 +197,6 @@ public class QueryUtils { } /** - * Create type candidate for type metadata. - * - * @param space Space. - * @param cctx Cache context. - * @param meta Type metadata. - * @param mustDeserializeClss Classes which must be deserialized. - * @return Type candidate. - * @throws IgniteCheckedException If failed. - */ - @SuppressWarnings("deprecation") - @Nullable public static QueryTypeCandidate typeForCacheMetadata(String space, GridCacheContext cctx, - CacheTypeMetadata meta, List<Class<?>> mustDeserializeClss) throws IgniteCheckedException { - if (F.isEmpty(meta.getValueType())) - throw new IgniteCheckedException("Value type is not set: " + meta); - - GridKernalContext ctx = cctx.kernalContext(); - CacheConfiguration<?,?> ccfg = cctx.config(); - - boolean binaryEnabled = ctx.cacheObjects().isBinaryEnabled(ccfg); - - CacheObjectContext coCtx = binaryEnabled ? ctx.cacheObjects().contextForCache(ccfg) : null; - - if (meta.getQueryFields().isEmpty() && meta.getAscendingFields().isEmpty() && - meta.getDescendingFields().isEmpty() && meta.getGroups().isEmpty()) - return null; - - QueryTypeDescriptorImpl desc = new QueryTypeDescriptorImpl(); - - // 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<?> keyCls = U.classForName(meta.getKeyType(), null); - Class<?> valCls = U.classForName(meta.getValueType(), null); - - // If local node has the classes and they are externalizable, we must use reflection properties. - boolean keyMustDeserialize = mustDeserializeBinary(ctx, keyCls); - boolean valMustDeserialize = mustDeserializeBinary(ctx, valCls); - - boolean keyOrValMustDeserialize = keyMustDeserialize || valMustDeserialize; - - if (keyCls == null) - keyCls = Object.class; - - String simpleValType = meta.getSimpleValueType(); - - if (simpleValType == null) - simpleValType = typeName(meta.getValueType()); - - desc.name(simpleValType); - - if (binaryEnabled && !keyOrValMustDeserialize) { - // Safe to check null. - if (SQL_TYPES.contains(valCls)) - desc.valueClass(valCls); - else - desc.valueClass(Object.class); - - if (SQL_TYPES.contains(keyCls)) - desc.keyClass(keyCls); - else - desc.keyClass(Object.class); - } - else { - desc.valueClass(valCls); - desc.keyClass(keyCls); - } - - desc.keyTypeName(meta.getKeyType()); - desc.valueTypeName(meta.getValueType()); - - if (binaryEnabled && keyOrValMustDeserialize) { - if (keyMustDeserialize) - mustDeserializeClss.add(keyCls); - - if (valMustDeserialize) - mustDeserializeClss.add(valCls); - } - - QueryTypeIdKey typeId; - QueryTypeIdKey altTypeId = null; - - if (valCls == null || (binaryEnabled && !keyOrValMustDeserialize)) { - processBinaryMeta(ctx, meta, desc); - - typeId = new QueryTypeIdKey(space, ctx.cacheObjects().typeId(meta.getValueType())); - - if (valCls != null) - altTypeId = new QueryTypeIdKey(space, valCls); - } - else { - processClassMeta(meta, desc, coCtx); - - typeId = new QueryTypeIdKey(space, valCls); - altTypeId = new QueryTypeIdKey(space, ctx.cacheObjects().typeId(meta.getValueType())); - } - - return new QueryTypeCandidate(typeId, altTypeId, desc); - } - - /** - * Processes declarative metadata for class. - * - * @param meta Type metadata. - * @param d Type descriptor. - * @param coCtx Cache object context. - * @throws IgniteCheckedException If failed. - */ - @SuppressWarnings("deprecation") - private static void processClassMeta(CacheTypeMetadata meta, QueryTypeDescriptorImpl d, CacheObjectContext coCtx) - throws IgniteCheckedException { - Map<String,String> aliases = meta.getAliases(); - - if (aliases == null) - aliases = Collections.emptyMap(); - - Class<?> keyCls = d.keyClass(); - Class<?> valCls = d.valueClass(); - - assert keyCls != null; - assert valCls != null; - - for (Map.Entry<String, Class<?>> entry : meta.getAscendingFields().entrySet()) - addToIndex(d, keyCls, valCls, entry.getKey(), entry.getValue(), 0, IndexType.ASC, null, aliases, coCtx); - - for (Map.Entry<String, Class<?>> entry : meta.getDescendingFields().entrySet()) - addToIndex(d, keyCls, valCls, entry.getKey(), entry.getValue(), 0, IndexType.DESC, null, aliases, coCtx); - - for (String txtField : meta.getTextFields()) - addToIndex(d, keyCls, valCls, txtField, String.class, 0, IndexType.TEXT, null, aliases, coCtx); - - Map<String, LinkedHashMap<String, IgniteBiTuple<Class<?>, Boolean>>> grps = meta.getGroups(); - - if (grps != null) { - for (Map.Entry<String, LinkedHashMap<String, IgniteBiTuple<Class<?>, Boolean>>> entry : grps.entrySet()) { - String idxName = entry.getKey(); - - LinkedHashMap<String, IgniteBiTuple<Class<?>, Boolean>> idxFields = entry.getValue(); - - int order = 0; - - for (Map.Entry<String, IgniteBiTuple<Class<?>, Boolean>> idxField : idxFields.entrySet()) { - Boolean descending = idxField.getValue().get2(); - - if (descending == null) - descending = false; - - addToIndex(d, keyCls, valCls, idxField.getKey(), idxField.getValue().get1(), order, - descending ? IndexType.DESC : IndexType.ASC, idxName, aliases, coCtx); - - order++; - } - } - } - - for (Map.Entry<String, Class<?>> entry : meta.getQueryFields().entrySet()) { - QueryClassProperty prop = buildClassProperty( - keyCls, - valCls, - entry.getKey(), - entry.getValue(), - aliases, - coCtx); - - d.addProperty(prop, false); - } - } - - /** - * @param d Type descriptor. - * @param keyCls Key class. - * @param valCls Value class. - * @param pathStr Path string. - * @param resType Result type. - * @param idxOrder Order number in index or {@code -1} if no need to index. - * @param idxType Index type. - * @param idxName Index name. - * @param aliases Aliases. - * @throws IgniteCheckedException If failed. - */ - private static void addToIndex( - QueryTypeDescriptorImpl d, - Class<?> keyCls, - Class<?> valCls, - String pathStr, - Class<?> resType, - int idxOrder, - IndexType idxType, - String idxName, - Map<String,String> aliases, - CacheObjectContext coCtx - ) throws IgniteCheckedException { - String propName; - Class<?> propCls; - - if (_VAL.equals(pathStr)) { - propName = _VAL; - propCls = valCls; - } - else { - QueryClassProperty prop = buildClassProperty( - keyCls, - valCls, - pathStr, - resType, - aliases, - coCtx); - - d.addProperty(prop, false); - - propName = prop.name(); - propCls = prop.type(); - } - - if (idxType != null) { - if (idxName == null) - idxName = propName + "_idx"; - - if (idxOrder == 0) // Add index only on the first field. - d.addIndex(idxName, isGeometryClass(propCls) ? QueryIndexType.GEOSPATIAL : QueryIndexType.SORTED); - - if (idxType == IndexType.TEXT) - d.addFieldToTextIndex(propName); - else - d.addFieldToIndex(idxName, propName, idxOrder, idxType == IndexType.DESC); - } - } - - /** - * Processes declarative metadata for binary object. - * - * @param ctx Kernal context. - * @param meta Declared metadata. - * @param d Type descriptor. - * @throws IgniteCheckedException If failed. - */ - @SuppressWarnings("deprecation") - public static void processBinaryMeta(GridKernalContext ctx, CacheTypeMetadata meta, QueryTypeDescriptorImpl d) - throws IgniteCheckedException { - Map<String,String> aliases = meta.getAliases(); - - if (aliases == null) - aliases = Collections.emptyMap(); - - for (Map.Entry<String, Class<?>> entry : meta.getAscendingFields().entrySet()) { - QueryBinaryProperty prop = buildBinaryProperty(ctx, entry.getKey(), entry.getValue(), aliases, null); - - d.addProperty(prop, false); - - String idxName = prop.name() + "_idx"; - - d.addIndex(idxName, isGeometryClass(prop.type()) ? QueryIndexType.GEOSPATIAL : QueryIndexType.SORTED); - - d.addFieldToIndex(idxName, prop.name(), 0, false); - } - - for (Map.Entry<String, Class<?>> entry : meta.getDescendingFields().entrySet()) { - QueryBinaryProperty prop = buildBinaryProperty(ctx, entry.getKey(), entry.getValue(), aliases, null); - - d.addProperty(prop, false); - - String idxName = prop.name() + "_idx"; - - d.addIndex(idxName, isGeometryClass(prop.type()) ? QueryIndexType.GEOSPATIAL : QueryIndexType.SORTED); - - d.addFieldToIndex(idxName, prop.name(), 0, true); - } - - for (String txtIdx : meta.getTextFields()) { - QueryBinaryProperty prop = buildBinaryProperty(ctx, txtIdx, String.class, aliases, null); - - d.addProperty(prop, false); - - d.addFieldToTextIndex(prop.name()); - } - - Map<String, LinkedHashMap<String, IgniteBiTuple<Class<?>, Boolean>>> grps = meta.getGroups(); - - if (grps != null) { - for (Map.Entry<String, LinkedHashMap<String, IgniteBiTuple<Class<?>, Boolean>>> entry : grps.entrySet()) { - String idxName = entry.getKey(); - - LinkedHashMap<String, IgniteBiTuple<Class<?>, Boolean>> idxFields = entry.getValue(); - - int order = 0; - - for (Map.Entry<String, IgniteBiTuple<Class<?>, Boolean>> idxField : idxFields.entrySet()) { - QueryBinaryProperty prop = buildBinaryProperty(ctx, idxField.getKey(), idxField.getValue().get1(), - aliases, null); - - d.addProperty(prop, false); - - Boolean descending = idxField.getValue().get2(); - - d.addFieldToIndex(idxName, prop.name(), order, descending != null && descending); - - order++; - } - } - } - - for (Map.Entry<String, Class<?>> entry : meta.getQueryFields().entrySet()) { - QueryBinaryProperty prop = buildBinaryProperty(ctx, entry.getKey(), entry.getValue(), aliases, null); - - if (!d.properties().containsKey(prop.name())) - d.addProperty(prop, false); - } - } - - /** * Processes declarative metadata for binary object. * * @param ctx Kernal context. @@ -976,7 +665,6 @@ public class QueryUtils { */ public static boolean isEnabled(CacheConfiguration<?,?> ccfg) { return !F.isEmpty(ccfg.getIndexedTypes()) || - !F.isEmpty(ccfg.getTypeMetadata()) || !F.isEmpty(ccfg.getQueryEntities()); } @@ -986,18 +674,4 @@ public class QueryUtils { private QueryUtils() { // No-op. } - /** - * The way to index. - */ - private enum IndexType { - /** Ascending index. */ - ASC, - - /** Descending index. */ - DESC, - - /** Text index. */ - TEXT - } - } http://git-wip-us.apache.org/repos/asf/ignite/blob/1811ede4/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheConfiguration.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheConfiguration.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheConfiguration.java index cf2ba7a..30973b0 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheConfiguration.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheConfiguration.java @@ -139,7 +139,7 @@ public class VisorCacheConfiguration implements Serializable, LessNamingBean { maxConcurrentAsyncOps = ccfg.getMaxConcurrentAsyncOperations(); memoryMode = ccfg.getMemoryMode(); interceptor = compactClass(ccfg.getInterceptor()); - typeMeta = VisorCacheTypeMetadata.list(ccfg.getQueryEntities(), ccfg.getCacheStoreFactory(), ccfg.getTypeMetadata()); + typeMeta = VisorCacheTypeMetadata.list(ccfg.getQueryEntities(), ccfg.getCacheStoreFactory()); statisticsEnabled = ccfg.isStatisticsEnabled(); mgmtEnabled = ccfg.isManagementEnabled(); ldrFactory = compactClass(ccfg.getCacheLoaderFactory()); http://git-wip-us.apache.org/repos/asf/ignite/blob/1811ede4/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheTypeFieldMetadata.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheTypeFieldMetadata.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheTypeFieldMetadata.java index f3dffd6..c9bf960 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheTypeFieldMetadata.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheTypeFieldMetadata.java @@ -18,12 +18,11 @@ package org.apache.ignite.internal.visor.cache; import java.io.Serializable; -import org.apache.ignite.cache.CacheTypeFieldMetadata; +import org.apache.ignite.cache.store.jdbc.JdbcTypeField; import org.apache.ignite.internal.LessNamingBean; -import org.apache.ignite.internal.util.typedef.internal.U; /** - * Data transfer object for {@link CacheTypeFieldMetadata}. + * Data transfer object for {@link JdbcTypeField}. */ public class VisorCacheTypeFieldMetadata implements Serializable, LessNamingBean { /** */ @@ -42,15 +41,6 @@ public class VisorCacheTypeFieldMetadata implements Serializable, LessNamingBean private String javaType; /** - * @param f Actual field metadata. - * @return Data transfer object for given cache field metadata. - */ - public static VisorCacheTypeFieldMetadata from(CacheTypeFieldMetadata f) { - return new VisorCacheTypeFieldMetadata(f.getDatabaseName(), f.getDatabaseType(), - f.getJavaName(), U.compact(f.getJavaType().getName())); - } - - /** * Empty constructor. */ public VisorCacheTypeFieldMetadata() { http://git-wip-us.apache.org/repos/asf/ignite/blob/1811ede4/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheTypeMetadata.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheTypeMetadata.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheTypeMetadata.java index c87ad05..7463887 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheTypeMetadata.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheTypeMetadata.java @@ -23,8 +23,6 @@ import java.util.Collection; import java.util.Collections; import java.util.LinkedHashMap; import java.util.Map; -import org.apache.ignite.cache.CacheTypeFieldMetadata; -import org.apache.ignite.cache.CacheTypeMetadata; import org.apache.ignite.cache.QueryEntity; import org.apache.ignite.cache.QueryIndex; import org.apache.ignite.cache.store.jdbc.CacheJdbcPojoStoreFactory; @@ -39,7 +37,7 @@ import org.apache.ignite.lang.IgniteBiTuple; import javax.cache.configuration.Factory; /** - * Data transfer object for {@link CacheTypeMetadata}. + * Data transfer object for {@link JdbcType}. */ public class VisorCacheTypeMetadata implements Serializable, LessNamingBean { /** */ @@ -88,11 +86,9 @@ public class VisorCacheTypeMetadata implements Serializable, LessNamingBean { /** * @param qryEntities Collection of query entities. * @param factory Store factory to extract JDBC types info. - * @param types Cache types metadata configurations. * @return Data transfer object for cache type metadata configurations. */ - public static Collection<VisorCacheTypeMetadata> list(Collection<QueryEntity> qryEntities, Factory factory, - Collection<CacheTypeMetadata> types) { + public static Collection<VisorCacheTypeMetadata> list(Collection<QueryEntity> qryEntities, Factory factory) { final Collection<VisorCacheTypeMetadata> metas = new ArrayList<>(); Map<String, VisorCacheTypeMetadata> metaMap = @@ -164,11 +160,6 @@ public class VisorCacheTypeMetadata implements Serializable, LessNamingBean { } } - // Add old deprecated CacheTypeMetadata for compatibility. - if (types != null) - for (CacheTypeMetadata type : types) - metas.add(from(type)); - return metas; } @@ -220,84 +211,6 @@ public class VisorCacheTypeMetadata implements Serializable, LessNamingBean { } /** - * @param m Actual cache type metadata. - * @return Data transfer object for given cache type metadata. - */ - public static VisorCacheTypeMetadata from(CacheTypeMetadata m) { - assert m != null; - - VisorCacheTypeMetadata metadata = new VisorCacheTypeMetadata(); - - metadata.dbSchema = m.getDatabaseSchema(); - metadata.dbTbl = m.getDatabaseTable(); - metadata.keyType = m.getKeyType(); - metadata.valType = m.getValueType(); - - ArrayList<VisorCacheTypeFieldMetadata> fields = new ArrayList<>(m.getKeyFields().size()); - - for (CacheTypeFieldMetadata field : m.getKeyFields()) - fields.add(VisorCacheTypeFieldMetadata.from(field)); - - metadata.keyFields = fields; - - fields = new ArrayList<>(m.getValueFields().size()); - - for (CacheTypeFieldMetadata field : m.getValueFields()) - fields.add(VisorCacheTypeFieldMetadata.from(field)); - - metadata.valFields = fields; - - metadata.qryFlds = convertFieldsMap(m.getQueryFields()); - metadata.ascFlds = convertFieldsMap(m.getAscendingFields()); - metadata.descFlds = convertFieldsMap(m.getDescendingFields()); - metadata.txtFlds = m.getTextFields(); - metadata.grps = convertGrpsMap(m.getGroups()); - - return metadata; - } - - /** - * Convert class object to string class name in the fields map. - * - * @param base Map with class object. - * @return Map with string class name. - */ - private static Map<String, String> convertFieldsMap(Map<String, Class<?>> base) { - Map<String, String> res = new LinkedHashMap<>(base.size()); - - for (Map.Entry<String, Class<?>> e : base.entrySet()) - res.put(e.getKey(), U.compact(e.getValue().getName())); - - return res; - } - - /** - * Convert class object to string class name in the groups map. - * - * @param base Map with class object. - * @return Map with string class name. - */ - private static Map<String, LinkedHashMap<String, IgniteBiTuple<String, Boolean>>> convertGrpsMap( - Map<String, LinkedHashMap<String, IgniteBiTuple<Class<?>, Boolean>>> base) { - Map<String, LinkedHashMap<String, IgniteBiTuple<String, Boolean>>> res = new LinkedHashMap<>(base.size()); - - for (Map.Entry<String, LinkedHashMap<String, IgniteBiTuple<Class<?>, Boolean>>> e : base.entrySet()) { - LinkedHashMap<String, IgniteBiTuple<Class<?>, Boolean>> intBase = e.getValue(); - LinkedHashMap<String, IgniteBiTuple<String, Boolean>> intRes = new LinkedHashMap<>(intBase.size()); - - for (Map.Entry<String, IgniteBiTuple<Class<?>, Boolean>> intE : intBase.entrySet()) { - IgniteBiTuple<Class<?>, Boolean> val = intE.getValue(); - - intRes.put(intE.getKey(), new IgniteBiTuple<>(U.compact(val.get1().getName()), val.get2())); - } - - res.put(e.getKey(), intRes); - } - - return res; - } - - /** * @return Schema name in database. */ public String dbSchema() { http://git-wip-us.apache.org/repos/asf/ignite/blob/1811ede4/modules/core/src/main/resources/META-INF/classnames.properties ---------------------------------------------------------------------- diff --git a/modules/core/src/main/resources/META-INF/classnames.properties b/modules/core/src/main/resources/META-INF/classnames.properties index c5f4b92..9cce826 100644 --- a/modules/core/src/main/resources/META-INF/classnames.properties +++ b/modules/core/src/main/resources/META-INF/classnames.properties @@ -44,7 +44,6 @@ org.apache.ignite.cache.CachePeekMode org.apache.ignite.cache.CacheRebalanceMode org.apache.ignite.cache.CacheServerNotFoundException org.apache.ignite.cache.CacheTypeFieldMetadata -org.apache.ignite.cache.CacheTypeMetadata org.apache.ignite.cache.CacheWriteSynchronizationMode org.apache.ignite.cache.QueryEntity org.apache.ignite.cache.QueryIndex http://git-wip-us.apache.org/repos/asf/ignite/blob/1811ede4/modules/core/src/test/config/store/jdbc/ignite-jdbc-type.xml ---------------------------------------------------------------------- diff --git a/modules/core/src/test/config/store/jdbc/ignite-jdbc-type.xml b/modules/core/src/test/config/store/jdbc/ignite-jdbc-type.xml new file mode 100644 index 0000000..4df4f04 --- /dev/null +++ b/modules/core/src/test/config/store/jdbc/ignite-jdbc-type.xml @@ -0,0 +1,279 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<!-- + XML generated by Apache Ignite Schema Import utility: 02/03/2015 +--> +<beans xmlns="http://www.springframework.org/schema/beans" + xmlns:util="http://www.springframework.org/schema/util" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.springframework.org/schema/beans + http://www.springframework.org/schema/beans/spring-beans.xsd + http://www.springframework.org/schema/util + http://www.springframework.org/schema/util/spring-util.xsd"> + <bean class="org.apache.ignite.cache.store.jdbc.JdbcType"> + <property name="databaseSchema" value="PUBLIC"/> + <property name="databaseTable" value="ORGANIZATION"/> + <property name="keyType" value="org.apache.ignite.cache.store.jdbc.model.OrganizationKey"/> + <property name="valueType" value="org.apache.ignite.cache.store.jdbc.model.Organization"/> + <property name="keyFields"> + <list> + <bean class="org.apache.ignite.cache.store.jdbc.JdbcTypeField"> + <property name="databaseFieldName" value="ID"/> + <property name="databaseFieldType"> + <util:constant static-field="java.sql.Types.INTEGER"/> + </property> + <property name="javaFieldName" value="id"/> + <property name="javaFieldType" value="java.lang.Integer"/> + </bean> + </list> + </property> + <property name="valueFields"> + <list> + <bean class="org.apache.ignite.cache.store.jdbc.JdbcTypeField"> + <property name="databaseFieldName" value="ID"/> + <property name="databaseFieldType"> + <util:constant static-field="java.sql.Types.INTEGER"/> + </property> + <property name="javaFieldName" value="id"/> + <property name="javaFieldType" value="java.lang.Integer"/> + </bean> + <bean class="org.apache.ignite.cache.store.jdbc.JdbcTypeField"> + <property name="databaseFieldName" value="NAME"/> + <property name="databaseFieldType"> + <util:constant static-field="java.sql.Types.VARCHAR"/> + </property> + <property name="javaFieldName" value="name"/> + <property name="javaFieldType" value="java.lang.String"/> + </bean> + <bean class="org.apache.ignite.cache.store.jdbc.JdbcTypeField"> + <property name="databaseFieldName" value="CITY"/> + <property name="databaseFieldType"> + <util:constant static-field="java.sql.Types.VARCHAR"/> + </property> + <property name="javaFieldName" value="city"/> + <property name="javaFieldType" value="java.lang.String"/> + </bean> + </list> + </property> + </bean> + + <bean class="org.apache.ignite.cache.store.jdbc.JdbcType"> + <property name="databaseSchema" value="PUBLIC"/> + <property name="databaseTable" value="PERSON"/> + <property name="keyType" value="org.apache.ignite.cache.store.jdbc.model.PersonKey"/> + <property name="valueType" value="org.apache.ignite.cache.store.jdbc.model.Person"/> + <property name="keyFields"> + <list> + <bean class="org.apache.ignite.cache.store.jdbc.JdbcTypeField"> + <property name="databaseFieldName" value="ID"/> + <property name="databaseFieldType"> + <util:constant static-field="java.sql.Types.INTEGER"/> + </property> + <property name="javaFieldName" value="id"/> + <property name="javaFieldType" value="java.lang.Integer"/> + </bean> + </list> + </property> + <property name="valueFields"> + <list> + <bean class="org.apache.ignite.cache.store.jdbc.JdbcTypeField"> + <property name="databaseFieldName" value="ID"/> + <property name="databaseFieldType"> + <util:constant static-field="java.sql.Types.INTEGER"/> + </property> + <property name="javaFieldName" value="id"/> + <property name="javaFieldType" value="java.lang.Integer"/> + </bean> + <bean class="org.apache.ignite.cache.store.jdbc.JdbcTypeField"> + <property name="databaseFieldName" value="ORG_ID"/> + <property name="databaseFieldType"> + <util:constant static-field="java.sql.Types.INTEGER"/> + </property> + <property name="javaFieldName" value="orgId"/> + <property name="javaFieldType" value="java.lang.Integer"/> + </bean> + <bean class="org.apache.ignite.cache.store.jdbc.JdbcTypeField"> + <property name="databaseFieldName" value="NAME"/> + <property name="databaseFieldType"> + <util:constant static-field="java.sql.Types.VARCHAR"/> + </property> + <property name="javaFieldName" value="name"/> + <property name="javaFieldType" value="java.lang.String"/> + </bean> + </list> + </property> + </bean> + + <bean class="org.apache.ignite.cache.store.jdbc.JdbcType"> + <property name="databaseSchema" value="PUBLIC"/> + <property name="databaseTable" value="PERSON_COMPLEX"/> + <property name="keyType" value="org.apache.ignite.cache.store.jdbc.model.PersonComplexKey"/> + <property name="valueType" value="org.apache.ignite.cache.store.jdbc.model.Person"/> + <property name="keyFields"> + <list> + <bean class="org.apache.ignite.cache.store.jdbc.JdbcTypeField"> + <property name="databaseFieldName" value="ID"/> + <property name="databaseFieldType"> + <util:constant static-field="java.sql.Types.INTEGER"/> + </property> + <property name="javaFieldName" value="id"/> + <property name="javaFieldType" value="int"/> + </bean> + <bean class="org.apache.ignite.cache.store.jdbc.JdbcTypeField"> + <property name="databaseFieldName" value="ORG_ID"/> + <property name="databaseFieldType"> + <util:constant static-field="java.sql.Types.INTEGER"/> + </property> + <property name="javaFieldName" value="orgId"/> + <property name="javaFieldType" value="int"/> + </bean> + <bean class="org.apache.ignite.cache.store.jdbc.JdbcTypeField"> + <property name="databaseFieldName" value="CITY_ID"/> + <property name="databaseFieldType"> + <util:constant static-field="java.sql.Types.INTEGER"/> + </property> + <property name="javaFieldName" value="cityId"/> + <property name="javaFieldType" value="int"/> + </bean> + </list> + </property> + <property name="valueFields"> + <list> + <bean class="org.apache.ignite.cache.store.jdbc.JdbcTypeField"> + <property name="databaseFieldName" value="ID"/> + <property name="databaseFieldType"> + <util:constant static-field="java.sql.Types.INTEGER"/> + </property> + <property name="javaFieldName" value="id"/> + <property name="javaFieldType" value="java.lang.Integer"/> + </bean> + <bean class="org.apache.ignite.cache.store.jdbc.JdbcTypeField"> + <property name="databaseFieldName" value="ORG_ID"/> + <property name="databaseFieldType"> + <util:constant static-field="java.sql.Types.INTEGER"/> + </property> + <property name="javaFieldName" value="orgId"/> + <property name="javaFieldType" value="java.lang.Integer"/> + </bean> + <bean class="org.apache.ignite.cache.store.jdbc.JdbcTypeField"> + <property name="databaseFieldName" value="NAME"/> + <property name="databaseFieldType"> + <util:constant static-field="java.sql.Types.VARCHAR"/> + </property> + <property name="javaFieldName" value="name"/> + <property name="javaFieldType" value="java.lang.String"/> + </bean> + <bean class="org.apache.ignite.cache.store.jdbc.JdbcTypeField"> + <property name="databaseFieldName" value="salary"/> + <property name="databaseFieldType"> + <util:constant static-field="java.sql.Types.INTEGER"/> + </property> + <property name="javaFieldName" value="salary"/> + <property name="javaFieldType" value="java.lang.Integer"/> + </bean> + </list> + </property> + </bean> + + <bean class="org.apache.ignite.cache.store.jdbc.JdbcType"> + <property name="databaseSchema" value="PUBLIC"/> + <property name="databaseTable" value="STRING_ENTRIES"/> + <property name="keyType" value="java.lang.String"/> + <property name="valueType" value="java.lang.String"/> + <property name="keyFields"> + <list> + <bean class="org.apache.ignite.cache.store.jdbc.JdbcTypeField"> + <property name="databaseFieldName" value="KEY"/> + <property name="databaseFieldType"> + <util:constant static-field="java.sql.Types.VARCHAR"/> + </property> + </bean> + </list> + </property> + <property name="valueFields"> + <list> + <bean class="org.apache.ignite.cache.store.jdbc.JdbcTypeField"> + <property name="databaseFieldName" value="VAL"/> + <property name="databaseFieldType"> + <util:constant static-field="java.sql.Types.VARCHAR"/> + </property> + </bean> + </list> + </property> + </bean> + + <bean class="org.apache.ignite.cache.store.jdbc.JdbcType"> + <property name="databaseSchema" value="PUBLIC"/> + <property name="databaseTable" value="UUID_ENTRIES"/> + <property name="keyType" value="java.util.UUID"/> + <property name="valueType" value="java.util.UUID"/> + <property name="keyFields"> + <list> + <bean class="org.apache.ignite.cache.store.jdbc.JdbcTypeField"> + <property name="databaseFieldName" value="KEY"/> + <property name="databaseFieldType"> + <util:constant static-field="java.sql.Types.BINARY"/> + </property> + <property name="javaFieldType" value="java.util.UUID"/> + </bean> + </list> + </property> + <property name="valueFields"> + <list> + <bean class="org.apache.ignite.cache.store.jdbc.JdbcTypeField"> + <property name="databaseFieldName" value="VAL"/> + <property name="databaseFieldType"> + <util:constant static-field="java.sql.Types.BINARY"/> + </property> + <property name="javaFieldType" value="java.util.UUID"/> + </bean> + </list> + </property> + </bean> + + <bean class="org.apache.ignite.cache.store.jdbc.JdbcType"> + <property name="databaseSchema" value="PUBLIC"/> + <property name="databaseTable" value="TIMESTAMP_ENTRIES"/> + <property name="keyType" value="java.sql.Timestamp"/> + <property name="valueType" value="java.lang.Integer"/> + <property name="keyFields"> + <list> + <bean class="org.apache.ignite.cache.store.jdbc.JdbcTypeField"> + <property name="databaseFieldName" value="KEY"/> + <property name="databaseFieldType"> + <util:constant static-field="java.sql.Types.TIMESTAMP"/> + </property> + <property name="javaFieldType" value="java.sql.Timestamp"/> + </bean> + </list> + </property> + <property name="valueFields"> + <list> + <bean class="org.apache.ignite.cache.store.jdbc.JdbcTypeField"> + <property name="databaseFieldName" value="VAL"/> + <property name="databaseFieldType"> + <util:constant static-field="java.sql.Types.INTEGER"/> + </property> + <property name="javaFieldType" value="java.lang.Integer"/> + </bean> + </list> + </property> + </bean> +</beans>
