You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by GitBox <gi...@apache.org> on 2020/04/02 16:58:38 UTC

[GitHub] [beam] TheNeuralBit commented on a change in pull request #11286: [BEAM-4374] Short IDs for the Python SDK

TheNeuralBit commented on a change in pull request #11286: [BEAM-4374] Short IDs for the Python SDK
URL: https://github.com/apache/beam/pull/11286#discussion_r402466621
 
 

 ##########
 File path: sdks/python/apache_beam/runners/worker/sdk_worker.py
 ##########
 @@ -76,6 +79,50 @@
 DEFAULT_BUNDLE_PROCESSOR_CACHE_SHUTDOWN_THRESHOLD_S = 60
 
 
+class ShortIdCache(object):
+  """ Cache for MonitoringInfo "short ids"
+  """
+  def __init__(self):
+    self._lock = threading.Lock()
+    self._lastShortId = 0
+    self._infoKeyToShortId = {}  # type: Dict[FrozenSet, str]
+    self._shortIdToInfo = {}  # type: Dict[str, metrics_pb2.MonitoringInfo]
+
+  def getShortId(self, monitoring_info):
+    """ Returns the assigned shortId for a given MonitoringInfo, assigns one if
+    not assigned already.
+    """
+    # type: (metrics_pb2.MonitoringInfo) -> str
+    with self._lock:
+      key = monitoring_infos.to_key(monitoring_info)
 
 Review comment:
   This function exists already: https://github.com/apache/beam/blob/master/sdks/python/apache_beam/metrics/monitoring_infos.py#L329-L338

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services