THIS IS A TEST INSTANCE. ALL YOUR CHANGES WILL BE LOST!!!!
/** * Query entity is a description of {@link IgniteCache cache} entry (composed of key and value) * in a way of how it must be indexed and can be queried. */ public class QueryEntity { private String keyType; private String valType; // Map of field names to type names. private LinkedHashMap<String, String> flds; // Collection of indexes. private Collection<QueryIndex> idxs; // In addition to the obvious getters and setters, // we should also have these convenience methods. // All these methods should throw an exception // in case if a duplicate field or index already exists. public void addField(String name, String type); public void addField(String name, Class<?> type); public void addIndex(QueryIndex idx); } // I only show constructors here, but we should also have // corresponding setter methods. public class QueryIndex { private LinkedHashMap<String, Boolean> fields; private QueryIndexType idxType; // Creates index for one field. // // If index is sorted, then ascending sorting is used by default. // To specify sort order, use the next method. // // This constructor should also have a corresponding setter method. public QueryIndex(String field, QueryIndexType type) {...} // Creates index for one field. The last boolean parameter // is ignored for non-sorted indexes. // // This constructor should also have a corresponding setter method. public QueryIndex(String field, QueryIndexType type, boolean asc) {...} // Creates index for multiple fields. // // If index is sorted, then ascending sorting is used by default. // To specify sort order, use the next method. // // This constructor should also have a corresponding setter method. public QueryIndex(Collection<String> fields, QueryIndexType type) {...} // Creates index for multiple fields. // Fields are passed in as a map, with field name as a key and sort order // as a value (true for ascending). The value is ignored for non-sorted indexes. // // This constructor is useful for sorted indexes, where it is necessary to specify // a separate sort order for each field. // // This constructor should also have a corresponding setter method. public QueryIndex(LinkedHashMap<String, Boolean> fields, QueryIndexType type) {...} // Basic getters. public LinkedHashMap<String, Boolean> getFields(); public QueryIndexType getIndexType(); public List<String> getFieldNames(); public boolean hasField(String field); // Returns null if field does not exist. public Boolean getSortOrder(String field); } enum QueryIndexType { SORTED, FULLTEXT, GEOSPATIAL } //***** Design for CacheJdbcPojoStore configuration. *****// // Description of how field declared in database and in cache. public class CacheJdbcPojoStoreTypeField implements Serializable { /** Field JDBC type in database. */ private int dbFieldType; /** Field name in database. */ private String dbFieldName; /** Field java type. */ private Class<?> javaFieldType; /** Field name in java object. */ private String javaFieldName; ... } // Description for type that could be stored into database by store. public class CacheJdbcPojoStoreType implements Serializable { /** Cache name. */ private String cacheName; /** 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; /** List of fields descriptors for key object. */ @GridToStringInclude private CacheJdbcPojoStoreTypeField[] keyFields; /** Value class used to store value in cache. */ private String valType; /** List of fields descriptors for value object. */ @GridToStringInclude private CacheJdbcPojoStoreTypeField[] valFields; /** If {@code true} object is stored as IgniteObject. */ private boolean keepSerialized; ... } // JDBC POJO store configuration. public class CacheJdbcPojoStoreConfiguration implements Serializable { /** Maximum batch size for writeAll and deleteAll operations. */ private int batchSz = DFLT_BATCH_SIZE; /** Name of data source bean. */ private String dataSrcBean; /** Database dialect. */ private JdbcDialect dialect; /** Max workers thread count. These threads are responsible for load cache. */ private int maxPoolSz = Runtime.getRuntime().availableProcessors(); /** Maximum write attempts in case of database error. */ private int maxWrtAttempts = DFLT_WRITE_ATTEMPTS; /** Parallel load cache minimum threshold. If {@code 0} then load sequentially. */ private int parallelLoadCacheMinThreshold = DFLT_PARALLEL_LOAD_CACHE_MINIMUM_THRESHOLD; /** Types that store could process. */ private CacheJdbcPojoStoreType[] types; ... } // POJO Store public class CacheJdbcPojoStoreFactory<K, V> implements Factory<CacheJdbcPojoStore<K, V>> { /** POJO store configuration. */ private CacheJdbcPojoStoreConfiguration cfg; /** Data source. */ private transient DataSource dataSrc; /** Application context. */ @SpringApplicationContextResource private transient Object appCtx; ... }