MCPcopy Create free account
hub / github.com/logpai/logparser / Get_Mapping_Position

Method Get_Mapping_Position

logparser/IPLoM/IPLoM.py:585–672  ·  view source on GitHub ↗
(self, partition, uniqueTokensCountLS)

Source from the content-addressed store, hash-verified

583 return (-1, -1)
584
585 def Get_Mapping_Position(self, partition, uniqueTokensCountLS):
586 p1 = p2 = -1
587
588 # Caculate #unqiueterms in each column, and record how many column with each #uniqueterms
589 numOfUniqueTokensD = {}
590 for columnIdx in range(partition.lenOfLogs):
591 if len(uniqueTokensCountLS[columnIdx]) not in numOfUniqueTokensD:
592 numOfUniqueTokensD[len(uniqueTokensCountLS[columnIdx])] = 0
593 numOfUniqueTokensD[len(uniqueTokensCountLS[columnIdx])] += 1
594
595 if partition.stepNo == 2:
596 # Find the largest card and second largest card
597 maxIdx = secondMaxIdx = -1
598 maxCount = secondMaxCount = 0
599 for key in numOfUniqueTokensD:
600 if key == 1:
601 continue
602 if numOfUniqueTokensD[key] > maxCount:
603 secondMaxIdx = maxIdx
604 secondMaxCount = maxCount
605 maxIdx = key
606 maxCount = numOfUniqueTokensD[key]
607 elif (
608 numOfUniqueTokensD[key] > secondMaxCount
609 and numOfUniqueTokensD[key] != maxCount
610 ):
611 secondMaxIdx = key
612 secondMaxCount = numOfUniqueTokensD[key]
613
614 # If the frequency of the freq_card>1 then
615 if maxCount > 1:
616 for columnIdx in range(partition.lenOfLogs):
617 if len(uniqueTokensCountLS[columnIdx]) == maxIdx:
618 if p1 == -1:
619 p1 = columnIdx
620 else:
621 p2 = columnIdx
622 break
623
624 # If the frequency of the freq_card==1 then
625 else:
626 for columnIdx in range(partition.lenOfLogs):
627 if len(uniqueTokensCountLS[columnIdx]) == maxIdx:
628 p1 = columnIdx
629 break
630
631 for columnIdx in range(partition.lenOfLogs):
632 if len(uniqueTokensCountLS[columnIdx]) == secondMaxIdx:
633 p2 = columnIdx
634 break
635
636 if p1 == -1 or p2 == -1:
637 return (-1, -1)
638 else:
639 return (p1, p2)
640
641 # If it is from step 1
642 else:

Callers 1

DetermineP1P2Method · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected