Module analytics_context

Module analytics_context 

Source
Expand description

Analytics context for grouped buffer lifecycle management.

This module provides the AnalyticsContext type for managing buffer allocations during analytics operations like DFG mining, BFS traversal, and pattern detection.

§Purpose

Analytics operations often need multiple temporary buffers that are used together and released together. The AnalyticsContext provides:

  • Grouped lifecycle: All buffers are released when the context drops
  • Statistics tracking: Peak memory usage, allocation count
  • Named contexts: For debugging and profiling

§Example

use ringkernel_core::analytics_context::AnalyticsContext;

// Create context for a BFS operation
let mut ctx = AnalyticsContext::new("bfs_traversal");

// Allocate buffers for frontier, visited, and distances
let frontier_idx = ctx.allocate(1024);
let visited_idx = ctx.allocate(1024);
let distances_idx = ctx.allocate_typed::<u32>(256);

// Use the buffers
ctx.get_mut(frontier_idx)[0] = 1;

// Check stats
let stats = ctx.stats();
println!("Peak memory: {} bytes", stats.peak_bytes);

// All buffers released when ctx drops

Structs§

AllocationHandle
Handle to an allocation within an AnalyticsContext.
AnalyticsContext
Context for analytics operations with grouped buffer lifecycle.
AnalyticsContextBuilder
Builder for AnalyticsContext with pre-configuration.
ContextStats
Statistics for an analytics context.