@@ -7,14 +7,18 @@ use tokio::sync::Mutex;
77use crate :: {
88 crypto:: hash_buffer,
99 error:: Result ,
10- model:: { ToYaml , packet:: Packet , serialize_hashmap} ,
10+ model:: { ToYaml , packet:: ArrowPacket , serialize_hashmap} ,
1111} ;
1212
1313/// Trait that all operators must implement for it to work in the pipeline
1414#[ async_trait:: async_trait]
1515pub trait Operator {
1616 /// Method where the operator get pass a packet for processing one at a time
17- async fn process_packet ( & self , stream_name : String , packet : Packet ) -> Result < Vec < Packet > > ;
17+ async fn process_packet (
18+ & self ,
19+ stream_name : String ,
20+ packet : ArrowPacket ,
21+ ) -> Result < Vec < ArrowPacket > > ;
1822}
1923
2024/// Operator class that map `input_keys` to `output_key`, effectively renaming it
@@ -52,7 +56,7 @@ impl MapOperator {
5256/// Operator class that join packets from multiple parent streams into one packet
5357pub struct JoinOperator {
5458 parent_count : usize ,
55- received_packets : Arc < Mutex < HashMap < String , Vec < Packet > > > > ,
59+ received_packets : Arc < Mutex < HashMap < String , Vec < ArrowPacket > > > > ,
5660}
5761
5862impl JoinOperator {
@@ -67,7 +71,11 @@ impl JoinOperator {
6771
6872#[ async_trait:: async_trait]
6973impl Operator for JoinOperator {
70- async fn process_packet ( & self , stream_name : String , packet : Packet ) -> Result < Vec < Packet > > {
74+ async fn process_packet (
75+ & self ,
76+ stream_name : String ,
77+ packet : ArrowPacket ,
78+ ) -> Result < Vec < ArrowPacket > > {
7179 let mut received_packets = self . received_packets . lock ( ) . await ;
7280 received_packets
7381 . entry ( stream_name. clone ( ) )
@@ -105,7 +113,7 @@ impl Operator for JoinOperator {
105113
106114#[ async_trait:: async_trait]
107115impl Operator for MapOperator {
108- async fn process_packet ( & self , _: String , packet : Packet ) -> Result < Vec < Packet > > {
116+ async fn process_packet ( & self , _: String , packet : ArrowPacket ) -> Result < Vec < ArrowPacket > > {
109117 Ok ( vec ! [
110118 packet
111119 . iter( )
@@ -140,7 +148,7 @@ mod tests {
140148
141149 use crate :: {
142150 error:: Result ,
143- model:: packet:: { Blob , BlobKind , Packet , PathSet , URI } ,
151+ model:: packet:: { ArrowPacket , Blob , BlobKind , PathSet , URI } ,
144152 operator:: { JoinOperator , MapOperator , Operator } ,
145153 } ;
146154 use std:: { collections:: HashMap , path:: PathBuf } ;
@@ -161,8 +169,8 @@ mod tests {
161169
162170 async fn next_batch (
163171 operator : impl Operator ,
164- packets : Vec < ( String , Packet ) > ,
165- ) -> Result < Vec < Packet > > {
172+ packets : Vec < ( String , ArrowPacket ) > ,
173+ ) -> Result < Vec < ArrowPacket > > {
166174 let mut next_packets = vec ! [ ] ;
167175 for ( stream_name, packet) in packets {
168176 next_packets. extend ( operator. process_packet ( stream_name, packet) . await ?) ;
@@ -178,7 +186,7 @@ mod tests {
178186 . map ( |i| {
179187 (
180188 "left" . into ( ) ,
181- Packet :: from ( [ make_packet_key (
189+ ArrowPacket :: from ( [ make_packet_key (
182190 "subject" . into ( ) ,
183191 format ! ( "left/subject{i}.png" ) ,
184192 ) ] ) ,
@@ -190,7 +198,7 @@ mod tests {
190198 . map ( |i| {
191199 (
192200 "right" . into ( ) ,
193- Packet :: from ( [ make_packet_key (
201+ ArrowPacket :: from ( [ make_packet_key (
194202 "style" . into ( ) ,
195203 format ! ( "right/style{i}.t7" ) ,
196204 ) ] ) ,
@@ -204,27 +212,27 @@ mod tests {
204212 assert_eq ! (
205213 next_batch( operator, input_streams) . await ?,
206214 vec![
207- Packet :: from( [
215+ ArrowPacket :: from( [
208216 make_packet_key( "subject" . into( ) , "left/subject0.png" . into( ) ) ,
209217 make_packet_key( "style" . into( ) , "right/style0.t7" . into( ) ) ,
210218 ] ) ,
211- Packet :: from( [
219+ ArrowPacket :: from( [
212220 make_packet_key( "subject" . into( ) , "left/subject1.png" . into( ) ) ,
213221 make_packet_key( "style" . into( ) , "right/style0.t7" . into( ) ) ,
214222 ] ) ,
215- Packet :: from( [
223+ ArrowPacket :: from( [
216224 make_packet_key( "subject" . into( ) , "left/subject2.png" . into( ) ) ,
217225 make_packet_key( "style" . into( ) , "right/style0.t7" . into( ) ) ,
218226 ] ) ,
219- Packet :: from( [
227+ ArrowPacket :: from( [
220228 make_packet_key( "subject" . into( ) , "left/subject0.png" . into( ) ) ,
221229 make_packet_key( "style" . into( ) , "right/style1.t7" . into( ) ) ,
222230 ] ) ,
223- Packet :: from( [
231+ ArrowPacket :: from( [
224232 make_packet_key( "subject" . into( ) , "left/subject1.png" . into( ) ) ,
225233 make_packet_key( "style" . into( ) , "right/style1.t7" . into( ) ) ,
226234 ] ) ,
227- Packet :: from( [
235+ ArrowPacket :: from( [
228236 make_packet_key( "subject" . into( ) , "left/subject2.png" . into( ) ) ,
229237 make_packet_key( "style" . into( ) , "right/style1.t7" . into( ) ) ,
230238 ] ) ,
@@ -243,7 +251,7 @@ mod tests {
243251 operator
244252 . process_packet(
245253 "right" . into( ) ,
246- Packet :: from( [ make_packet_key( "style" . into( ) , "right/style0.t7" . into( ) ) ] )
254+ ArrowPacket :: from( [ make_packet_key( "style" . into( ) , "right/style0.t7" . into( ) ) ] )
247255 )
248256 . await ?,
249257 vec![ ] ,
@@ -254,7 +262,7 @@ mod tests {
254262 operator
255263 . process_packet(
256264 "right" . into( ) ,
257- Packet :: from( [ make_packet_key( "style" . into( ) , "right/style1.t7" . into( ) ) ] )
265+ ArrowPacket :: from( [ make_packet_key( "style" . into( ) , "right/style1.t7" . into( ) ) ] )
258266 )
259267 . await ?,
260268 vec![ ] ,
@@ -265,18 +273,18 @@ mod tests {
265273 operator
266274 . process_packet(
267275 "left" . into( ) ,
268- Packet :: from( [ make_packet_key(
276+ ArrowPacket :: from( [ make_packet_key(
269277 "subject" . into( ) ,
270278 "left/subject0.png" . into( )
271279 ) ] )
272280 )
273281 . await ?,
274282 vec![
275- Packet :: from( [
283+ ArrowPacket :: from( [
276284 make_packet_key( "subject" . into( ) , "left/subject0.png" . into( ) ) ,
277285 make_packet_key( "style" . into( ) , "right/style0.t7" . into( ) ) ,
278286 ] ) ,
279- Packet :: from( [
287+ ArrowPacket :: from( [
280288 make_packet_key( "subject" . into( ) , "left/subject0.png" . into( ) ) ,
281289 make_packet_key( "style" . into( ) , "right/style1.t7" . into( ) ) ,
282290 ] ) ,
@@ -291,7 +299,7 @@ mod tests {
291299 . map( |i| {
292300 (
293301 "left" . into( ) ,
294- Packet :: from( [ make_packet_key(
302+ ArrowPacket :: from( [ make_packet_key(
295303 "subject" . into( ) ,
296304 format!( "left/subject{i}.png" ) ,
297305 ) ] ) ,
@@ -301,19 +309,19 @@ mod tests {
301309 )
302310 . await ?,
303311 vec![
304- Packet :: from( [
312+ ArrowPacket :: from( [
305313 make_packet_key( "subject" . into( ) , "left/subject1.png" . into( ) ) ,
306314 make_packet_key( "style" . into( ) , "right/style0.t7" . into( ) ) ,
307315 ] ) ,
308- Packet :: from( [
316+ ArrowPacket :: from( [
309317 make_packet_key( "subject" . into( ) , "left/subject1.png" . into( ) ) ,
310318 make_packet_key( "style" . into( ) , "right/style1.t7" . into( ) ) ,
311319 ] ) ,
312- Packet :: from( [
320+ ArrowPacket :: from( [
313321 make_packet_key( "subject" . into( ) , "left/subject2.png" . into( ) ) ,
314322 make_packet_key( "style" . into( ) , "right/style0.t7" . into( ) ) ,
315323 ] ) ,
316- Packet :: from( [
324+ ArrowPacket :: from( [
317325 make_packet_key( "subject" . into( ) , "left/subject2.png" . into( ) ) ,
318326 make_packet_key( "style" . into( ) , "right/style1.t7" . into( ) ) ,
319327 ] ) ,
@@ -332,13 +340,13 @@ mod tests {
332340 operator
333341 . process_packet(
334342 "parent" . into( ) ,
335- Packet :: from( [
343+ ArrowPacket :: from( [
336344 make_packet_key( "key_old" . into( ) , "some/key.txt" . into( ) ) ,
337345 make_packet_key( "subject" . into( ) , "some/subject.txt" . into( ) ) ,
338346 ] ) ,
339347 )
340348 . await ?,
341- vec![ Packet :: from( [
349+ vec![ ArrowPacket :: from( [
342350 make_packet_key( "key_new" . into( ) , "some/key.txt" . into( ) ) ,
343351 make_packet_key( "subject" . into( ) , "some/subject.txt" . into( ) ) ,
344352 ] ) , ] ,
0 commit comments