pub fn replay_segments(&mut self, partition_path: PathBuf) -> Result<(), Error> {
        let mut fsa_files = HashSet::new();
        let mut segment_ids = Vec::new();
        let partition_name = partition_path
            .file_name()
            .unwrap()
            .to_os_string()
            .into_string()
            .unwrap();

        for entry in read_dir(&partition_path)? {
            let entry = entry?;
            let entry_path = entry.path();
            assert_eq!(entry_path.is_file(), true);
            // check whether it is fsa or segment file.
            let extension = entry_path.extension().unwrap();
            if extension == "fst" {
                // There may be case where fsa file is created but
                // index is not flushed. we need some mechanism to detect
                // that or we could just check the size and build index
                // from the begining.
                // TODO: @balajijinnah.
                let file_name = entry_path.file_stem().unwrap();
                let splits = file_name.to_str().unwrap().split("_");
                let splits = splits.collect::<Vec<&str>>();
                fsa_files.insert(splits[2].to_string());
                continue;
            }
            assert_eq!(extension, "segment");
            let file_name = entry_path.file_stem().unwrap();
            segment_ids.push(file_name.to_str().unwrap().parse::<u64>().unwrap());
        }
        // reverse it because only last file doesn't have partition.
        segment_ids.reverse();
        for segment_id in segment_ids {
            if !fsa_files.contains(&segment_id.to_string()) {
                // this segment file doesn't have index file, so
                // rebuild the index file.
                self.build_fst(&partition_path, segment_id, &partition_name)?;
            }
        }
        Ok(())
    }
/// replay_segments will check whether segment file have
replay_segments will check whether segment file have
replay_segments will check whether segment file have
pub fn replay_segments(&mut self, partition_path: PathBuf) -> Result<(), Error> {
        let mut fsa_files = HashSet::new();
        let mut segment_ids = Vec::new();
        let partition_name = partition_path
            .file_name()
            .unwrap()
            .to_os_string()
            .into_string()
            .unwrap();
        for entry in read_dir(&partition_path)? {
            let entry = entry?;
            let entry_path = entry.path();
            assert_eq!(entry_path.is_file(), true);
            // check whether it is fsa or segment file.
            let extension = entry_path.extension().unwrap();
            if extension == "fst" {
                // There may be case where fsa file is created but
                // index is not flushed. we need some mechanism to detect
                // that or we could just check the size and build index
                // from the begining.
                // TODO: @balajijinnah.
                let file_name = entry_path.file_stem().unwrap();
                let splits = file_name.to_str().unwrap().split("_");
                let splits = splits.collect::<Vec<&str>>();
                fsa_files.insert(splits[2].to_string());
                continue;
            }
            assert_eq!(extension, "segment");
            let file_name = entry_path.file_stem().unwrap();
            segment_ids.push(file_name.to_str().unwrap().parse::<u64>().unwrap());
        }
        // reverse it because only last file doesn't have partition.
        segment_ids.reverse();
        for segment_id in segment_ids {
            if !fsa_files.contains(&segment_id.to_string()) {
                // this segment file doesn't have index file, so
                // rebuild the index file.
                self.build_fst(&partition_path, segment_id, &partition_name)?;
            }
        }
        Ok(())
    }
pub fn replay_segments ( & mut self , partition_path : PathBuf ) -> Result < ( ) , Error > { let mut fsa_files = HashSet :: new ( ) ; let mut segment_ids = Vec :: new ( ) ; let partition_name = partition_path . file_name ( ) . unwrap ( ) . to_os_string ( ) . into_string ( ) . unwrap ( ) ; for entry in read_dir ( & partition_path ) ? { let entry = entry ? ; let entry_path = entry . path ( ) ; assert_eq ! ( entry_path is_file ( ) true ) ; // check whether it is fsa or segment file. let extension = entry_path . extension ( ) . unwrap ( ) ; if extension == " " { // There may be case where fsa file is created but // index is not flushed. we need some mechanism to detect // that or we could just check the size and build index // from the begining. // TODO: @balajijinnah. let file_name = entry_path . file_stem ( ) . unwrap ( ) ; let splits = file_name . to_str ( ) . unwrap ( ) . split ( " " ) ; let splits = splits . collect :: < Vec < & str > > ( ) ; fsa_files . insert ( splits [ 2 ] . to_string ( ) ) ; continue ; } assert_eq ! ( extension " " ) ; let file_name = entry_path . file_stem ( ) . unwrap ( ) ; segment_ids . push ( file_name . to_str ( ) . unwrap ( ) . parse :: < u64 > ( ) . unwrap ( ) ) ; } // reverse it because only last file doesn't have partition. segment_ids . reverse ( ) ; for segment_id in segment_ids { if ! fsa_files . contains ( & segment_id . to_string ( ) ) { // this segment file doesn't have index file, so // rebuild the index file. self . build_fst ( & partition_path , segment_id , & partition_name ) ? ; } } Ok ( ( ) ) }
replay_segments will check whether segment file have
replay_segments will check whether segment file have
&mut self
partition_path
PathBuf