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


Java Query.setKeysOnly方法代码示例

本文整理汇总了Java中com.google.appengine.api.datastore.Query.setKeysOnly方法的典型用法代码示例。如果您正苦于以下问题:Java Query.setKeysOnly方法的具体用法?Java Query.setKeysOnly怎么用?Java Query.setKeysOnly使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.appengine.api.datastore.Query的用法示例。


在下文中一共展示了Query.setKeysOnly方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getDeltaEntityIterator

import com.google.appengine.api.datastore.Query; //导入方法依赖的package包/类
private CheckedIterator getDeltaEntityIterator(long startVersion, @Nullable Long endVersion,
    FetchOptions fetchOptions, boolean forward, boolean keysOnly)
    throws PermanentFailure, RetryableFailure {
  checkRange(startVersion, endVersion);
  if (endVersion != null && startVersion == endVersion) {
    return CheckedIterator.EMPTY;
  }
  Query.Filter filter = FilterOperator.GREATER_THAN_OR_EQUAL.of(Entity.KEY_RESERVED_PROPERTY,
      makeDeltaKey(objectId, startVersion));
  if (endVersion != null) {
    filter = Query.CompositeFilterOperator.and(filter,
        FilterOperator.LESS_THAN.of(Entity.KEY_RESERVED_PROPERTY,
            makeDeltaKey(objectId, endVersion)));
  }
  Query q = new Query(deltaEntityKind)
      .setAncestor(makeRootEntityKey(objectId))
      .setFilter(filter)
      .addSort(Entity.KEY_RESERVED_PROPERTY,
          forward ? SortDirection.ASCENDING : SortDirection.DESCENDING);
  if (keysOnly) {
    q.setKeysOnly();
  }
  return tx.prepare(q).asIterator(fetchOptions);
}
 
开发者ID:ArloJamesBarnes,项目名称:walkaround,代码行数:25,代码来源:MutationLog.java

示例2: getAccountKeyByUser

import com.google.appengine.api.datastore.Query; //导入方法依赖的package包/类
/**
 * Returns the Account key associated with the specified user.
 * @param pm   reference to the persistence manager
 * @param user user to return the account key for
 * @return the Account key associated with the specified user; or <code>null</code> if no account is associated with the specified user
 */
public static Key getAccountKeyByUser( final PersistenceManager pm, final User user ) {
	final String memcacheKey = CACHE_KEY_USER_ACCOUNT_KEY_PREFIX + user.getEmail();
	final String accountKeyString = (String) memcacheService.get( memcacheKey );
	if ( accountKeyString != null )
		return KeyFactory.stringToKey( accountKeyString );
	
	final Query q = new Query( Account.class.getSimpleName() );
	q.setFilter( new FilterPredicate( "user", FilterOperator.EQUAL, user ) );
	q.setKeysOnly();
	final List< Entity > entityList = DatastoreServiceFactory.getDatastoreService().prepare( q ).asList( FetchOptions.Builder.withDefaults() );
	if ( entityList.isEmpty() )
		return null;
	
	final Key accountKey = entityList.get( 0 ).getKey();
	try {
		memcacheService.put( memcacheKey, KeyFactory.keyToString( accountKey ) );
	}
	catch ( final MemcacheServiceException mse ) {
		LOGGER.log( Level.WARNING, "Failed to put key to memcache: " + memcacheKey, mse );
		// Ignore memcache errors, do not prevent serving user request
	}
	
	return accountKey;
}
 
开发者ID:icza,项目名称:sc2gears,代码行数:31,代码来源:CachingService.java

示例3: getAccountKeyByAuthKey

import com.google.appengine.api.datastore.Query; //导入方法依赖的package包/类
/**
 * Returns the Account key associated with the specified authorization key.
 * @param pm               reference to the persistence manager
 * @param authorizationKey authorization key to return the account key for
 * @return the Account key associated with the specified authorization key; or <code>null</code> if the authorization key is invalid
 */
public static Key getAccountKeyByAuthKey( final PersistenceManager pm, final String authorizationKey ) {
	final String memcacheKey = CACHE_KEY_AUTH_KEY_ACCOUNT_KEY_PREFIX + authorizationKey;
	final String accountKeyString = (String) memcacheService.get( memcacheKey );
	if ( accountKeyString != null )
		return KeyFactory.stringToKey( accountKeyString );
	
	final Query q = new Query( Account.class.getSimpleName() );
	q.setFilter( new FilterPredicate( "authorizationKey", FilterOperator.EQUAL, authorizationKey ) );
	q.setKeysOnly();
	final List< Entity > entityList = DatastoreServiceFactory.getDatastoreService().prepare( q ).asList( FetchOptions.Builder.withDefaults() );
	if ( entityList.isEmpty() )
		return null;
	
	final Key accountKey = entityList.get( 0 ).getKey();
	try {
		memcacheService.put( memcacheKey, KeyFactory.keyToString( accountKey ) );
	}
	catch ( final MemcacheServiceException mse ) {
		LOGGER.log( Level.WARNING, "Failed to put key to memcache: " + memcacheKey, mse );
		// Ignore memcache errors, do not prevent serving user request
	}
	
	return accountKey;
}
 
开发者ID:icza,项目名称:sc2gears,代码行数:31,代码来源:CachingService.java

示例4: listRawEntity

import com.google.appengine.api.datastore.Query; //导入方法依赖的package包/类
public Iterable<Entity> listRawEntity(Query q, Boolean returnKeysOnly) {
    DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
    if (returnKeysOnly) {
        q.setKeysOnly();
    }
    PreparedQuery pq = datastore.prepare(q);
    return pq.asIterable();
}
 
开发者ID:deniotokiari,项目名称:training-epam-2016,代码行数:9,代码来源:StoreServlet.java

示例5: deleteAll

import com.google.appengine.api.datastore.Query; //导入方法依赖的package包/类
private boolean deleteAll(CheckedTransaction tx, Query q)
    throws RetryableFailure, PermanentFailure {
  q.setKeysOnly();
  CheckedIterator i = tx.prepare(q).asIterator();
  if (!i.hasNext()) {
    return false;
  }
  while (i.hasNext()) {
    tx.delete(i.next().getKey());
  }
  return true;
}
 
开发者ID:ArloJamesBarnes,项目名称:walkaround,代码行数:13,代码来源:PerUserTable.java


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