Skip to content

Commit 60a2d61

Browse files
Apply formatting to AINodeTestUtils.java
1 parent 641784a commit 60a2d61

File tree

1 file changed

+63
-64
lines changed

1 file changed

+63
-64
lines changed

integration-test/src/test/java/org/apache/iotdb/ainode/utils/AINodeTestUtils.java

Lines changed: 63 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -66,28 +66,29 @@ public class AINodeTestUtils {
6666
public static final Map<String, FakeModelInfo> BUILTIN_MODEL_MAP;
6767

6868
static {
69-
Map<String, FakeModelInfo> tmp = Stream.of(
70-
new AbstractMap.SimpleEntry<>(
71-
"arima", new FakeModelInfo("arima", "sktime", "builtin", "active")),
72-
new AbstractMap.SimpleEntry<>(
73-
"holtwinters", new FakeModelInfo("holtwinters", "sktime", "builtin", "active")),
74-
new AbstractMap.SimpleEntry<>(
75-
"exponential_smoothing",
76-
new FakeModelInfo("exponential_smoothing", "sktime", "builtin", "active")),
77-
new AbstractMap.SimpleEntry<>(
78-
"naive_forecaster",
79-
new FakeModelInfo("naive_forecaster", "sktime", "builtin", "active")),
80-
new AbstractMap.SimpleEntry<>(
81-
"stl_forecaster",
82-
new FakeModelInfo("stl_forecaster", "sktime", "builtin", "active")),
83-
new AbstractMap.SimpleEntry<>(
84-
"gaussian_hmm",
85-
new FakeModelInfo("gaussian_hmm", "sktime", "builtin", "active")),
86-
new AbstractMap.SimpleEntry<>(
87-
"gmm_hmm", new FakeModelInfo("gmm_hmm", "sktime", "builtin", "active")),
88-
new AbstractMap.SimpleEntry<>(
89-
"stray", new FakeModelInfo("stray", "sktime", "builtin", "active")))
90-
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
69+
Map<String, FakeModelInfo> tmp =
70+
Stream.of(
71+
new AbstractMap.SimpleEntry<>(
72+
"arima", new FakeModelInfo("arima", "sktime", "builtin", "active")),
73+
new AbstractMap.SimpleEntry<>(
74+
"holtwinters", new FakeModelInfo("holtwinters", "sktime", "builtin", "active")),
75+
new AbstractMap.SimpleEntry<>(
76+
"exponential_smoothing",
77+
new FakeModelInfo("exponential_smoothing", "sktime", "builtin", "active")),
78+
new AbstractMap.SimpleEntry<>(
79+
"naive_forecaster",
80+
new FakeModelInfo("naive_forecaster", "sktime", "builtin", "active")),
81+
new AbstractMap.SimpleEntry<>(
82+
"stl_forecaster",
83+
new FakeModelInfo("stl_forecaster", "sktime", "builtin", "active")),
84+
new AbstractMap.SimpleEntry<>(
85+
"gaussian_hmm",
86+
new FakeModelInfo("gaussian_hmm", "sktime", "builtin", "active")),
87+
new AbstractMap.SimpleEntry<>(
88+
"gmm_hmm", new FakeModelInfo("gmm_hmm", "sktime", "builtin", "active")),
89+
new AbstractMap.SimpleEntry<>(
90+
"stray", new FakeModelInfo("stray", "sktime", "builtin", "active")))
91+
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
9192
tmp.putAll(BUILTIN_LTSM_MAP);
9293
BUILTIN_MODEL_MAP = Collections.unmodifiableMap(tmp);
9394
}
@@ -116,35 +117,36 @@ public static void concurrentInference(
116117
AtomicBoolean allPass = new AtomicBoolean(true);
117118
Thread[] threads = new Thread[threadCnt];
118119
for (int i = 0; i < threadCnt; i++) {
119-
threads[i] = new Thread(
120-
() -> {
121-
try {
122-
for (int j = 0; j < loop; j++) {
123-
try (ResultSet resultSet = statement.executeQuery(sql)) {
124-
int outputCnt = 0;
125-
while (resultSet.next()) {
126-
outputCnt++;
120+
threads[i] =
121+
new Thread(
122+
() -> {
123+
try {
124+
for (int j = 0; j < loop; j++) {
125+
try (ResultSet resultSet = statement.executeQuery(sql)) {
126+
int outputCnt = 0;
127+
while (resultSet.next()) {
128+
outputCnt++;
129+
}
130+
if (expectedOutputLength != outputCnt) {
131+
allPass.set(false);
132+
fail(
133+
"Output count mismatch for SQL: "
134+
+ sql
135+
+ ". Expected: "
136+
+ expectedOutputLength
137+
+ ", but got: "
138+
+ outputCnt);
139+
}
140+
} catch (SQLException e) {
141+
allPass.set(false);
142+
fail(e.getMessage());
143+
}
127144
}
128-
if (expectedOutputLength != outputCnt) {
129-
allPass.set(false);
130-
fail(
131-
"Output count mismatch for SQL: "
132-
+ sql
133-
+ ". Expected: "
134-
+ expectedOutputLength
135-
+ ", but got: "
136-
+ outputCnt);
137-
}
138-
} catch (SQLException e) {
145+
} catch (Exception e) {
139146
allPass.set(false);
140147
fail(e.getMessage());
141148
}
142-
}
143-
} catch (Exception e) {
144-
allPass.set(false);
145-
fail(e.getMessage());
146-
}
147-
});
149+
});
148150
threads[i].start();
149151
}
150152
for (Thread thread : threads) {
@@ -162,7 +164,8 @@ public static void checkModelOnSpecifiedDevice(Statement statement, String model
162164
LOGGER.info("Checking model: {} on target devices: {}", modelId, targetDevices);
163165
for (int retry = 0; retry < 200; retry++) {
164166
Set<String> foundDevices = new HashSet<>();
165-
try (final ResultSet resultSet = statement.executeQuery(String.format("SHOW LOADED MODELS '%s'", device))) {
167+
try (final ResultSet resultSet =
168+
statement.executeQuery(String.format("SHOW LOADED MODELS '%s'", device))) {
166169
while (resultSet.next()) {
167170
String deviceId = resultSet.getString("DeviceId");
168171
String loadedModelId = resultSet.getString("ModelId");
@@ -190,7 +193,8 @@ public static void checkModelNotOnSpecifiedDevice(
190193
LOGGER.info("Checking model: {} not on target devices: {}", modelId, targetDevices);
191194
for (int retry = 0; retry < 50; retry++) {
192195
Set<String> foundDevices = new HashSet<>();
193-
try (final ResultSet resultSet = statement.executeQuery(String.format("SHOW LOADED MODELS '%s'", device))) {
196+
try (final ResultSet resultSet =
197+
statement.executeQuery(String.format("SHOW LOADED MODELS '%s'", device))) {
194198
while (resultSet.next()) {
195199
String deviceId = resultSet.getString("DeviceId");
196200
String loadedModelId = resultSet.getString("ModelId");
@@ -211,18 +215,16 @@ public static void checkModelNotOnSpecifiedDevice(
211215
fail("Model " + modelId + " is still loaded on device " + device);
212216
}
213217

214-
private static final String[] WRITE_SQL_IN_TREE = new String[] {
215-
"CREATE DATABASE root.AI",
216-
"CREATE TIMESERIES root.AI.s0 WITH DATATYPE=FLOAT, ENCODING=RLE",
217-
"CREATE TIMESERIES root.AI.s1 WITH DATATYPE=DOUBLE, ENCODING=RLE",
218-
"CREATE TIMESERIES root.AI.s2 WITH DATATYPE=INT32, ENCODING=RLE",
219-
"CREATE TIMESERIES root.AI.s3 WITH DATATYPE=INT64, ENCODING=RLE",
220-
};
218+
private static final String[] WRITE_SQL_IN_TREE =
219+
new String[] {
220+
"CREATE DATABASE root.AI",
221+
"CREATE TIMESERIES root.AI.s0 WITH DATATYPE=FLOAT, ENCODING=RLE",
222+
"CREATE TIMESERIES root.AI.s1 WITH DATATYPE=DOUBLE, ENCODING=RLE",
223+
"CREATE TIMESERIES root.AI.s2 WITH DATATYPE=INT32, ENCODING=RLE",
224+
"CREATE TIMESERIES root.AI.s3 WITH DATATYPE=INT64, ENCODING=RLE",
225+
};
221226

222-
/**
223-
* Prepare root.AI(s0 FLOAT, s1 DOUBLE, s2 INT32, s3 INT64) with 5760 rows of
224-
* data in tree.
225-
*/
227+
/** Prepare root.AI(s0 FLOAT, s1 DOUBLE, s2 INT32, s3 INT64) with 5760 rows of data in tree. */
226228
public static void prepareDataInTree() throws SQLException {
227229
prepareData(WRITE_SQL_IN_TREE);
228230
try (Connection connection = EnvFactory.getEnv().getConnection(BaseEnv.TREE_SQL_DIALECT);
@@ -236,10 +238,7 @@ public static void prepareDataInTree() throws SQLException {
236238
}
237239
}
238240

239-
/**
240-
* Prepare db.AI(s0 FLOAT, s1 DOUBLE, s2 INT32, s3 INT64) with 5760 rows of data
241-
* in table.
242-
*/
241+
/** Prepare db.AI(s0 FLOAT, s1 DOUBLE, s2 INT32, s3 INT64) with 5760 rows of data in table. */
243242
public static void prepareDataInTable() throws SQLException {
244243
try (Connection connection = EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
245244
Statement statement = connection.createStatement()) {

0 commit comments

Comments
 (0)