Skip to content

Commit

Permalink
rename parallelism to numThreads
Browse files Browse the repository at this point in the history
  • Loading branch information
Jelmer Kuperus committed Dec 30, 2024
1 parent 9607cf5 commit 9e76066
Showing 1 changed file with 24 additions and 26 deletions.
50 changes: 24 additions & 26 deletions hnswlib-spark/src/main/python/pyspark_hnsw/knn.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, Dict, Optional, TYPE_CHECKING
from typing import Any, Dict, TYPE_CHECKING

from pyspark.ml.wrapper import JavaEstimator, JavaModel
from pyspark.ml.param.shared import (
Expand All @@ -16,8 +16,6 @@
# noinspection PyProtectedMember
from pyspark.ml.util import JavaMLReadable, JavaMLWritable, MLReader, _jvm

if TYPE_CHECKING:
from py4j.java_gateway import JavaObject

__all__ = [
"HnswSimilarity",
Expand Down Expand Up @@ -74,9 +72,9 @@ class _KnnModelParams(HasFeaturesCol, HasPredictionCol):
typeConverter=TypeConverters.toString,
)

parallelism = Param(
numThreads = Param(
Params._dummy(),
"parallelism",
"numThreads",
"number of threads to use",
typeConverter=TypeConverters.toInt,
)
Expand Down Expand Up @@ -128,11 +126,11 @@ def getQueryPartitionsCol(self):
"""
return self.getOrDefault(self.queryPartitionsCol)

def getParallelism(self):
def getNumThreads(self):
"""
Gets the value of parallelism or its default value.
Gets the value of numThreads.
"""
return self.getOrDefault(self.parallelism)
return self.getOrDefault(self.numThreads)

def getK(self):
"""
Expand Down Expand Up @@ -312,10 +310,10 @@ def __init__(
partitionCol=None,
queryIdentifierCol=None,
queryPartitionsCol=None,
parallelism=None,
numThreads=None,
featuresCol="features",
predictionCol="prediction",
numPartitions=1,
numPartitions=None,
numReplicas=0,
k=5,
distanceFunction="cosine",
Expand Down Expand Up @@ -367,11 +365,11 @@ def setQueryPartitionsCol(self, value):
"""
return self._set(queryPartitionsCol=value)

def setParallelism(self, value):
def setNumThreads(self, value):
"""
Sets the value of :py:attr:`parallelism`.
Sets the value of :py:attr:`numThreads`.
"""
return self._set(parallelism=value)
return self._set(numThreads=value)

def setNumPartitions(self, value):
"""
Expand Down Expand Up @@ -428,7 +426,7 @@ def setParams(
identifierCol="id",
queryIdentifierCol=None,
queryPartitionsCol=None,
parallelism=None,
numThreads=None,
featuresCol="features",
predictionCol="prediction",
numPartitions=1,
Expand Down Expand Up @@ -471,11 +469,11 @@ def setQueryPartitionsCol(self, value):
"""
return self._set(queryPartitionsCol=value)

def setParallelism(self, value):
def setNumThreads(self, value):
"""
Sets the value of :py:attr:`parallelism`.
Sets the value of :py:attr:`numThreads`.
"""
return self._set(parallelism=value)
return self._set(numThreads=value)

def setK(self, value):
"""
Expand Down Expand Up @@ -526,7 +524,7 @@ def __init__(
identifierCol="id",
queryIdentifierCol=None,
queryPartitionsCol=None,
parallelism=None,
numThreads=None,
featuresCol="features",
predictionCol="prediction",
m=16,
Expand Down Expand Up @@ -588,11 +586,11 @@ def setQueryPartitionsCol(self, value):
"""
return self._set(queryPartitionsCol=value)

def setParallelism(self, value):
def setNumThreads(self, value):
"""
Sets the value of :py:attr:`parallelism`.
Sets the value of :py:attr:`numThreads`.
"""
return self._set(parallelism=value)
return self._set(numThreads=value)

def setNumPartitions(self, value):
"""
Expand Down Expand Up @@ -667,13 +665,13 @@ def setParams(
identifierCol="id",
queryIdentifierCol=None,
queryPartitionsCol=None,
parallelism=None,
numThreads=None,
featuresCol="features",
predictionCol="prediction",
m=16,
ef=10,
efConstruction=200,
numPartitions=1,
numPartitions=None,
numReplicas=0,
k=5,
distanceFunction="cosine",
Expand Down Expand Up @@ -709,11 +707,11 @@ def setQueryPartitionsCol(self, value):
"""
return self._set(queryPartitionsCol=value)

def setParallelism(self, value):
def setNumThreads(self, value):
"""
Sets the value of :py:attr:`parallelism`.
Sets the value of :py:attr:`numThreads`.
"""
return self._set(parallelism=value)
return self._set(numThreads=value)

def setK(self, value):
"""
Expand Down

0 comments on commit 9e76066

Please sign in to comment.