@@ -20,13 +20,15 @@ use std::hash::Hasher;
2020use std:: io:: Write ;
2121use std:: sync:: Arc ;
2222
23+ use databend_common_base:: base:: GlobalUniqName ;
2324use databend_common_catalog:: plan:: compute_row_id_prefix;
2425use databend_common_catalog:: plan:: split_prefix;
2526use databend_common_catalog:: plan:: PartInfo ;
2627use databend_common_catalog:: plan:: PartInfoPtr ;
2728use databend_common_catalog:: plan:: PartInfoType ;
2829use databend_common_catalog:: plan:: Partitions ;
2930use databend_common_catalog:: plan:: PartitionsShuffleKind ;
31+ use databend_common_meta_types:: NodeInfo ;
3032use databend_storages_common_table_meta:: meta:: NUM_BLOCK_ID_BITS ;
3133use goldenfile:: Mint ;
3234
@@ -73,18 +75,34 @@ fn gen_parts(kind: PartitionsShuffleKind, size: usize) -> Partitions {
7375 Partitions :: create ( kind, parts)
7476}
7577
78+ fn create_node ( cache_id : String ) -> Arc < NodeInfo > {
79+ Arc :: new ( NodeInfo :: create (
80+ GlobalUniqName :: unique ( ) ,
81+ String :: new ( ) ,
82+ 0 ,
83+ String :: new ( ) ,
84+ String :: new ( ) ,
85+ String :: new ( ) ,
86+ String :: new ( ) ,
87+ cache_id,
88+ ) )
89+ }
90+
7691#[ test]
7792fn test_partition_reshuffle ( ) {
7893 let mut mint = Mint :: new ( "tests/it/testdata" ) ;
7994 let file = & mut mint. new_goldenfile ( "partition-reshuffle.txt" ) . unwrap ( ) ;
8095
8196 let executors_3 = vec ! [
82- "node-1" . to_string( ) ,
83- "node-2" . to_string( ) ,
84- "node-3" . to_string( ) ,
97+ create_node ( "node-1" . to_string( ) ) ,
98+ create_node ( "node-2" . to_string( ) ) ,
99+ create_node ( "node-3" . to_string( ) ) ,
85100 ] ;
86101
87- let executors_2 = vec ! [ "node-1" . to_string( ) , "node-2" . to_string( ) ] ;
102+ let executors_2 = vec ! [
103+ create_node( "node-1" . to_string( ) ) ,
104+ create_node( "node-2" . to_string( ) ) ,
105+ ] ;
88106
89107 // None.
90108 {
@@ -96,13 +114,13 @@ fn test_partition_reshuffle() {
96114 "PartitionsShuffleKind::Seq : 11 partitions of 3 executors"
97115 )
98116 . unwrap ( ) ;
99- let e1_parts = shuffle. get ( & executors_3[ 0 ] ) . unwrap ( ) ;
117+ let e1_parts = shuffle. get ( & executors_3[ 0 ] . id ) . unwrap ( ) ;
100118 writeln ! ( file, "{:?}" , e1_parts) . unwrap ( ) ;
101119
102- let e2_parts = shuffle. get ( & executors_3[ 1 ] ) . unwrap ( ) ;
120+ let e2_parts = shuffle. get ( & executors_3[ 1 ] . id ) . unwrap ( ) ;
103121 writeln ! ( file, "{:?}" , e2_parts) . unwrap ( ) ;
104122
105- let e3_parts = shuffle. get ( & executors_3[ 2 ] ) . unwrap ( ) ;
123+ let e3_parts = shuffle. get ( & executors_3[ 2 ] . id ) . unwrap ( ) ;
106124 writeln ! ( file, "{:?}" , e3_parts) . unwrap ( ) ;
107125 }
108126
@@ -116,13 +134,13 @@ fn test_partition_reshuffle() {
116134 "PartitionsShuffleKind::Seq : 2 partitions of 3 executors"
117135 )
118136 . unwrap ( ) ;
119- let e1_parts = shuffle. get ( & executors_3[ 0 ] ) . unwrap ( ) ;
137+ let e1_parts = shuffle. get ( & executors_3[ 0 ] . id ) . unwrap ( ) ;
120138 writeln ! ( file, "{:?}" , e1_parts) . unwrap ( ) ;
121139
122- let e2_parts = shuffle. get ( & executors_3[ 1 ] ) . unwrap ( ) ;
140+ let e2_parts = shuffle. get ( & executors_3[ 1 ] . id ) . unwrap ( ) ;
123141 writeln ! ( file, "{:?}" , e2_parts) . unwrap ( ) ;
124142
125- let e3_parts = shuffle. get ( & executors_3[ 2 ] ) . unwrap ( ) ;
143+ let e3_parts = shuffle. get ( & executors_3[ 2 ] . id ) . unwrap ( ) ;
126144 writeln ! ( file, "{:?}" , e3_parts) . unwrap ( ) ;
127145 }
128146
@@ -136,13 +154,13 @@ fn test_partition_reshuffle() {
136154 "PartitionsShuffleKind::Mod : 10 partitions of 3 executors"
137155 )
138156 . unwrap ( ) ;
139- let e1_parts = shuffle. get ( & executors_3[ 0 ] ) . unwrap ( ) ;
157+ let e1_parts = shuffle. get ( & executors_3[ 0 ] . id ) . unwrap ( ) ;
140158 writeln ! ( file, "{:?}" , e1_parts) . unwrap ( ) ;
141159
142- let e2_parts = shuffle. get ( & executors_3[ 1 ] ) . unwrap ( ) ;
160+ let e2_parts = shuffle. get ( & executors_3[ 1 ] . id ) . unwrap ( ) ;
143161 writeln ! ( file, "{:?}" , e2_parts) . unwrap ( ) ;
144162
145- let e3_parts = shuffle. get ( & executors_3[ 2 ] ) . unwrap ( ) ;
163+ let e3_parts = shuffle. get ( & executors_3[ 2 ] . id ) . unwrap ( ) ;
146164 writeln ! ( file, "{:?}" , e3_parts) . unwrap ( ) ;
147165 }
148166
@@ -156,13 +174,13 @@ fn test_partition_reshuffle() {
156174 "PartitionsShuffleKind::Mod : 11 partitions of 3 executors"
157175 )
158176 . unwrap ( ) ;
159- let e1_parts = shuffle. get ( & executors_3[ 0 ] ) . unwrap ( ) ;
177+ let e1_parts = shuffle. get ( & executors_3[ 0 ] . id ) . unwrap ( ) ;
160178 writeln ! ( file, "{:?}" , e1_parts) . unwrap ( ) ;
161179
162- let e2_parts = shuffle. get ( & executors_3[ 1 ] ) . unwrap ( ) ;
180+ let e2_parts = shuffle. get ( & executors_3[ 1 ] . id ) . unwrap ( ) ;
163181 writeln ! ( file, "{:?}" , e2_parts) . unwrap ( ) ;
164182
165- let e3_parts = shuffle. get ( & executors_3[ 2 ] ) . unwrap ( ) ;
183+ let e3_parts = shuffle. get ( & executors_3[ 2 ] . id ) . unwrap ( ) ;
166184 writeln ! ( file, "{:?}" , e3_parts) . unwrap ( ) ;
167185 }
168186
@@ -176,10 +194,10 @@ fn test_partition_reshuffle() {
176194 "PartitionsShuffleKind::Mod : 11 partitions of 2 executors"
177195 )
178196 . unwrap ( ) ;
179- let e1_parts = shuffle. get ( & executors_2[ 0 ] ) . unwrap ( ) ;
197+ let e1_parts = shuffle. get ( & executors_2[ 0 ] . id ) . unwrap ( ) ;
180198 writeln ! ( file, "{:?}" , e1_parts) . unwrap ( ) ;
181199
182- let e2_parts = shuffle. get ( & executors_2[ 1 ] ) . unwrap ( ) ;
200+ let e2_parts = shuffle. get ( & executors_2[ 1 ] . id ) . unwrap ( ) ;
183201 writeln ! ( file, "{:?}" , e2_parts) . unwrap ( ) ;
184202 }
185203
@@ -193,10 +211,10 @@ fn test_partition_reshuffle() {
193211 "PartitionsShuffleKind::ConsistentHash : 11 partitions of 2 executors"
194212 )
195213 . unwrap ( ) ;
196- let e1_parts = shuffle. get ( & executors_2[ 0 ] ) . unwrap ( ) ;
214+ let e1_parts = shuffle. get ( & executors_2[ 0 ] . id ) . unwrap ( ) ;
197215 writeln ! ( file, "{:?}" , e1_parts) . unwrap ( ) ;
198216
199- let e2_parts = shuffle. get ( & executors_2[ 1 ] ) . unwrap ( ) ;
217+ let e2_parts = shuffle. get ( & executors_2[ 1 ] . id ) . unwrap ( ) ;
200218 writeln ! ( file, "{:?}" , e2_parts) . unwrap ( ) ;
201219 }
202220
@@ -210,13 +228,13 @@ fn test_partition_reshuffle() {
210228 "PartitionsShuffleKind::ConsistentHash : 11 partitions of 3 executors"
211229 )
212230 . unwrap ( ) ;
213- let e1_parts = shuffle. get ( & executors_3[ 0 ] ) . unwrap ( ) ;
231+ let e1_parts = shuffle. get ( & executors_3[ 0 ] . id ) . unwrap ( ) ;
214232 writeln ! ( file, "{:?}" , e1_parts) . unwrap ( ) ;
215233
216- let e2_parts = shuffle. get ( & executors_3[ 1 ] ) . unwrap ( ) ;
234+ let e2_parts = shuffle. get ( & executors_3[ 1 ] . id ) . unwrap ( ) ;
217235 writeln ! ( file, "{:?}" , e2_parts) . unwrap ( ) ;
218236
219- let e3_parts = shuffle. get ( & executors_3[ 2 ] ) . unwrap ( ) ;
237+ let e3_parts = shuffle. get ( & executors_3[ 2 ] . id ) . unwrap ( ) ;
220238 writeln ! ( file, "{:?}" , e3_parts) . unwrap ( ) ;
221239 }
222240
@@ -230,10 +248,10 @@ fn test_partition_reshuffle() {
230248 "PartitionsShuffleKind::Rand: 11 partitions of 2 executors"
231249 )
232250 . unwrap ( ) ;
233- let e1_parts = shuffle. get ( & executors_2[ 0 ] ) . unwrap ( ) ;
251+ let e1_parts = shuffle. get ( & executors_2[ 0 ] . id ) . unwrap ( ) ;
234252 writeln ! ( file, "{:?}" , e1_parts. len( ) ) . unwrap ( ) ;
235253
236- let e2_parts = shuffle. get ( & executors_2[ 1 ] ) . unwrap ( ) ;
254+ let e2_parts = shuffle. get ( & executors_2[ 1 ] . id ) . unwrap ( ) ;
237255 writeln ! ( file, "{:?}" , e2_parts. len( ) ) . unwrap ( ) ;
238256 }
239257
@@ -247,10 +265,10 @@ fn test_partition_reshuffle() {
247265 "PartitionsShuffleKind::Broadcast: 3 partitions of 2 executors"
248266 )
249267 . unwrap ( ) ;
250- let e1_parts = shuffle. get ( & executors_2[ 0 ] ) . unwrap ( ) ;
268+ let e1_parts = shuffle. get ( & executors_2[ 0 ] . id ) . unwrap ( ) ;
251269 writeln ! ( file, "{:?}" , e1_parts) . unwrap ( ) ;
252270
253- let e2_parts = shuffle. get ( & executors_2[ 1 ] ) . unwrap ( ) ;
271+ let e2_parts = shuffle. get ( & executors_2[ 1 ] . id ) . unwrap ( ) ;
254272 writeln ! ( file, "{:?}" , e2_parts) . unwrap ( ) ;
255273 }
256274}
0 commit comments