private ArrayList runQueryOnClientUsingFunc(Function func, String regionName, Set filter,
      String query) {
    ResultCollector rcollector = null;

    // Filter can not be set as null if withFilter() is called.
    if (filter != null) {
      rcollector = FunctionService.onRegion(CacheFactory.getAnyInstance().getRegion(regionName))
          .setArguments(query).withFilter(filter).execute(func);
    } else {
      rcollector = FunctionService.onRegion(CacheFactory.getAnyInstance().getRegion(regionName))
          .setArguments(query).execute(func);
    }
    Object result = rcollector.getResult();
    assertTrue(result instanceof ArrayList);

    // Results from multiple nodes.
    ArrayList resultList = (ArrayList) result;
    resultList.trimToSize();
    List queryResults = null;

    if (resultList.size() != 0 && resultList.get(0) instanceof ArrayList) {
      queryResults = new ArrayList();
      for (Object obj : resultList) {
        if (obj != null) {
          queryResults.addAll((ArrayList) obj);
        }
      }
    }

    return (ArrayList) queryResults;
  }
Run query using a function executed by client on a region on server with filter.

@return ArrayList of results
geode-core/src/distributedTest/java/org/apache/geode/cache/query/dunit/QueryUsingFunctionContextDUnitTest.java