graphrecords_overview/
attribute.rs1use graphrecords_core::prelude::{DataType, GraphRecordValue};
2use itertools::Itertools;
3
4#[derive(Debug, Clone)]
5pub enum AttributeOverviewData {
6 Categorical {
7 distinct_values: Vec<GraphRecordValue>,
8 },
9 Continuous {
10 min: GraphRecordValue,
11 mean: GraphRecordValue,
12 max: GraphRecordValue,
13 },
14 Temporal {
15 min: GraphRecordValue,
16 max: GraphRecordValue,
17 },
18 Unstructured {
19 distinct_count: usize,
20 },
21}
22
23impl AttributeOverviewData {
24 pub(crate) const fn attribute_type_name(&self) -> &'static str {
25 match self {
26 Self::Categorical { .. } => "Categorical",
27 Self::Continuous { .. } => "Continuous",
28 Self::Temporal { .. } => "Temporal",
29 Self::Unstructured { .. } => "Unstructured",
30 }
31 }
32
33 pub(crate) fn details(&self) -> String {
34 match self {
35 Self::Categorical { distinct_values } => {
36 format!(
37 "Distinct values: [{}]",
38 distinct_values
39 .iter()
40 .map(std::string::ToString::to_string)
41 .join(", ")
42 )
43 }
44 Self::Continuous { min, mean, max } => {
45 format!("Min: {min}\nMean: {mean}\nMax: {max}")
46 }
47 Self::Temporal { min, max } => {
48 format!("Min: {min}\nMax: {max}")
49 }
50 Self::Unstructured { distinct_count } => {
51 format!("Distinct value count: {distinct_count}")
52 }
53 }
54 }
55}
56
57#[derive(Debug, Clone)]
58pub struct AttributeOverview {
59 pub data_type: DataType,
60 pub data: AttributeOverviewData,
61}