提交 fb02511b 编写于 作者: O o2sword

设计搜索内存优化,减少对象创建,减少数据输出

上级 c51727e4
...@@ -86,7 +86,6 @@ public class WrapDesigner extends GsonPropertyObject { ...@@ -86,7 +86,6 @@ public class WrapDesigner extends GsonPropertyObject {
public void setPatternList(Map<String, String> map) { public void setPatternList(Map<String, String> map) {
if(map!=null && !map.isEmpty()){ if(map!=null && !map.isEmpty()){
List<DesignerPattern> patternList = new ArrayList<>();
for (String key : map.keySet()){ for (String key : map.keySet()){
DesignerPattern pattern = new DesignerPattern(); DesignerPattern pattern = new DesignerPattern();
pattern.setProperty(key); pattern.setProperty(key);
...@@ -97,9 +96,10 @@ public class WrapDesigner extends GsonPropertyObject { ...@@ -97,9 +96,10 @@ public class WrapDesigner extends GsonPropertyObject {
} }
} }
pattern.setPropertyValue(propertyValue); pattern.setPropertyValue(propertyValue);
patternList.add(pattern); this.patternList.add(pattern);
} }
this.patternList = patternList; map.clear();
map = null;
} }
} }
...@@ -118,6 +118,8 @@ public class WrapDesigner extends GsonPropertyObject { ...@@ -118,6 +118,8 @@ public class WrapDesigner extends GsonPropertyObject {
pattern.setPropertyValue(propertyValue); pattern.setPropertyValue(propertyValue);
this.patternList.add(pattern); this.patternList.add(pattern);
} }
map.clear();
map = null;
} }
} }
...@@ -138,6 +140,8 @@ public class WrapDesigner extends GsonPropertyObject { ...@@ -138,6 +140,8 @@ public class WrapDesigner extends GsonPropertyObject {
pattern.setPropertyValue(propertyValue); pattern.setPropertyValue(propertyValue);
this.patternList.add(pattern); this.patternList.add(pattern);
} }
map.clear();
map = null;
} }
} }
...@@ -190,6 +194,7 @@ public class WrapDesigner extends GsonPropertyObject { ...@@ -190,6 +194,7 @@ public class WrapDesigner extends GsonPropertyObject {
} }
this.lines = lines; this.lines = lines;
map.clear(); map.clear();
map = null;
} }
} }
......
...@@ -88,7 +88,7 @@ class ActionSearch extends BaseAction { ...@@ -88,7 +88,7 @@ class ActionSearch extends BaseAction {
wi.getCaseSensitive(), wi.getMatchWholeWord(), wi.getMatchRegExp()); wi.getCaseSensitive(), wi.getMatchWholeWord(), wi.getMatchRegExp());
if (!map.isEmpty()) { if (!map.isEmpty()) {
Wo wo = new Wo(); Wo wo = new Wo();
AppInfo appInfo = emc.find( woScript.getAppId(), AppInfo.class ); AppInfo appInfo = emc.fetch(woScript.getAppId(), AppInfo.class, ListTools.toList(AppInfo.id_FIELDNAME, AppInfo.appName_FIELDNAME));
if(appInfo != null){ if(appInfo != null){
wo.setAppId(appInfo.getId()); wo.setAppId(appInfo.getId());
wo.setAppName(appInfo.getAppName()); wo.setAppName(appInfo.getAppName());
...@@ -102,6 +102,7 @@ class ActionSearch extends BaseAction { ...@@ -102,6 +102,7 @@ class ActionSearch extends BaseAction {
} }
} }
woScripts.clear(); woScripts.clear();
woScripts = null;
}catch (Exception e){ }catch (Exception e){
logger.error(e); logger.error(e);
} }
...@@ -126,7 +127,7 @@ class ActionSearch extends BaseAction { ...@@ -126,7 +127,7 @@ class ActionSearch extends BaseAction {
wi.getCaseSensitive(), wi.getMatchWholeWord(), wi.getMatchRegExp()); wi.getCaseSensitive(), wi.getMatchWholeWord(), wi.getMatchRegExp());
if (!map.isEmpty()) { if (!map.isEmpty()) {
Wo wo = new Wo(); Wo wo = new Wo();
AppInfo appInfo = emc.find( woForm.getAppId(), AppInfo.class ); AppInfo appInfo = emc.fetch(woForm.getAppId(), AppInfo.class, ListTools.toList(AppInfo.id_FIELDNAME, AppInfo.appName_FIELDNAME));
if(appInfo != null){ if(appInfo != null){
wo.setAppId(appInfo.getId()); wo.setAppId(appInfo.getId());
wo.setAppName(appInfo.getAppName()); wo.setAppName(appInfo.getAppName());
...@@ -140,6 +141,7 @@ class ActionSearch extends BaseAction { ...@@ -140,6 +141,7 @@ class ActionSearch extends BaseAction {
} }
} }
woForms.clear(); woForms.clear();
woForms = null;
} }
}catch (Exception e){ }catch (Exception e){
......
...@@ -91,7 +91,7 @@ class ActionSearch extends BaseAction { ...@@ -91,7 +91,7 @@ class ActionSearch extends BaseAction {
wi.getCaseSensitive(), wi.getMatchWholeWord(), wi.getMatchRegExp()); wi.getCaseSensitive(), wi.getMatchWholeWord(), wi.getMatchRegExp());
if (!map.isEmpty()) { if (!map.isEmpty()) {
Wo wo = new Wo(); Wo wo = new Wo();
Portal portal = emc.find(woScript.getPortal(), Portal.class); Portal portal = emc.fetch(woScript.getPortal(), Portal.class, ListTools.toList(Portal.id_FIELDNAME, Portal.name_FIELDNAME));
if(portal != null){ if(portal != null){
wo.setAppId(portal.getId()); wo.setAppId(portal.getId());
wo.setAppName(portal.getName()); wo.setAppName(portal.getName());
...@@ -105,6 +105,7 @@ class ActionSearch extends BaseAction { ...@@ -105,6 +105,7 @@ class ActionSearch extends BaseAction {
} }
} }
woScripts.clear(); woScripts.clear();
woScripts = null;
}catch (Exception e){ }catch (Exception e){
logger.error(e); logger.error(e);
} }
...@@ -129,7 +130,7 @@ class ActionSearch extends BaseAction { ...@@ -129,7 +130,7 @@ class ActionSearch extends BaseAction {
wi.getCaseSensitive(), wi.getMatchWholeWord(), wi.getMatchRegExp()); wi.getCaseSensitive(), wi.getMatchWholeWord(), wi.getMatchRegExp());
if (!map.isEmpty()) { if (!map.isEmpty()) {
Wo wo = new Wo(); Wo wo = new Wo();
Portal portal = emc.find(wopage.getPortal(), Portal.class); Portal portal = emc.fetch(wopage.getPortal(), Portal.class, ListTools.toList(Portal.id_FIELDNAME, Portal.name_FIELDNAME));
if(portal != null){ if(portal != null){
wo.setAppId(portal.getId()); wo.setAppId(portal.getId());
wo.setAppName(portal.getName()); wo.setAppName(portal.getName());
...@@ -143,6 +144,7 @@ class ActionSearch extends BaseAction { ...@@ -143,6 +144,7 @@ class ActionSearch extends BaseAction {
} }
} }
wos.clear(); wos.clear();
wos = null;
} }
}catch (Exception e){ }catch (Exception e){
...@@ -169,7 +171,7 @@ class ActionSearch extends BaseAction { ...@@ -169,7 +171,7 @@ class ActionSearch extends BaseAction {
wi.getCaseSensitive(), wi.getMatchWholeWord(), wi.getMatchRegExp()); wi.getCaseSensitive(), wi.getMatchWholeWord(), wi.getMatchRegExp());
if (!map.isEmpty()) { if (!map.isEmpty()) {
Wo wo = new Wo(); Wo wo = new Wo();
Portal portal = emc.find(woWidget.getPortal(), Portal.class); Portal portal = emc.fetch(woWidget.getPortal(), Portal.class, ListTools.toList(Portal.id_FIELDNAME, Portal.name_FIELDNAME));
if(portal != null){ if(portal != null){
wo.setAppId(portal.getId()); wo.setAppId(portal.getId());
wo.setAppName(portal.getName()); wo.setAppName(portal.getName());
...@@ -183,6 +185,7 @@ class ActionSearch extends BaseAction { ...@@ -183,6 +185,7 @@ class ActionSearch extends BaseAction {
} }
} }
wos.clear(); wos.clear();
wos = null;
} }
}catch (Exception e){ }catch (Exception e){
......
...@@ -93,6 +93,7 @@ class ActionSearch extends BaseAction { ...@@ -93,6 +93,7 @@ class ActionSearch extends BaseAction {
} }
} }
woAgents.clear(); woAgents.clear();
woAgents = null;
}catch (Exception e){ }catch (Exception e){
logger.error(e); logger.error(e);
} }
...@@ -127,6 +128,7 @@ class ActionSearch extends BaseAction { ...@@ -127,6 +128,7 @@ class ActionSearch extends BaseAction {
} }
} }
woInvokes.clear(); woInvokes.clear();
woInvokes = null;
}catch (Exception e){ }catch (Exception e){
logger.error(e); logger.error(e);
} }
......
...@@ -96,7 +96,7 @@ class ActionSearch extends BaseAction { ...@@ -96,7 +96,7 @@ class ActionSearch extends BaseAction {
wi.getCaseSensitive(), wi.getMatchWholeWord(), wi.getMatchRegExp()); wi.getCaseSensitive(), wi.getMatchWholeWord(), wi.getMatchRegExp());
if (!map.isEmpty()) { if (!map.isEmpty()) {
Wo wo = new Wo(); Wo wo = new Wo();
Query query = emc.find(woView.getQuery(), Query.class); Query query = emc.fetch(woView.getQuery(), Query.class, ListTools.toList(Query.id_FIELDNAME, Query.name_FIELDNAME));
if (query != null) { if (query != null) {
wo.setAppId(query.getId()); wo.setAppId(query.getId());
wo.setAppName(query.getName()); wo.setAppName(query.getName());
...@@ -135,7 +135,7 @@ class ActionSearch extends BaseAction { ...@@ -135,7 +135,7 @@ class ActionSearch extends BaseAction {
wi.getCaseSensitive(), wi.getMatchWholeWord(), wi.getMatchRegExp()); wi.getCaseSensitive(), wi.getMatchWholeWord(), wi.getMatchRegExp());
if (!map.isEmpty()) { if (!map.isEmpty()) {
Wo wo = new Wo(); Wo wo = new Wo();
Query query = emc.find(woTable.getQuery(), Query.class); Query query = emc.fetch(woTable.getQuery(), Query.class, ListTools.toList(Query.id_FIELDNAME, Query.name_FIELDNAME));
if (query != null) { if (query != null) {
wo.setAppId(query.getId()); wo.setAppId(query.getId());
wo.setAppName(query.getName()); wo.setAppName(query.getName());
...@@ -149,6 +149,7 @@ class ActionSearch extends BaseAction { ...@@ -149,6 +149,7 @@ class ActionSearch extends BaseAction {
} }
} }
woTables.clear(); woTables.clear();
woTables = null;
}catch (Exception e){ }catch (Exception e){
logger.error(e); logger.error(e);
} }
...@@ -174,7 +175,7 @@ class ActionSearch extends BaseAction { ...@@ -174,7 +175,7 @@ class ActionSearch extends BaseAction {
wi.getCaseSensitive(), wi.getMatchWholeWord(), wi.getMatchRegExp()); wi.getCaseSensitive(), wi.getMatchWholeWord(), wi.getMatchRegExp());
if (!map.isEmpty()) { if (!map.isEmpty()) {
Wo wo = new Wo(); Wo wo = new Wo();
Query query = emc.find(woStat.getQuery(), Query.class); Query query = emc.fetch(woStat.getQuery(), Query.class, ListTools.toList(Query.id_FIELDNAME, Query.name_FIELDNAME));
if (query != null) { if (query != null) {
wo.setAppId(query.getId()); wo.setAppId(query.getId());
wo.setAppName(query.getName()); wo.setAppName(query.getName());
...@@ -188,6 +189,7 @@ class ActionSearch extends BaseAction { ...@@ -188,6 +189,7 @@ class ActionSearch extends BaseAction {
} }
} }
woStats.clear(); woStats.clear();
woStats = null;
}catch (Exception e){ }catch (Exception e){
logger.error(e); logger.error(e);
} }
...@@ -213,7 +215,7 @@ class ActionSearch extends BaseAction { ...@@ -213,7 +215,7 @@ class ActionSearch extends BaseAction {
wi.getCaseSensitive(), wi.getMatchWholeWord(), wi.getMatchRegExp()); wi.getCaseSensitive(), wi.getMatchWholeWord(), wi.getMatchRegExp());
if (!map.isEmpty()) { if (!map.isEmpty()) {
Wo wo = new Wo(); Wo wo = new Wo();
Query query = emc.find(woStatement.getQuery(), Query.class); Query query = emc.fetch(woStatement.getQuery(), Query.class, ListTools.toList(Query.id_FIELDNAME, Query.name_FIELDNAME));
if (query != null) { if (query != null) {
wo.setAppId(query.getId()); wo.setAppId(query.getId());
wo.setAppName(query.getName()); wo.setAppName(query.getName());
...@@ -227,6 +229,7 @@ class ActionSearch extends BaseAction { ...@@ -227,6 +229,7 @@ class ActionSearch extends BaseAction {
} }
} }
woStatements.clear(); woStatements.clear();
woStatements = null;
}catch (Exception e){ }catch (Exception e){
logger.error(e); logger.error(e);
} }
......
...@@ -33,8 +33,8 @@ class ActionSearch extends BaseAction { ...@@ -33,8 +33,8 @@ class ActionSearch extends BaseAction {
if(StringUtils.isBlank(wi.getKeyword())){ if(StringUtils.isBlank(wi.getKeyword())){
throw new ExceptionFieldEmpty("keyword"); throw new ExceptionFieldEmpty("keyword");
} }
logger.info("{}搜索全局设计:{}", effectivePerson.getDistinguishedName(), wi); logger.info("{}搜索设计:{}的关键字:{}", effectivePerson.getDistinguishedName(), wi.getModuleList(), wi.getKeyword());
if (ListTools.isEmpty(wi.getModuleList())) { if (ListTools.isNotEmpty(wi.getModuleList())) {
result.setData(search(wi)); result.setData(search(wi));
}else{ }else{
lock.lock(); lock.lock();
...@@ -112,7 +112,7 @@ class ActionSearch extends BaseAction { ...@@ -112,7 +112,7 @@ class ActionSearch extends BaseAction {
private CompletableFuture<List<WrapDesigner>> searchAsync(final Wi wi, final Map<String, List<WiDesigner.ModuleApp>> moduleMap, final String moduleType, final Class<?> applicationClass, Executor executor){ private CompletableFuture<List<WrapDesigner>> searchAsync(final Wi wi, final Map<String, List<WiDesigner.ModuleApp>> moduleMap, final String moduleType, final Class<?> applicationClass, Executor executor){
CompletableFuture<List<WrapDesigner>> cf = CompletableFuture.supplyAsync(() -> { CompletableFuture<List<WrapDesigner>> cf = CompletableFuture.supplyAsync(() -> {
List<WrapDesigner> swList = new ArrayList<>(); List<WrapDesigner> swList = null;
if(moduleMap.containsKey(moduleType)) { if(moduleMap.containsKey(moduleType)) {
try { try {
WiDesigner wiDesigner = new WiDesigner(); WiDesigner wiDesigner = new WiDesigner();
...@@ -126,7 +126,7 @@ class ActionSearch extends BaseAction { ...@@ -126,7 +126,7 @@ class ActionSearch extends BaseAction {
} catch (Exception e) { } catch (Exception e) {
logger.error(e); logger.error(e);
} }
if (swList.size() > 2) { if (swList!=null && swList.size() > 2) {
try { try {
SortTools.desc(swList, "designerType","appId"); SortTools.desc(swList, "designerType","appId");
} catch (Exception e) { } catch (Exception e) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册