当前位置: 首页>>代码示例>>Java>>正文


Java Cache.getQueryService方法代码示例

本文整理汇总了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;
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:19,代码来源:IndexMaintainceTest.java

示例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();
  }

}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:22,代码来源:IndexMaintenanceTest.java

示例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");
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:23,代码来源:CommandTest.java

示例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());
  }
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:29,代码来源:IndexMaintenanceTest.java

示例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();
  }

}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:16,代码来源:AsynchIndexMaintenanceTest.java

示例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);
  }
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:15,代码来源:QueryUsingFunctionContextDUnitTest.java

示例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();
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:31,代码来源:DistinctResultsWithDupValuesInRegionTest.java

示例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());
  }
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:43,代码来源:IndexMaintenanceTest.java

示例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;
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:28,代码来源:IndexMaintenanceAsynchTest.java

示例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());
  }
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:32,代码来源:IndexMaintenanceTest.java

示例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();
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:30,代码来源:DistinctResultsWithDupValuesInRegionTest.java

示例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();
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:30,代码来源:DistinctResultsWithDupValuesInRegionTest.java

示例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();
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:30,代码来源:DistinctResultsWithDupValuesInRegionTest.java

示例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);
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:8,代码来源:CompactRangeIndexIndexMapTest.java

示例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();
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:30,代码来源:DistinctResultsWithDupValuesInRegionTest.java


注:本文中的com.gemstone.gemfire.cache.Cache.getQueryService方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。