Internal and experimental! Creates a {@link CacheQuery}, filtered according to the given {@link HSQuery}.

@param hSearchQuery {@link HSQuery}
@return the CacheQuery object which can be used to iterate through results
541071
public <E> CacheQuery<E> getQuery(HSQuery hSearchQuery, IndexedQueryMode queryMode) {
      if (timeoutExceptionFactory != null) {
         hSearchQuery.timeoutExceptionFactory(timeoutExceptionFactory);
      }
      Class<?>[] classes = hSearchQuery.getTargetedEntities().toPojosSet().toArray(new Class[hSearchQuery.getTargetedEntities().size()]);
      queryInterceptor.enableClasses(classes);

      if (queryMode == IndexedQueryMode.BROADCAST) {
         ExecutorService asyncExecutor = queryInterceptor.getAsyncExecutor();
         return new ClusteredCacheQueryImpl<>(new QueryDefinition(hSearchQuery), asyncExecutor, cache, keyTransformationHandler, null);
      } else {
         return new CacheQueryImpl<>(hSearchQuery, cache, keyTransformationHandler);
      }
   }
894347
public Query query(DataRange dataRange) {
        RowPosition startPosition = dataRange.startKey();
        RowPosition stopPosition = dataRange.stopKey();
        Token startToken = startPosition.getToken();
        Token stopToken = stopPosition.getToken();
        boolean isSameToken = startToken.compareTo(stopToken) == 0 && !tokenMapper.isMinimum(startToken);
        BooleanClause.Occur occur = isSameToken ? MUST : SHOULD;
        boolean includeStart = tokenMapper.includeStart(startPosition);
        boolean includeStop = tokenMapper.includeStop(stopPosition);

        SliceQueryFilter sqf;
        if (startPosition instanceof DecoratedKey) {
            sqf = (SliceQueryFilter) dataRange.columnFilter(((DecoratedKey) startPosition).getKey());
        } else {
            sqf = (SliceQueryFilter) dataRange.columnFilter(ByteBufferUtil.EMPTY_BYTE_BUFFER);
        }
        Composite startName = sqf.start();
        Composite stopName = sqf.finish();

        BooleanQuery query = new BooleanQuery();

        if (!startName.isEmpty()) {
            BooleanQuery q = new BooleanQuery();
            q.add(tokenMapper.query(startToken), MUST);
            q.add(clusteringKeyMapper.query(startName, null), MUST);
            query.add(q, occur);
            includeStart = false;
        }

        if (!stopName.isEmpty()) {
            BooleanQuery q = new BooleanQuery();
            q.add(tokenMapper.query(stopToken), MUST);
            q.add(clusteringKeyMapper.query(null, stopName), MUST);
            query.add(q, occur);
            includeStop = false;
        }

        if (!isSameToken) {
            Query rangeQuery = tokenMapper.query(startToken, stopToken, includeStart, includeStop);
            if (rangeQuery != null) query.add(rangeQuery, SHOULD);
        } else if (query.getClauses().length == 0) {
            return tokenMapper.query(startToken);
        }

        return query.getClauses().length == 0 ? null : query;
    }
98819
public static Search get(final String _name)
        throws CacheReloadException
    {
        return AbstractUserInterfaceObject.<Search>get(_name, Search.class, CIAdminUserInterface.Search.getType());
    }
962999
public static LazyQueryContainer createDSLazyQueryContainer(
            final BeanQueryFactory<? extends AbstractBeanQuery<?>> queryFactory) {
        queryFactory.setQueryConfiguration(Collections.emptyMap());
        return new LazyQueryContainer(new LazyQueryDefinition(true, 20, "tagIdName"), queryFactory);
    }
98113
def _query(self, url, xpath):
        
        return self.session.query(CachedRequest).filter(CachedRequest.url == url).filter(CachedRequest.xpath == xpath)
731006
private Cache<QueryCacheKey, Object> getCache() {
      final Cache<QueryCacheKey, Object> cache = lazyCache;

      //Most likely branch first:
      if (cache != null) {
         return cache;
      }
      synchronized (this) {
         if (lazyCache == null) {
            // define the query cache configuration if it does not already exist (from a previous call or manually defined by the user)
            internalCacheRegistry.registerInternalCache(QUERY_CACHE_NAME, getQueryCacheConfig().build(), EnumSet.noneOf(InternalCacheRegistry.Flag.class));
            lazyCache = cacheManager.getCache(QUERY_CACHE_NAME);
         }
         return lazyCache;
      }
   }
905491
@Override
    public final Query createQuery(String query)
    {
        checkClosed();
        checkTransactionNeeded();
        return getPersistenceDelegator().createQuery(query);
    }
113574
public <T> T asSingleResult() {
		T javaObject = null;
		String cacheKey = getCacheKey();
		if (isCacheable() && transaction == null) {
			Collection<Key> keys = getCacheManager().get(cacheNamespace, cacheKey);
			if (keys != null && keys.size() > 0) {
				Key key = keys.iterator().next();
				try {
					javaObject = (T) entityManager.get(key);
				} catch (EntityNotFoundException e) {
					throw new InconsistentCacheException("Entity Key " + key + " found in the cache but not in the Datastore");
				}
			}
		}
		if (javaObject == null) {
			Entity entity = getDatastoreService().prepare(query).asSingleEntity();
			if (entity == null) {
				throw new org.simpleds.exception.EntityNotFoundException("No " + getKind() + " found with " + getFilterPredicates());
			}
			javaObject = (T) entityManager.datastoreToJava(entity);
			if (isCacheable()) {
                populateCache(cacheKey, ImmutableList.of(entity.getKey()));
			}
		}
		return javaObject;

	}
555653
public BoxRequestsSearch.Search getSearchRequest(String query) {
        BoxRequestsSearch.Search request = new BoxRequestsSearch.Search(query, getSearchUrl(), mSession);
        return request;
    }
972881
public static QueryFactory getQueryFactory(Cache<?, ?> cache) {
      if (cache == null || cache.getAdvancedCache() == null) {
         throw new IllegalArgumentException("cache parameter shall not be null");
      }
      AdvancedCache<?, ?> advancedCache = cache.getAdvancedCache();
      ensureAccessPermissions(advancedCache);
      EmbeddedQueryEngine queryEngine = SecurityActions.getCacheComponentRegistry(advancedCache).getComponent(EmbeddedQueryEngine.class);
      if (queryEngine == null) {
         throw log.queryModuleNotInitialised();
      }
      return new EmbeddedQueryFactory(queryEngine);
   }
299661
protected String getMultiGetQueryCacheQuery(EntityKey[] keys) {
		int numberOfKeys = keys.length;
		String query = multiGetQueryCache.get( numberOfKeys );
		if ( query == null ) {
			query = createMultiGetOnMultiplePropertiesId( numberOfKeys );
			String cached = multiGetQueryCache.putIfAbsent( numberOfKeys, query );
			if ( cached != null ) {
				query = cached;
			}
		}
		return query;
	}
212248
public EntryList edgeStoreQuery(final KeySliceQuery query) {
        return executeRead(new Callable<EntryList>() {
            @Override
            public EntryList call() throws Exception {
                return cacheEnabled?edgeStore.getSlice(query, storeTx):
                                    edgeStore.getSliceNoCache(query,storeTx);
            }

            @Override
            public String toString() {
                return "EdgeStoreQuery";
            }
        });
    }
1175140
@Override
    public final InternalQueryCache createNew(String cacheId) {
        try {
            QueryCacheConfig queryCacheConfig = initQueryCacheConfig(request, cacheId);
            if (queryCacheConfig == null) {
                // no matching configuration was found, `null` will
                // be returned to user from IMap#getQueryCache call.
                return NULL_QUERY_CACHE;
            }
            queryCache = createUnderlyingQueryCache(queryCacheConfig, request, cacheId);

            AccumulatorInfo info = toAccumulatorInfo(queryCacheConfig, mapName, cacheId, predicate);
            addInfoToSubscriberContext(info);

            info.setPublishable(true);

            String publisherListenerId = queryCache.getPublisherListenerId();
            if (publisherListenerId == null) {
                createSubscriberAccumulator(info);
            }
            createPublisherAccumulator(info);

            queryCache.setPublisherListenerId(this.publisherListenerId);

        } catch (Throwable throwable) {
            removeQueryCacheConfig(mapName, request.getCacheName());
            throw rethrow(throwable);
        }

        return queryCache;
    }
1052291
public <T> List<T> search(org.beangle.commons.dao.query.Query<T> query) {
    if (query instanceof LimitQuery) {
      org.beangle.commons.dao.query.LimitQuery<T> limitQuery = (org.beangle.commons.dao.query.LimitQuery<T>) query;
      if (null == limitQuery.getLimit()) {
        return QuerySupport.find(limitQuery, getSession());
      } else {
        return new SinglePage<T>(limitQuery.getLimit().getPageIndex(), limitQuery.getLimit().getPageSize(),
            QuerySupport.count(limitQuery, getSession()), QuerySupport.find(query, getSession()));
      }
    } else {
      return QuerySupport.find(query, getSession());
    }
  }
145293
def search(query, query_type, nocache=False):
    
    settings = get_current_registry().settings
    memcache_servers = settings['memcache-servers'].split()
    if not memcache_servers:
        # memcache is not enabled, do a database search directly
        return database_search(query, query_type)

    # sort query params and create a key for the search
    search_params = []
    search_params += copy.deepcopy(query.terms)
    search_params += copy.deepcopy(query.filters)
    search_params += [('sort', i) for i in query.sorts]
    search_params.sort(key=lambda record: (record[0], record[1]))
    search_params.append(('query_type', query_type))

    # search_key should look something like:
    # '"sort:pubDate" "text:college physics" "query_type:weakAND"'
    search_key = u' '.join([u'"{}"'.format(u':'.join(param))
                           for param in search_params])
    # hash the search_key so it never exceeds the key length limit (250) in
    # memcache
    mc_search_key = binascii.hexlify(
        hashlib.pbkdf2_hmac('sha1', search_key.encode('utf-8'), b'', 1))

    # look for search results in memcache first, unless nocache
    mc = memcache.Client(memcache_servers,
                         server_max_value_length=128*1024*1024, debug=0)

    if not nocache:
        search_results = mc.get(mc_search_key)
    else:
        search_results = None

    if not search_results:
        # search results is not in memcache, do a database search
        search_results = database_search(query, query_type)

        cache_length = int(settings['search-cache-expiration'])

        # for particular searches, store in memcache for longer
        if (len(search_params) == 2 and
                # search by subject
                search_params[0][0] == 'subject' or
                # search single terms
                search_params[0][0] == 'text' and
                                       ' ' not in search_params[0][1]):
                # search with one term or one filter, plus query_type
            cache_length = int(settings['search-long-cache-expiration'])

        # store in memcache
        mc.set(mc_search_key, search_results, time=cache_length,
               min_compress_len=1024*1024)  # compress when > 1MB

    # return search results
    return search_results
416692
public UrlBuilder withQuery(String query) {
        if (query == null || query.isEmpty()) {
            this.query.clear();
        } else {
            with(query, UrlTokenizerState.QUERY);
        }
        return this;
    }
976632
public static SearchExecutor newLdaptiveSearchExecutor(final String baseDn, final String filterQuery,
                                                           final List<String> params,
                                                           final String[] returnAttributes) {
        val executor = new SearchExecutor();
        executor.setBaseDn(baseDn);
        executor.setSearchFilter(newLdaptiveSearchFilter(filterQuery, params));
        executor.setReturnAttributes(returnAttributes);
        executor.setSearchScope(SearchScope.SUBTREE);
        return executor;
    }