aboutsummaryrefslogtreecommitdiff
path: root/python/pyspark/ml/util.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/pyspark/ml/util.py')
-rw-r--r--python/pyspark/ml/util.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/python/pyspark/ml/util.py b/python/pyspark/ml/util.py
index d3cb100a9e..cee9d67b05 100644
--- a/python/pyspark/ml/util.py
+++ b/python/pyspark/ml/util.py
@@ -39,9 +39,16 @@ class Identifiable(object):
"""
def __init__(self):
- #: A unique id for the object. The default implementation
- #: concatenates the class name, "_", and 8 random hex chars.
- self.uid = type(self).__name__ + "_" + uuid.uuid4().hex[:8]
+ #: A unique id for the object.
+ self.uid = self._randomUID()
def __repr__(self):
return self.uid
+
+ @classmethod
+ def _randomUID(cls):
+ """
+ Generate a unique id for the object. The default implementation
+ concatenates the class name, "_", and 12 random hex chars.
+ """
+ return cls.__name__ + "_" + uuid.uuid4().hex[12:]