spuru9 commented on PR #1187:
URL: 
https://github.com/apache/flink-kubernetes-operator/pull/1187#issuecomment-5352911187

   ```
   Old regex:
   ^.*?  (\.kafkaCluster\.(?<kafkaCluster>.+))?  \.KafkaSourceReader \.topic 
\.(?<kafkaTopic>.+) \.partition \.(?<kafkaId>\d+) \.currentOffset$
   
   After split("."), the tail is always these 6 segments (indices from the 
end), plus an optional 2-segment cluster prefix:
   
   
┌─────────────────────────────────────────────────┬──────────────────────────────────────────────────────────────┬────────────────────────────────────────────────────────┐
   │                   regex token                   │                          
new parser                          │                        meaning            
             │
   
├─────────────────────────────────────────────────┼──────────────────────────────────────────────────────────────┼────────────────────────────────────────────────────────┤
   │ ^.*?                                            │ (nothing — never 
inspected)                                  │ ignore everything before the tail 
(the operator scope) │
   
├─────────────────────────────────────────────────┼──────────────────────────────────────────────────────────────┼────────────────────────────────────────────────────────┤
   │ \.KafkaSourceReader                             │ 
parts[n-6].equals(KAFKA_SOURCE_READER)                       │ literal marker   
                                      │
   
├─────────────────────────────────────────────────┼──────────────────────────────────────────────────────────────┼────────────────────────────────────────────────────────┤
   │ \.topic                                         │ parts[n-5].equals(TOPIC) 
                                    │ literal marker                            
             │
   
├─────────────────────────────────────────────────┼──────────────────────────────────────────────────────────────┼────────────────────────────────────────────────────────┤
   │ (?<kafkaTopic>.+)                               │ parts[n-4]               
                                    │ the topic (extracted, not validated)      
             │
   
├─────────────────────────────────────────────────┼──────────────────────────────────────────────────────────────┼────────────────────────────────────────────────────────┤
   │ \.partition                                     │ 
parts[n-3].equals(PARTITION)                                 │ literal marker   
                                      │
   
├─────────────────────────────────────────────────┼──────────────────────────────────────────────────────────────┼────────────────────────────────────────────────────────┤
   │ (?<kafkaId>\d+)                                 │ isAllDigits(parts[n-2])  
                                    │ partition id = digits                     
             │
   
├─────────────────────────────────────────────────┼──────────────────────────────────────────────────────────────┼────────────────────────────────────────────────────────┤
   │ \.currentOffset$                                │ 
parts[n-1].equals(CURRENT_OFFSET)                            │ $ → must be the 
last segment                           │
   
├─────────────────────────────────────────────────┼──────────────────────────────────────────────────────────────┼────────────────────────────────────────────────────────┤
   │ (\.kafkaCluster\.(?<kafkaCluster>.+))?          │ n>=8 && 
parts[n-8].equals(KAFKA_CLUSTER) ? parts[n-7] : null │ the optional ? group, 2 
segments ahead of the tail     │
   
├─────────────────────────────────────────────────┼──────────────────────────────────────────────────────────────┼────────────────────────────────────────────────────────┤
   │ kafkaCluster + "-" + kafkaTopic + "-" + kafkaId │ cluster + "-" + 
parts[n-4] + "-" + parts[n-2]                │ same key (cluster renders as 
"null" when absent)       │
   
└─────────────────────────────────────────────────┴──────────────────────────────────────────────────────────────┴────────────────────────────────────────────────────────┘
   
   Pulsar
   
   Old regex:
   ^.*  \.PulsarConsumer  \.(?<pulsarTopic>.+)-partition-(?<pulsarId>\d+)  \. 
.*  \.numMsgsReceived$
   
   
┌───────────────────────────────────────────────┬──────────────────────────────────────────────────────┬───────────────────────────────────────────────────────────────────────────────────────────────────┐
   │                  regex token                  │                      new 
parser                      │                                              
meaning                                              │
   
├───────────────────────────────────────────────┼──────────────────────────────────────────────────────┼───────────────────────────────────────────────────────────────────────────────────────────────────┤
   │ ^.*\.PulsarConsumer                           │ the for loop scanning for  
                          │ find the marker segment; anything before it is the 
ignored prefix                                 │
   │                                               │ 
parts[i].equals(PULSAR_CONSUMER)                     │                          
                                                                         │
   
├───────────────────────────────────────────────┼──────────────────────────────────────────────────────┼───────────────────────────────────────────────────────────────────────────────────────────────────┤
   │ (?<pulsarTopic>.+)-partition-(?<pulsarId>\d+) │ segment = parts[i+1], then 
                          │ topic-partition lives in one segment; lastIndexOf 
mirrors greedy .+ (prefers the last             │
   │                                               │ lastIndexOf("-partition-") 
splits it                 │ -partition-)                                        
                                              │
   
├───────────────────────────────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
   │ (?<pulsarId>\d+)                              │ isAllDigits(id) where id = 
segment.substring(idx+11) │ id after -partition- must be digits                 
                                              │
   
├───────────────────────────────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
   │ \..*\.numMsgsReceived$                        │ 
parts[n-1].equals(NUM_MSGS_RECEIVED) + loop bound    │ the $ anchor (last 
segment) + require room for a segment before it; the .* (consumer-hash) in     │
   │                                               │ i+1 < n-1                  
             not checked, so any middle segments are accepted                   
                    │
   
├───────────────────────────────────────────────┼──────────────────────────────────────────────────────┼───────────────────────────────────────────────────────────────────────────────────────────────────┤
   │ pulsarTopic + "-" + pulsarId                  │ segment.substring(0, idx) 
+ "-" + id    rops the -partition- infix)                                       
                     │
   
└───────────────────────────────────────────────┴──────────────────────────────────────────────────────┴───────────────────────────────────────────────────────────────────────────────────────────────────┘
   ```


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

Reply via email to