You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by "olehborysevych (via GitHub)" <gi...@apache.org> on 2023/01/25 09:28:12 UTC

[GitHub] [beam] olehborysevych commented on a diff in pull request #25032: Update Playground examples

olehborysevych commented on code in PR #25032:
URL: https://github.com/apache/beam/pull/25032#discussion_r1085527402


##########
examples/java/src/main/java/org/apache/beam/examples/KafkaPassengerCount.java:
##########
@@ -0,0 +1,162 @@
+/*
+ * 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.beam.examples;

Review Comment:
   please add empty line before package name



##########
examples/java/src/main/java/org/apache/beam/examples/KafkaWordCountAvro.java:
##########
@@ -19,16 +19,14 @@
 
 // beam-playground:
 //   name: KafkaWordCountAvro
-//   description: Test example with Apache Kafka
+//   description: Read CountWords dataset from Kafka server to count word frequency

Review Comment:
   Those two examples have same description. I advise to mention dataset format in description: Avro/Json



##########
playground/backend/internal/fs_tool/java_fs.go:
##########
@@ -52,27 +56,53 @@ func executableName(executableFileFolderPath string) (string, error) {
 	}
 
 	if len(dirEntries) == 1 {
-		return strings.Split(dirEntries[0].Name(), ".")[0], nil
+		return utils.TrimExtension(dirEntries[0].Name()), nil
 	}
 
 	for _, entry := range dirEntries {
-		content, err := ioutil.ReadFile(fmt.Sprintf("%s/%s", executableFileFolderPath, entry.Name()))
+		filePath := fmt.Sprintf("%s/%s", executableFileFolderPath, entry.Name())
+		content, err := os.ReadFile(filePath)
 		if err != nil {
 			logger.Error(fmt.Sprintf("error during file reading: %s", err.Error()))
 			break
 		}
-		ext := strings.Split(entry.Name(), ".")[1]
-		sdk := utils.ToSDKFromExt("." + ext)
+		ext := filepath.Ext(entry.Name())
+		filename := strings.TrimSuffix(entry.Name(), ext)
+		sdk := utils.ToSDKFromExt(ext)
 
 		if sdk == pb.Sdk_SDK_UNSPECIFIED {
-			logger.Error("invalid a file extension")
+			logger.Error("invalid file extension")
 			break
 		}
 
-		if utils.IsFileMain(string(content), sdk) {
-			return strings.Split(entry.Name(), ".")[0], nil
+		switch ext {
+		case javaCompiledFileExtension:
+			isMain, err := isMainClass(executableFileFolderPath, filename)
+			if err != nil {
+				return "", err
+			}
+			if isMain {
+				return filename, nil

Review Comment:
   please ensure we are returning what we intend if false



-- 
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: github-unsubscribe@beam.apache.org

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