Skip to content

Commit cc61bd8

Browse files
Add an if-check since we cannot break
1 parent 8f9d836 commit cc61bd8

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

algo/src/main/java/org/neo4j/gds/kmeans/Kmeans.java

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -198,35 +198,35 @@ private static SplittableRandom getSplittableRandom(Optional<Long> randomSeed) {
198198
}
199199

200200
private InputCondition checkInputValidity() {
201-
202201
AtomicInteger inputState = new AtomicInteger(InputCondition.NORMAL.value);
203202
ParallelUtil.parallelForEachNode(graph.nodeCount(), concurrency, nodeId -> {
204-
if (nodePropertyValues.valueType() == ValueType.FLOAT_ARRAY) {
205-
var value = nodePropertyValues.floatArrayValue(nodeId);
206-
if (value.length != dimensions) {
207-
inputState.set(InputCondition.UNEQUALDIMENSION.value);
208-
} else {
209-
for (int dimension = 0; dimension < dimensions; ++dimension) {
210-
if (Float.isNaN(value[dimension])) {
211-
inputState.set(InputCondition.NAN.value);
212-
break;
203+
if (inputState.get() == InputCondition.NORMAL.value) {
204+
if (nodePropertyValues.valueType() == ValueType.FLOAT_ARRAY) {
205+
var value = nodePropertyValues.floatArrayValue(nodeId);
206+
if (value.length != dimensions) {
207+
inputState.set(InputCondition.UNEQUALDIMENSION.value);
208+
} else {
209+
for (int dimension = 0; dimension < dimensions; ++dimension) {
210+
if (Float.isNaN(value[dimension])) {
211+
inputState.set(InputCondition.NAN.value);
212+
break;
213+
}
213214
}
214215
}
215-
}
216-
} else {
217-
var value = nodePropertyValues.doubleArrayValue(nodeId);
218-
if (value.length != dimensions) {
219-
inputState.set(InputCondition.UNEQUALDIMENSION.value);
220216
} else {
221-
for (int dimension = 0; dimension < dimensions; ++dimension) {
222-
if (Double.isNaN(value[dimension])) {
223-
inputState.set(InputCondition.NAN.value);
224-
break;
217+
var value = nodePropertyValues.doubleArrayValue(nodeId);
218+
if (value.length != dimensions) {
219+
inputState.set(InputCondition.UNEQUALDIMENSION.value);
220+
} else {
221+
for (int dimension = 0; dimension < dimensions; ++dimension) {
222+
if (Double.isNaN(value[dimension])) {
223+
inputState.set(InputCondition.NAN.value);
224+
break;
225+
}
225226
}
226227
}
227228
}
228229
}
229-
230230
});
231231
InputCondition inputCondition = InputCondition.NORMAL;
232232
if (inputState.get() == InputCondition.UNEQUALDIMENSION.value) {

0 commit comments

Comments
 (0)