fn rebuild_predicate_cache(&self) -> Result<()> {
        *self.pred_by_name.borrow_mut() = HashMap::new();
        *self.insert_by_name.borrow_mut() = HashMap::new();
        {
            let conn = self.conn_pool.get()?;
            // Scoped borrow of connection
            let pred_stmt = conn.prepare(
                "select predicates.name,
                              predicates.description, \
                              fields.name, \
                              fields.description, \
                              fields.type from predicates JOIN fields ON \
                              predicates.id = fields.pred_id ORDER BY predicates.id, \
                              fields.ordinal",
            )?;
            let pred_types = try!(pred_stmt.query(&[]));
            for type_entry in pred_types.iter() {
                let mut row = RowIter::new(&type_entry);
                let name: String = row.next().unwrap();
                // TODO: there's funny layering of nested options issues here
                let pred_descr: Option<String> = row.next();
                let field_name: Option<String> = row.next();
                let field_descr: Option<String> = row.next();
                let h_type_str: String = row.next().unwrap();
                let h_type = match self.get_type(&h_type_str) {
                    Some(ty) => ty,
                    None => types::Trap::new(),
                };
                let field = Field {
                    name: field_name,
                    description: field_descr,
                    type_: h_type.clone(),
                };
                match self.pred_by_name.borrow_mut().entry(name.clone()) {
                    Vacant(entry) => {
                        entry.insert(Predicate {
                            name: name.clone(),
                            description: pred_descr,
                            fields: vec![field],
                        });
                    }
                    Occupied(mut entry) => {
                        entry.get_mut().fields.push(field);
                    }
                }
            }
        }
        // Populate fact insert cache
        self.pred_by_name
            .borrow()
            .values()
            .inspect(|pred| self.gen_insert_stmt(pred))
            .count();
        Ok(())
    }
// Rebuilds the predicate cache
// I'm assuming for the moment that there isn't going to be a lot of
// dynamic type adding/removal, and so rebuilding the predicate/insert
// statement cache on add/remove isn't a big deal
Rebuilds the predicate cache
I'm assuming for the moment that there isn't going to be a lot of
dynamic type adding/removal, and so rebuilding the predicate/insert
statement cache on add/remove isn't a big deal
Rebuilds the predicate cache I ' m assuming for the moment that there isn ' t going to be a lot of dynamic type adding / removal and so rebuilding the predicate / insert statement cache on add / remove isn ' t a big deal
fn rebuild_predicate_cache(&self) -> Result<()> {
        *self.pred_by_name.borrow_mut() = HashMap::new();
        *self.insert_by_name.borrow_mut() = HashMap::new();
        {
            let conn = self.conn_pool.get()?;
            // Scoped borrow of connection
            let pred_stmt = conn.prepare(
                "select predicates.name,
                              predicates.description, \
                              fields.name, \
                              fields.description, \
                              fields.type from predicates JOIN fields ON \
                              predicates.id = fields.pred_id ORDER BY predicates.id, \
                              fields.ordinal",
            )?;
            let pred_types = try!(pred_stmt.query(&[]));
            for type_entry in pred_types.iter() {
                let mut row = RowIter::new(&type_entry);
                let name: String = row.next().unwrap();
                // TODO: there's funny layering of nested options issues here
                let pred_descr: Option<String> = row.next();
                let field_name: Option<String> = row.next();
                let field_descr: Option<String> = row.next();
                let h_type_str: String = row.next().unwrap();
                let h_type = match self.get_type(&h_type_str) {
                    Some(ty) => ty,
                    None => types::Trap::new(),
                };
                let field = Field {
                    name: field_name,
                    description: field_descr,
                    type_: h_type.clone(),
                };
                match self.pred_by_name.borrow_mut().entry(name.clone()) {
                    Vacant(entry) => {
                        entry.insert(Predicate {
                            name: name.clone(),
                            description: pred_descr,
                            fields: vec![field],
                        });
                    }
                    Occupied(mut entry) => {
                        entry.get_mut().fields.push(field);
                    }
                }
            }
        }
        // Populate fact insert cache
        self.pred_by_name
            .borrow()
            .values()
            .inspect(|pred| self.gen_insert_stmt(pred))
            .count();
        Ok(())
    }
fn rebuild_predicate_cache ( & self ) -> Result < ( ) > { * self . pred_by_name . borrow_mut ( ) = HashMap :: new ( ) ; * self . insert_by_name . borrow_mut ( ) = HashMap :: new ( ) ; { let conn = self . conn_pool . get ( ) ? ; // Scoped borrow of connection let pred_stmt = conn . prepare ( " \
 \
 \
 \
 \
 " , ) ? ; let pred_types = try ! ( pred_stmt query ( [ ] ) ) ; for type_entry in pred_types . iter ( ) { let mut row = RowIter :: new ( & type_entry ) ; let name : String = row . next ( ) . unwrap ( ) ; // TODO: there's funny layering of nested options issues here let pred_descr : Option < String > = row . next ( ) ; let field_name : Option < String > = row . next ( ) ; let field_descr : Option < String > = row . next ( ) ; let h_type_str : String = row . next ( ) . unwrap ( ) ; let h_type = match self . get_type ( & h_type_str ) { Some ( ty ) => ty , None => types :: Trap :: new ( ) , } ; let field = Field { name : field_name , description : field_descr , type_ : h_type . clone ( ) , } ; match self . pred_by_name . borrow_mut ( ) . entry ( name . clone ( ) ) { Vacant ( entry ) => { entry . insert ( Predicate { name : name . clone ( ) , description : pred_descr , fields : vec ! [ field ] , } ) ; } Occupied ( mut entry ) => { entry . get_mut ( ) . fields . push ( field ) ; } } } } // Populate fact insert cache self . pred_by_name . borrow ( ) . values ( ) . inspect ( | pred | self . gen_insert_stmt ( pred ) ) . count ( ) ; Ok ( ( ) ) }
Rebuilds the predicate cache
I'm assuming for the moment that there isn't going to be a lot of
dynamic type adding/removal, and so rebuilding the predicate/insert
statement cache on add/remove isn't a big deal
Rebuilds the predicate cache I ' m assuming for the moment that there isn ' t going to be a lot of dynamic type adding / removal and so rebuilding the predicate / insert statement cache on add / remove isn ' t a big deal
&self
&self