store

package
v0.1.16 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 8, 2026 License: MIT Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultPath

func DefaultPath(root string) (string, error)

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

func EnrichCommitKey(origin string) string

EnrichCommitKey is the meta key holding the git commit an exchange file was built from.

func SplitWords

func SplitWords(name string) string

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 FileMeta

type FileMeta struct {
	Hash    string
	Size    int64
	MtimeNs int64
}

FileMeta is the change-detection state of an indexed file.

type Stats

type Stats struct {
	Files   int
	Symbols int
}

type Store

type Store struct {
	// contains filtered or unexported fields
}

func Open

func Open(path, projectRoot string) (*Store, error)

Open opens (creating or rebuilding if needed) the index database.

func (*Store) BeginBulkWrite

func (s *Store) BeginBulkWrite() (*Writer, error)

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 (s *Store) BeginWrite() (*Writer, error)

func (*Store) Close

func (s *Store) Close() error

func (*Store) DB

func (s *Store) DB() *sql.DB

func (*Store) EnrichStats added in v0.1.8

func (s *Store) EnrichStats() (map[string]int, error)

EnrichStats returns enrichment edge counts per source.

func (*Store) FileSizes added in v0.1.16

func (s *Store) FileSizes(paths []string) (int64, error)

FileSizes sums the indexed sizes of paths. Unknown paths add nothing.

func (*Store) FileStates

func (s *Store) FileStates() (map[string]FileMeta, error)

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

func (s *Store) ImportedEnrichOrigins() ([]string, error)

ImportedEnrichOrigins lists exchange files (root-relative paths) whose edges are currently in the store.

func (*Store) IndexedPaths

func (s *Store) IndexedPaths() (map[string]bool, error)

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

func (s *Store) LangCounts() (map[string]int, error)

LangCounts returns non-vendor indexed file counts per language.

func (*Store) Meta

func (s *Store) Meta(key string) (string, error)

Meta reads an arbitrary metadata value ("" when absent).

func (*Store) Path

func (s *Store) Path() string

func (*Store) ProjectPaths added in v0.1.10

func (s *Store) ProjectPaths(prefix string) ([]string, error)

ProjectPaths returns non-vendor indexed file paths, optionally narrowed by a path prefix.

func (*Store) ReplaceExtEdges

func (s *Store) ReplaceExtEdges(origin, source string, rows []ExtEdge) error

ReplaceExtEdges swaps the whole enrichment edge set of one origin (exchange file); source labels the edges in query output.

func (*Store) SetMeta

func (s *Store) SetMeta(key, value string) error

SetMeta stores an arbitrary metadata value.

func (*Store) Stats

func (s *Store) Stats() (Stats, error)

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) Commit

func (w *Writer) Commit() error

func (*Writer) DeleteFile

func (w *Writer) DeleteFile(path string) error

DeleteFile removes a file and all its data from the index.

func (*Writer) ReplaceFile

func (w *Writer) ReplaceFile(d FileData) error

ReplaceFile removes any previous data for the file and inserts the fresh extraction result.

func (*Writer) Rollback

func (w *Writer) Rollback() error

func (*Writer) TouchFile

func (w *Writer) TouchFile(path string, size, mtimeNs int64) error

TouchFile refreshes size/mtime for a file whose content hash is unchanged (e.g. after a branch switch and back), so future runs take the stat fast path again.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL