org.opencb.commons.datastore.core.Query.keySet()方法的使用及代码示例

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

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

Query.keySet介绍

暂无

代码示例

代码示例来源:origin: opencb/opencga

private boolean isQueryingIndividualFields(Query query) {
  for (String s : query.keySet()) {
    if (s.startsWith("individual")) {
      return true;
    }
  }
  return false;
}

代码示例来源:origin: opencb/opencga

public String createKey(String studyId, String allowedType, Query query, QueryOptions queryOptions) {
  queryOptions.remove("cache");
  queryOptions.remove("sId");
  StringBuilder key = new StringBuilder(PREFIX_DATABASE_KEY);
  key.append(studyId).append(":").append(allowedType);
  SortedMap<String, SortedSet<Object>> map = new TreeMap<>();
  for (String item : query.keySet()) {
    map.put(item.toLowerCase(), new TreeSet<>(query.getAsStringList(item)));
  }
  for (String item : queryOptions.keySet()) {
    map.put(item.toLowerCase(), new TreeSet<>(queryOptions.getAsStringList(item)));
  }
  String sha1 = DigestUtils.sha1Hex(map.toString());
  key.append(":").append(sha1);
  queryOptions.add("cache", "true");
  return key.toString();
}

代码示例来源:origin: org.opencb.biodata/biodata-tools

protected List<Predicate<Sample>> parseSampleQuery(Query query) {
  List<Predicate<Sample>> filters = new ArrayList<>();
  Iterator<String> iterator = query.keySet().iterator();
  while (iterator.hasNext()) {
    String key = iterator.next();

代码示例来源:origin: opencb/opencga

public String getMessage(Query query) {
  try {
    return "Query " + (query == null ? null : new ObjectMapper().addMixIn(GenericRecord.class, GenericRecordAvroJsonMixin.class).writeValueAsString(query)) + " is not fully supported";
  } catch (JsonProcessingException e) {
    e.printStackTrace();
    return "Query " + (query == null ? null : query.keySet()) + " is not fully supported";
  }
}

代码示例来源:origin: opencb/cellbase

@Override
public QueryResult<Long> count(Query query) {
  Bson document = parseQuery(query);
  Bson match = Aggregates.match(document);
  List<String> includeFields = new ArrayList<>();
  for (String s : query.keySet()) {
    if (StringUtils.isNotEmpty(query.getString(s))) {
      includeFields.add(s);
    }
  }
  Bson include;
  if (includeFields.size() > 0) {
    include = Aggregates.project(Projections.include(includeFields));
  } else {
    include = Aggregates.project(Projections.include("transcripts.id"));
  }
  Bson unwind = Aggregates.unwind("$transcripts");
  Bson match2 = Aggregates.match(document);
  Bson project = Aggregates.project(new Document("transcripts", "$transcripts.id"));
  Bson group = Aggregates.group("transcripts", Accumulators.sum("count", 1));
  QueryResult<Document> queryResult =
      mongoDBCollection.aggregate(Arrays.asList(match, include, unwind, match2, project, group), null);
  Number number = (Number) queryResult.first().get("count");
  Long count = number.longValue();
  return new QueryResult<>(null, queryResult.getDbTime(), queryResult.getNumResults(),
      queryResult.getNumTotalResults(), queryResult.getWarningMsg(), queryResult.getErrorMsg(),
      Collections.singletonList(count));
}

代码示例来源:origin: org.opencb.cellbase/cellbase-lib

@Override
public QueryResult<Long> count(Query query) {
  Bson document = parseQuery(query);
  Bson match = Aggregates.match(document);
  List<String> includeFields = new ArrayList<>();
  for (String s : query.keySet()) {
    if (StringUtils.isNotEmpty(query.getString(s))) {
      includeFields.add(s);
    }
  }
  Bson include;
  if (includeFields.size() > 0) {
    include = Aggregates.project(Projections.include(includeFields));
  } else {
    include = Aggregates.project(Projections.include("transcripts.id"));
  }
  Bson unwind = Aggregates.unwind("$transcripts");
  Bson match2 = Aggregates.match(document);
  Bson project = Aggregates.project(new Document("transcripts", "$transcripts.id"));
  Bson group = Aggregates.group("transcripts", Accumulators.sum("count", 1));
  QueryResult<Document> queryResult =
      mongoDBCollection.aggregate(Arrays.asList(match, include, unwind, match2, project, group), null);
  Number number = (Number) queryResult.first().get("count");
  Long count = number.longValue();
  return new QueryResult<>(null, queryResult.getDbTime(), queryResult.getNumResults(),
      queryResult.getNumTotalResults(), queryResult.getWarningMsg(), queryResult.getErrorMsg(),
      Collections.singletonList(count));
}

相关文章