Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Our goal is to define a single place where all type information will reside. We define TypeConfiguration class which will have multiple type extensions for different features. This configuration will be set for the whole Ignite instance with ability to override it on per-cache level.

TypeConfiguration

Code Block
languagejava
public class TypeConfiguration implements Serializable {
    /**
 *
 Serial version UID. */
public class TypeConfiguration {    private static final long serialVersionUID = 0L;
 
    /** 
     * Type name. Can be one of three things:
     * - Simple type name. Use it when type is not in classpath;
     * - Fully qualified type name. Prefer it when type is in classpath to avoid conflicts. 
     *   E.g. "my.package.employee.Address", "my.package.organization.Address";
     * - Package wildcard. Must ends with ".*" in this case. E.g. "my.package.*".
     */
    private String typeName;
 
    /** Affinity key field nameUsed to configure single type when it is not in classpath. */
    public privatevoid setTypeName(String affKeyFieldName);
 
    /** Portable configuration (only needed if portable marshaller is used) Used to configure specific class. Both typeName and packageName fields will be set. */
    public void setClass(Class);
 
    /** Affinity key field name. */
    private PortableConfigurationString portableCfgaffKeyFieldName;

    /** Persistence configuration (only needed if {@link org.apache.ignite.cache.store.jdbc.CacheJdbcPojoStore} is used). */
    private PersistenceConfiguration persistenceCfg;
} Type info extensions. */
    private Map<Class<? extends TypeInfo>, ? extends TypeInfo> typeInfos;

    public TypeInfo[] getTypeInfo() {...} 
    public void setTypeInfo(TypeInfo... typeInfos) {...}  

    public <T extends TypeInfo> T getTypeInfo(Class<T> infoCls) {...}
}

Notes:

  • TypeInfo's are set as varargs to follow general Ignite rules (e.g. IgniteConfiguration.setCacheConfiguration()).
  • TypeInfo getter/setter do not have "s" at the end to follow general Ignite rules (e.g. IgniteConfiguration.setCacheConfiguration());
  • Shouldn't we move "affKeyFieldName" to another TypeInfo, e.g. AffinityKeyTypeInfo?

TypeInfo

Code Block
languagejava
public interface TypeInfo extends Serializable {
    /** Whether implemenation supports single type. */
    bool supportSingleType();
 
    /** Whether implementation supports multiple types. */
    bool supportMultipleTypes();
}

Notes:

  • Package configuration are only supported by PortableTypeInfo for now. For this reason it makes sense to add "support*" methods to prevent misconfiguration.

PersistenceTypeInfo

Code Block
languagejava
public class PersistenceTypeInfo implements TypeInfo {
    /**
 *
 Serial version UID. */
public class PersistenceTypeConfiguration {    private static final long serialVersionUID = 0L;

    /** Schema name in database. */
    private String dbSchema;

    /** Table name in database. */
    private String dbTbl;

    /** Persisted fields. */
    @GridToStringInclude
    private Collection<CacheTypeFieldMetadata>Collection<PersistenceField> fields;
}
Code Block
languagejava
public class PersistenceField implements Serializable {
    /** Serial version UID. */
    private static final long serialVersionUID = 0L;

    /** Column name in database. */
    private String dbFieldName;

    /** Column JDBC type in database. */
    private int dbFieldType;

    /** Field name in java object. */
    private String javaFieldName;

    /** Corresponding java type. */
    private Class<?> javaFieldType;
}

Notes:

  • Package wildcards are not supported.

PortableTypeInfo

Code Block
languagejava
public class PortableTypeConfigurationPortableTypeInfo implements TypeInfo {
    /** IDSerial version mapperUID. */
    private PortableIdMapper idMapper static final long serialVersionUID = 0L;

    /** ID Serializermapper. */
    private PortableSerializerPortableIdMapper serializeridMapper;

    /** Use timestamp flagSerializer. */
    private BooleanPortableSerializer useTsserializer;

    /** MetaPortable datametadata enabled flag. When disabled queries and pretty toString() will not work. */
    private Boolean metaDataEnabled = true;
}

Notes:

  • Supported for both types and package wildcards.

QueryTypeInfo

Code Block
languagejava
public class QueryTypeInfo implements TypeInfo {
    /** Serial version UID. */
    private static final *
long serialVersionUID = 0L;

    /** Fields. */
public    classprivate QueryTypeConfiguration {QueryField[] flds;
 
    /** KeyGroup typeindexes. */
    private StringQueryCompoundIndex[] keyTypegrpIdxs;
 
    /** Value type Fields to index as text. */
    private String[] valueTypetxtIdxs;    
}
Code Block
languagejava
public class QueryField implements Serializable {
    /** Serial version UID. * Field name-to-type map to be queried, in addition to indexed fields. */
    @GridToStringInclude/
    private static final long serialVersionUID = 0L;

    /** Field name. */
    private String name;
 
    /** Field class. */
    private Map<String, Class<?>> qryFldsClass cls;
 
    /** FieldWhether name-to-type mapindex tothe indexfield. inDisabled ascendingby orderdefault. */
    private QueryFieldIndexType idxTyp = QueryFieldIndexType.NONE;
}
Code Block
languagejava
public enum QueryFieldIndexType @GridToStringInclude
    private Map<String, Class<?>> ascFlds;
{
    /** Do not index the field. */
    NONE,
 
    /** Field name-to-type map to index in descending Ascending order. */ 
    ASC,
 
    /** Descending order. */ 
    DESC
}
Code Block
languagejava
public class QueryCompoundIndex implements Serializable {
    /** Serial version UID. */@GridToStringInclude
    private Map<String, Class<?>> descFldsstatic final long serialVersionUID = 0L;

    /** Index name. * Fields to index as text/
    String name;
 
    /** Participating fields. */
    @GridToStringInclude private QueryFieldInfo[] flds;
}

Notes

  • QueryFieldInfo.cls is a problem for non-Java users, because they have to write ugly things like "java.lang.Integer" which is very hard to understand for non-Java users. Lets switch to enum here?

IgniteConfiguration

Code Block
languagejava
public class IgniteConfiguration {
    /** Type configurations. */
    private Collection<String>TypeConfiguration[] txtFldstypeCfg;
 
    public TypeConfiguration[] getTypeConfiguration();
    public void  /** Fields to create group indexes forsetTypeConfiguration(TypeConfiguration... typeCfg);
}

CacheConfiguration

Code Block
languagejava
public class CacheConfiguration {
    /** Type configurations. */
    @GridToStringIncludeprivate TypeConfiguration[] typeCfg;
 
    private Map<String, LinkedHashMap<String, IgniteBiTuple<Class<?>, Boolean>>> grpspublic TypeConfiguration[] getTypeConfiguration();
    public void setTypeConfiguration(TypeConfiguration... typeCfg);
}