zhztheplayer commented on code in PR #8904:
URL: https://github.com/apache/incubator-gluten/pull/8904#discussion_r1993848656


##########
gluten-core/src/main/scala/org/apache/gluten/GlutenPlugin.scala:
##########
@@ -267,6 +268,7 @@ private[gluten] class GlutenExecutorPlugin extends 
ExecutorPlugin {
 
   /** Initialize the executor plugin. */
   override def init(ctx: PluginContext, extraConf: util.Map[String, String]): 
Unit = {
+    CodedInputStreamClassInitializer

Review Comment:
   Can we give an API for this? E.g.,
   
   ```scala
   CodedInputStreamClassInitializer.modifyDefaultRecursionLimitUnsafe(100000)
   ```



##########
gluten-core/src/main/scala/org/apache/gluten/initializer/CodedInputStreamClassInitializer.scala:
##########
@@ -0,0 +1,42 @@
+/*
+ * 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.gluten.initializer
+
+import java.lang.reflect.Field
+
+/**
+ * Pre-load the class instance for CodedInputStream and modify its 
defaultRecursionLimit to avoid
+ * the limit is hit for deeply nested plans. This is based on the fact that 
the same class loader is
+ * used to load this class in the program, then this modification will really 
take effect.
+ */
+object CodedInputStreamClassInitializer {
+  {
+    try {
+      // scalastyle:off classforname
+      // Use the shaded class name.
+      val clazz: Class[_] =
+        
Class.forName("org.apache.gluten.shaded.com.google.protobuf.CodedInputStream")
+      // scalastyle:on classforname
+      val field: Field = clazz.getDeclaredField("defaultRecursionLimit")
+      field.setAccessible(true)
+      // Enlarge defaultRecursionLimit whose original value is 100.
+      field.setInt(null, 100000)

Review Comment:
   nit: We can add a log for such settings.
   
   ```
   logInfo("... has been modified to ...")
   ```



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to