Repository navigation
Add idx family of commands for in-memory indexing - #18142
Conversation
|
Will fix the CI issues after dmtrKovalenko/fff#430 lands and there's a release. However, this PR still works for anyone who wants to play with it. |
|
WOW! I see this one is merged, this is absolutely stoked :) I see that you figured out your previous problems with watch mode, but PLEASE let me know if something goes wrong or you see any related issues, I am absolutely ready to maintain them and fix any problem related to fff
|
|
Hey @dmtrKovalenko! Thanks for checking in. Actually I didn't figure out the watch at all. It's hard coded to false right now. No matter what I did (the other day) I couldn't get it to work so I gave up on that part. I noticed you've worked on that stuff quite a bit recently so I may give it another try. It would be uber cool to auto update the index via the built-in watch functionality. |
|
I will check it out |
Description
This PR adds the
idxcommand family for in-memory filesystem indexing and search.Built on
fff-search(v0.7.0), which walks the path and stores file and directory metadata in memory arenas. The global runtime lives in astatic OnceLock<Mutex<Option<IdxRuntime>>>so a single index is shared across all commands in a session.The implementation includes:
idx init,idx status,idx files,idx dirs,idx find,idx search,idx export,idx import, andidx dropcommandsidx exportand metadata-driven rehydration foridx importUser-facing changes (Release notes)
Add the
idxcommand family for in-memory filesystem indexing and search.Commands
idx init <path> [--wait]Initializes the global idx runtime by scanning
<path>. If the runtime is already initialized it is dropped and re-scanned.--waitblocks until the initial scan completes; omitting it returns immediately with ascanning = truestatus.idx statusReturns a record describing the current runtime:
initialized,base_path,watch,scanning,scan_duration_ms,files,dirs, and arena memory usage fields.idx dirsReturns all indexed directories as records with
relative_pathandfull_pathcolumns.idx files [<path>]Returns all indexed files as records with
relative_path,full_path,file_name,directory,size, andmodifiedcolumns. If an optional<path>is provided it performs a direct lookup by relative or absolute path.idx find <query> [--files] [--dirs] [--verbose] [--limit <n>]Fuzzy-searches the index using
fff-searchscoring. By default searches both files and directories.--filesor--dirsnarrows the search.--verboseadds ascore_detailscolumn.--limitcaps the result count (default 100).idx search <pattern>... [--regex] [--fuzzy] [--limit <n>]Searches the contents of indexed files. Plain text is the default.
--regexenables regex matching.--fuzzyenables approximate line matching. Multiple patterns are searched withmulti_grep.--limitcaps matches (default 50).idx export <filepath>Persists the current runtime to a SQLite database at
<filepath>. Returns a record withstored,path,file_count,dir_count,base_path, andformat.idx import <filepath>Imports a SQLite snapshot created by
idx export. Performs true offline restoration by hydrating the index from stored file and directory rows in the database with no filesystem rescanning. Returns a record withrestored,source_path,base_path,watch,rehydration_mode,status,restored_files,restored_dirs, andformat. Therehydration_modeisoffline_from_snapshot_rows, and the status fields (scanning,scan_duration_ms).idx dropDrops the current runtime from memory. Returns
{dropped: bool, status: record}wherestatusis always the default (zeroed) status after the drop.Additional notes
Right now fff-search uses the
ignorecrate and there is no way to control what is ignored other than changing/adding .gitignore or .ignore files.