本文整理汇总了Java中com.gemstone.gemfire.cache.Cache.getQueryService方法的典型用法代码示例。如果您正苦于以下问题:Java Cache.getQueryService方法的具体用法?Java Cache.getQueryService怎么用?Java Cache.getQueryService使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.gemstone.gemfire.cache.Cache
的用法示例。
在下文中一共展示了Cache.getQueryService方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
private static void init() {
try {
Cache cache = CacheUtils.getCache();
region = CacheUtils.createRegion("portfolio", Portfolio.class);
region.put("0", new Portfolio(0));
region.put("1", new Portfolio(1));
region.put("2", new Portfolio(2));
region.put("3", new Portfolio(3));
qs = cache.getQueryService();
index = (IndexProtocol) qs.createIndex("statusIndex",
IndexType.FUNCTIONAL, "status", "/portfolio");
assertTrue(index instanceof CompactRangeIndex);
}
catch (Exception e) {
e.printStackTrace();
}
isInitDone = true;
}
示例2: init
import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
private void init() {
idSet = new HashSet();
try {
CacheUtils.startCache();
Cache cache = CacheUtils.getCache();
region = CacheUtils.createRegion("portfolio", Portfolio.class);
region.put("0", new Portfolio(0));
region.put("1", new Portfolio(1));
region.put("2", new Portfolio(2));
region.put("3", new Portfolio(3));
for (int j = 0; j < 6; ++j) {
idSet.add(j + "");
}
qs = cache.getQueryService();
}
catch (Exception e) {
e.printStackTrace();
}
}
示例3: addIndex
import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
/**
* This is called to add a simple index
*/
private void addIndex() {
Log.getLogWriter().info("addIndex-Start");
Cache cache = CacheHelper.getCache();
if (cache != null) {
QueryService queryService = cache.getQueryService();
Region<Object, Object> region = cache.getRegion(getRandomRegion());
String regionPath = region.getFullPath();
Log.getLogWriter().info("addIndex-regionPath=" + regionPath);
try {
queryService.createIndex("index1", "myValue", regionPath);
} catch (Exception e) {
throw new TestException(TestHelper.getStackTrace(e));
}
}
Log.getLogWriter().info("addIndex-End");
}
示例4: test017IndexMaintenanceOnPutAll
import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
/**
* Tests Index maintenance on data loaded via cache loader
* @author Asif
*/
public void test017IndexMaintenanceOnPutAll() {
try {
IndexManager.TEST_RANGEINDEX_ONLY = true;
Cache cache = CacheUtils.getCache();
qs = cache.getQueryService();
region = CacheUtils.createRegion("portfolio1", null);
region.put("1", new Portfolio(1));
Index i1 = qs.createIndex("indx1", IndexType.FUNCTIONAL,
"posvals.secId", "/portfolio1 pf, pf.positions.values posvals ");
Map data = new HashMap();
for(int i = 1 ; i <11;++i) {
data.put(""+i, new Portfolio(i+2));
}
region.putAll(data);
// region.putAll(data);
}
catch (Exception e) {
CacheUtils.getLogger().error(e);
fail(e.toString());
}
}
示例5: init
import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
private void init() {
idSet = new HashSet();
try {
CacheUtils.startCache();
Cache cache = CacheUtils.getCache();
region = CacheUtils.createRegion("portfolio", Portfolio.class, false);
qs = cache.getQueryService();
}
catch (Exception e) {
e.printStackTrace();
}
}
示例6: execute
import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
@Override
public void execute(FunctionContext context) {
Cache cache = CacheFactory.getAnyInstance();
QueryService queryService = cache.getQueryService();
ArrayList allQueryResults = new ArrayList();
String qstr = (String) context.getArguments();
try {
Query query = queryService.newQuery(qstr);
context.getResultSender().lastResult((ArrayList) ((SelectResults) query
.execute((RegionFunctionContext) context)).asList());
} catch (Exception e) {
throw new FunctionException(e);
}
}
示例7: testQueriesOnReplicatedRegionWithIndex
import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
/**
* Test on Replicated Region data
*/
public void testQueriesOnReplicatedRegionWithIndex() {
Cache cache = CacheUtils.getCache();
createReplicatedRegion();
assertNotNull(cache.getRegion(regionName));
assertEquals(numElem * 2, cache.getRegion(regionName).size());
QueryService queryService = cache.getQueryService();
Query query1 = null;
try {
queryService.createIndex("idIndex", "p.ID", "/" + regionName + " p");
for (String queryStr : queries) {
query1 = queryService.newQuery(queryStr);
SelectResults result1 = (SelectResults) query1.execute();
assertEquals(queryStr, numElem * 2, result1.size());
verifyDistinctResults(result1);
}
} catch (Exception e) {
e.printStackTrace();
fail("Query " + query1 + " Execution Failed!");
}
// Destroy current Region for other tests
cache.getRegion(regionName).destroyRegion();
}
示例8: test016IndexMaintenanceOnCacheLoadedData
import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
/**
* Tests Index maintenance on data loaded via cache loader
* @author Asif
*/
public void test016IndexMaintenanceOnCacheLoadedData() {
try {
IndexManager.TEST_RANGEINDEX_ONLY = true;
Cache cache = CacheUtils.getCache();
qs = cache.getQueryService();
region = CacheUtils.createRegion("portfolio1", null);
AttributesMutator am = region.getAttributesMutator();
am.setCacheLoader(new CacheLoader() {
public Object load(LoaderHelper helper) throws CacheLoaderException {
String key = (String)helper.getKey();
Portfolio p = new Portfolio(Integer.parseInt(key));
return p;
}
public void close() {
// TODO Auto-generated method stub
}
});
Index i1 = qs.createIndex("indx1", IndexType.FUNCTIONAL,
"pf.getID()", "/portfolio1 pf");
List keys = new ArrayList();
keys.add("1");
keys.add("2");
keys.add("3");
keys.add("4");
region.getAll(keys);
}
catch (Exception e) {
CacheUtils.getLogger().error(e);
fail(e.toString());
}
}
示例9: init
import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
private static void init(){
try{
String queryString;
Query query;
Object result;
Cache cache = CacheUtils.getCache();
region = CacheUtils.createRegion("portfolios",Portfolio.class, false);
for (int i = 0; i < 4; i++){
region.put(""+i,new Portfolio(i));
}
qs = cache.getQueryService();
index = (IndexProtocol)qs.createIndex("statusIndex", IndexType.FUNCTIONAL,"status","/portfolios");
IndexStatistics stats = index.getStatistics();
assertEquals(4, stats.getNumUpdates());
// queryString= "SELECT DISTINCT * FROM /portfolios p, p.positions.values pos where pos.secId='IBM'";
queryString= "SELECT DISTINCT * FROM /portfolios";
query = CacheUtils.getQueryService().newQuery(queryString);
result = query.execute();
System.out.println(Utils.printResult(result));
}catch(Exception e){
e.printStackTrace();
}
isInitDone = true;
}
示例10: test018Bug43597
import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
public void test018Bug43597() {
try {
IndexManager.TEST_RANGEINDEX_ONLY = true;
Cache cache = CacheUtils.getCache();
qs = cache.getQueryService();
region = CacheUtils.createRegion("portfolio1", null);
Index i1 = qs.createIndex("indx1", IndexType.FUNCTIONAL,
"posvals", "/portfolio1 pf, pf.getCollectionHolderMap.values posvals ");
Portfolio pf1 = new Portfolio(1);
Map collHolderMap = pf1.getCollectionHolderMap();
collHolderMap.clear();
collHolderMap.put(1, 1);
collHolderMap.put(2, 1);
region.put("1", pf1);
pf1 = new Portfolio(2);
collHolderMap = pf1.getCollectionHolderMap();
collHolderMap.clear();
collHolderMap.put(3, 1);
collHolderMap.put(4, 1);
region.put("1", pf1);
// region.putAll(data);
}
catch (Exception e) {
CacheUtils.getLogger().error(e);
fail(e.toString());
}
}
示例11: testQueriesOnReplicatedRegion
import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
/**
* Test on Replicated Region data
*/
public void testQueriesOnReplicatedRegion() {
Cache cache = CacheUtils.getCache();
createReplicatedRegion();
assertNotNull(cache.getRegion(regionName));
assertEquals(numElem * 2, cache.getRegion(regionName).size());
QueryService queryService = cache.getQueryService();
Query query1 = null;
try {
for (String queryStr : queries) {
query1 = queryService.newQuery(queryStr);
SelectResults result1 = (SelectResults) query1.execute();
assertEquals(queryStr, numElem * 2, result1.size());
verifyDistinctResults(result1);
}
} catch (Exception e) {
e.printStackTrace();
fail("Query " + query1 + " Execution Failed!");
}
// Destroy current Region for other tests
cache.getRegion(regionName).destroyRegion();
}
示例12: testQueriesOnPartitionedRegion
import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
/**
* Test on Partitioned Region data
*/
public void testQueriesOnPartitionedRegion() {
Cache cache = CacheUtils.getCache();
createPartitionedRegion();
assertNotNull(cache.getRegion(regionName));
assertEquals(numElem * 2, cache.getRegion(regionName).size());
QueryService queryService = cache.getQueryService();
Query query1 = null;
try {
for (String queryStr : queries) {
query1 = queryService.newQuery(queryStr);
SelectResults result1 = (SelectResults) query1.execute();
assertEquals(queryStr, numElem * 2, result1.size());
verifyDistinctResults(result1);
}
} catch (Exception e) {
e.printStackTrace();
fail("Query " + query1 + " Execution Failed!");
}
// Destroy current Region for other tests
cache.getRegion(regionName).destroyRegion();
}
示例13: testQueriesOnReplicatedRegionWithSameProjAttr
import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
/**
* Test on Replicated Region data
*/
public void testQueriesOnReplicatedRegionWithSameProjAttr() {
Cache cache = CacheUtils.getCache();
createReplicatedRegion();
assertNotNull(cache.getRegion(regionName));
assertEquals(numElem * 2, cache.getRegion(regionName).size());
QueryService queryService = cache.getQueryService();
Query query1 = null;
try {
for (String queryStr : moreQueries) {
query1 = queryService.newQuery(queryStr);
SelectResults result1 = (SelectResults) query1.execute();
assertEquals(queryStr, numElem, result1.size());
verifyDistinctResults(result1);
}
} catch (Exception e) {
e.printStackTrace();
fail("Query " + query1 + " Execution Failed!");
}
// Destroy current Region for other tests
cache.getRegion(regionName).destroyRegion();
}
示例14: testLDMIndexCreation
import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
public void testLDMIndexCreation() throws Exception {
Cache cache = CacheUtils.getCache();
Region region = createLDMRegion("portfolios");
QueryService queryService = cache.getQueryService();
Index index = queryService.createIndex("IDIndex", "p.ID", "/portfolios p, p.positions ps");
assertTrue(index instanceof CompactRangeIndex);
}
示例15: testQueriesOnReplicatedRegionWithNullProjAttr
import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
/**
* Test on Replicated Region data
*/
public void testQueriesOnReplicatedRegionWithNullProjAttr() {
Cache cache = CacheUtils.getCache();
createLocalRegionWithNullValues();
assertNotNull(cache.getRegion(regionName));
assertEquals(numElem * 2, cache.getRegion(regionName).size());
QueryService queryService = cache.getQueryService();
Query query1 = null;
try {
for (String queryStr : moreQueries) {
query1 = queryService.newQuery(queryStr);
SelectResults result1 = (SelectResults) query1.execute();
cache.getLogger().fine(result1.asList().toString());
assertEquals(queryStr, numElem, result1.size());
verifyDistinctResults(result1);
}
} catch (Exception e) {
e.printStackTrace();
fail("Query " + query1 + " Execution Failed!");
}
// Destroy current Region for other tests
cache.getRegion(regionName).destroyRegion();
}