Documentation
¶
Overview ¶
Package store persists the code index in SQLite (with an FTS5 index over symbol names/FQNs/docs). The database is a derived artifact: it lives in the user cache dir, is keyed by project root, and is silently rebuilt when the schema version changes.
Index ¶
- func DefaultPath(root string) (string, error)
- func EnrichCommitKey(origin string) string
- func SplitWords(name string) string
- type ExtEdge
- type FileData
- type FileMeta
- type Stats
- type Store
- func (s *Store) BeginBulkWrite() (*Writer, error)
- func (s *Store) BeginWrite() (*Writer, error)
- func (s *Store) Close() error
- func (s *Store) DB() *sql.DB
- func (s *Store) EnrichStats() (map[string]int, error)
- func (s *Store) FileSizes(paths []string) (int64, error)
- func (s *Store) FileStates() (map[string]FileMeta, error)
- func (s *Store) ImportedEnrichOrigins() ([]string, error)
- func (s *Store) IndexedPaths() (map[string]bool, error)
- func (s *Store) LangCounts() (map[string]int, error)
- func (s *Store) Meta(key string) (string, error)
- func (s *Store) Path() string
- func (s *Store) ProjectPaths(prefix string) ([]string, error)
- func (s *Store) ReplaceExtEdges(origin, source string, rows []ExtEdge) error
- func (s *Store) SetMeta(key, value string) error
- func (s *Store) Stats() (Stats, error)
- type Writer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultPath ¶
DefaultPath returns the cache location of the index database for a project root: <UserCacheDir>/kartograf/<base>-<hash8>/index.db.
func EnrichCommitKey ¶ added in v0.1.16
EnrichCommitKey is the meta key holding the git commit an exchange file was built from.
func SplitWords ¶
SplitWords breaks an identifier into lowercase words for full-text search: "BannerHTTPRepository_v2" -> "banner http repository v2".
Types ¶
type ExtEdge ¶
type ExtEdge struct {
From string `json:"from"`
Kind string `json:"kind"`
To string `json:"to"`
File string `json:"file,omitempty"`
Line int `json:"line,omitempty"`
}
ExtEdge is one enrichment edge (exact by definition: it comes from a full type-inference tool).
type FileData ¶
type FileData struct {
FI *model.FileIndex
Hash string
Size int64
MtimeNs int64
Vendor bool
Indexed int64 // unix seconds
}
FileData is one file's extraction result plus bookkeeping.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
func (*Store) BeginBulkWrite ¶
BeginBulkWrite is BeginWrite for loading into an empty index: it defers index/FTS maintenance to Commit. Callers must not rely on per-file deletes (there is nothing to delete in a fresh database).
func (*Store) BeginWrite ¶
func (*Store) EnrichStats ¶ added in v0.1.8
EnrichStats returns enrichment edge counts per source.
func (*Store) FileSizes ¶ added in v0.1.16
FileSizes sums the indexed sizes of paths. Unknown paths add nothing.
func (*Store) FileStates ¶
FileStates returns path -> meta for every indexed file; the indexer diffs the working tree against it (mtime+size fast path, hash as the source of truth).
func (*Store) ImportedEnrichOrigins ¶ added in v0.1.11
ImportedEnrichOrigins lists exchange files (root-relative paths) whose edges are currently in the store.
func (*Store) IndexedPaths ¶
IndexedPaths returns the set of indexed file paths (for mapping external tool output paths onto the index).
func (*Store) LangCounts ¶ added in v0.1.8
LangCounts returns non-vendor indexed file counts per language.
func (*Store) ProjectPaths ¶ added in v0.1.10
ProjectPaths returns non-vendor indexed file paths, optionally narrowed by a path prefix.
func (*Store) ReplaceExtEdges ¶
ReplaceExtEdges swaps the whole enrichment edge set of one origin (exchange file); source labels the edges in query output.
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer batches index mutations in a single transaction with multi-row inserts (the insert path is hot on cold runs). In bulk mode (fresh database) secondary indexes and FTS triggers are dropped up front and rebuilt once at Commit.
func (*Writer) DeleteFile ¶
DeleteFile removes a file and all its data from the index.
func (*Writer) ReplaceFile ¶
ReplaceFile removes any previous data for the file and inserts the fresh extraction result.