@@ -48,12 +48,14 @@ def checksum_match(project, checksum_field, logger=None):
4848 """Match using checksum."""
4949 project_files = project .codebaseresources .files ().not_empty ()
5050 from_resources = project_files .from_codebase ().has_value (checksum_field )
51- to_resources = project_files .to_codebase ().has_value (checksum_field )
51+ to_resources = (
52+ project_files .to_codebase ().has_value (checksum_field ).has_no_relation ()
53+ )
5254
5355 if logger :
5456 resource_count = to_resources .count ()
5557 logger (
56- f"Matching { resource_count } to/ resources using { checksum_field } "
58+ f"Matching { resource_count :,d } to/ resources using { checksum_field } "
5759 f"against from/ codebase"
5860 )
5961
@@ -80,7 +82,8 @@ def java_to_class_match(project, logger=None):
8082
8183 to_resources_dot_class = to_resources .filter (name__endswith = to_extension )
8284 if logger :
83- logger (f"Matching { to_resources_dot_class .count ()} .class resources to .java" )
85+ count = to_resources_dot_class .count ()
86+ logger (f"Matching { count :,d} .class resources to .java" )
8487
8588 for to_resource in to_resources_dot_class :
8689 qualified_class = to_resource .path .split ("-extract/" )[- 1 ]
@@ -105,22 +108,29 @@ def java_to_class_match(project, logger=None):
105108
106109def path_match (project , logger = None ):
107110 """Match using path similarities."""
108- project_files = project .codebaseresources .files ().only ("path" )
111+ project_files = project .codebaseresources .files ().not_empty (). only ("path" )
109112 from_resources = project_files .from_codebase ()
110113 to_resources = project_files .to_codebase ().has_no_relation ()
114+ resource_count = to_resources .count ()
111115
112116 if logger :
113- resource_count = to_resources .count ()
114117 logger (
115- f"Matching { resource_count } to/ resources using path match "
118+ f"Matching { resource_count :,d } to/ resources using path match "
116119 f"against from/ codebase"
117120 )
118121
119- for to_resource in to_resources :
122+ resource_iterator = to_resources .iterator (chunk_size = 2000 )
123+ last_percent = 0
124+ for resource_index , to_resource in enumerate (resource_iterator ):
125+ last_percent = pipes .log_progress (
126+ logger , resource_index , resource_count , last_percent , increment_percent = 5
127+ )
128+
120129 path_parts = Path (to_resource .path .lstrip ("/" )).parts
121130 path_parts_len = len (path_parts )
122- for index in range (1 , path_parts_len ):
123- current_parts = path_parts [index :]
131+
132+ for path_parts_index in range (1 , path_parts_len ):
133+ current_parts = path_parts [path_parts_index :]
124134 current_path = "/" .join (current_parts )
125135 # The slash "/" prefix matters during the match as we do not want to
126136 # match on filenames sharing the same ending.
@@ -157,7 +167,9 @@ def purldb_match(project, extensions, logger=None):
157167 if logger :
158168 resource_count = to_resources .count ()
159169 extensions_str = ", " .join (extensions )
160- logger (f"Matching { resource_count } { extensions_str } resources against PurlDB" )
170+ logger (
171+ f"Matching { resource_count :,d} { extensions_str } resources against PurlDB"
172+ )
161173
162174 for resource in to_resources :
163175 if results := purldb .match_by_sha1 (sha1 = resource .sha1 ):
0 commit comments