Hi everyone! I’m very new to Flink and wanted to ...
# troubleshooting
p
Hi everyone! I’m very new to Flink and wanted to thank everyone for taking the time to look at my issue. I do not know if this is the correct pattern to leverage, but what I’m attempting to do is leverage a ‘flatMap’ Dataset Transformation to do the following: Input to the transformation is a datastream of file pointers. Within the transformation class, I’m creating another StreamExecution Environment to open the file and ingest the file contents into another stream. I’m trying to return the new datastream of the file content. First is flatMap the correct way to do this? How do it output.collect(file_contents_ds) If I don’t use a Flink connector to open the file and just open the file normally, then use for loop to iterate over each line and finally send each line back via output.collect(each_line) it works, but then a single worker is used to read in the file. The files are quite large and emitted every minute. Is there a better way to input from one stream and get multiple outputs from another stream?
m
The dataset with the file pointers what is the source for that?
p
Another transformation that is fed from Kafka stream. I have an object store setup to generate events on object create to a Kafka stream with the object location/name/etc. Flink listens to that Kafka stream as the trigger. Each event comes in and goes through the first transformation as a map. 1:1 that sends back the formatted file path needed to open the object directly from object store. Im trying to create a new datastream for the file contents and pass that back to the main. I figured I needed a flatMap as it’s now 1:many
t
Using
flatMap
to read and process files within a Flink transformation is not the ideal approach, especially if you're creating a new
StreamExecutionEnvironment
within the transformation. Instead, consider using Flink's built-in connectors or write a custom source function to read the files efficiently and in parallel. This method leverages Flink's distributed processing capabilities and is better suited for handling large files emitted frequently.
p
I was trying to use Flink’s built in connector within the transformation. What is the ideal way to receive file pointers from one datastream to create / return a new datastream with the built in connector with the files contents?