• Levin Zimmermann's avatar
    erp5_wendelin/DataBucketStream: Migrate len(bucket) to bucket.getBucketCount()... · 6a48d21d
    Levin Zimmermann authored
    erp5_wendelin/DataBucketStream: Migrate len(bucket) to bucket.getBucketCount() to speed up reindexing
    
    When a folder is recursively reindexed, it calculates the length of
    child containers [1]. Calling __len__ on a Data Bucket Stream triggers
    loading (unghostifying) the entire bucket tree, which can be very slow
    for large trees.
    
    However, this cost is unnecessary — the buckets themselves are not meant
    to be indexed. To avoid the overhead, this patch refactors len(bucket)
    to bucket.getBucketCount(), significantly improving performance.
    
    This change also aligns with the design introduced in 3ef452de,
    where buckets were decoupled from the Folder API. Since __len__ on a
    Folder reflects the number of folder-contained objects - and buckets are
    no longer part of that - returning their count from __len__ would be
    misleading.
    
    ---
    
    [1] https://lab.nexedi.com/nexedi/erp5/-/blob/1b555dbf/product/ERP5Type/Core/Folder.py#L587-588
    
    /reviewed-on !171
    /reviewed-by @Tyagov, @klaus and @paul.graydon
    6a48d21d