GT-3359 improve performance of DataTypeDB.setCategoryPath()

This commit is contained in:
dev747368 2019-11-29 16:14:54 -05:00
parent 76bd653deb
commit fab4085be7
2 changed files with 10 additions and 10 deletions

View file

@ -362,11 +362,12 @@ abstract class DataTypeDB extends DatabaseObject implements DataType, ChangeList
return;
}
long oldCatId = doGetCategoryID();
Category cat = dataMgr.createCategory(path);
try {
doSetCategoryPathRecord(cat.getID());
category = cat;
dataMgr.dataTypeCategoryPathChanged(this, myPath);
dataMgr.dataTypeCategoryPathChanged(this, myPath, oldCatId);
}
catch (IOException e) {
dataMgr.dbError(e);

View file

@ -2625,20 +2625,19 @@ abstract public class DataTypeManagerDB implements DataTypeManager {
* Notifys the category path changed
* @param dt the datatype whose path changed.
* @param oldPath the old category.
* @param oldCatId the old category's record id
*/
void dataTypeCategoryPathChanged(DataTypeDB dt, CategoryPath oldPath) {
void dataTypeCategoryPathChanged(DataTypeDB dt, CategoryPath oldPath, long oldCatId) {
if (!(dt instanceof Array) && !(dt instanceof Pointer)) {
try {
RecordIterator it = arrayAdapter.getRecords();
while (it.hasNext()) {
Record rec = it.next();
ArrayDB array = (ArrayDB) getDataType(rec.getKey(), rec);
for (long arrayId : arrayAdapter.getRecordIdsInCategory(oldCatId)) {
Record rec = arrayAdapter.getRecord(arrayId);
ArrayDB array = (ArrayDB) getDataType(arrayId, rec);
array.updatePath(dt);
}
it = pointerAdapter.getRecords();
while (it.hasNext()) {
Record rec = it.next();
PointerDB ptr = (PointerDB) getDataType(rec.getKey(), rec);
for (long ptrId : pointerAdapter.getRecordIdsInCategory(oldCatId)) {
Record rec = pointerAdapter.getRecord(ptrId);
PointerDB ptr = (PointerDB) getDataType(ptrId, rec);
ptr.updatePath(dt);
}
}