Skip to content

Commit 7d525b3

Browse files
authored
Настройки чтения MDC (#531)
создан справочник с настройками чтения MDC. Использование skipSupport переведено на настройку
1 parent 73d3abd commit 7d525b3

File tree

20 files changed

+422
-117
lines changed

20 files changed

+422
-117
lines changed

benchmark-compare.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ BUILD_DIR="build/libs"
1919
echo "🔨 Начало сравнения производительности MDClasses"
2020
echo "================================================"
2121

22+
rm -rf "$RESULTS_DIR"
2223
mkdir -p $RESULTS_DIR
2324

2425
# Функция для проверки является ли параметром JAR файл

src/jmh/java/com/github/_1c_syntax/bsl/mdclasses/benchmark/MDClassesBenchmark.java

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,17 @@
2121
*/
2222
package com.github._1c_syntax.bsl.mdclasses.benchmark;
2323

24+
import com.github._1c_syntax.bsl.mdclasses.MDCReadSettings;
2425
import com.github._1c_syntax.bsl.mdclasses.MDClasses;
2526
import org.openjdk.jmh.annotations.Benchmark;
2627
import org.openjdk.jmh.annotations.BenchmarkMode;
2728
import org.openjdk.jmh.annotations.Fork;
28-
import org.openjdk.jmh.annotations.Level;
2929
import org.openjdk.jmh.annotations.Measurement;
3030
import org.openjdk.jmh.annotations.Mode;
3131
import org.openjdk.jmh.annotations.OutputTimeUnit;
3232
import org.openjdk.jmh.annotations.Scope;
3333
import org.openjdk.jmh.annotations.Setup;
3434
import org.openjdk.jmh.annotations.State;
35-
import org.openjdk.jmh.annotations.TearDown;
3635
import org.openjdk.jmh.annotations.Warmup;
3736
import org.openjdk.jmh.infra.Blackhole;
3837

@@ -49,35 +48,42 @@ public class MDClassesBenchmark {
4948

5049
private final Path configPathEDT = Path.of("src/test/resources/ext/edt/ssl_3_1/configuration");
5150
private final Path configPathDesigner = Path.of("src/test/resources/ext/designer/ssl_3_1/src/cf");
51+
private static final MDCReadSettings SKIP_ALL = MDCReadSettings.builder()
52+
.skipSupport(true)
53+
.skipRoleData(true)
54+
.skipFormElementItems(true)
55+
.skipXdtoPackage(true)
56+
.skipDataCompositionSchema(true)
57+
.build();
5258

5359
@Setup
5460
public void setup() {
5561
// Предварительная загрузка для разогрева
56-
MDClasses.createConfiguration(configPathEDT, false);
57-
MDClasses.createConfiguration(configPathDesigner, false);
62+
MDClasses.createConfiguration(configPathEDT);
63+
MDClasses.createConfiguration(configPathDesigner);
5864
}
5965

6066
@Benchmark
6167
public void test_EDT_CreateConfiguration_SkipSupport_False(Blackhole blackhole) {
62-
var model = MDClasses.createConfiguration(configPathEDT, false);
68+
var model = MDClasses.createConfiguration(configPathEDT);
6369
blackhole.consume(model);
6470
}
6571

6672
@Benchmark
6773
public void test_EDT_CreateConfiguration_SkipSupport_True(Blackhole blackhole) {
68-
var model = MDClasses.createConfiguration(configPathEDT, true);
74+
var model = MDClasses.createConfiguration(configPathEDT, SKIP_ALL);
6975
blackhole.consume(model);
7076
}
7177

7278
@Benchmark
7379
public void test_Designer_CreateConfiguration_SkipSupport_False(Blackhole blackhole) {
74-
var model = MDClasses.createConfiguration(configPathDesigner, false);
80+
var model = MDClasses.createConfiguration(configPathDesigner);
7581
blackhole.consume(model);
7682
}
7783

7884
@Benchmark
7985
public void test_Designer_CreateConfiguration_SkipSupport_True(Blackhole blackhole) {
80-
var model = MDClasses.createConfiguration(configPathDesigner, true);
86+
var model = MDClasses.createConfiguration(configPathDesigner, SKIP_ALL);
8187
blackhole.consume(model);
8288
}
8389
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/*
2+
* This file is a part of MDClasses.
3+
*
4+
* Copyright (c) 2019 - 2025
5+
* Tymko Oleg <[email protected]>, Maximov Valery <[email protected]> and contributors
6+
*
7+
* SPDX-License-Identifier: LGPL-3.0-or-later
8+
*
9+
* MDClasses is free software; you can redistribute it and/or
10+
* modify it under the terms of the GNU Lesser General Public
11+
* License as published by the Free Software Foundation; either
12+
* version 3.0 of the License, or (at your option) any later version.
13+
*
14+
* MDClasses is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17+
* Lesser General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU Lesser General Public
20+
* License along with MDClasses.
21+
*/
22+
package com.github._1c_syntax.bsl.mdclasses;
23+
24+
import lombok.Builder;
25+
import lombok.Value;
26+
27+
/**
28+
* Настройки чтения MDC
29+
*/
30+
@Value
31+
@Builder
32+
public class MDCReadSettings {
33+
/**
34+
* Настройки по умолчанию
35+
*/
36+
public static final MDCReadSettings DEFAULT = MDCReadSettings.builder().build();
37+
38+
/**
39+
* Шаблон с отключением только чтения поддержки
40+
*/
41+
public static final MDCReadSettings SKIP_SUPPORT = MDCReadSettings.builder().skipSupport(true).build();
42+
43+
/**
44+
* Пропускать чтение настроек поставки конфигурации
45+
*/
46+
boolean skipSupport;
47+
48+
/**
49+
* Пропускать чтение содержимого ролей
50+
*/
51+
boolean skipRoleData;
52+
53+
/**
54+
* Пропускать чтение содержимого xdto пакетов
55+
*/
56+
boolean skipXdtoPackage;
57+
58+
/**
59+
* Пропускать чтение элементов форм
60+
*/
61+
boolean skipFormElementItems;
62+
63+
/**
64+
* Пропускать чтение элементов макетов системы компоновки
65+
*/
66+
boolean skipDataCompositionSchema;
67+
68+
}

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

Lines changed: 59 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,18 +72,30 @@ public ExternalSource createExternalReport() {
7272
* @return Конфигурация или расширение
7373
*/
7474
public MDClass createConfiguration(Path path) {
75-
return createConfiguration(path, false);
75+
return createConfiguration(path, MDCReadSettings.DEFAULT);
7676
}
7777

7878
/**
7979
* Создает конфигурацию или расширение по указанному пути
8080
*
81+
* @param path Путь к корню проекта
82+
* @param readSettings Настройки чтения
83+
* @return Конфигурация или расширение
84+
*/
85+
public MDClass createConfiguration(Path path, MDCReadSettings readSettings) {
86+
return MDOReader.readConfiguration(path, readSettings);
87+
}
88+
89+
/**
8190
* @param path Путь к корню проекта
8291
* @param skipSupport Флаг управления чтением информации о поддержке
8392
* @return Конфигурация или расширение
93+
* @deprecated Стоит использовать метод с параметром MDCReadSettings.
94+
* Создает конфигурацию или расширение по указанному пути
8495
*/
96+
@Deprecated(since = "0.16.0")
8597
public MDClass createConfiguration(Path path, boolean skipSupport) {
86-
return MDOReader.readConfiguration(path, skipSupport);
98+
return createConfiguration(path, MDCReadSettings.builder().skipSupport(skipSupport).build());
8799
}
88100

89101
/**
@@ -103,7 +115,7 @@ public MDClass createExternalSource(Path mdoPath) {
103115
* @return Список прочитанных контейнеров конфигураций и расширений
104116
*/
105117
public List<MDClass> createConfigurations(Path sourcePath) {
106-
return createConfigurations(sourcePath, false);
118+
return createConfigurations(sourcePath, MDCReadSettings.DEFAULT);
107119
}
108120

109121
/**
@@ -112,10 +124,25 @@ public List<MDClass> createConfigurations(Path sourcePath) {
112124
* @param sourcePath каталог исходных файлов
113125
* @param skipSupport Флаг управления чтением информации о поддержке
114126
* @return Список прочитанных контейнеров конфигураций и расширений
127+
* @deprecated Стоит использовать метод с параметром MDCReadSettings.
115128
*/
129+
@Deprecated(since = "0.16.0")
116130
public List<MDClass> createConfigurations(Path sourcePath, boolean skipSupport) {
117131
return findFiles(sourcePath, SEARCH_CONFIGURATION).parallelStream()
118-
.map(path -> createConfiguration(path, skipSupport))
132+
.map(path -> createConfiguration(path, MDCReadSettings.builder().skipSupport(skipSupport).build()))
133+
.toList();
134+
}
135+
136+
/**
137+
* Возвращает список конфигураций\расширений в указанном каталоге исходных файлов
138+
*
139+
* @param sourcePath каталог исходных файлов
140+
* @param readSettings Настройки чтения
141+
* @return Список прочитанных контейнеров конфигураций и расширений
142+
*/
143+
public List<MDClass> createConfigurations(Path sourcePath, MDCReadSettings readSettings) {
144+
return findFiles(sourcePath, SEARCH_CONFIGURATION).parallelStream()
145+
.map(path -> createConfiguration(path, readSettings))
119146
.toList();
120147
}
121148

@@ -126,8 +153,19 @@ public List<MDClass> createConfigurations(Path sourcePath, boolean skipSupport)
126153
* @return Список прочитанных контейнеров внешних отчетов и обработок
127154
*/
128155
public List<MDClass> createExternalSources(Path sourcePath) {
156+
return createExternalSources(sourcePath, MDCReadSettings.DEFAULT);
157+
}
158+
159+
/**
160+
* Возвращает список внешних отчетов и обработок в указанном каталоге исходных файлов
161+
*
162+
* @param sourcePath каталог исходных файлов
163+
* @param readSettings Настройки чтения
164+
* @return Список прочитанных контейнеров внешних отчетов и обработок
165+
*/
166+
public List<MDClass> createExternalSources(Path sourcePath, MDCReadSettings readSettings) {
129167
return findFiles(sourcePath, SEARCH_EX_RES).parallelStream()
130-
.map(MDOReader::readExternalSource)
168+
.map(mdoPath -> MDOReader.readExternalSource(mdoPath, readSettings))
131169
.toList();
132170
}
133171

@@ -138,7 +176,7 @@ public List<MDClass> createExternalSources(Path sourcePath) {
138176
* @return Список прочитанных контейнеров
139177
*/
140178
public List<MDClass> create(Path sourcePath) {
141-
return create(sourcePath, false);
179+
return create(sourcePath, MDCReadSettings.DEFAULT);
142180
}
143181

144182
/**
@@ -147,10 +185,23 @@ public List<MDClass> create(Path sourcePath) {
147185
* @param sourcePath каталог исходных файлов
148186
* @param skipSupport Флаг управления чтением информации о поддержке
149187
* @return Список прочитанных контейнеров
188+
* @deprecated Стоит использовать метод с параметром MDCReadSettings.
150189
*/
190+
@Deprecated(since = "0.16.0")
151191
public List<MDClass> create(Path sourcePath, boolean skipSupport) {
152-
var result = new ArrayList<>(createConfigurations(sourcePath, skipSupport));
153-
result.addAll(createExternalSources(sourcePath));
192+
return create(sourcePath, MDCReadSettings.builder().skipSupport(skipSupport).build());
193+
}
194+
195+
/**
196+
* Возвращает список контейнеров метаданных в указанном каталоге исходных файлов
197+
*
198+
* @param sourcePath каталог исходных файлов
199+
* @param readSettings Настройки чтения
200+
* @return Список прочитанных контейнеров
201+
*/
202+
public List<MDClass> create(Path sourcePath, MDCReadSettings readSettings) {
203+
var result = new ArrayList<>(createConfigurations(sourcePath, readSettings));
204+
result.addAll(createExternalSources(sourcePath, readSettings));
154205
return result;
155206
}
156207

src/main/java/com/github/_1c_syntax/bsl/mdo/storage/DataCompositionSchema.java

Lines changed: 38 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,28 @@
1-
/*
2-
* This file is a part of MDClasses.
3-
*
4-
* Copyright (c) 2019 - 2025
5-
* Tymko Oleg <[email protected]>, Maximov Valery <[email protected]> and contributors
6-
*
7-
* SPDX-License-Identifier: LGPL-3.0-or-later
8-
*
9-
* MDClasses is free software; you can redistribute it and/or
10-
* modify it under the terms of the GNU Lesser General Public
11-
* License as published by the Free Software Foundation; either
12-
* version 3.0 of the License, or (at your option) any later version.
13-
*
14-
* MDClasses is distributed in the hope that it will be useful,
15-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17-
* Lesser General Public License for more details.
18-
*
19-
* You should have received a copy of the GNU Lesser General Public
20-
* License along with MDClasses.
21-
*/
22-
package com.github._1c_syntax.bsl.mdo.storage;
1+
/*
2+
* This file is a part of MDClasses.
3+
*
4+
* Copyright (c) 2019 - 2025
5+
* Tymko Oleg <[email protected]>, Maximov Valery <[email protected]> and contributors
6+
*
7+
* SPDX-License-Identifier: LGPL-3.0-or-later
8+
*
9+
* MDClasses is free software; you can redistribute it and/or
10+
* modify it under the terms of the GNU Lesser General Public
11+
* License as published by the Free Software Foundation; either
12+
* version 3.0 of the License, or (at your option) any later version.
13+
*
14+
* MDClasses is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17+
* Lesser General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU Lesser General Public
20+
* License along with MDClasses.
21+
*/
22+
package com.github._1c_syntax.bsl.mdo.storage;
2323

2424
import com.github._1c_syntax.bsl.mdo.support.DataSetType;
25+
import com.github._1c_syntax.utils.Lazy;
2526
import lombok.Builder;
2627
import lombok.Builder.Default;
2728
import lombok.EqualsAndHashCode;
@@ -49,7 +50,7 @@ public class DataCompositionSchema implements TemplateData {
4950
/**
5051
* Плоский список наборов данных
5152
*/
52-
List<DataSet> plainDataSets;
53+
Lazy<List<DataSet>> plainDataSets = new Lazy<>(this::computePlainDataSets);
5354

5455
/**
5556
* Путь к файлу с данными макета
@@ -59,8 +60,6 @@ public class DataCompositionSchema implements TemplateData {
5960

6061
public DataCompositionSchema(@NonNull List<DataSet> dataSetsTree, @NonNull Path path) {
6162
dataSets = dataSetsTree;
62-
plainDataSets = new ArrayList<>();
63-
fillPlaintDataSetByList(dataSetsTree);
6463
dataPath = path;
6564
}
6665

@@ -69,10 +68,21 @@ public boolean isEmpty() {
6968
return false;
7069
}
7170

72-
private void fillPlaintDataSetByList(List<DataSet> items) {
71+
public List<DataSet> getPlainDataSets() {
72+
return plainDataSets.getOrCompute();
73+
}
74+
75+
private List<DataSet> computePlainDataSets() {
76+
List<DataSet> result = new ArrayList<>();
77+
fillPlainDataSetByList(result, dataSets);
78+
79+
return result;
80+
}
81+
82+
private static void fillPlainDataSetByList(List<DataSet> result, List<DataSet> items) {
7383
items.forEach((DataSet dataSet) -> {
74-
plainDataSets.add(dataSet);
75-
fillPlaintDataSetByList(dataSet.getItems());
84+
result.add(dataSet);
85+
fillPlainDataSetByList(result, dataSet.getItems());
7686
});
7787
}
7888

src/main/java/com/github/_1c_syntax/bsl/reader/FakeReader.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import com.github._1c_syntax.bsl.mdclasses.Configuration;
2525
import com.github._1c_syntax.bsl.mdclasses.ExternalReport;
2626
import com.github._1c_syntax.bsl.mdclasses.ExternalSource;
27+
import com.github._1c_syntax.bsl.mdclasses.MDCReadSettings;
2728
import com.github._1c_syntax.bsl.mdclasses.MDClass;
2829
import com.github._1c_syntax.bsl.mdo.MDObject;
2930
import com.github._1c_syntax.bsl.mdo.storage.EmptyFormData;
@@ -69,6 +70,12 @@ public Path getRootPath() {
6970
return Path.of("fake-path");
7071
}
7172

73+
@Override
74+
@NonNull
75+
public MDCReadSettings getReadSettings() {
76+
return MDCReadSettings.DEFAULT;
77+
}
78+
7279
@Override
7380
@Nullable
7481
public MDObject read(Path path) {

0 commit comments

Comments
 (0)