liyongjing commented on issue #1969:
URL: https://github.com/apache/arrow-rs/issues/1969#issuecomment-1171850627

   I call `write` multiple times, call `close` one times using static HashMap.
   ```rust
   fn global() -> &'static Mutex<HashMap<String, Writer>> {
       static INSTANCE: OnceCell<Mutex<HashMap<String, Writer>>> = 
OnceCell::new();
       INSTANCE.get_or_init(|| Mutex::new(HashMap::new()))
   }
   pub fn write(path: &str, val: Vec<u8>) {
       let mut g = global_channel().lock().unwrap();
       let w = g.entry(path.to_string()).or_insert(Writer::new(path));
       let batch =  ...;
       w.write(&batch);
   }
   pub fn close(path: &str) {
       let mut g = global_channel().lock().unwrap();
       if let Some(v) = g.get_mut(path) {
           // *v don't copy
           v.close();
       }
       g.remove(path);
   }
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscr...@arrow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to