liquid_cache_server/admin_server/
models.rs

1use serde::{Deserialize, Serialize};
2
3/// Parameters for the set_execution_stats endpoint
4#[derive(Deserialize, Serialize, Clone)]
5pub struct ExecutionStats {
6    /// Plan ID for the execution plan
7    pub plan_ids: Vec<String>,
8    /// Display name for the execution plan
9    pub display_name: String,
10    /// Flamegraph SVG for the execution plan
11    pub flamegraph_svg: Option<String>,
12    /// Network traffic bytes for the execution plan
13    pub network_traffic_bytes: u64,
14    /// Execution time in milliseconds
15    pub execution_time_ms: u64,
16    /// User input SQL
17    pub user_sql: Vec<String>,
18}
19
20/// Execution stats with plan
21#[derive(Serialize)]
22pub struct ExecutionStatsWithPlan {
23    /// Execution stats
24    pub execution_stats: ExecutionStats,
25    /// Plan info
26    pub plans: Vec<PlanInfo>,
27}
28
29/// Response for the admin server
30#[derive(Serialize, Deserialize)]
31pub struct ApiResponse {
32    /// Message for the response
33    pub message: String,
34    /// Status for the response
35    pub status: String,
36}
37
38/// Schema field
39#[derive(Serialize)]
40pub struct SchemaField {
41    /// Field name
42    pub name: String,
43    /// Field data type
44    pub data_type: String,
45}
46
47/// Column statistics
48#[derive(Serialize)]
49pub struct ColumnStatistics {
50    /// Column name
51    pub name: String,
52    /// Null count
53    pub null: Option<String>,
54    /// Max value
55    pub max: Option<String>,
56    /// Min value
57    pub min: Option<String>,
58    /// Sum value
59    pub sum: Option<String>,
60    /// Distinct count
61    pub distinct_count: Option<String>,
62}
63
64/// Statistics
65#[derive(Serialize)]
66pub struct Statistics {
67    /// Number of rows
68    pub num_rows: String,
69    /// Total byte size
70    pub total_byte_size: String,
71    /// Column statistics
72    pub column_statistics: Vec<ColumnStatistics>,
73}
74
75/// Metric
76#[derive(Serialize)]
77pub struct MetricValues {
78    /// Metric name
79    pub name: String,
80    /// Metric value
81    pub value: String,
82}
83
84/// Execution plan with stats
85#[derive(Serialize)]
86pub struct ExecutionPlanWithStats {
87    /// Execution plan name
88    pub name: String,
89    /// Schema fields
90    pub schema: Vec<SchemaField>,
91    /// Statistics
92    pub statistics: Statistics,
93    /// Metrics
94    pub metrics: Vec<MetricValues>,
95    /// Children
96    pub children: Vec<ExecutionPlanWithStats>,
97}
98
99/// Plan info
100#[derive(Serialize)]
101pub struct PlanInfo {
102    /// Created at
103    pub created_at: u64,
104    /// Execution plan
105    pub plan: ExecutionPlanWithStats,
106    /// ID
107    pub id: String,
108    /// Predicate
109    pub predicate: Option<String>,
110}