本文整理汇总了Java中org.apache.ignite.configuration.CacheConfiguration.setKeyConfiguration方法的典型用法代码示例。如果您正苦于以下问题:Java CacheConfiguration.setKeyConfiguration方法的具体用法?Java CacheConfiguration.setKeyConfiguration怎么用?Java CacheConfiguration.setKeyConfiguration使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.ignite.configuration.CacheConfiguration
的用法示例。
在下文中一共展示了CacheConfiguration.setKeyConfiguration方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: cacheConfiguration
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/**
* @param name Cache name.
* @param clsK Key class.
* @param clsV Value class.
* @return Cache configuration.
*/
@SuppressWarnings("unchecked")
private CacheConfiguration cacheConfiguration(@NotNull String name, String sqlSchema, Class<?> clsK,
Class<?> clsV) {
CacheConfiguration cc = defaultCacheConfiguration();
cc.setName(name);
cc.setCacheMode(CacheMode.PARTITIONED);
cc.setAtomicityMode(CacheAtomicityMode.ATOMIC);
cc.setNearConfiguration(null);
cc.setWriteSynchronizationMode(FULL_SYNC);
cc.setRebalanceMode(SYNC);
cc.setSqlSchema(sqlSchema);
cc.setSqlFunctionClasses(GridQueryParsingTest.class);
cc.setIndexedTypes(clsK, clsV);
if (!QueryUtils.isSqlType(clsK))
cc.setKeyConfiguration(new CacheKeyConfiguration(clsK));
return cc;
}
示例2: cacheConfig
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/**
* @param name Cache name.
* @param partitioned Partition or replicated cache.
* @param escapeSql whether identifiers should be quoted - see {@link CacheConfiguration#setSqlEscapeAll}
* @param idxTypes Indexed types.
* @return Cache configuration.
*/
static CacheConfiguration cacheConfig(String name, boolean partitioned, boolean escapeSql, Class<?>... idxTypes) {
CacheConfiguration res = new CacheConfiguration(DEFAULT_CACHE_NAME)
.setName(name)
.setCacheMode(partitioned ? CacheMode.PARTITIONED : CacheMode.REPLICATED)
.setAtomicityMode(CacheAtomicityMode.ATOMIC)
.setBackups(1)
.setSqlEscapeAll(escapeSql)
.setIndexedTypes(idxTypes);
for (int i = 0; i < idxTypes.length / 2; i++) {
Class<?> keyType = idxTypes[i];
if (!QueryUtils.isSqlType(keyType))
res.setKeyConfiguration(new CacheKeyConfiguration(keyType));
}
return res;
}
示例3: main
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/**
* Executes example.
*
* @param args Command line arguments, none required.
*/
public static void main(String[] args) {
try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
System.out.println();
System.out.println(">>> Binary objects cache query example started.");
CacheConfiguration<Integer, Organization> orgCacheCfg = new CacheConfiguration<>();
orgCacheCfg.setCacheMode(CacheMode.PARTITIONED);
orgCacheCfg.setName(ORGANIZATION_CACHE_NAME);
orgCacheCfg.setQueryEntities(Arrays.asList(createOrganizationQueryEntity()));
CacheConfiguration<EmployeeKey, Employee> employeeCacheCfg = new CacheConfiguration<>();
employeeCacheCfg.setCacheMode(CacheMode.PARTITIONED);
employeeCacheCfg.setName(EMPLOYEE_CACHE_NAME);
employeeCacheCfg.setQueryEntities(Arrays.asList(createEmployeeQueryEntity()));
employeeCacheCfg.setKeyConfiguration(new CacheKeyConfiguration(EmployeeKey.class));
try (IgniteCache<Integer, Organization> orgCache = ignite.getOrCreateCache(orgCacheCfg);
IgniteCache<EmployeeKey, Employee> employeeCache = ignite.getOrCreateCache(employeeCacheCfg)
) {
if (ignite.cluster().forDataNodes(orgCache.getName()).nodes().isEmpty()) {
System.out.println();
System.out.println(">>> This example requires remote cache nodes to be started.");
System.out.println(">>> Please start at least 1 remote cache node.");
System.out.println(">>> Refer to example's javadoc for details on configuration.");
System.out.println();
return;
}
// Populate cache with sample data entries.
populateCache(orgCache, employeeCache);
// Get cache that will work with binary objects.
IgniteCache<BinaryObject, BinaryObject> binaryCache = employeeCache.withKeepBinary();
// Run SQL query example.
sqlQuery(binaryCache);
// Run SQL query with join example.
sqlJoinQuery(binaryCache);
// Run SQL fields query example.
sqlFieldsQuery(binaryCache);
// Run full text query example.
textQuery(binaryCache);
System.out.println();
}
finally {
// Delete caches with their content completely.
ignite.destroyCache(ORGANIZATION_CACHE_NAME);
ignite.destroyCache(EMPLOYEE_CACHE_NAME);
}
}
}