Skip to content

Commit 9511d1f

Browse files
authored
Оптимизация хранения данных (#537)
* упрощено хранение dataPath для элементов форм * упрощено хранение QuerySource * упрощено хранение состава плана обмена * фикс для определения неизменяемого списка * переезд на lazy lombok * перевод на record * перевод на record
1 parent 22e1cb2 commit 9511d1f

File tree

105 files changed

+3925
-10509
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+3925
-10509
lines changed

src/main/java/com/github/_1c_syntax/bsl/mdclasses/Configuration.java

Lines changed: 16 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,10 @@
8787
import com.github._1c_syntax.bsl.types.ModuleType;
8888
import com.github._1c_syntax.bsl.types.MultiLanguageString;
8989
import com.github._1c_syntax.bsl.types.ScriptVariant;
90-
import com.github._1c_syntax.utils.Lazy;
9190
import lombok.Builder;
9291
import lombok.Builder.Default;
9392
import lombok.EqualsAndHashCode;
93+
import lombok.Getter;
9494
import lombok.Singular;
9595
import lombok.ToString;
9696
import lombok.Value;
@@ -150,7 +150,8 @@ public class Configuration implements CF {
150150
ApplicationRunMode defaultRunMode = ApplicationRunMode.AUTO;
151151
@Default
152152
List<Module> modules = Collections.emptyList();
153-
Lazy<List<Module>> allModules = new Lazy<>(this::computeAllModules);
153+
@Getter(lazy = true)
154+
List<Module> allModules = LazyLoader.computeAllModules(this);
154155
@Default
155156
String vendor = "";
156157
@Default
@@ -259,13 +260,19 @@ public class Configuration implements CF {
259260

260261
@Singular
261262
List<MD> children;
262-
Lazy<List<MD>> plainChildren = new Lazy<>(this::computePlainChildren);
263-
264-
Lazy<Map<URI, ModuleType>> modulesByType = new Lazy<>(this::computeModulesByType);
265-
Lazy<Map<URI, Module>> modulesByURI = new Lazy<>(this::computeModulesByURI);
266-
Lazy<Map<URI, MD>> modulesByObject = new Lazy<>(this::computeModulesByObject);
267-
Lazy<Map<String, CommonModule>> commonModulesByName = new Lazy<>(this::computeCommonModulesByName);
268-
Lazy<Map<MdoReference, MD>> childrenByMdoRef = new Lazy<>(this::computeChildrenByMdoRef);
263+
@Getter(lazy = true)
264+
List<MD> plainChildren = LazyLoader.computePlainChildren(this);
265+
266+
@Getter(lazy = true)
267+
Map<URI, ModuleType> modulesByType = LazyLoader.computeModulesByType(this);
268+
@Getter(lazy = true)
269+
Map<URI, Module> modulesByURI = LazyLoader.computeModulesByURI(this);
270+
@Getter(lazy = true)
271+
Map<URI, MD> modulesByObject = LazyLoader.computeModulesByObject(this);
272+
@Getter(lazy = true)
273+
Map<String, CommonModule> commonModulesByName = LazyLoader.computeCommonModulesByName(this);
274+
@Getter(lazy = true)
275+
Map<MdoReference, MD> childrenByMdoRef = LazyLoader.computeChildrenByMdoRef(this);
269276

270277
/*
271278
* Свое
@@ -329,76 +336,13 @@ public class Configuration implements CF {
329336
@Default
330337
MultiLanguageString briefInformation = MultiLanguageString.EMPTY;
331338

332-
@Override
333-
public List<Module> getAllModules() {
334-
return allModules.getOrCompute();
335-
}
336-
337-
@Override
338-
public List<MD> getPlainChildren() {
339-
return plainChildren.getOrCompute();
340-
}
341-
342-
@Override
343-
public Map<URI, ModuleType> getModulesByType() {
344-
return modulesByType.getOrCompute();
345-
}
346-
347-
@Override
348-
public Map<URI, MD> getModulesByObject() {
349-
return modulesByObject.getOrCompute();
350-
}
351-
352-
@Override
353-
public Map<URI, Module> getModulesByURI() {
354-
return modulesByURI.getOrCompute();
355-
}
356-
357-
@Override
358-
public Map<String, CommonModule> getCommonModulesByName() {
359-
return commonModulesByName.getOrCompute();
360-
}
361-
362-
@Override
363-
public Map<MdoReference, MD> getChildrenByMdoRef() {
364-
return childrenByMdoRef.getOrCompute();
365-
}
366-
367339
/**
368340
* Возвращает перечень возможных прав доступа
369341
*/
370342
public static List<RoleRight> possibleRights() {
371343
return POSSIBLE_RIGHTS;
372344
}
373345

374-
private List<MD> computePlainChildren() {
375-
return LazyLoader.computePlainChildren(this);
376-
}
377-
378-
private Map<URI, ModuleType> computeModulesByType() {
379-
return LazyLoader.computeModulesByType(this);
380-
}
381-
382-
private Map<URI, MD> computeModulesByObject() {
383-
return LazyLoader.computeModulesByObject(this);
384-
}
385-
386-
private List<Module> computeAllModules() {
387-
return LazyLoader.computeAllModules(this);
388-
}
389-
390-
private Map<URI, Module> computeModulesByURI() {
391-
return LazyLoader.computeModulesByURI(this);
392-
}
393-
394-
private Map<String, CommonModule> computeCommonModulesByName() {
395-
return LazyLoader.computeCommonModulesByName(this);
396-
}
397-
398-
private Map<MdoReference, MD> computeChildrenByMdoRef() {
399-
return LazyLoader.computeChildrenByMdoRef(this);
400-
}
401-
402346
private static Configuration createEmptyConfiguration() {
403347
var emptyString = "empty";
404348

src/main/java/com/github/_1c_syntax/bsl/mdclasses/ConfigurationExtension.java

Lines changed: 15 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,10 @@
8686
import com.github._1c_syntax.bsl.types.ModuleType;
8787
import com.github._1c_syntax.bsl.types.MultiLanguageString;
8888
import com.github._1c_syntax.bsl.types.ScriptVariant;
89-
import com.github._1c_syntax.utils.Lazy;
9089
import lombok.Builder;
9190
import lombok.Builder.Default;
9291
import lombok.EqualsAndHashCode;
92+
import lombok.Getter;
9393
import lombok.Singular;
9494
import lombok.ToString;
9595
import lombok.Value;
@@ -143,7 +143,8 @@ public class ConfigurationExtension implements CF {
143143
ApplicationRunMode defaultRunMode = ApplicationRunMode.AUTO;
144144
@Default
145145
List<Module> modules = Collections.emptyList();
146-
Lazy<List<Module>> allModules = new Lazy<>(this::computeAllModules);
146+
@Getter(lazy = true)
147+
List<Module> allModules = LazyLoader.computeAllModules(this);
147148
@Default
148149
String vendor = "";
149150
@Default
@@ -252,13 +253,19 @@ public class ConfigurationExtension implements CF {
252253

253254
@Singular
254255
List<MD> children;
255-
Lazy<List<MD>> plainChildren = new Lazy<>(this::computePlainChildren);
256+
@Getter(lazy = true)
257+
List<MD> plainChildren = LazyLoader.computePlainChildren(this);
256258

257-
Lazy<Map<URI, ModuleType>> modulesByType = new Lazy<>(this::computeModulesByType);
258-
Lazy<Map<URI, MD>> modulesByObject = new Lazy<>(this::computeModulesByObject);
259-
Lazy<Map<URI, Module>> modulesByURI = new Lazy<>(this::computeModulesByURI);
260-
Lazy<Map<String, CommonModule>> commonModulesByName = new Lazy<>(this::computeCommonModulesByName);
261-
Lazy<Map<MdoReference, MD>> childrenByMdoRef = new Lazy<>(this::computeChildrenByMdoRef);
259+
@Getter(lazy = true)
260+
Map<URI, ModuleType> modulesByType = LazyLoader.computeModulesByType(this);
261+
@Getter(lazy = true)
262+
Map<URI, Module> modulesByURI = LazyLoader.computeModulesByURI(this);
263+
@Getter(lazy = true)
264+
Map<URI, MD> modulesByObject = LazyLoader.computeModulesByObject(this);
265+
@Getter(lazy = true)
266+
Map<String, CommonModule> commonModulesByName = LazyLoader.computeCommonModulesByName(this);
267+
@Getter(lazy = true)
268+
Map<MdoReference, MD> childrenByMdoRef = LazyLoader.computeChildrenByMdoRef(this);
262269

263270
/*
264271
* Свое
@@ -276,74 +283,11 @@ public class ConfigurationExtension implements CF {
276283
@Default
277284
String namePrefix = "";
278285

279-
@Override
280-
public List<Module> getAllModules() {
281-
return allModules.getOrCompute();
282-
}
283-
284-
@Override
285-
public List<MD> getPlainChildren() {
286-
return plainChildren.getOrCompute();
287-
}
288-
289-
@Override
290-
public Map<URI, ModuleType> getModulesByType() {
291-
return modulesByType.getOrCompute();
292-
}
293-
294-
@Override
295-
public Map<URI, MD> getModulesByObject() {
296-
return modulesByObject.getOrCompute();
297-
}
298-
299-
@Override
300-
public Map<URI, Module> getModulesByURI() {
301-
return modulesByURI.getOrCompute();
302-
}
303-
304-
@Override
305-
public Map<String, CommonModule> getCommonModulesByName() {
306-
return commonModulesByName.getOrCompute();
307-
}
308-
309-
@Override
310-
public Map<MdoReference, MD> getChildrenByMdoRef() {
311-
return childrenByMdoRef.getOrCompute();
312-
}
313-
314286
/**
315287
* Возвращает перечень возможных прав доступа
316288
*/
317289
public static List<RoleRight> possibleRights() {
318290
return Configuration.possibleRights();
319291
}
320292

321-
private List<MD> computePlainChildren() {
322-
return LazyLoader.computePlainChildren(this);
323-
}
324-
325-
private Map<URI, ModuleType> computeModulesByType() {
326-
return LazyLoader.computeModulesByType(this);
327-
}
328-
329-
private Map<URI, MD> computeModulesByObject() {
330-
return LazyLoader.computeModulesByObject(this);
331-
}
332-
333-
private List<Module> computeAllModules() {
334-
return LazyLoader.computeAllModules(this);
335-
}
336-
337-
private Map<URI, Module> computeModulesByURI() {
338-
return LazyLoader.computeModulesByURI(this);
339-
}
340-
341-
private Map<String, CommonModule> computeCommonModulesByName() {
342-
return LazyLoader.computeCommonModulesByName(this);
343-
}
344-
345-
private Map<MdoReference, MD> computeChildrenByMdoRef() {
346-
return LazyLoader.computeChildrenByMdoRef(this);
347-
}
348-
349293
}

src/main/java/com/github/_1c_syntax/bsl/mdclasses/ExternalDataProcessor.java

Lines changed: 11 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@
3232
import com.github._1c_syntax.bsl.types.ConfigurationSource;
3333
import com.github._1c_syntax.bsl.types.MdoReference;
3434
import com.github._1c_syntax.bsl.types.MultiLanguageString;
35-
import com.github._1c_syntax.utils.Lazy;
3635
import lombok.Builder;
3736
import lombok.Builder.Default;
3837
import lombok.EqualsAndHashCode;
38+
import lombok.Getter;
3939
import lombok.Singular;
4040
import lombok.ToString;
4141
import lombok.Value;
@@ -65,7 +65,8 @@ public class ExternalDataProcessor implements ExternalSource {
6565

6666
@Default
6767
List<Module> modules = Collections.emptyList();
68-
Lazy<List<Module>> allModules = new Lazy<>(this::computeAllModules);
68+
@Getter(lazy = true)
69+
List<Module> allModules = LazyLoader.computeAllModules(this);
6970

7071
@Default
7172
ConfigurationSource configurationSource = ConfigurationSource.EMPTY;
@@ -79,61 +80,19 @@ public class ExternalDataProcessor implements ExternalSource {
7980
@Singular
8081
List<TabularSection> tabularSections;
8182

82-
Lazy<List<MD>> storageFields = new Lazy<>(this::computeStorageFields);
83-
Lazy<List<MD>> plainStorageFields = new Lazy<>(this::computePlainStorageFields);
83+
@Getter(lazy = true)
84+
List<MD> storageFields = LazyLoader.computeStorageFields(this);
85+
@Getter(lazy = true)
86+
List<MD> plainStorageFields = LazyLoader.computePlainStorageFields(this);
8487

8588
@Singular
8689
List<ObjectForm> forms;
8790

8891
@Singular
8992
List<ObjectTemplate> templates;
9093

91-
Lazy<List<MD>> children = new Lazy<>(this::computeChildren);
92-
Lazy<List<MD>> plainChildren = new Lazy<>(this::computePlainChildren);
93-
94-
@Override
95-
public List<MD> getChildren() {
96-
return children.getOrCompute();
97-
}
98-
99-
@Override
100-
public List<MD> getPlainChildren() {
101-
return plainChildren.getOrCompute();
102-
}
103-
104-
@Override
105-
public List<MD> getStorageFields() {
106-
return storageFields.getOrCompute();
107-
}
108-
109-
@Override
110-
public List<MD> getPlainStorageFields() {
111-
return plainStorageFields.getOrCompute();
112-
}
113-
114-
@Override
115-
public List<Module> getAllModules() {
116-
return allModules.getOrCompute();
117-
}
118-
119-
private List<MD> computeChildren() {
120-
return LazyLoader.computeChildren(this);
121-
}
122-
123-
private List<MD> computePlainChildren() {
124-
return LazyLoader.computePlainChildren(this);
125-
}
126-
127-
private List<MD> computeStorageFields() {
128-
return LazyLoader.computeStorageFields(this);
129-
}
130-
131-
private List<MD> computePlainStorageFields() {
132-
return LazyLoader.computePlainStorageFields(this);
133-
}
134-
135-
private List<Module> computeAllModules() {
136-
return LazyLoader.computeAllModules(this);
137-
}
138-
94+
@Getter(lazy = true)
95+
List<MD> children = LazyLoader.computeChildren(this);
96+
@Getter(lazy = true)
97+
List<MD> plainChildren = LazyLoader.computePlainChildren(this);
13998
}

0 commit comments

Comments
 (0)