You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "cloud-fan (via GitHub)" <gi...@apache.org> on 2026/04/01 10:39:21 UTC

Re: [PR] [SPARK-55278] Introduce core abstraction for UDF worker. [spark]

cloud-fan commented on code in PR #55089:
URL: https://github.com/apache/spark/pull/55089#discussion_r3021251971


##########
udf/worker/core/src/main/scala/org/apache/spark/udf/worker/core/WorkerSession.scala:
##########
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.spark.udf.worker.core
+
+import org.apache.spark.annotation.Experimental
+
+/**
+ * :: Experimental ::
+ * Represents one single UDF execution.
+ *
+ * A [[WorkerSession]] is obtained from [[WorkerDispatcher#createSession]] and
+ * can carry per-execution state for that UDF invocation. Implementations may
+ * add concrete data-processing methods and lifecycle hooks as needed.
+ *
+ * A WorkerSession is not 1-to-1 mapped to an actual worker process. Multiple
+ * WorkerSessions may be backed by the same worker when the worker is reused.
+ * Worker reuse and pooling are managed by each [[WorkerDispatcher]]
+ * implementation based on the [[WorkerSpecification]].
+ */
+@Experimental
+abstract class WorkerSession

Review Comment:
   `WorkerSession` does not extend `AutoCloseable`, while `WorkerDispatcher` does. Since a session "can carry per-execution state" and implementations "may add lifecycle hooks," callers have no standard way to release per-session resources. If `AutoCloseable` is added later, all callers must be updated. Consider `abstract class WorkerSession extends AutoCloseable` from the start, even if concrete implementations initially no-op on `close()`.



##########
udf/worker/core/src/main/scala/org/apache/spark/udf/worker/core/WorkerSecurityScope.scala:
##########
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.spark.udf.worker.core
+
+import org.apache.spark.annotation.Experimental
+
+/**
+ * :: Experimental ::
+ * Identifies a security boundary for worker connection pooling.
+ *
+ * Workers are only reused within the same security scope.
+ */
+@Experimental
+abstract class WorkerSecurityScope

Review Comment:
   The Scaladoc says "Workers are only reused within the same security scope," which implies dispatcher implementations will compare scopes for equality. The default `Object.equals` (reference equality) means structurally equivalent scopes won't match, silently preventing worker reuse. Consider documenting that subclasses must override `equals`/`hashCode`, or making this a `sealed trait` with concrete implementations that enforce it.



-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org