Cd/ls through the directory layer?

To be clear: I do not want to list all the kv pairs.

Imagine a vfs consisted solely of directories (but no files, no kv pairs) consisting of the DirectoryLayer directories we have defined in fdb.

Is there a way, in the fdbcli (or some other tool) to cd/ls through this vfs ? I just want to be able to cd into sub directories, cd .. to parent dir, ls to see all sub directories. The goal is to get a gist / high level view of fdb directory layer structure, without looking at any kv pairs.

Thanks!

It’s a bit cumbersome in it’s current form, but you can use FQL (my query language) to do this. Currently, I doesn’t have the concept of a “current directory” so you’ll need to query the directories at the root:

/<>
/users
/tasks
/auth

Then you’ll query them at the second layer, etc:

/users/<>
/user/name
/user/address
/user/bio

Let me know what you think. It’s still a work in progress.

is one of my favorite pieces of documentation. It shows the command, followed by the crux of the golang impl. I’m going to LLM convert this to Rust, then bind it to Elixir via rustler. :slight_smile:

I have plans to port this to rust and integrate with Elixir somehow. Been meaning to write a project in that language, and Rust will be better for connecting it to all programming languages.

iex(1)> SFfi.KVDir.ls("")                                                                                                                                                                                                                    │
│kv_dir_ls: started                                                                                                                                                                                                                           │
│kv_dir_ls: done                                                                                                                                                                                                                              │
│path: ""                                                                                                                                                                                                                                     │
│line0                                                                                                                                                                                                                                        │
│     Timeout                                                                                                                                                                                                                                 │
│:ok                                                                                                                                                                                                                                          │
│iex(2)> SFfi.KVDir.ls("resumee")                                                                                                                                                                                                             │
│kv_dir_ls: started                                                                                                                                                                                                                           │
│kv_dir_ls: done                                                                                                                                                                                                                              │
│path: "resumee"                                                                                                                                                                                                                              │
│line0                                                                                                                                                                                                                                        │
│line1                                                                                                                                                                                                                                        │
│data: ["doc_to_term", "inv_index", "inv_indx", "ptrs", "term_to_doc", "word_to_doc"]                                                                                                                                                         │
│                                                                                    ["doc_to_term", "inv_index", "inv_indx", "ptrs", "term_to_doc", "word_to_doc"]                                                                           │
│iex(3)> SFfi.KVDir.ls("")                                                                                                                                                                                                                    │
│kv_dir_ls: started                                                                                                                                                                                                                           │
│kv_dir_ls: done                                                                                                                                                                                                                              │
│path: ""                               

I have this very weird situation, where ls(““) hangs, but ls(“resumee”) works fine.
The fact the latter works means everything is working fine with fdb connection.
As for the former hanging, I trace it down to this line:

    async fn ls<'a>(path: String) -> Result<Vec<String>, DirectoryError> {
        print!("path: {:?}\n\r", path);
        let trx: Transaction = G_SFfi_Global.get().unwrap().db.create_trx()?;
        print!("line0\n\r");
        let fdbo_root = KVDir_Obj::new(&trx, &path).await?;
        print!("line1\n\r");
        let data = fdbo_root.obj_root.dir.list(&trx, &[]).await?;
        print!("data: {:?}\n\r", data);
        Ok(data)
    }

which boils down to calling create_or_open on a empty &[] path.

Is this a known issue? That we can not create_or_open on “fdb root” ?

just got ls/rm working

1 Like

I have never tried to open an empty dir. If there is a bug it would be in the Rust bindings. FDB doesn’t have any knowledge of directories. It only sees the key-value byte strings.