Skip to content

Commit 87cb23e

Browse files
derrickburnsclaude
andcommitted
fix: use trait-based cross-version compat for parallel collections
Created ParCollectionCompat trait with version-specific implementations: - Scala 2.12: Empty trait (parallel collections built-in) - Scala 2.13: Trait with CollectionConverters import KMeansPlusPlus now extends ParCollectionCompat to get .par support. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent dd12343 commit 87cb23e

File tree

5 files changed

+11
-13
lines changed

5 files changed

+11
-13
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package com.massivedatascience.clusterer.compat
2+
3+
// Scala 2.12 compatibility: parallel collections are built-in, no import needed
4+
trait ParCollectionCompat

src/main/scala-2.12/com/massivedatascience/clusterer/compat/package.scala

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package com.massivedatascience.clusterer.compat
2+
3+
import scala.collection.parallel.CollectionConverters._
4+
5+
// Scala 2.13 compatibility: re-export parallel collection converters
6+
trait ParCollectionCompat

src/main/scala-2.13/com/massivedatascience/clusterer/compat/package.scala

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/main/scala/com/massivedatascience/clusterer/KMeansPlusPlus.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,14 @@ import com.massivedatascience.util.XORShiftRandom
2424

2525
import scala.annotation.tailrec
2626
import scala.collection.mutable.ArrayBuffer
27-
import com.massivedatascience.clusterer.compat._
2827

2928
/** This implements the <a href="http://ilpubs.stanford.edu:8090/778/1/2006-13.pdf">KMeans++ initialization
3029
* algorithm</a>
3130
*
3231
* @param ops
3332
* distance function
3433
*/
35-
class KMeansPlusPlus(ops: BregmanPointOps) extends Serializable with Logging {
34+
class KMeansPlusPlus(ops: BregmanPointOps) extends Serializable with Logging with compat.ParCollectionCompat {
3635

3736
/** Select centers in rounds. On each round, select 'perRound' centers, with probability of selection equal to the
3837
* product of the given weights and distance to the closest cluster center of the previous round.

0 commit comments

Comments
 (0)