You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: mmap_directory.rs
    path of file: ./repos/rucene/src/core/store/directory
    
    the code of the file until where you have to start completion: // Copyright 2019 Zhizhesihai (Beijing) Technology Limited.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// See the License for the specific language governing permissions and
// limitations under the License.

use std::collections::hash_map::Entry as HashMapEntry;
use std::collections::HashMap;
use std::fmt;
use std::path::{Path, PathBuf};
use std::sync::{Arc, Mutex, Weak};

use memmap::Mmap;

use core::store::directory::{Directory, FSDirectory, FilterDirectory};
use core::store::io::{FSIndexOutput, IndexInput, MmapIndexInput, ReadOnlySource};
use core::store::IOContext;
use error::Result;

#[de
    
    fn get_mmap(&mut self, full_path: &PathBuf) -> Result<Option<Arc<Mmap>>> {
        // if we exceed this limit, then we go through the weak
        // and remove those that are obsolete.
        if self.cache.len() > self.purge_weak_limit {
            self.cleanup();
        }

        match self.cache.entry(full_path.clone()) {
            HashMapEntry::Occupied(mut occupied) => {
                if let Some(mmap) = occupied.get().upgrade() {
                    self.stat.hit += 1;
                    Ok(Some(Arc::clone(&mmap)))
                } else {
                    // The entry exists but the weak ref has been destroyed.
                    self.stat.miss_weak += 1;
                    if let Some(mmap) = MmapIndexInput::mmap(&full_path, 0, 0)? {
                        occupied.insert(Arc::downgrade(&mmap));
                        Ok(Some(mmap))
                    } else {
                        Ok(None)
                    }
                }
            }

            HashMapEntry::Vacant(vacant) => {
                self.stat.miss_empty += 1;
                if let Some(mmap) = MmapIndexInput::mmap(&full_path, 0, 0)? {
                    vacant.insert(Arc::downgrade(&mmap));
                    Ok(Some(mmap))
                } else {
                    Ok(None)
                }
            }
        }
    }