mayankshriv commented on code in PR #19378:
URL: https://github.com/apache/pinot/pull/19378#discussion_r3928619648


##########
pinot-plugins/pinot-input-format/pinot-protobuf/src/main/java/org/apache/pinot/plugin/inputformat/protobuf/ProtoBufCodeGenMessageDecoder.java:
##########
@@ -49,12 +68,21 @@ public void init(Map<String, String> props, Set<String> 
fieldsToRead, String top
         "Protocol Buffer Message class name must be provided");
     String protoClassName = props.getOrDefault(PROTO_CLASS_NAME, "");
     String jarPath = props.getOrDefault(PROTOBUF_JAR_FILE_PATH, "");
-    ClassLoader protoMessageClsLoader = loadClass(jarPath);
-    Descriptors.Descriptor descriptor = 
getDescriptorForProtoClass(protoMessageClsLoader, protoClassName);
-    String codeGenCode = new MessageCodeGen().codegen(descriptor, 
fieldsToRead);
-    Class<?> recordExtractor = compileClass(protoMessageClsLoader,
-        MessageCodeGen.EXTRACTOR_PACKAGE_NAME + "." + 
MessageCodeGen.EXTRACTOR_CLASS_NAME, codeGenCode);
-    _decodeMethod = 
recordExtractor.getMethod(MessageCodeGen.EXTRACTOR_METHOD_NAME, byte[].class, 
GenericRow.class);
+    File jarFile = resolveToLocalFile(jarPath);

Review Comment:
   Agreed - reverted all codegen-JAR changes. The PR now only fixes the 
descriptor path: `getDescriptorFileInputStream` (which called 
`getFileCopiedToLocal` and leaked a temp dir per init) is replaced by 
`openDescriptorFile` that streams directly via `PinotFS.open()`. 
`ProtoBufCodeGenMessageDecoder` is untouched from master. The codegen JAR 
lifecycle (classloader + temp dir management on offload) can be addressed 
properly in a follow-up.



##########
pinot-plugins/pinot-input-format/pinot-protobuf/src/test/java/org/apache/pinot/plugin/inputformat/protobuf/ProtoBufTempFileLeakTest.java:
##########
@@ -0,0 +1,387 @@
+/**
+ * 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.pinot.plugin.inputformat.protobuf;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URL;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+import org.apache.commons.io.FileUtils;
+import org.apache.pinot.spi.data.readers.GenericRow;
+import org.apache.pinot.spi.filesystem.LocalPinotFS;
+import org.apache.pinot.spi.filesystem.PinotFSFactory;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import static 
org.apache.pinot.plugin.inputformat.protobuf.ProtoBufCodeGenMessageDecoder.PROTOBUF_JAR_FILE_PATH;
+import static 
org.apache.pinot.plugin.inputformat.protobuf.ProtoBufCodeGenMessageDecoder.PROTO_CLASS_NAME;
+import static 
org.apache.pinot.plugin.inputformat.protobuf.ProtoBufTestDataGenerator.createComplexTypeRecord;
+import static 
org.apache.pinot.plugin.inputformat.protobuf.ProtoBufTestDataGenerator.getComplexTypeObject;
+import static 
org.apache.pinot.plugin.inputformat.protobuf.ProtoBufTestDataGenerator.getFieldsInSampleRecord;
+import static 
org.apache.pinot.plugin.inputformat.protobuf.ProtoBufTestDataGenerator.getSampleRecordMessage;
+import static 
org.apache.pinot.plugin.inputformat.protobuf.ProtoBufTestDataGenerator.getSourceFieldsForComplexType;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.fail;
+
+
+/// Verifies that protobuf decoder and reader operations do not leak temporary 
directories.

Review Comment:
   Simplified. Removed all complex-type variants and codegen tests (functional 
coverage already exists elsewhere, and temp-file behavior does not depend on 
schema complexity). The test class now has three focused regressions:
   
   1. `testMessageDecoderInitDoesNotLeakTempDir` - descriptor decoder, local 
path
   2. `testRecordReaderLifecycleDoesNotLeakTempDir` - record reader, local path
   3. `testOpenDescriptorFileWithRemoteFS` - descriptor read via remote PinotFS
   
   The fake PinotFS is now `ClasspathPinotFS` - serves classpath resources 
directly from `getResourceAsStream()`, no staging directory or static state 
needed.



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