pub(crate) async fn populate_virtual_directories(
        &self,
        mut query: Query,
        parent_inode: u64,
    ) -> Result<()> {
        query.facets = true;
        let results = self.client.query(query.clone()).await?;
        ensure!(results.facets.is_some(), "missing facets");

        let facets = results.facets.unwrap();

        // Build "tags" virtual directory.
        let tags: Vec<String> = facets.tags.into_iter().map(|(tag, _count)| tag).collect();

        let kv: HashMap<String, Vec<String>> = facets
            .meta
            .into_iter()
            .map(|(key, meta_counts)| {
                (
                    key,
                    meta_counts.into_iter().map(|(key, _count)| key).collect(),
                )
            })
            .collect();

        // Register the inode for our tag directory.
        let tags_inode = self.get_virtual_inode(parent_inode, "tags").await;
        self.virtual_directories_inodes
            .insert(tags_inode, VirtualDirectory::InMemory(tags.clone()))
            .await;

        // Register a virtual directory for every tag.
        for tag in tags.into_iter() {
            let tag_inode = self.get_virtual_inode(tags_inode, &tag).await;
            self.virtual_directories_inodes
                .insert(
                    tag_inode,
                    VirtualDirectory::Query {
                        query: query.clone().and_tag(tag.clone()),
                    },
                )
                .await;
        }

        // Build k/v virtual directories
        for (key, values) in kv.into_iter() {
            let key_inode = self.get_virtual_inode(parent_inode, &key).await;
            self.virtual_directories_inodes
                .insert(key_inode, VirtualDirectory::InMemory(values.clone()))
                .await;

            for value in values.into_iter() {
                let value_inode = self.get_virtual_inode(key_inode, &value).await;
                self.virtual_directories_inodes
                    .insert(
                        value_inode,
                        VirtualDirectory::Query {
                            query: query.clone().and_meta(key.clone(), value.clone()),
                        },
                    )
                    .await;
            }
        }

        Ok(())
    }
/// Populates the metadata maps for virtual directories.
///
/// This creates the virtual subdirectories for `query` mounts, creating directories for each tag and k/v pair.
Populates the metadata maps for virtual directories.
This creates the virtual subdirectories for `query` mounts, creating directories for each tag and k/v pair.
Populates the metadata maps for virtual directories . This creates the virtual subdirectories for ` query ` mounts creating directories for each tag and k / v pair .
pub(crate) async fn populate_virtual_directories(
        &self,
        mut query: Query,
        parent_inode: u64,
    ) -> Result<()> {
        query.facets = true;
        let results = self.client.query(query.clone()).await?;
        ensure!(results.facets.is_some(), "missing facets");
        let facets = results.facets.unwrap();
        // Build "tags" virtual directory.
        let tags: Vec<String> = facets.tags.into_iter().map(|(tag, _count)| tag).collect();
        let kv: HashMap<String, Vec<String>> = facets
            .meta
            .into_iter()
            .map(|(key, meta_counts)| {
                (
                    key,
                    meta_counts.into_iter().map(|(key, _count)| key).collect(),
                )
            })
            .collect();
        // Register the inode for our tag directory.
        let tags_inode = self.get_virtual_inode(parent_inode, "tags").await;
        self.virtual_directories_inodes
            .insert(tags_inode, VirtualDirectory::InMemory(tags.clone()))
            .await;
        // Register a virtual directory for every tag.
        for tag in tags.into_iter() {
            let tag_inode = self.get_virtual_inode(tags_inode, &tag).await;
            self.virtual_directories_inodes
                .insert(
                    tag_inode,
                    VirtualDirectory::Query {
                        query: query.clone().and_tag(tag.clone()),
                    },
                )
                .await;
        }
        // Build k/v virtual directories
        for (key, values) in kv.into_iter() {
            let key_inode = self.get_virtual_inode(parent_inode, &key).await;
            self.virtual_directories_inodes
                .insert(key_inode, VirtualDirectory::InMemory(values.clone()))
                .await;
            for value in values.into_iter() {
                let value_inode = self.get_virtual_inode(key_inode, &value).await;
                self.virtual_directories_inodes
                    .insert(
                        value_inode,
                        VirtualDirectory::Query {
                            query: query.clone().and_meta(key.clone(), value.clone()),
                        },
                    )
                    .await;
            }
        }
        Ok(())
    }
pub ( crate ) async fn populate_virtual_directories ( & self , mut query : Query , parent_inode : u64 , ) -> Result < ( ) > { query . facets = true ; let results = self . client . query ( query . clone ( ) ) . await ? ; ensure ! ( results facets is_some ( ) " " ) ; let facets = results . facets . unwrap ( ) ; // Build "tags" virtual directory. let tags : Vec < String > = facets . tags . into_iter ( ) . map ( | ( tag , _count ) | tag ) . collect ( ) ; let kv : HashMap < String , Vec < String > > = facets . meta . into_iter ( ) . map ( | ( key , meta_counts ) | { ( key , meta_counts . into_iter ( ) . map ( | ( key , _count ) | key ) . collect ( ) , ) } ) . collect ( ) ; // Register the inode for our tag directory. let tags_inode = self . get_virtual_inode ( parent_inode , " " ) . await ; self . virtual_directories_inodes . insert ( tags_inode , VirtualDirectory :: InMemory ( tags . clone ( ) ) ) . await ; // Register a virtual directory for every tag. for tag in tags . into_iter ( ) { let tag_inode = self . get_virtual_inode ( tags_inode , & tag ) . await ; self . virtual_directories_inodes . insert ( tag_inode , VirtualDirectory :: Query { query : query . clone ( ) . and_tag ( tag . clone ( ) ) , } , ) . await ; } // Build k/v virtual directories for ( key , values ) in kv . into_iter ( ) { let key_inode = self . get_virtual_inode ( parent_inode , & key ) . await ; self . virtual_directories_inodes . insert ( key_inode , VirtualDirectory :: InMemory ( values . clone ( ) ) ) . await ; for value in values . into_iter ( ) { let value_inode = self . get_virtual_inode ( key_inode , & value ) . await ; self . virtual_directories_inodes . insert ( value_inode , VirtualDirectory :: Query { query : query . clone ( ) . and_meta ( key . clone ( ) , value . clone ( ) ) , } , ) . await ; } } Ok ( ( ) ) }
Populates the metadata maps for virtual directories.
Populates the metadata maps for virtual directories .
&self
query
Query
parent_inode
u64
&self
query
Query
parent_inode
u64