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


Java SelectResults类代码示例

本文整理汇总了Java中com.gemstone.gemfire.cache.query.SelectResults的典型用法代码示例。如果您正苦于以下问题:Java SelectResults类的具体用法?Java SelectResults怎么用?Java SelectResults使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SelectResults类属于com.gemstone.gemfire.cache.query包,在下文中一共展示了SelectResults类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: executeRangeQueryWithoutDistinct

import com.gemstone.gemfire.cache.query.SelectResults; //导入依赖的package包/类
private int executeRangeQueryWithoutDistinct( int expResults){
  String[] queries = { "181" };
  int results = 0;
  for (Object result :  utils.executeQueriesWithoutDistinct(queries)) {
    if (result instanceof SelectResults) {
     Collection<?> collection = ((SelectResults<?>) result).asList();
     results = collection.size();
     assertEquals(expResults, results);
     List expectedIds = new ArrayList(Arrays.asList( 10, 9, 8, 7, 6, 5, 4, 3, 3 ));
     for (Object e : collection) {
       if(e instanceof Portfolio){
         assertTrue(expectedIds.contains(((Portfolio) e).getID()));
         expectedIds.remove((Integer)((Portfolio) e).getID());
       }
     }
   }
 }
  return results;
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:20,代码来源:CompactRangeIndexTest.java

示例2: testMapIndexUsableQueryOnEmptyRegion

import com.gemstone.gemfire.cache.query.SelectResults; //导入依赖的package包/类
public void testMapIndexUsableQueryOnEmptyRegion() throws Exception
{

  QueryService qs;
  qs = CacheUtils.getQueryService();
  LocalRegion testRgn = (LocalRegion)CacheUtils.createRegion("testRgn", null);
  Index i1 = qs.createIndex("Index1", IndexType.FUNCTIONAL,
      "objs.maap['key2','key3']", "/testRgn objs");
  qs = CacheUtils.getQueryService();
  // Execute Queries without Indexes
  Query q = CacheUtils.getQueryService().newQuery(
      "SELECT DISTINCT * FROM /testRgn itr1  WHERE itr1.maap['key2'] >= 3 ");
  SelectResults sr = (SelectResults)q.execute();
  assertTrue(sr.isEmpty());

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

示例3: testBug40428_2

import com.gemstone.gemfire.cache.query.SelectResults; //导入依赖的package包/类
public void testBug40428_2() throws Exception {
  Object shortData1 = new Object() {
    public short shortField = 4;
  };
  Object shortData2 = new Object() {
    public short shortField = 5;
  };

  Region region = CacheUtils.createRegion("shortFieldTest", Object.class);
  region.put("0", shortData1);
  QueryService qs = CacheUtils.getQueryService();
  String qry = "select * from /shortFieldTest.entries sf where sf.value.shortField < 10 ";
  qs.createIndex("shortIndex", IndexType.FUNCTIONAL, "value.shortField",
      "/shortFieldTest.entries");
  region.put("1", shortData2);
  Query query = null;
  Object result = null;

  query = qs.newQuery(qry);

  SelectResults rs = (SelectResults)query.execute();
  assertEquals(rs.size(), 2);
  
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:25,代码来源:MiscTest.java

示例4: testOrderByQuery

import com.gemstone.gemfire.cache.query.SelectResults; //导入依赖的package包/类
public void testOrderByQuery() throws Exception
{
  Region region = PartitionedRegionTestHelper.createPartitionedRegion(
      regionName, "100", 0);
  String[] values = new String[100];
  for (int j = 0; j < 100; j++) {
    values[j] = new String(""+ j);
  }
  PRQueryProcessor.TEST_NUM_THREADS = 10;
  try {
    populateData(region, values);

    String queryString = "Select distinct p from /" + region.getName() + " p order by p";
    Query query = region.getCache().getQueryService().newQuery(queryString);
    SelectResults sr = (SelectResults)query.execute();

    Assert.assertTrue(sr.size() == 100);
  } finally {
    PRQueryProcessor.TEST_NUM_THREADS = 0;
    region.close();
  }
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:23,代码来源:PRQueryNumThreadsJUnitTest.java

示例5: getSubsetResults

import com.gemstone.gemfire.cache.query.SelectResults; //导入依赖的package包/类
@Override
  protected Object getSubsetResults(int fetchSize)
{
	SelectResults sr2;
	CollectionType type = sr.getCollectionType();
	ObjectType elementType = type.getElementType();
	if (elementType.isStructType()) {
		sr2 = new StructBag();
	} else {
		if (isPriorTo6011AndNot57()) { // 6.0 - 6.0.1
			sr2 = new GfshResultsBag();
		} else {
			sr2 = new ResultsBag();
		}
	}
	sr2.setElementType(elementType);

	int count = 0;
	while (count < fetchSize && iterator.hasNext()) {
		Object object = iterator.next();
		sr2.add(object);
		count++;
	}
	returnedSize += count;
	return sr2;
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:27,代码来源:QueryTask.java

示例6: evaluateQuery

import com.gemstone.gemfire.cache.query.SelectResults; //导入依赖的package包/类
/**
 * Applies the query on the event.
 * This method takes care of the performance related changed done to improve 
 * the CQ-query performance. When CQ-query is executed first time, it saves the 
 * query related information in the execution context and uses that info in later 
 * executions. 
 * @param cQuery
 * @param event
 * @return boolean
 */
private boolean evaluateQuery(CqQueryImpl cQuery, Object[] event) throws Exception {
  ExecutionContext execContext = cQuery.getQueryExecutionContext();
  execContext.reset();
  execContext.setBindArguments(event);
  boolean status = false;
  
  // Check if the CQ query is executed once.
  // If not execute the query in normal way.
  // During this phase the query execution related info are stored in the
  // ExecutionContext.
  if (execContext.getScopeNum() <= 0) {
    SelectResults results = (SelectResults)((DefaultQuery)cQuery.getQuery()).executeUsingContext(execContext);
    if (results != null && results.size() > 0) {
      status = true;
    } 
  } else {
    // Execute using the saved query info (in ExecutionContext).
    // This avoids building resultSet, index look-up, generating build-plans
    // that are not required for; query execution on single object.
    CompiledSelect cs = ((DefaultQuery)(cQuery.getQuery())).getSelect();
    status = cs.evaluateCq(execContext);
  }
  return status;
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:35,代码来源:CqService.java

示例7: compare

import com.gemstone.gemfire.cache.query.SelectResults; //导入依赖的package包/类
/**
 * Sort the array in ascending order of collection sizes.
 */
public int compare(Object obj1, Object obj2) {
  if (!(obj1 instanceof SelectResults) || !(obj2 instanceof SelectResults)) {
    Support.assertionFailed("The objects need to be of type SelectResults");
  }
  int answer = -1;
  SelectResults sr1 = (SelectResults) obj1;
  SelectResults sr2 = (SelectResults) obj2;
  int sizeDifference = sr1.size() - sr2.size();
  if (obj1 == obj2) {
    answer = 0;
  }
  else if (sizeDifference > 0) {
    answer = 1;
  }
  return answer;
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:20,代码来源:SelectResultsComparator.java

示例8: testIMQFailureAsMethodKeysNAInDummyQRegion

import com.gemstone.gemfire.cache.query.SelectResults; //导入依赖的package包/类
/**
 * Test the Index maiantenance as it may use the method keys() of QRegion
 * instead of DummyQRegion while running an IndexMaintenanceQuery
 * @author Asif
 */
public void testIMQFailureAsMethodKeysNAInDummyQRegion() {
  QueryService qs;
  qs = CacheUtils.getQueryService();
  try{
      Index i1 = qs.createIndex("keyIndex", IndexType.FUNCTIONAL, "ks.hashCode","/portfolios.keys() ks");         
      Region rgn = CacheUtils.getRegion("/portfolios");
      rgn.put("4",new Portfolio(4));
      rgn.put("5",new Portfolio(5));
      System.out.println(((CompactRangeIndex)i1).dump());
      
      Query qr = qs.newQuery("Select distinct keys.hashCode  from /portfolios.keys() keys where keys.hashCode >= $1");
      SelectResults sr = (SelectResults)qr.execute(new Object[]{new Integer(-1)});
      assertEquals(6,sr.size());
  }catch(Exception e) {
    CacheUtils.getLogger().error(e);
    fail("Test failed because of exception. e="+e);        
  }   
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:24,代码来源:IndexCreationTest.java

示例9: testSizeEstimateGTInCompactRangeIndexForNullMap

import com.gemstone.gemfire.cache.query.SelectResults; //导入依赖的package包/类
public void testSizeEstimateGTInCompactRangeIndexForNullMap() throws Exception {
  QueryService qs = CacheUtils.getQueryService();
  LocalRegion testRgn = (LocalRegion)CacheUtils.createRegion("testRgn", null);
  //Create indexes
  Index i1 = qs.createIndex("Index1", IndexType.FUNCTIONAL,
      "p.status", "/testRgn p");
  Index i2 = qs.createIndex("Index2", IndexType.FUNCTIONAL,
      "p.ID", "/testRgn p");
  
  //put values
  testRgn.put(0, new Portfolio(0));
  testRgn.put(1, new Portfolio(1));

  //Set TestHook in RangeIndex
  TestHook hook = new RangeIndexTestHook();
  CompactRangeIndex.setTestHook(hook);
  // Execute Queries without Indexes
  Query q = CacheUtils.getQueryService().newQuery(
      "<trace> SELECT * FROM /testRgn p where p.status = 'active' AND p.ID < 0 ");
  
  //Following should throw NullPointerException.
  SelectResults sr = (SelectResults)q.execute();
  
  assertTrue("RangeIndexTestHook was not hooked for spot 1", ((RangeIndexTestHook)hook).isHooked(1));
  CompactRangeIndex.setTestHook(null);
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:27,代码来源:IndexUseTest.java

示例10: lockedQuery

import com.gemstone.gemfire.cache.query.SelectResults; //导入依赖的package包/类
@Override
void lockedQuery(Object key, int operator, Collection results,
    CompiledValue iterOps, RuntimeIterator runtimeItr,
    ExecutionContext context, List projAttrib,
    SelectResults intermediateResults, boolean isIntersection)
    throws TypeMismatchException, FunctionDomainException,
    NameResolutionException, QueryInvocationTargetException
{
  Object[] mapKeyAndVal = (Object[])key;
  RangeIndex ri = this.mapKeyToValueIndex.get(mapKeyAndVal[1]);
  if (ri != null) {
    long start = CFactory.nanoTime();
    ri.internalIndexStats.incUsesInProgress(1);
    ri.lockedQuery(mapKeyAndVal[0], operator, results, iterOps, runtimeItr,
        context, projAttrib, intermediateResults, isIntersection);
    ri.internalIndexStats.incNumUses();
    ri.internalIndexStats.incUsesInProgress(-1);
    ri.internalIndexStats.incUseTime(CFactory.nanoTime() - start);
  }
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:21,代码来源:MapRangeIndex.java

示例11: testQueryOnSingleDataStore

import com.gemstone.gemfire.cache.query.SelectResults; //导入依赖的package包/类
/**
 * Tests the execution of query on a PartitionedRegion created on a single
 * data store. <br>
 * 1. Creates a PR with redundancy=0 on a single VM. 2. Puts some test Objects
 * in cache. 3. Fires queries on the data and verifies the result.
 * 
 * @throws Exception
 */
public void testQueryOnSingleDataStore() throws Exception
{
  Region region = PartitionedRegionTestHelper.createPartitionedRegion(
      regionName, "100", 0);
  PortfolioData[] portfolios = new PortfolioData[100];
  for (int j = 0; j < 100; j++) {
    portfolios[j] = new PortfolioData(j);
  }
  try {
    populateData(region, portfolios);

    String queryString = "ID < 5";
    SelectResults resSet = region.query(queryString);
    Assert.assertTrue(resSet.size() == 5);

    queryString = "ID > 5 and ID <=15";
    resSet = region.query(queryString);
    Assert.assertTrue(resSet.size() == 10);
  } finally { 
    region.close();
  }
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:31,代码来源:PRQueryJUnitTest.java

示例12: testSizeEstimateGTInRangeIndexForNullMap

import com.gemstone.gemfire.cache.query.SelectResults; //导入依赖的package包/类
public void testSizeEstimateGTInRangeIndexForNullMap() throws Exception {
  QueryService qs = CacheUtils.getQueryService();
  LocalRegion testRgn = (LocalRegion)CacheUtils.createRegion("testRgn", null);
  //Create indexes
  Index i1 = qs.createIndex("Index1", IndexType.FUNCTIONAL,
      "p.status", "/testRgn p, p.positions");
  Index i2 = qs.createIndex("Index2", IndexType.FUNCTIONAL,
      "p.ID", "/testRgn p, p.positions");
  
  //put values
  testRgn.put(0, new Portfolio(0));
  testRgn.put(1, new Portfolio(1));

  //Set TestHook in RangeIndex
  TestHook hook = new RangeIndexTestHook();
  RangeIndex.setTestHook(hook);
  // Execute Queries without Indexes
  Query q = CacheUtils.getQueryService().newQuery(
      "<trace> SELECT * FROM /testRgn p, p.positions where p.status = 'active' AND p.ID < 0 ");
  
  //Following should throw NullPointerException.
  SelectResults sr = (SelectResults)q.execute();
  
  assertTrue("RangeIndexTestHook was not hooked for spot 1", ((RangeIndexTestHook)hook).isHooked(1));
  RangeIndex.setTestHook(null);
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:27,代码来源:IndexUseTest.java

示例13: testIndexOnCommitForPut

import com.gemstone.gemfire.cache.query.SelectResults; //导入依赖的package包/类
/**
 * verify that queries on indexes work with transaction
 * @see bug#40842
 * @throws Exception
 */
public void testIndexOnCommitForPut() throws Exception {
  AttributesFactory af = new AttributesFactory();
  af.setDataPolicy(DataPolicy.REPLICATE);
  Region region = cache.createRegion("sample", af.create());
  qs.createIndex("foo", IndexType.FUNCTIONAL, "age", "/sample");
  Context ctx = cache.getJNDIContext();
  UserTransaction utx = (UserTransaction)ctx.lookup("java:/UserTransaction");
  Integer x = new Integer(0);
  utx.begin();
  region.create(x, new Person("xyz", 45));
  utx.commit();
  Query q = qs.newQuery("select * from /sample where age < 50");
  assertEquals(1, ((SelectResults)q.execute()).size());
  Person dsample = (Person)CopyHelper.copy(region.get(x));
  dsample.setAge(55);
  utx.begin();
  region.put(x, dsample);
  utx.commit();
  System.out.println((region.get(x)));
  assertEquals(0, ((SelectResults) q.execute()).size());
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:27,代码来源:QueryAndJtaTest.java

示例14: filterEvaluate

import com.gemstone.gemfire.cache.query.SelectResults; //导入依赖的package包/类
/**
 * Asif : Evaluates as a filter taking advantage of indexes if appropriate.
 * This function has a meaningful implementation only in CompiledComparison &
 * CompiledUndefined . It is unsupported in other classes. The additional
 * parameters which it takes are a boolean which is used to indicate whether
 * the index result set needs to be expanded to the top level or not. The
 * second is a CompiledValue representing the operands which are only iter
 * evaluatable. The CompiledValue passed will be null except if a
 * GroupJunction has only one filter evaluatable condition & rest are iter
 * operands. In such cases , the iter operands will be evaluated while
 * expanding/cutting down the index resultset
 * 
 * @return SelectResults
 */
public SelectResults filterEvaluate(ExecutionContext context,
    SelectResults intermediateResults, boolean completeExpansionNeeded,
    CompiledValue iterOperands, RuntimeIterator[] indpndntItrs, boolean isIntersection, boolean conditioningNeeded, boolean evalProj)
    throws FunctionDomainException, TypeMismatchException,
    NameResolutionException, QueryInvocationTargetException
{
  // see if we're dependent on the current iterator
  // if not let super handle it
  // RuntimeIterator itr = context.getCurrentIterator();
  // Support.Assert(itr != null);
  if (!isDependentOnCurrentScope(context))
    return super.filterEvaluate(context, intermediateResults);
  IndexInfo[] idxInfo = getIndexInfo(context);
  Support
      .Assert(
          idxInfo != null,
          "a comparison that is dependent, not indexed, and filter evaluated is not possible");
  Support.Assert(idxInfo.length == 1,
      "In operator should have only one index");

  return singleBaseCollectionFilterEvaluate(context, intermediateResults,
      completeExpansionNeeded, iterOperands, idxInfo[0], indpndntItrs, isIntersection,conditioningNeeded,evalProj);

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

示例15: xtestBug32763

import com.gemstone.gemfire.cache.query.SelectResults; //导入依赖的package包/类
public void xtestBug32763() throws FunctionDomainException, TypeMismatchException, NameResolutionException,
    QueryInvocationTargetException, TimeoutException, CacheWriterException
  {
  Region region = CacheUtils.createRegion("pos", 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));
  QueryService qs = CacheUtils.getQueryService();
  String qStr = "SELECT DISTINCT key: key, iD: entry.value.iD, secId: posnVal.secId  FROM /pos.entries entry, entry.value.positions.values posnVal  WHERE entry.value.\"type\" = 'type0' AND posnVal.secId = 'YHOO'";
  Query q = qs.newQuery(qStr);
  SelectResults result = (SelectResults) q.execute();
  StructType type = (StructType) result.getCollectionType().getElementType();
  String names[] = type.getFieldNames();
  List list = result.asList();
  if (list.size() < 1) fail("Test failed as the resultset's size is zero");
  for (int i = 0; i < list.size(); ++i) {
    Struct stc = (Struct) list.get(i);
    if (!stc.get(names[2]).equals("YHOO")) {
      fail("Test failed as the SecID value is not YHOO");
    }
  }
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:24,代码来源:MiscTest.java


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