本文整理了Java中javax.jdo.Query.setOrdering
方法的一些代码示例,展示了Query.setOrdering
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.setOrdering
方法的具体详情如下:
包路径:javax.jdo.Query
类名称:Query
方法名:setOrdering
[英]Set the ordering specification for the result Collection
. The ordering specification is a String
containing one or more ordering declarations separated by commas.
Each ordering declaration is the name of the field on which to order the results followed by one of the following words: "ascending
" or "descending
".
The field must be declared in the candidate class or must be a navigation expression starting with a field in the candidate class.
Valid field types are primitive types except boolean
; wrapper types except Boolean
; BigDecimal
; BigInteger
; String
; and Date
.
[中]设置结果[$0$]的订购规格。订购规范是一个String
,包含一个或多个由逗号分隔的订购声明。
每个排序声明都是要对结果进行排序的字段的名称,后跟以下单词之一:“ascending
”或“descending
”。
字段必须在候选类中声明,或者必须是以候选类中的字段开头的导航表达式。
有效字段类型是除boolean
之外的基本类型;包装类型,除了Boolean
;BigDecimal
; BigInteger
; String
; 和[$9$]。
代码示例来源:origin: apache/hive
query.setOrdering("functionName ascending");
Collection names = (Collection) query.executeWithArray(parameterVals.toArray(new String[parameterVals.size()]));
funcs = new ArrayList<>();
代码示例来源:origin: apache/hive
@Override
public List<String> getDatabases(String catName, String pattern) throws MetaException {
if (pattern == null || pattern.equals("*")) {
return getAllDatabases(catName);
}
boolean commited = false;
List<String> databases = null;
Query query = null;
try {
openTransaction();
// Take the pattern and split it on the | to get all the composing
// patterns
String[] subpatterns = pattern.trim().split("\\|");
StringBuilder filterBuilder = new StringBuilder();
List<String> parameterVals = new ArrayList<>(subpatterns.length);
appendSimpleCondition(filterBuilder, "catalogName", new String[] {catName}, parameterVals);
appendPatternCondition(filterBuilder, "name", subpatterns, parameterVals);
query = pm.newQuery(MDatabase.class, filterBuilder.toString());
query.setResult("name");
query.setOrdering("name ascending");
Collection<String> names = (Collection<String>) query.executeWithArray(parameterVals.toArray(new String[0]));
databases = new ArrayList<>(names);
commited = commitTransaction();
} finally {
rollbackAndCleanup(commited, query);
}
return databases;
}
代码示例来源:origin: apache/hive
query.declareParameters(parameterDeclaration);
if (ascending) {
query.setOrdering("partitionName ascending");
} else {
query.setOrdering("partitionName descending");
代码示例来源:origin: apache/hive
private List<RuntimeStat> getMRuntimeStats(int maxEntries, int maxCreateTime) {
Query<MRuntimeStat> query = pm.newQuery(MRuntimeStat.class);
query.setOrdering("createTime descending");
if (maxCreateTime > 0) {
query.setFilter("createTime < "+maxCreateTime);
}
if (maxEntries < 0) {
maxEntries = Integer.MAX_VALUE;
}
List<RuntimeStat> ret = new ArrayList<>();
List<MRuntimeStat> res = (List<MRuntimeStat>) query.execute();
int totalEntries = 0;
for (MRuntimeStat mRuntimeStat : res) {
pm.retrieve(mRuntimeStat);
totalEntries += mRuntimeStat.getWeight();
ret.add(MRuntimeStat.toThrift(mRuntimeStat));
if (totalEntries >= maxEntries) {
break;
}
}
return ret;
}
代码示例来源:origin: apache/hive
query.setOrdering("eventId ascending");
int maxEventResponse = MetastoreConf.getIntVar(conf, ConfVars.METASTORE_MAX_EVENT_RESPONSE);
int maxEvents = (rqst.getMaxEvents() < maxEventResponse && rqst.getMaxEvents() > 0) ? rqst.getMaxEvents() : maxEventResponse;
代码示例来源:origin: apache/hive
String parameterDeclaration = makeParameterDeclarationStringObj(params);
query.declareParameters(parameterDeclaration);
query.setOrdering("partitionName ascending");
if (fieldNames == null || fieldNames.isEmpty()) {
代码示例来源:origin: apache/hive
query.setOrdering("database,table ascending");
List<MTxnWriteNotificationLog> mplans = (List<MTxnWriteNotificationLog>)query.executeWithArray(
parameterVals.toArray(new String[parameterVals.size()]));
代码示例来源:origin: apache/hive
query.setOrdering("tableName ascending");
Collection<String> names = (Collection<String>) query.executeWithArray(parameterVals.toArray(new String[0]));
tbls = new ArrayList<>(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
private List<MPartition> listMPartitions(String catName, String dbName, String tableName,
int max, QueryWrapper queryWrapper) {
boolean success = false;
List<MPartition> mparts = null;
try {
openTransaction();
LOG.debug("Executing listMPartitions");
dbName = normalizeIdentifier(dbName);
tableName = normalizeIdentifier(tableName);
Query query = queryWrapper.query = pm.newQuery(MPartition.class,
"table.tableName == t1 && table.database.name == t2 && table.database.catalogName == t3");
query.declareParameters("java.lang.String t1, java.lang.String t2, java.lang.String t3");
query.setOrdering("partitionName ascending");
if (max >= 0) {
query.setRange(0, max);
}
mparts = (List<MPartition>) query.execute(tableName, dbName, catName);
LOG.debug("Done executing query for listMPartitions");
pm.retrieveAll(mparts);
success = commitTransaction();
LOG.debug("Done retrieving all objects for listMPartitions {}", mparts);
} finally {
if (!success) {
rollbackTransaction();
}
}
return mparts;
}
代码示例来源:origin: apache/hive
query.setOrdering("partitionName ascending");
@SuppressWarnings("unchecked")
List<MPartition> mparts = (List<MPartition>) query.executeWithMap(params);
代码示例来源:origin: apache/hive
query.setFilter(filter);
query.declareParameters(paramStr);
query.setOrdering("partitionName ascending");
@SuppressWarnings("unchecked")
List<MPartitionColumnStatistics> result =
代码示例来源:origin: apache/hive
query.declareParameters("java.lang.String schemaName, java.lang.String dbName," +
" java.lang.String cat");
query.setOrdering("version descending");
List<MSchemaVersion> mSchemaVersions = query.setParameters(name, dbName, catName).executeList();
pm.retrieveAll(mSchemaVersions);
代码示例来源:origin: apache/hive
"java.lang.String cat");
query.setUnique(true);
query.setOrdering("version descending");
query.setRange(0, 1);
MSchemaVersion mSchemaVersion = (MSchemaVersion)query.execute(name, dbName, catName);
代码示例来源:origin: anjuke/hwi
public Pagination<MCrontab> crontabPaginate(int page, int pageSize) {
Query query = getPM().newQuery(MCrontab.class);
query.setOrdering("id DESC");
return crontabPaginate(query, null, page, pageSize);
}
代码示例来源: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.executeWithArray(values);
}
}, true);
代码示例来源: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: springframework/spring-orm
public Object doInJdo(PersistenceManager pm) throws JDOException {
Query query = (filter != null ? pm.newQuery(entityClass, filter) : pm.newQuery(entityClass));
prepareQuery(query);
if (ordering != null) {
query.setOrdering(ordering);
}
return query.execute();
}
}, true);
代码示例来源: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: 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;
}
内容来源于网络,如有侵权,请联系作者删除!