1+ use std:: collections:: BTreeMap ;
12use std:: io:: { BufRead , BufReader } ;
23use std:: fs:: File ;
34
4- use indexmap:: IndexMap ;
5-
65use timely:: progress:: Timestamp ;
76use timely:: order:: Product ;
87use timely:: dataflow:: Scope ;
@@ -152,12 +151,12 @@ impl Query {
152151 }
153152
154153 /// Creates a dataflow implementing the query, and returns input and trace handles.
155- pub fn render_in < G > ( & self , scope : & mut G ) -> IndexMap < String , RelationHandles < G :: Timestamp > >
154+ pub fn render_in < G > ( & self , scope : & mut G ) -> BTreeMap < String , RelationHandles < G :: Timestamp > >
156155 where
157156 G : Scope < Timestamp : Lattice +:: timely:: order:: TotalOrder > ,
158157 {
159158 // Create new input (handle, stream) pairs
160- let mut input_map = IndexMap :: new ( ) ;
159+ let mut input_map = BTreeMap :: new ( ) ;
161160 for production in self . productions . iter ( ) {
162161 input_map. entry ( production. left_hand . clone ( ) ) . or_insert_with ( || scope. new_collection ( ) ) ;
163162 }
@@ -166,11 +165,11 @@ impl Query {
166165 scope. iterative :: < Iter , _ , _ > ( |subscope| {
167166
168167 // create map from relation name to input handle and collection.
169- let mut result_map = IndexMap :: new ( ) ;
170- let mut variable_map = IndexMap :: new ( ) ;
168+ let mut result_map = BTreeMap :: new ( ) ;
169+ let mut variable_map = BTreeMap :: new ( ) ;
171170
172171 // create variables and result handles for each named relation.
173- for ( name, ( input, collection) ) in input_map. drain ( .. ) {
172+ for ( name, ( input, collection) ) in input_map {
174173 let edge_variable = EdgeVariable :: from ( & collection. enter ( subscope) , Product :: new ( Default :: default ( ) , 1 ) ) ;
175174 let trace = edge_variable. variable . leave ( ) . arrange_by_self ( ) . trace ;
176175 result_map. insert ( name. clone ( ) , RelationHandles { input, trace } ) ;
@@ -188,14 +187,14 @@ impl Query {
188187
189188 // We'll track the path transposed, so that it is indexed by *destination* rather than source.
190189 let mut transposed = match & rule[ 0 ] {
191- Relation :: Forward ( name) => variable_map[ name] . reverse ( ) . clone ( ) ,
192- Relation :: Reverse ( name) => variable_map[ name] . forward ( ) . clone ( ) ,
190+ Relation :: Forward ( name) => variable_map. get_mut ( name) . unwrap ( ) . reverse ( ) . clone ( ) ,
191+ Relation :: Reverse ( name) => variable_map. get_mut ( name) . unwrap ( ) . forward ( ) . clone ( ) ,
193192 } ;
194193
195194 for relation in rule[ 1 ..] . iter ( ) {
196195 let to_join = match relation {
197- Relation :: Forward ( name) => variable_map[ name] . forward ( ) ,
198- Relation :: Reverse ( name) => variable_map[ name] . reverse ( ) ,
196+ Relation :: Forward ( name) => variable_map. get_mut ( name) . unwrap ( ) . forward ( ) ,
197+ Relation :: Reverse ( name) => variable_map. get_mut ( name) . unwrap ( ) . reverse ( ) ,
199198 } ;
200199
201200 transposed =
@@ -205,11 +204,11 @@ impl Query {
205204 }
206205
207206 // Reverse the direction before adding it as a production.
208- variable_map[ name] . add_production ( & transposed. as_collection ( |& dst, & src| ( src, dst) ) ) ;
207+ variable_map. get_mut ( name) . unwrap ( ) . add_production ( & transposed. as_collection ( |& dst, & src| ( src, dst) ) ) ;
209208 }
210209 }
211210
212- for ( _name, variable) in variable_map. drain ( .. ) {
211+ for ( _name, variable) in variable_map {
213212 variable. complete ( ) ;
214213 }
215214 result_map
0 commit comments