com.gemstone.gemfire.cache.query.Query类的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(8.2k)|赞(0)|评价(0)|浏览(114)

本文整理了Java中com.gemstone.gemfire.cache.query.Query类的一些代码示例,展示了Query类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query类的具体详情如下:
包路径:com.gemstone.gemfire.cache.query.Query
类名称:Query

Query介绍

[英]Interface for query objects. Supports execution of queries with optional parameters.
[中]查询对象的接口。支持使用可选参数执行查询。

代码示例

代码示例来源:origin: io.snappydata/gemfire-junit

public void testBug35905KeySet() throws Exception{
 Query query = CacheUtils.getQueryService().newQuery("select distinct * from /Portfolios.keySet where toString = '1'");
 Collection result = (Collection)query.execute();
 if(!result.iterator().next().equals("1"))
  fail(query.getQueryString());
}

代码示例来源:origin: io.snappydata/gemfire-junit

public void test007IsCompiled() {
 System.out.println("testIsCompiled");
 String queryStr = "SELECT DISTINCT * FROM /root";
 Query q = CacheUtils.getQueryService().newQuery(queryStr);
 if(q.isCompiled())
  fail("Query.isCompiled() returns true for non-compiled query");
}

代码示例来源:origin: org.apache.geode/gemfire-core

private List<?> getRemoveKeys(ExecutionHandlerContext context, ByteArrayWrapper key, int startRank, int stopRank) throws Exception {
  Query query = getQuery(key, SortedSetQuery.ZREMRANGEBYRANK, context);
  Object[] params = {stopRank + 1};

  SelectResults<?> results = (SelectResults<?>) query.execute(params);

  return results.asList().subList(startRank, stopRank + 1);
 }
}

代码示例来源:origin: org.apache.geode/gemfire-core

@Override
public String toString(){
 return new StringBuffer()
 .append("QueryThreadTask[StartTime:").append(this.StartTime)
 .append(", queryThread:").append(this.queryThread)
 .append(", threadId:").append(this.queryThread.getId())
 .append(", query:").append(this.query.getQueryString())
 .append(", queryExecutionStatus:").append(this.queryExecutionStatus)
 .append("]").toString();
}

代码示例来源:origin: io.snappydata/gemfire-junit

public void testUntyped() throws QueryException {
 // one untyped iterator is now resolved fine
 Query q = this.qs.newQuery("SELECT DISTINCT * " +
       "FROM /pos " +
       "WHERE ID = 3 ");
 q.execute();
 
 // if there are two untyped iterators, then it's a problem, see bug 32251 and BugTest
 q = this.qs.newQuery("SELECT DISTINCT * FROM /pos, positions WHERE ID = 3");
 try {
  q.execute();
  fail("Expected a TypeMismatchException");
 }
 catch (TypeMismatchException e) {
  // pass
 }
}

代码示例来源:origin: io.snappydata/gemfire-core

@Override
public String toString(){
 return new StringBuffer()
 .append("QueryThreadTask[StartTime:").append(this.StartTime)
 .append(", queryThread:").append(this.queryThread)
 .append(", threadId:").append(this.queryThread.getId())
 .append(", query:").append(this.query.getQueryString())
 .append(", queryExecutionStatus:").append(this.queryExecutionStatus)
 .append("]").toString();
}

代码示例来源:origin: io.snappydata/gemfire-junit

public void testBug35905EntrySet() throws Exception{
 Query query = CacheUtils.getQueryService().newQuery("select distinct key from /Portfolios.entrySet , value.positions.values   where value.ID = 1 and key = '1'");
 Collection result = (Collection)query.execute();
 if(!result.iterator().next().equals("1"))
  fail(query.getQueryString());
}

代码示例来源:origin: org.apache.geode/gemfire-core

private List<Struct> getRange(ExecutionHandlerContext context, ByteArrayWrapper key, int start, int stop, Region r) throws Exception {

  Query query = getQuery(key, ListQuery.LRANGE, context);

  Object[] params = {Integer.valueOf(stop + 1)};
  SelectResults<Struct> results = (SelectResults<Struct>) query.execute(params);
  int size = results.size();
  if (results == null || size <= start) {
   return null;
  }

  return results.asList().subList(start, size);
 }
}

代码示例来源:origin: io.snappydata/gemfire-junit

public void test000GetQueryString() {
 System.out.println("testGetQueryString");
 String queryStr = "SELECT DISTINCT * FROM /root";
 Query q = CacheUtils.getQueryService().newQuery(queryStr);
 if(!queryStr.equals(q.getQueryString())){
  fail("Query.getQueryString() returns different query string");
 }
}

代码示例来源:origin: io.snappydata/gemfire-junit

public void testGetKeys() throws Exception{
 Query query = CacheUtils.getQueryService().newQuery("select distinct * from /Portfolios.keys where toString = '1'");
 Collection result = (Collection)query.execute();
 if(!result.iterator().next().equals("1"))
  fail(query.getQueryString());
}

代码示例来源:origin: io.snappydata/gemfire-junit

/**
 * Tests that hash index is used and that it returns the correct result
 * @throws Exception
 */
private void helpTestHashIndexNotUsedInRangeQuery() throws Exception {
 SelectResults results = (SelectResults)qs.newQuery("Select * FROM /portfolios p where p.ID < 2").execute();
 assertFalse(observer.indexUsed);
}

代码示例来源:origin: io.snappydata/gemfire-junit

public void testMiscQueries() throws Exception{
 String testData[][] ={
  {"/Portfolios.fullPath","/Portfolios"},
  {"/Portfolios.size","4"},
  {"/Portfolios.size > 0","true"},
 };
 for(int i=0;i<testData.length;i++){
  Query query = CacheUtils.getQueryService().newQuery(testData[i][0]);
  String result = query.execute().toString();
  if(!result.equals(testData[i][1]))
   fail(query.getQueryString());
 }
}

代码示例来源:origin: org.apache.geode/gemfire-core

private Integer getIndexKey(ExecutionHandlerContext context, ByteArrayWrapper key, int index) throws Exception {
  Query query = getQuery(key, ListQuery.LSET, context);

  Object[] params = {Integer.valueOf(index + 1)};
  
  SelectResults<Integer> results = (SelectResults<Integer>) query.execute(params);
  int size = results.size();
  if (results == null || size == 0) {
   return null;
  }

  return results.asList().get(size - 1);
 }
}

代码示例来源:origin: io.snappydata/gemfire-junit

public void testFALSE() throws Exception{
 Query query = CacheUtils.getQueryService().newQuery("SELECT DISTINCT * FROM /Portfolios where FALSE");
 Object result = query.execute();
 if(!(result instanceof Collection) || ((Collection)result).size() != 0)
  fail(query.getQueryString());
}

代码示例来源:origin: io.snappydata/gemfire-junit

public void testMiscSet() throws Exception {
 Query q = CacheUtils.getQueryService().newQuery(" $1 IN SET(1, 'a', $2, $3, $4, $5)");
 Object params[] = {null, new Integer(0), "str", null, new Object()};
 
 for(int i=1;i<params.length;i++){
  params[0] = params[i];
  Object result = q.execute(params);
  System.out.println(Utils.printResult(result));
  if(!result.equals(Boolean.TRUE))
   fail("Failed for Mix set with IN operator");
 }
 
}

代码示例来源:origin: io.snappydata/gemfire-junit

public void testNULL() throws Exception{
  Query query = CacheUtils.getQueryService().newQuery("SELECT DISTINCT * FROM /Portfolios where NULL");
  Object result = query.execute();
  if(!(result instanceof Collection) || ((Collection)result).size() != 0)
   fail(query.getQueryString());
  
  query = CacheUtils.getQueryService().newQuery("SELECT DISTINCT * FROM NULL");
  result = query.execute();
  if(!result.equals(QueryService.UNDEFINED))
   fail(query.getQueryString());
 }
}

代码示例来源:origin: io.snappydata/gemfire-junit

public Object runQuery(Object array, int index) throws Exception{
 Query q = CacheUtils.getQueryService().newQuery("$1[$2]");
 Object params[] = {array, new Integer(index)};
 Object result = q.execute(params);
 System.out.println(Utils.printResult(result));
 return result;
}

代码示例来源:origin: io.snappydata/gemfire-junit

public void testTRUE() throws Exception{
 Query query = CacheUtils.getQueryService().newQuery("SELECT DISTINCT * FROM /Portfolios where TRUE");
 Object result = query.execute();
 if(!(result instanceof Collection) || ((Collection)result).size() != 4)
  fail(query.getQueryString());
}

代码示例来源:origin: io.snappydata/gemfire-junit

public void testShortNumSet() throws Exception {
 Short num = Short.valueOf("1");
 Object params[]=new Object[1];
 params[0]= num;
 
 Query q = CacheUtils.getQueryService().newQuery("$1 IN SET(1,2,3)");
 
 Object result = q.execute(params);
 System.out.println(Utils.printResult(result));
 if(!result.equals(Boolean.TRUE))
  fail("Failed for ShortNum with IN operator");
}

代码示例来源:origin: io.snappydata/gemfire-junit

public void testUNDEFINED() throws Exception{
 Query query = CacheUtils.getQueryService().newQuery("SELECT DISTINCT * FROM /Portfolios where UNDEFINED");
 Object result = query.execute();
 if(!(result instanceof Collection) || ((Collection)result).size() != 0)
  fail(query.getQueryString());
 
 query = CacheUtils.getQueryService().newQuery("SELECT DISTINCT * FROM UNDEFINED");
 result = query.execute();
 if(!result.equals(QueryService.UNDEFINED))
  fail(query.getQueryString());
}

相关文章