org.molgenis.data.Query.getFetch()方法的使用及代码示例

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

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

Query.getFetch介绍

暂无

代码示例

代码示例来源:origin: org.molgenis/molgenis-data-postgresql

@Override
 protected List<Entity> getBatch(Query<Entity> batchQuery) {
  List<Object> parameters = new ArrayList<>();
  String sql = getSqlSelect(getEntityType(), batchQuery, parameters, true);
  RowMapper<Entity> entityMapper =
    postgreSqlEntityFactory.createRowMapper(getEntityType(), batchQuery.getFetch());
  LOG.debug("Fetching [{}] data for query [{}]", getName(), batchQuery);
  LOG.trace("SQL: {}, parameters: {}", sql, parameters);
  Stopwatch sw = createStarted();
  List<Entity> result =
    jdbcTemplate.query(
      sql, parameters.toArray(new Object[parameters.size()]), entityMapper);
  LOG.trace("That took {}", sw);
  return result;
 }
};

代码示例来源:origin: org.molgenis/molgenis-data-cache

/**
  * Retrieves a single identifier from the {@link L3Cache} if the {@link Repository} is cacheable
  * and hasn't been touched in this transaction.
  *
  * @param query The {@link Query}
  * @return A single {@link Entity} or null if not found
  */
 @Override
 public Entity findOne(Query<Entity> query) {
  if (transactionInformation.isRepositoryCompletelyClean(getEntityType()) && cacheable) {
   // pageSize is irrelevant for findOne, would be a waste to cache them in different entries
   // sort may affect which of the results is the first result, so cannot ignore that.
   QueryImpl<Entity> cacheKey = new QueryImpl<>(query).setPageSize(1);
   List<Object> ids = l3Cache.get(delegate(), cacheKey);
   if (ids.isEmpty()) {
    return null;
   }
   return delegate().findOneById(ids.get(0), query.getFetch());
  }
  return delegate().findOne(query);
 }
}

代码示例来源:origin: org.molgenis/molgenis-data-postgresql

.forEach(
  attr -> {
   if (q.getFetch() == null
     || q.getFetch().hasField(attr.getName())
     || (q.getSort() != null && q.getSort().hasField(attr.getName()))) {
    if (count.get() > 0) {

代码示例来源:origin: org.molgenis/molgenis-data-index

@Override
public Entity findOne(Query<Entity> q) {
 if (querySupported(q)) {
  LOG.debug(
    "public Entity findOne({}) entityTypeId: [{}] repository: [{}]",
    q,
    getEntityType().getId(),
    DECORATED_REPOSITORY);
  return delegate().findOne(q);
 } else {
  LOG.debug(
    "public Entity findOne({}) entityTypeId: [{}] repository: [{}]",
    q,
    getEntityType().getId(),
    INDEX_REPOSITORY);
  Object entityId = tryTwice(() -> searchService.searchOne(getEntityType(), q));
  return entityId != null ? delegate().findOneById(entityId, q.getFetch()) : null;
 }
}

代码示例来源:origin: org.molgenis/molgenis-data-index

@Override
public Stream<Entity> findAll(Query<Entity> q) {
 if (querySupported(q)) {
  LOG.debug(
    "public Entity findAll({}) entityTypeId: [{}] repository: [{}]",
    q,
    getEntityType().getId(),
    DECORATED_REPOSITORY);
  return delegate().findAll(q);
 } else {
  LOG.debug(
    "public Entity findAll({}) entityTypeId: [{}] repository: [{}]",
    q,
    getEntityType().getId(),
    INDEX_REPOSITORY);
  Stream<Object> entityIds = tryTwice(() -> searchService.search(getEntityType(), q));
  return delegate().findAll(entityIds, q.getFetch());
 }
}

代码示例来源:origin: org.molgenis/molgenis-data-cache

/**
 * Retrieves a {@link List} of identifiers from the {@link L3Cache} if the {@link Repository} is
 * cacheable and the {@link Query} is limited (i.e. contains a pageSize) between 0 and
 * MAX_PAGE_SIZE
 *
 * @param query The {@link Query}
 * @return A stream of {@link Entity}
 */
@Override
public Stream<Entity> findAll(Query<Entity> query) {
 if (transactionInformation.isRepositoryCompletelyClean(getEntityType())) {
  // FIXME page size for metadata is always 0, and batching is done by the postgres repository
  // FIXME Only superusers are able to use the L3 cache for metadata
  if (cacheable && query.getPageSize() > 0 && query.getPageSize() <= MAX_PAGE_SIZE) {
   List<Object> ids = l3Cache.get(delegate(), query);
   return delegate().findAll(ids.stream(), query.getFetch());
  }
 } else {
  LOG.debug("Repository is dirty: {}", getName());
 }
 return delegate().findAll(query);
}

相关文章