/** * Given a list of model field schemas, create a new model column descriptor. * @param cols the columns the column descriptor contains * @return a new column descriptor db-backed object */ private MColumnDescriptor createNewMColumnDescriptor(List<MFieldSchema> cols) { if (cols == null) { return null; } return new MColumnDescriptor(cols); }
public MFunction(String functionName, MDatabase database, String className, String ownerName, String ownerType, int createTime, int functionType, List<MResourceUri> resourceUris) { this.setFunctionName(functionName); this.setDatabase(database); this.setFunctionType(functionType); this.setClassName(className); this.setOwnerName(ownerName); this.setOwnerType(ownerType); this.setCreateTime(createTime); this.setResourceUris(resourceUris); }
private WMMapping fromMMapping(MWMMapping mMapping, String rpName) { WMMapping result = new WMMapping(rpName, mMapping.getEntityType().toString(), mMapping.getEntityName()); if (mMapping.getPool() != null) { result.setPoolPath(mMapping.getPool().getPath()); } if (mMapping.getOrdering() != null) { result.setOrdering(mMapping.getOrdering()); } result.setNs(mMapping.getResourcePlan().getNs()); return result; }
private List<HiveObjectPrivilege> convertPartCols(List<MPartitionColumnPrivilege> privs) { List<HiveObjectPrivilege> result = new ArrayList<>(); for (MPartitionColumnPrivilege priv : privs) { String pname = priv.getPrincipalName(); String authorizer = priv.getAuthorizer(); PrincipalType ptype = PrincipalType.valueOf(priv.getPrincipalType()); MPartition mpartition = priv.getPartition(); MTable mtable = mpartition.getTable(); MDatabase mdatabase = mtable.getDatabase(); HiveObjectRef objectRef = new HiveObjectRef(HiveObjectType.COLUMN, mdatabase.getName(), mtable.getTableName(), mpartition.getValues(), priv.getColumnName()); objectRef.setCatName(mdatabase.getCatalogName()); PrivilegeGrantInfo grantor = new PrivilegeGrantInfo(priv.getPrivilege(), priv.getCreateTime(), priv.getGrantor(), PrincipalType.valueOf(priv.getGrantorType()), priv.getGrantOption()); result.add(new HiveObjectPrivilege(objectRef, pname, ptype, grantor, authorizer)); } return result; }
private Partition convertToPart(MPartition mpart) throws MetaException { if (mpart == null) { return null; } //its possible that MPartition is partially filled, do null checks to avoid NPE MTable table = mpart.getTable(); String dbName = table == null ? null : table.getDatabase() == null ? null : table.getDatabase().getName(); String tableName = table == null ? null : table.getTableName(); String catName = table == null ? null : table.getDatabase() == null ? null : table.getDatabase().getCatalogName(); Partition p = new Partition(convertList(mpart.getValues()), dbName, tableName, mpart.getCreateTime(), mpart.getLastAccessTime(), convertToStorageDescriptor(mpart.getSd()), convertMap(mpart.getParameters())); p.setCatName(catName); p.setWriteId(mpart.getWriteId()); return p; }
private NotificationEvent translateDbToThrift(MNotificationLog dbEvent) { NotificationEvent event = new NotificationEvent(); event.setEventId(dbEvent.getEventId()); event.setEventTime(dbEvent.getEventTime()); event.setEventType(dbEvent.getEventType()); event.setCatName(dbEvent.getCatalogName()); event.setDbName(dbEvent.getDbName()); event.setTableName(dbEvent.getTableName()); event.setMessage((dbEvent.getMessage())); event.setMessageFormat(dbEvent.getMessageFormat()); return event; }
public static ColumnStatisticsDesc getPartitionColumnStatisticsDesc( MPartitionColumnStatistics mStatsObj) { ColumnStatisticsDesc statsDesc = new ColumnStatisticsDesc(); statsDesc.setIsTblLevel(false); statsDesc.setCatName(mStatsObj.getCatName()); statsDesc.setDbName(mStatsObj.getDbName()); statsDesc.setTableName(mStatsObj.getTableName()); statsDesc.setPartName(mStatsObj.getPartitionName()); statsDesc.setLastAnalyzed(mStatsObj.getLastAnalyzed()); return statsDesc; }
public static ColumnStatisticsDesc getTableColumnStatisticsDesc( MTableColumnStatistics mStatsObj) { ColumnStatisticsDesc statsDesc = new ColumnStatisticsDesc(); statsDesc.setIsTblLevel(true); statsDesc.setCatName(mStatsObj.getCatName()); statsDesc.setDbName(mStatsObj.getDbName()); statsDesc.setTableName(mStatsObj.getTableName()); statsDesc.setLastAnalyzed(mStatsObj.getLastAnalyzed()); return statsDesc; }
private WMResourcePlan fromMResourcePlan(MWMResourcePlan mplan) { if (mplan == null) { return null; } WMResourcePlan rp = new WMResourcePlan(); rp.setName(mplan.getName()); rp.setNs(mplan.getNs()); rp.setStatus(WMResourcePlanStatus.valueOf(mplan.getStatus().name())); if (mplan.getQueryParallelism() != null) { rp.setQueryParallelism(mplan.getQueryParallelism()); } if (mplan.getDefaultPool() != null) { rp.setDefaultPoolPath(mplan.getDefaultPool().getPath()); } return rp; }
/** * Add role names of parentRoles and its parents to processedRoles * * @param processedRoleNames * @param parentRoles */ private void getAllRoleAncestors(Set<String> processedRoleNames, List<MRoleMap> parentRoles) { for (MRoleMap parentRole : parentRoles) { String parentRoleName = parentRole.getRole().getRoleName(); if (!processedRoleNames.contains(parentRoleName)) { // unprocessed role: get its parents, add it to processed, and call this // function recursively List<MRoleMap> nextParentRoles = listMRoles(parentRoleName, PrincipalType.ROLE); processedRoleNames.add(parentRoleName); getAllRoleAncestors(processedRoleNames, nextParentRoles); } } }
private MType getMType(Type type) { List<MFieldSchema> fields = new ArrayList<>(); if (type.getFields() != null) { for (FieldSchema field : type.getFields()) { fields.add(new MFieldSchema(field.getName(), field.getType(), field .getComment())); } } return new MType(type.getName(), type.getType1(), type.getType2(), fields); }
private WMPool fromMPool(MWMPool mPool, String rpName) { WMPool result = new WMPool(rpName, mPool.getPath()); assert mPool.getAllocFraction() != null; result.setAllocFraction(mPool.getAllocFraction()); assert mPool.getQueryParallelism() != null; result.setQueryParallelism(mPool.getQueryParallelism()); result.setSchedulingPolicy(mPool.getSchedulingPolicy()); result.setNs(mPool.getResourcePlan().getNs()); return result; }
private WMTrigger fromMWMTrigger(MWMTrigger mTrigger, String resourcePlanName) { WMTrigger trigger = new WMTrigger(); trigger.setResourcePlanName(resourcePlanName); trigger.setTriggerName(mTrigger.getName()); trigger.setTriggerExpression(mTrigger.getTriggerExpression()); trigger.setActionExpression(mTrigger.getActionExpression()); trigger.setIsInUnmanaged(mTrigger.getIsInUnmanaged()); trigger.setNs(mTrigger.getResourcePlan().getNs()); return trigger; }
private Catalog mCatToCat(MCatalog mCat) { Catalog cat = new Catalog(mCat.getName(), mCat.getLocationUri()); if (mCat.getDescription() != null) { cat.setDescription(mCat.getDescription()); } cat.setCreateTime(mCat.getCreateTime()); return cat; }
private static MFieldSchema getColumnFromTableColumns(List<MFieldSchema> cols, String col) { if (cols == null) { return null; } for (MFieldSchema mfs : cols) { if (mfs.getName().equalsIgnoreCase(col)) { return mfs; } } return null; }
private List<MStringList> convertToMStringLists(List<List<String>> mLists) { List<MStringList> lists = null ; if (null != mLists) { lists = new ArrayList<>(); for (List<String> mList : mLists) { lists.add(new MStringList(mList)); } } return lists; }
@Override public String getMetaStoreSchemaVersion() throws MetaException { MVersionTable mSchemaVer; try { mSchemaVer = getMSchemaVersion(); } catch (NoSuchObjectException e) { return null; } return mSchemaVer.getSchemaVersion(); }
private void deactivateActiveResourcePlan(String ns) { boolean commited = false; Query query = null; try { query = createActivePlanQuery(); MWMResourcePlan mResourcePlan = (MWMResourcePlan) query.execute( Status.ACTIVE.toString(), getNsOrDefault(ns)); // We may not have an active resource plan in the start. if (mResourcePlan != null) { mResourcePlan.setStatus(Status.ENABLED); } commited = commitTransaction(); } finally { rollbackAndCleanup(commited, query); } }
public int hashCode() { return toString().hashCode(); }
private static int getColumnIndexFromTableColumns(List<MFieldSchema> cols, String col) { if (cols == null) { return -1; } for (int i = 0; i < cols.size(); i++) { MFieldSchema mfs = cols.get(i); if (mfs.getName().equalsIgnoreCase(col)) { return i; } } return -1; }