MayaFlux 0.2.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ cache_region_if_needed()

void MayaFlux::Kakshya::RegionProcessorBase::cache_region_if_needed ( const RegionSegment segment,
const std::shared_ptr< SignalSourceContainer > &  container 
)
protectedvirtual

Cache a region's data if beneficial and not already cached.

Uses heuristics (e.g., segment size vs. cache size) to decide.

Parameters
segmentThe region segment to consider for caching.
containerThe container providing the data.

Definition at line 35 of file RegionProcessorBase.cpp.

36{
38 return;
39
40 if (m_cache_manager->get_cached_segment(segment)) {
41 return;
42 }
43
44 uint64_t segment_size = segment.get_total_elements();
45 if (segment_size <= m_max_cache_size / 10) { // Use max 10% of cache per segment
46 try {
47 RegionCache cache;
48 cache.data = container->get_region_data(segment.source_region);
49 cache.source_region = segment.source_region;
50 cache.load_time = std::chrono::steady_clock::now();
51
52 m_cache_manager->cache_region(cache);
53 } catch (const std::exception& e) {
55 "Failed to cache region segment: {}", e.what());
56 }
57 }
58}
#define MF_WARN(comp, ctx,...)
std::unique_ptr< RegionCacheManager > m_cache_manager
@ ContainerProcessing
Container operations (Kakshya - file/stream/region processing)
@ Kakshya
Containers[Signalsource, Stream, File], Regions, DataProcessors.

References MayaFlux::Journal::ContainerProcessing, MayaFlux::Kakshya::RegionCache::data, MayaFlux::Kakshya::RegionSegment::get_total_elements(), MayaFlux::Journal::Kakshya, MayaFlux::Kakshya::RegionCache::load_time, m_auto_caching, m_cache_manager, m_max_cache_size, MF_WARN, MayaFlux::Kakshya::RegionCache::source_region, and MayaFlux::Kakshya::RegionSegment::source_region.

Referenced by MayaFlux::Kakshya::RegionOrganizationProcessor::add_segment_to_region(), and MayaFlux::Kakshya::RegionOrganizationProcessor::organize_group().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: