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) {
query.declareParameters(parameterDeclaration); query.setFilter(queryFilterString); Collection<String> names = (Collection<String>)query.executeWithMap(params);
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(); } /**
Collection<String> names = (Collection<String>) query.executeWithMap(params); partNames = new ArrayList<String>(names);
/** * 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; }
/** * 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; }
query.setOrdering("partitionName ascending"); @SuppressWarnings("unchecked") List<MPartition> mparts = (List<MPartition>) query.executeWithMap(params); LOG.debug("Done executing query for getPartitionsViaOrmFilter");
return (Collection) query.executeWithMap(params);
public Object doInJdo(PersistenceManager pm) throws JDOException { Query query = pm.newQuery(queryString); prepareQuery(query); return query.executeWithMap(values); } }, true);
@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); }
public Object doInJdo(PersistenceManager pm) throws JDOException { Query query = getJdoDialect().newNamedQuery(pm, entityClass, queryName); prepareQuery(query); return query.executeWithMap(values); } }, true);
@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; }
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);
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; }
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; }
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; } });
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; }
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; }
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; }
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; } });