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; return;
} }
long oldCatId = doGetCategoryID();
Category cat = dataMgr.createCategory(path); Category cat = dataMgr.createCategory(path);
try { try {
doSetCategoryPathRecord(cat.getID()); doSetCategoryPathRecord(cat.getID());
category = cat; category = cat;
dataMgr.dataTypeCategoryPathChanged(this, myPath); dataMgr.dataTypeCategoryPathChanged(this, myPath, oldCatId);
} }
catch (IOException e) { catch (IOException e) {
dataMgr.dbError(e); dataMgr.dbError(e);

View file

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