本文整理汇总了Java中com.tangosol.net.NamedCache.addIndex方法的典型用法代码示例。如果您正苦于以下问题:Java NamedCache.addIndex方法的具体用法?Java NamedCache.addIndex怎么用?Java NamedCache.addIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.tangosol.net.NamedCache
的用法示例。
在下文中一共展示了NamedCache.addIndex方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ensureIndexes
import com.tangosol.net.NamedCache; //导入方法依赖的package包/类
protected void ensureIndexes(NamedCache cache) {
if (indexes != null && indexes.size() > 0) {
for (ValueExtractor ex : indexes) {
cache.addIndex(ex, true, null);
log.debug("applied index: {}", ex);
}
}
}
示例2: givenSomeDataAndIndexesInCache
import com.tangosol.net.NamedCache; //导入方法依赖的package包/类
private static NamedCache givenSomeDataAndIndexesInCache(String cacheName, int count) {
NamedCache cache = givenSomeDataInCache(cacheName, count);
if (cacheName.contains("java")) {
cache.addIndex(TestType.INTEGER_PROP_JAVA_EXTRACTOR, true, null);
cache.addIndex(TestType.STRING_PROP_JAVA_EXTRACTOR, false, null);
} else {
cache.addIndex(TestType.INTEGER_PROP_POF_EXTRACTOR, true, null);
cache.addIndex(TestType.STRING_PROP_POF_EXTRACTOR, false, null);
}
return cache;
}
示例3: main
import com.tangosol.net.NamedCache; //导入方法依赖的package包/类
public static void main(String... args) throws Exception {
System.setProperty("tangosol.coherence.cacheconfig", "client-config.xml");
NamedCache cache = CacheFactory.getCache("dist-cache");
int size = 100000;
ValueExtractor extractor = new CacheObjectBloomExtractor();
cache.addIndex(extractor, false, null);
System.out.println("Starting cache puts..");
for (int i = 0; i < size; i++) {
cache.put(UUID.randomUUID().toString(), new CacheObject("Value" + i));
}
Random random = new Random(0L);
System.out.println("Starting random gets..");
long start = System.nanoTime();
for (int i = 0; i < 1000; i++) {
String key = "Value" + random.nextInt(size);
int test = (Integer) cache.aggregate(new BloomEqualsFilter(extractor, key), new Count());
if (test != 1) {
throw new RuntimeException("Failed count, on key: " + key + ": " + test);
}
}
long end = System.nanoTime();
System.out.println("Get time: " + ((end - start) / NANO_TO_MILLISECONDS));
}
示例4: main
import com.tangosol.net.NamedCache; //导入方法依赖的package包/类
public static void main(String... args) throws Exception {
System.setProperty("tangosol.coherence.cacheconfig", "client-config.xml");
NamedCache cache = CacheFactory.getCache("dist-cache");
int size = 100000;
ValueExtractor extractor = new CacheObjectExtractor();
cache.addIndex(extractor, false, null);
System.out.println("Starting cache puts..");
for (int i = 0; i < size; i++) {
cache.put(UUID.randomUUID().toString(), new CacheObject("Value" + i));
}
Random random = new Random(0L);
System.out.println("Starting random gets..");
long start = System.nanoTime();
for (int i = 0; i < 1000; i++) {
String key = "Value" + random.nextInt(size);
int test = (Integer) cache.aggregate(new EqualsFilter(extractor, key), new Count());
if (test != 1) {
throw new RuntimeException("Failed count, on key: " + key + ": " + test);
}
}
long end = System.nanoTime();
System.out.println("Get time: " + ((end - start) / NANO_TO_MILLISECONDS));
}