本文整理了Java中javax.jdo.Query.executeWithMap
方法的一些代码示例,展示了Query.executeWithMap
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.executeWithMap
方法的具体详情如下:
包路径:javax.jdo.Query
类名称:Query
方法名:executeWithMap
[英]Execute the query and return the filtered Collection
. The query is executed with the parameters set by the Map
values. Each Map
entry consists of a key which is the name of the parameter in the declareParameters
method, and a value which is the value used in the execute
method. The keys in the Map
and the declared parameters must exactly match or a JDOUserException
is thrown.
Cancellation of the query using cancel() will result in JDOQueryInterruptedException being thrown here.
[中]执行查询并返回经过筛选的Collection
。使用Map
值设置的参数执行查询。每个Map
条目由一个键和一个值组成,键是declareParameters
方法中参数的名称,值是execute
方法中使用的值。Map
中的键和声明的参数必须完全匹配,否则会抛出JDOUserException
。
使用cancel()取消查询将导致在此处抛出JDOQueryInterruptedException。
代码示例来源:origin: apache/hive
if (fieldNames == null || fieldNames.isEmpty()) {
mparts = (List<MPartition>) query.executeWithMap(params);
pm.retrieveAll(mparts);
} else {
List<Object[]> results = (List<Object[]>) query.executeWithMap(params);
mparts = new ArrayList<>(results.size());
for (Object[] row : results) {
List<Object> results = (List<Object>) query.executeWithMap(params);
mparts = new ArrayList<>(results.size());
for (Object row : results) {
代码示例来源:origin: apache/hive
query.declareParameters(parameterDeclaration);
query.setFilter(queryFilterString);
Collection<String> names = (Collection<String>)query.executeWithMap(params);
代码示例来源:origin: apache/hive
private Integer getNumPartitionsViaOrmFilter(Table table, ExpressionTree tree, boolean isValidatedFilter)
throws MetaException {
Map<String, Object> params = new HashMap<>();
String jdoFilter = makeQueryFilterString(table.getCatName(), table.getDbName(), table, tree,
params, isValidatedFilter);
if (jdoFilter == null) {
assert !isValidatedFilter;
return null;
}
Query query = pm.newQuery(
"select count(partitionName) from org.apache.hadoop.hive.metastore.model.MPartition"
);
query.setFilter(jdoFilter);
String parameterDeclaration = makeParameterDeclarationStringObj(params);
query.declareParameters(parameterDeclaration);
Long result = (Long) query.executeWithMap(params);
query.closeAll();
return result.intValue();
}
/**
代码示例来源:origin: apache/hive
Collection<String> names = (Collection<String>) query.executeWithMap(params);
partNames = new ArrayList<String>(names);
代码示例来源:origin: apache/hive
/**
* Gets partition names from the table via ORM (JDOQL) name filter.
* @param dbName Database name.
* @param tblName Table name.
* @param partNames Partition names to get the objects for.
* @return Resulting partitions.
*/
private List<Partition> getPartitionsViaOrmFilter(String catName,
String dbName, String tblName, List<String> partNames) throws MetaException {
if (partNames.isEmpty()) {
return new ArrayList<>();
}
ObjectPair<Query, Map<String, String>> queryWithParams =
getPartQueryWithParams(catName, dbName, tblName, partNames);
Query query = queryWithParams.getFirst();
query.setResultClass(MPartition.class);
query.setClass(MPartition.class);
query.setOrdering("partitionName ascending");
@SuppressWarnings("unchecked")
List<MPartition> mparts = (List<MPartition>)query.executeWithMap(queryWithParams.getSecond());
List<Partition> partitions = convertToParts(catName, dbName, tblName, mparts);
if (query != null) {
query.closeAll();
}
return partitions;
}
代码示例来源:origin: apache/hive
/**
* Detaches column descriptors from storage descriptors; returns the set of unique CDs
* thus detached. This is done before dropping partitions because CDs are reused between
* SDs; so, we remove the links to delete SDs and then check the returned CDs to see if
* they are referenced by other SDs.
*/
private HashSet<MColumnDescriptor> detachCdsFromSdsNoTxn(
String catName, String dbName, String tblName, List<String> partNames) {
ObjectPair<Query, Map<String, String>> queryWithParams =
getPartQueryWithParams(catName, dbName, tblName, partNames);
Query query = queryWithParams.getFirst();
query.setClass(MPartition.class);
query.setResult("sd");
@SuppressWarnings("unchecked")
List<MStorageDescriptor> sds = (List<MStorageDescriptor>)query.executeWithMap(
queryWithParams.getSecond());
HashSet<MColumnDescriptor> candidateCds = new HashSet<>();
for (MStorageDescriptor sd : sds) {
if (sd != null && sd.getCD() != null) {
candidateCds.add(sd.getCD());
sd.setCD(null);
}
}
if (query != null) {
query.closeAll();
}
return candidateCds;
}
代码示例来源:origin: apache/hive
query.setOrdering("partitionName ascending");
@SuppressWarnings("unchecked")
List<MPartition> mparts = (List<MPartition>) query.executeWithMap(params);
LOG.debug("Done executing query for getPartitionsViaOrmFilter");
代码示例来源:origin: apache/hive
return (Collection) query.executeWithMap(params);
代码示例来源:origin: springframework/spring-orm
public Object doInJdo(PersistenceManager pm) throws JDOException {
Query query = pm.newQuery(queryString);
prepareQuery(query);
return query.executeWithMap(values);
}
}, true);
代码示例来源:origin: anjuke/hwi
@SuppressWarnings("unchecked")
public List<MCrontab> runningCrontabs() {
Query query = getPM().newQuery(MCrontab.class);
query.setFilter("status == :status");
query.setOrdering("id DESC");
HashMap<String, Object> map = new HashMap<String, Object>();
map.put("status", MCrontab.Status.RUNNING);
return (List<MCrontab>) query.executeWithMap(map);
}
代码示例来源:origin: springframework/spring-orm
public Object doInJdo(PersistenceManager pm) throws JDOException {
Query query = getJdoDialect().newNamedQuery(pm, entityClass, queryName);
prepareQuery(query);
return query.executeWithMap(values);
}
}, true);
代码示例来源:origin: anjuke/hwi
@SuppressWarnings("unchecked")
public List<T> getItems() {
if (items == null) {
Query newQuery = query.getPersistenceManager().newQuery(query);
int offset = (page - 1) * pageSize;
newQuery.setRange(offset, offset + pageSize);
items = (List<T>) newQuery.executeWithMap(map);
}
return items;
}
代码示例来源:origin: springframework/spring-orm
public Object doInJdo(PersistenceManager pm) throws JDOException {
Query query = pm.newQuery(entityClass, filter);
prepareQuery(query);
query.declareParameters(parameters);
if (ordering != null) {
query.setOrdering(ordering);
}
return query.executeWithMap(values);
}
}, true);
代码示例来源:origin: apache/sentry
private Set<MSentryGMPrivilege> populateIncludePrivileges(Set<MSentryRole> roles,
MSentryGMPrivilege parent, PersistenceManager pm) {
Set<MSentryGMPrivilege> childrens = Sets.newHashSet();
Query query = pm.newQuery(MSentryGMPrivilege.class);
QueryParamBuilder paramBuilder = populateIncludePrivilegesParams(parent);
// add filter for role names
if ((roles != null) && !roles.isEmpty()) {
QueryParamBuilder.addRolesFilter(query, paramBuilder, SentryStore.rolesToRoleNames(roles));
}
query.setFilter(paramBuilder.toString());
List<MSentryGMPrivilege> privileges =
(List<MSentryGMPrivilege>)query.executeWithMap(paramBuilder.getArguments());
childrens.addAll(privileges);
return childrens;
}
代码示例来源:origin: anjuke/hwi
public Long getTotal() {
if (total == null) {
Query newQuery = query.getPersistenceManager().newQuery(query);
newQuery.setOrdering(null);
newQuery.setResult("COUNT(id)");
total = (Long) newQuery.executeWithMap(map);
}
return total;
}
代码示例来源:origin: apache/sentry
public Set<String> execute(PersistenceManager pm) throws Exception {
pm.setDetachAllOnCommit(false); // No need to detach objects
Query query = pm.newQuery(MSentryGroup.class);
// Find privileges matching all roles
QueryParamBuilder paramBuilder = QueryParamBuilder.addRolesFilter(query, null,
roles);
query.setFilter(paramBuilder.toString());
List<MSentryGroup> mGroups =
(List<MSentryGroup>)query.executeWithMap(paramBuilder.getArguments());
Set<String> groupNames = new HashSet<>();
for(MSentryGroup g: mGroups) {
groupNames.add(g.getGroupName());
}
return groupNames;
}
});
代码示例来源:origin: com.facebook.presto.hive/hive-apache
private List<MPartition> getMPartitionsViaOrmFilter(String dbName,
String tblName, List<String> partNames, Out<Query> out) {
ObjectPair<Query, Map<String, String>> queryWithParams =
getPartQueryWithParams(dbName, tblName, partNames);
Query query = out.val = queryWithParams.getFirst();
query.setResultClass(MPartition.class);
query.setClass(MPartition.class);
query.setOrdering("partitionName ascending");
@SuppressWarnings("unchecked")
List<MPartition> result = (List<MPartition>)query.executeWithMap(queryWithParams.getSecond());
return result;
}
代码示例来源:origin: org.spark-project.hive/hive-metastore
private List<MPartition> getMPartitionsViaOrmFilter(String dbName,
String tblName, List<String> partNames, Out<Query> out) {
ObjectPair<Query, Map<String, String>> queryWithParams =
getPartQueryWithParams(dbName, tblName, partNames);
Query query = out.val = queryWithParams.getFirst();
query.setResultClass(MPartition.class);
query.setClass(MPartition.class);
query.setOrdering("partitionName ascending");
@SuppressWarnings("unchecked")
List<MPartition> result = (List<MPartition>)query.executeWithMap(queryWithParams.getSecond());
return result;
}
代码示例来源:origin: apache/sentry
private MSentryGMPrivilege getPrivilege(MSentryGMPrivilege privilege, PersistenceManager pm) {
Query query = pm.newQuery(MSentryGMPrivilege.class);
QueryParamBuilder paramBuilder = toQueryParam(privilege);
query.setFilter(paramBuilder.toString());
query.setUnique(true);
MSentryGMPrivilege result = (MSentryGMPrivilege)query.executeWithMap(paramBuilder.getArguments());
return result;
}
代码示例来源:origin: apache/sentry
public Boolean execute(PersistenceManager pm) throws Exception {
pm.setDetachAllOnCommit(false); // No need to detach objects
Query query = pm.newQuery(MSentryPrivilege.class);
query.addExtension(LOAD_RESULTS_AT_COMMIT, "false");
QueryParamBuilder paramBuilder = QueryParamBuilder.addUsersFilter(query,null, userNames);
paramBuilder.add(SERVER_NAME, serverName);
query.setFilter(paramBuilder.toString());
query.setResult("count(this)");
Long numPrivs = (Long) query.executeWithMap(paramBuilder.getArguments());
return numPrivs > 0;
}
});
内容来源于网络,如有侵权,请联系作者删除!