public void minimizeMemory() { allDataScope = null; indexByUNameIdx = null; List<ICFBamDataScopeObj> toForget = new LinkedList<ICFBamDataScopeObj>(); ICFBamDataScopeObj cur = null; Iterator<ICFBamDataScopeObj> iter = members.values().iterator(); while (iter.hasNext()) { cur = iter.next(); if (cur.getEdit() == null) { toForget.add(cur); } } iter = toForget.iterator(); while (iter.hasNext()) { cur = iter.next(); cur.forget(); } }
public List<ICFBamDataScopeObj> readAllDataScope(boolean forceRead) { final String S_ProcName = "readAllDataScope"; if ((allDataScope == null) || forceRead) { Map<CFBamDataScopePKey, ICFBamDataScopeObj> map = new HashMap<CFBamDataScopePKey, ICFBamDataScopeObj>(); allDataScope = map; CFBamDataScopeBuff[] buffList = ((ICFBamSchema) schema.getBackingStore()) .getTableDataScope() .readAllDerived(schema.getAuthorization()); CFBamDataScopeBuff buff; ICFBamDataScopeObj obj; for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; obj = newInstance(); obj.setPKey(((ICFBamSchema) schema.getBackingStore()).getFactoryDataScope().newPKey()); obj.setBuff(buff); ICFBamDataScopeObj realized = (ICFBamDataScopeObj) obj.realize(); } } Comparator<ICFBamDataScopeObj> cmp = new Comparator<ICFBamDataScopeObj>() { public int compare(ICFBamDataScopeObj lhs, ICFBamDataScopeObj rhs) { if (lhs == null) { if (rhs == null) { return (0); } else { return (-1); } } else if (rhs == null) { return (1); } else { CFBamDataScopePKey lhsPKey = lhs.getPKey(); CFBamDataScopePKey rhsPKey = rhs.getPKey(); int ret = lhsPKey.compareTo(rhsPKey); return (ret); } } }; int len = allDataScope.size(); ICFBamDataScopeObj arr[] = new ICFBamDataScopeObj[len]; Iterator<ICFBamDataScopeObj> valIter = allDataScope.values().iterator(); int idx = 0; while ((idx < len) && valIter.hasNext()) { arr[idx++] = valIter.next(); } if (idx < len) { throw CFLib.getDefaultExceptionFactory() .newArgumentUnderflowException(getClass(), S_ProcName, 0, "idx", idx, len); } else if (valIter.hasNext()) { throw CFLib.getDefaultExceptionFactory() .newArgumentOverflowException(getClass(), S_ProcName, 0, "idx", idx, len); } Arrays.sort(arr, cmp); ArrayList<ICFBamDataScopeObj> arrayList = new ArrayList<ICFBamDataScopeObj>(len); for (idx = 0; idx < len; idx++) { arrayList.add(arr[idx]); } List<ICFBamDataScopeObj> sortedList = arrayList; return (sortedList); }