// data source for cluster center input
@SuppressWarnings("unchecked")
FileDataSource clustersSource = new FileDataSource(new CsvInputFormat('|', IntValue.class, DoubleValue.class, DoubleValue.class, DoubleValue.class), clusterInput, "Centers");
MapOperator dataPoints = MapOperator.builder(new PointBuilder()).name("Build data points").input(pointsSource).build();
MapOperator clusterPoints = MapOperator.builder(new PointBuilder()).name("Build cluster points").input(clustersSource).build();
// ---------------------- Begin K-Means Loop ---------------------
BulkIteration iter = new BulkIteration("k-means loop");
iter.setInput(clusterPoints);
iter.setMaximumNumberOfIterations(numIterations);
// compute the distances and select the closest center
MapOperator findNearestClusterCenters = MapOperator.builder(new SelectNearestCenter())
.setBroadcastVariable("centers", iter.getPartialSolution())
.input(dataPoints)
.name("Find Nearest Centers")
.build();