com.googlecode.objectify.cmd.Query类的使用及代码示例

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

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

Query介绍

[英]The basic options for a typed Query. In addition to adding a few methods that are only available for typed queries, this interface overrides the QueryCommon methods to return the full Query.
[中]类型化查询的基本选项。除了添加一些仅适用于类型化查询的方法外,该接口还重写QueryCommon方法以返回完整查询。

代码示例

代码示例来源:origin: omerio/appstart

/**
 * Find all todos which are completed, not archived and are older than the provided
 * date.
 * @param date
 * @return
 */
public static List<Todo> findAllToArchive(Date date)	{
  return ofy().load().type(Todo.class)
      .filter("archived", false)
      .filter("completed", true)
      .filter("dateAdded <=", date).list();
}

代码示例来源:origin: TEAMMATES/teammates

/**
 * Fetches entities in batches and puts them into the buffer.
 */
private void batchFetching() {
  Query<T> newQuery = this.query.limit(BUFFER_SIZE);
  if (this.cursor != null) {
    newQuery = newQuery.startAt(this.cursor);
  }
  QueryResultIterator<T> iterator = newQuery.iterator();
  boolean shouldContinue = false;
  while (iterator.hasNext()) {
    shouldContinue = true;
    this.buffer.offer(iterator.next());
  }
  if (shouldContinue) {
    this.cursor = iterator.getCursor();
  }
}

代码示例来源:origin: TEAMMATES/teammates

while (shouldContinue) {
  shouldContinue = false;
  Query<T> filterQueryKeys = getFilterQuery().limit(getCursorInformationPrintCycle());
  if (cursor != null) {
    filterQueryKeys = filterQueryKeys.startAt(cursor);
  QueryResultIterator<Key<T>> iterator = filterQueryKeys.keys().iterator();

代码示例来源:origin: TEAMMATES/teammates

.filter("googleId =", oldGoogleId).list();
.filter("googleId =", oldGoogleId).list();

代码示例来源:origin: bedatadriven/activityinfo

public void query(long localVersion, long toVersion, Optional<String> startAt) {
  LOGGER.info("Starting VersionRange query...");
  Stopwatch stopwatch = Stopwatch.createStarted();
  Query<FormRecordSnapshotEntity> query = ofy().load().type(FormRecordSnapshotEntity.class)
      .ancestor(FormEntity.key(formClass))
      .filter("version >", localVersion)
      .chunk(500);
  if(startAt.isPresent()) {
    query = query.startAt(Cursor.fromWebSafeString(startAt.get()));
  }
  QueryResultIterator<FormRecordSnapshotEntity> it = query.iterator();
  while(it.hasNext()) {
    FormRecordSnapshotEntity snapshot = it.next();
    if(snapshot.getVersion() <= toVersion) {
      add(snapshot);
      if(!sizeEstimator.timeAndSpaceRemaining()) {
        stop(it.getCursor().toWebSafeString());
        break;
      }
    }
  }
  LOGGER.info("VersionRange query complete in " + stopwatch.elapsed(TimeUnit.SECONDS) +
      " with estimate size: " + sizeEstimator.getEstimatedSizeInBytes() + " bytes");
}

代码示例来源:origin: bedatadriven/activityinfo

@Override
  public List<FormRecord> run() {
    QueryResultIterable<FormRecordEntity> query = ofy().load()
        .type(FormRecordEntity.class)
        .ancestor(FormEntity.key(formClass))
        .filter("parentRecordId", this.parentRecordId.asString())
        .iterable();

    List<FormRecord> records = Lists.newArrayList();
    for (FormRecordEntity entity : query) {
      records.add(entity.toFormRecord(formClass));

    }
    return records;
  }
}

代码示例来源:origin: bedatadriven/activityinfo

public void query(long toVersion, Optional<String> startAt) {
  LOGGER.info("Starting initial sync query...");
  Stopwatch stopwatch = Stopwatch.createStarted();
  Query<FormRecordEntity> query = ofy().load().type(FormRecordEntity.class)
      .ancestor(FormEntity.key(formClass))
      .chunk(500);
  if(startAt.isPresent()) {
    query = query.startAt(Cursor.fromWebSafeString(startAt.get()));
  }
  QueryResultIterator<FormRecordEntity> it = query.iterator();
  while(it.hasNext()) {
    FormRecordEntity record = it.next();
    if(visibilityPredicate.test(record.getRecordId())) {
      add(record);
      if(!sizeEstimator.timeAndSpaceRemaining()) {
        stop(it.getCursor().toWebSafeString());
        break;
      }
    }
  }
  LOGGER.info("Initial sync query complete in " + stopwatch.elapsed(TimeUnit.SECONDS) +
      " with estimate size: " + sizeEstimator.getEstimatedSizeInBytes() + " bytes");
}

代码示例来源:origin: TEAMMATES/teammates

ofy().load().type(CourseStudent.class)
        .filter("createdAt >", queryEntitiesFrom)
        .filter("createdAt <=", queryEntitiesTo);
Query<Account> accountQuery =
    ofy().load().type(Account.class)
        .filter("createdAt >", queryEntitiesFrom)
        .filter("createdAt <=", queryEntitiesTo);

代码示例来源:origin: bedatadriven/activityinfo

public static Iterable<CatalogEntry> queryReports(String parentId) {

    if(parentId.charAt(0) != CuidAdapter.DATABASE_DOMAIN) {
      return Collections.emptyList();
    }

    QueryResultIterable<AnalysisEntity> result = Hrd.ofy().load()
      .type(AnalysisEntity.class)
      .filter("parentId", parentId)
      .iterable();

    return Iterables.transform(result, new Function<AnalysisEntity, CatalogEntry>() {
      @Override
      public CatalogEntry apply(AnalysisEntity analysisEntity) {
        return new CatalogEntry(analysisEntity.getId(), analysisEntity.getLabel(), CatalogEntryType.ANALYSIS);
      }
    });
  }
}

代码示例来源:origin: com.googlecode.luceneappengine/luceneappengine

@Override
public String[] listAll() {
  final Objectify objectify = ofy();
  final List<Key<Segment>> keys = objectify.load().type(Segment.class).ancestor(indexKey).keys().list();
  String[] names = new String[keys.size()];
  int i = 0;
  for (Key<Segment> name : keys)
    names[i++] = name.getName();
  return names;
}
/**

代码示例来源:origin: TEAMMATES/teammates

@Override
  public String load(String courseId) {
    List<Instructor> instructors =
        ofy().load().type(Instructor.class).filter("courseId =", courseId).list();
    for (Instructor instructor : instructors) {
      if (StringHelper.isEmpty(instructor.getGoogleId())) {
        continue;
      }
      Account account = ofy().load().key(Key.create(Account.class, instructor.getGoogleId())).now();
      if (account != null && !StringHelper.isEmpty(account.getInstitute())) {
        return account.getInstitute();
      }
    }
    return UNKNOWN_INSTITUTE;
  }
});

代码示例来源:origin: bedatadriven/activityinfo

.type(FormRecordSnapshotEntity.class)
      .ancestor(rootKey)
      .filter("parentRecordId", parentRecordId.asString());
for (FormRecordSnapshotEntity snapshot : query.iterable()) {
  RecordVersion version = new RecordVersion();
  version.setRecordId(snapshot.getRecordId());

代码示例来源:origin: com.threewks.thundr/thundr-gae

@Override
public List<E> list(int count) {
  return ofy().load().type(entityType).limit(count).list();
}

代码示例来源:origin: com.googlecode.luceneappengine/luceneappengine

/**
 * Method that return every lock created by this {@link GaeLockFactory}.
 * 
 * @return The list of {@link GaeLock} created by this
 *         {@link GaeLockFactory}
 */
List<GaeLock> getLocks(GaeDirectory gaeDirectory) {
  return ofy().load().type(GaeLock.class).ancestor(gaeDirectory.indexKey).list();
}

代码示例来源:origin: com.threewks.thundr/thundr-gae

@Override
public List<E> getByField(String field, Object value) {
  return ofy().load().type(entityType).filter(field, value).list();
}

代码示例来源:origin: com.threewks.thundr/thundr-gae

@Override
public List<E> getByField(String field, List<? extends Object> values) {
  return ofy().load().type(entityType).filter(field + " in", values).list();
}

代码示例来源:origin: omerio/appstart

public static List<Todo> findAllByArchived(boolean archived)	{
  return ofy().load().type(Todo.class).filter("archived", archived).list();
}

代码示例来源:origin: omerio/appstart

public static List<Todo> findAllByCompleted(boolean completed)	{
  return ofy().load().type(Todo.class).filter("completed", completed).list();
}

代码示例来源:origin: instacount/appengine-counter

.list();
assertThat(countersList.size(), is(3));
assertThat(countersList.get(0), is(counterData1));
countersList = ObjectifyService.ofy().load().type(CounterData.class).order("-numShards").list();
assertThat(countersList.size(), is(3));
assertThat(countersList.get(0), is(counterData3));
countersList = ObjectifyService.ofy().load().type(CounterData.class).order("description").list();
assertThat(countersList.size(), is(3));
assertThat(countersList.get(0), is(counterData1));
countersList = ObjectifyService.ofy().load().type(CounterData.class).order("-description").list();
assertThat(countersList.size(), is(3));
assertThat(countersList.get(0), is(counterData3));
countersList = ObjectifyService.ofy().load().type(CounterData.class).order("counterStatus").list();
assertThat(countersList.size(), is(3));
assertThat(countersList.get(0), is(counterData1));
countersList = ObjectifyService.ofy().load().type(CounterData.class).order("-counterStatus").list();
assertThat(countersList.size(), is(3));
assertThat(countersList.get(0), is(counterData3));
  .order("counterGroupData.eventuallyConsistentCount").list();
assertThat(countersList.size(), is(3));
assertThat(countersList.get(0), is(counterData1));
  .order("-counterGroupData.eventuallyConsistentCount").list();

相关文章