icydb_core/db/response/
grouped.rs1use crate::{db::diagnostics::ExecutionTrace, value::Value};
7
8#[derive(Clone, Debug, Eq, PartialEq)]
16pub struct GroupedRow {
17 group_key: Vec<Value>,
18 aggregate_values: Vec<Value>,
19}
20
21impl GroupedRow {
22 #[must_use]
24 pub const fn new(group_key: Vec<Value>, aggregate_values: Vec<Value>) -> Self {
25 Self {
26 group_key,
27 aggregate_values,
28 }
29 }
30
31 #[must_use]
32 pub fn from_parts<I, J>(group_key: I, aggregate_values: J) -> Self
33 where
34 I: IntoIterator<Item = Value>,
35 J: IntoIterator<Item = Value>,
36 {
37 Self {
38 group_key: group_key.into_iter().collect(),
39 aggregate_values: aggregate_values.into_iter().collect(),
40 }
41 }
42
43 #[must_use]
45 pub const fn group_key(&self) -> &[Value] {
46 self.group_key.as_slice()
47 }
48
49 #[must_use]
51 pub const fn aggregate_values(&self) -> &[Value] {
52 self.aggregate_values.as_slice()
53 }
54}
55
56#[derive(Clone, Debug)]
63pub struct PagedGroupedExecution {
64 rows: Vec<GroupedRow>,
65 continuation_cursor: Option<Vec<u8>>,
66}
67
68impl PagedGroupedExecution {
69 #[must_use]
71 pub const fn new(rows: Vec<GroupedRow>, continuation_cursor: Option<Vec<u8>>) -> Self {
72 Self {
73 rows,
74 continuation_cursor,
75 }
76 }
77
78 #[must_use]
80 pub const fn rows(&self) -> &[GroupedRow] {
81 self.rows.as_slice()
82 }
83
84 #[must_use]
86 pub fn continuation_cursor(&self) -> Option<&[u8]> {
87 self.continuation_cursor.as_deref()
88 }
89
90 #[must_use]
92 pub fn into_parts(self) -> (Vec<GroupedRow>, Option<Vec<u8>>) {
93 (self.rows, self.continuation_cursor)
94 }
95}
96
97#[derive(Clone, Debug)]
104pub struct PagedGroupedExecutionWithTrace {
105 rows: Vec<GroupedRow>,
106 continuation_cursor: Option<Vec<u8>>,
107 execution_trace: Option<ExecutionTrace>,
108}
109
110impl PagedGroupedExecutionWithTrace {
111 #[must_use]
113 pub const fn new(
114 rows: Vec<GroupedRow>,
115 continuation_cursor: Option<Vec<u8>>,
116 execution_trace: Option<ExecutionTrace>,
117 ) -> Self {
118 Self {
119 rows,
120 continuation_cursor,
121 execution_trace,
122 }
123 }
124
125 #[must_use]
127 pub const fn rows(&self) -> &[GroupedRow] {
128 self.rows.as_slice()
129 }
130
131 #[must_use]
133 pub fn continuation_cursor(&self) -> Option<&[u8]> {
134 self.continuation_cursor.as_deref()
135 }
136
137 #[must_use]
139 pub const fn execution_trace(&self) -> Option<&ExecutionTrace> {
140 self.execution_trace.as_ref()
141 }
142
143 #[must_use]
145 pub fn into_execution(self) -> PagedGroupedExecution {
146 PagedGroupedExecution {
147 rows: self.rows,
148 continuation_cursor: self.continuation_cursor,
149 }
150 }
151
152 #[must_use]
154 pub fn into_parts(self) -> (Vec<GroupedRow>, Option<Vec<u8>>, Option<ExecutionTrace>) {
155 (self.rows, self.continuation_cursor, self.execution_trace)
156 }
157}