Documentation
¶
Index ¶
- Constants
- func SetDefault(db *DB)
- type Blob
- type Commit
- type Content
- type ContentKey
- type DB
- func (db *DB) Begin(ctx context.Context) (pgx.Tx, error)
- func (db *DB) BeginTx(ctx context.Context, opts pgx.TxOptions) (pgx.Tx, error)
- func (db *DB) BlobExists(ctx context.Context, path, commitID string) (bool, error)
- func (db *DB) Close()
- func (db *DB) CommitExists(ctx context.Context, id string) (bool, error)
- func (db *DB) ContentExists(ctx context.Context, groupID, versionID int32) (bool, error)
- func (db *DB) CountBlobs(ctx context.Context) (int64, error)
- func (db *DB) CountCommits(ctx context.Context) (int, error)
- func (db *DB) CountContents(ctx context.Context) (int64, error)
- func (db *DB) CountFileRefs(ctx context.Context) (int64, error)
- func (db *DB) CountPaths(ctx context.Context) (int64, error)
- func (db *DB) CreateBlob(ctx context.Context, b *Blob) error
- func (db *DB) CreateBlobs(ctx context.Context, blobs []*Blob) error
- func (db *DB) CreateCommit(ctx context.Context, c *Commit) error
- func (db *DB) CreateCommitsBatch(ctx context.Context, commits []*Commit) error
- func (db *DB) CreateContent(ctx context.Context, c *Content) error
- func (db *DB) CreateContentBatch(ctx context.Context, contents []*Content) error
- func (db *DB) CreateContentTx(ctx context.Context, tx pgx.Tx, c *Content) error
- func (db *DB) CreateFileRef(ctx context.Context, ref *FileRef) error
- func (db *DB) CreateFileRefTx(ctx context.Context, tx pgx.Tx, ref *FileRef) error
- func (db *DB) CreateFileRefsBatch(ctx context.Context, refs []*FileRef) error
- func (db *DB) DeleteCommitsAfter(ctx context.Context, commitID string) error
- func (db *DB) DeleteMetadata(ctx context.Context, key string) error
- func (db *DB) DeleteRef(ctx context.Context, name string) error
- func (db *DB) DeleteSyncState(ctx context.Context, remoteName string) error
- func (db *DB) DropSchema(ctx context.Context) error
- func (db *DB) EnsureMetadataTable(ctx context.Context) error
- func (db *DB) Exec(ctx context.Context, sql string, args ...any) error
- func (db *DB) FileExistsInTree(ctx context.Context, path, commitID string) (bool, error)
- func (db *DB) FileRefExists(ctx context.Context, groupID int32, commitID string) (bool, error)
- func (db *DB) FindCommitByPartialID(ctx context.Context, partialID string) (*Commit, error)
- func (db *DB) FindCommonAncestor(ctx context.Context, commitA, commitB string) (string, error)
- func (db *DB) GetAllCommits(ctx context.Context) ([]*Commit, error)
- func (db *DB) GetAllPaths(ctx context.Context) ([]string, error)
- func (db *DB) GetAllPathsV2(ctx context.Context) ([]string, error)
- func (db *DB) GetAllRefs(ctx context.Context) ([]*Ref, error)
- func (db *DB) GetAllSyncStates(ctx context.Context) ([]*SyncState, error)
- func (db *DB) GetBlob(ctx context.Context, path, commitID string) (*Blob, error)
- func (db *DB) GetBlobStats(ctx context.Context) (map[string]interface{}, error)
- func (db *DB) GetBlobsAtCommit(ctx context.Context, commitID string) ([]*Blob, error)
- func (db *DB) GetBlobsAtCommitMetadata(ctx context.Context, commitID string) ([]*Blob, error)
- func (db *DB) GetChangedFileRefs(ctx context.Context, fromCommit, toCommit string) ([]*FileRef, error)
- func (db *DB) GetChangedFileRefsWithPaths(ctx context.Context, fromCommit, toCommit string) ([]*FileRefWithPath, error)
- func (db *DB) GetChangedFiles(ctx context.Context, fromCommit, toCommit string) ([]*Blob, error)
- func (db *DB) GetChangedFilesMetadata(ctx context.Context, fromCommit, toCommit string) ([]*Blob, error)
- func (db *DB) GetCommit(ctx context.Context, id string) (*Commit, error)
- func (db *DB) GetCommitLog(ctx context.Context, limit int) ([]*Commit, error)
- func (db *DB) GetCommitLogFrom(ctx context.Context, commitID string, limit int) ([]*Commit, error)
- func (db *DB) GetCommitStats(ctx context.Context) (map[string]interface{}, error)
- func (db *DB) GetCommitsBatch(ctx context.Context, ids []string) (map[string]*Commit, error)
- func (db *DB) GetContent(ctx context.Context, groupID, versionID int32) ([]byte, error)
- func (db *DB) GetContentForFileRef(ctx context.Context, ref *FileRef) ([]byte, error)
- func (db *DB) GetContentsBatch(ctx context.Context, keys []ContentKey) (map[ContentKey][]byte, error)
- func (db *DB) GetContentsByGroupID(ctx context.Context, groupID int32) ([]*Content, error)
- func (db *DB) GetContentsForFileRefs(ctx context.Context, refs []*FileRef) (map[ContentKey][]byte, error)
- func (db *DB) GetCurrentTree(ctx context.Context) ([]*Blob, error)
- func (db *DB) GetCurrentTreeMetadata(ctx context.Context) ([]*Blob, error)
- func (db *DB) GetDetailedTableSizes(ctx context.Context) (*DetailedTableSizes, error)
- func (db *DB) GetFileAtCommit(ctx context.Context, path, commitID string) (*Blob, error)
- func (db *DB) GetFileHistory(ctx context.Context, path string) ([]*Blob, error)
- func (db *DB) GetFileRef(ctx context.Context, groupID int32, commitID string) (*FileRef, error)
- func (db *DB) GetFileRefAtCommit(ctx context.Context, groupID int32, commitID string) (*FileRef, error)
- func (db *DB) GetFileRefHistory(ctx context.Context, groupID int32) ([]*FileRef, error)
- func (db *DB) GetFileRefsAtCommit(ctx context.Context, commitID string) ([]*FileRef, error)
- func (db *DB) GetFileRefsAtCommitWithPaths(ctx context.Context, commitID string) ([]*FileRefWithPath, error)
- func (db *DB) GetGroupIDByPath(ctx context.Context, path string) (int32, error)
- func (db *DB) GetHead(ctx context.Context) (string, error)
- func (db *DB) GetHeadCommit(ctx context.Context) (*Commit, error)
- func (db *DB) GetLatestCommitID(ctx context.Context) (string, error)
- func (db *DB) GetMetadata(ctx context.Context, key string) (string, error)
- func (db *DB) GetNextVersionID(ctx context.Context, groupID int32) (int32, error)
- func (db *DB) GetNextVersionIDTx(ctx context.Context, tx pgx.Tx, groupID int32) (int32, error)
- func (db *DB) GetOrCreatePath(ctx context.Context, path string) (int32, error)
- func (db *DB) GetOrCreatePathTx(ctx context.Context, tx pgx.Tx, path string) (int32, error)
- func (db *DB) GetOrCreatePathsBatch(ctx context.Context, paths []string) (map[string]int32, error)
- func (db *DB) GetPath(ctx context.Context, groupID int32) (string, error)
- func (db *DB) GetPathsByGroupIDs(ctx context.Context, groupIDs []int32) (map[int32]string, error)
- func (db *DB) GetRef(ctx context.Context, name string) (*Ref, error)
- func (db *DB) GetRepoPath(ctx context.Context) string
- func (db *DB) GetRepoStatsFast(ctx context.Context) (*RepoStats, error)
- func (db *DB) GetSchemaVersion(ctx context.Context) (int, error)
- func (db *DB) GetSyncState(ctx context.Context, remoteName string) (*SyncState, error)
- func (db *DB) GetTreeAtCommit(ctx context.Context, commitID string) ([]*Blob, error)
- func (db *DB) GetTreeMetadataAtCommit(ctx context.Context, commitID string) ([]*Blob, error)
- func (db *DB) GetTreeRefsAtCommit(ctx context.Context, commitID string) ([]*FileRef, error)
- func (db *DB) GetTreeRefsAtCommitWithPaths(ctx context.Context, commitID string) ([]*FileRefWithPath, error)
- func (db *DB) GetXpatchStats(ctx context.Context, tableName string) (*XpatchStats, error)
- func (db *DB) InitSchema(ctx context.Context) error
- func (db *DB) IsConnected() bool
- func (db *DB) IsSchemaV2(ctx context.Context) (bool, error)
- func (db *DB) Ping(ctx context.Context) error
- func (db *DB) Pool() *pgxpool.Pool
- func (db *DB) Query(ctx context.Context, sql string, args ...any) (pgx.Rows, error)
- func (db *DB) QueryRow(ctx context.Context, sql string, args ...any) pgx.Row
- func (db *DB) RefExists(ctx context.Context, name string) (bool, error)
- func (db *DB) SchemaExists(ctx context.Context) (bool, error)
- func (db *DB) SearchAllBlobs(ctx context.Context, pathPattern string) ([]*Blob, error)
- func (db *DB) SearchContent(ctx context.Context, opts SearchContentOptions) ([]*SearchContentResult, error)
- func (db *DB) SearchContentAtCommit(ctx context.Context, commitID string, opts SearchContentOptions) ([]*SearchContentResult, error)
- func (db *DB) SetHead(ctx context.Context, commitID string) error
- func (db *DB) SetMetadata(ctx context.Context, key, value string) error
- func (db *DB) SetRef(ctx context.Context, name, commitID string) error
- func (db *DB) SetRepoPath(ctx context.Context, path string) error
- func (db *DB) SetSchemaVersion(ctx context.Context, version int) error
- func (db *DB) SetSyncState(ctx context.Context, remoteName string, lastCommitID *string) error
- func (db *DB) URL() string
- func (db *DB) WithTx(ctx context.Context, fn func(tx pgx.Tx) error) error
- type DetailedTableSizes
- type FileRef
- type FileRefWithPath
- type Path
- type Ref
- type RepoStats
- type SearchContentOptions
- type SearchContentResult
- type SyncState
- type XpatchStats
Constants ¶
const (
MetaKeyRepoPath = "repo_path"
)
Metadata keys
const SchemaVersion = 2
SchemaVersion is the current schema version. Version 2 introduces the new three-table architecture: - pgit_paths: path registry (group_id -> path) - pgit_file_refs: file references (metadata, no content) - pgit_content: delta-compressed content storage
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Blob ¶
type Blob struct {
Path string
CommitID string
Content []byte // file bytes (empty for empty files)
ContentHash []byte // 16 bytes BLAKE3, nil = deleted
Mode int
IsSymlink bool
SymlinkTarget *string
}
Blob represents a file at a specific commit. This is the compatibility layer that combines data from pgit_paths, pgit_file_refs, and pgit_content tables in schema v2.
type Commit ¶
type Commit struct {
ID string
ParentID *string
TreeHash string
Message string
AuthorName string
AuthorEmail string
CreatedAt time.Time
}
Commit represents a commit in the database
type Content ¶
Content represents file content stored in the content table. Content is delta-compressed by xpatch, grouped by group_id.
type ContentKey ¶
ContentKey is used for batch lookups.
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB holds the database connection pool
func ConnectLite ¶ added in v2.1.0
ConnectLite establishes a lightweight connection (single connection, no pool) Use this for quick operations like metadata lookups
func (*DB) BlobExists ¶
BlobExists checks if a blob exists at a specific commit.
func (*DB) CommitExists ¶
CommitExists checks if a commit exists
func (*DB) ContentExists ¶
ContentExists checks if content exists for a specific (group_id, version_id).
func (*DB) CountBlobs ¶
CountBlobs returns the total number of blob versions (file refs).
func (*DB) CountCommits ¶
CountCommits returns the total number of commits
func (*DB) CountContents ¶
CountContents returns the total number of content entries.
func (*DB) CountFileRefs ¶
CountFileRefs returns the total number of file refs.
func (*DB) CountPaths ¶
CountPaths returns the number of unique paths in the repository.
func (*DB) CreateBlob ¶
CreateBlob inserts a new blob into the database. This writes to pgit_paths, pgit_file_refs, and pgit_content tables.
func (*DB) CreateBlobs ¶
CreateBlobs inserts multiple blobs efficiently. Blobs should be pre-sorted by path for optimal delta compression.
func (*DB) CreateCommit ¶
CreateCommit inserts a new commit into the database
func (*DB) CreateCommitsBatch ¶
CreateCommitsBatch inserts multiple commits using pgx.CopyFrom for speed Commits must be in order (parents before children)
func (*DB) CreateContent ¶
CreateContent inserts content into the content table.
func (*DB) CreateContentBatch ¶
CreateContentBatch inserts multiple content entries using COPY for speed. This is optimized for bulk imports.
func (*DB) CreateContentTx ¶
CreateContentTx inserts content within a transaction.
func (*DB) CreateFileRef ¶
CreateFileRef inserts a new file reference.
func (*DB) CreateFileRefTx ¶
CreateFileRefTx inserts a new file reference within a transaction.
func (*DB) CreateFileRefsBatch ¶
CreateFileRefsBatch inserts multiple file references using COPY for speed.
func (*DB) DeleteCommitsAfter ¶
DeleteCommitsAfter deletes all commits after (and including) the given commit ID This is used during the "rebuild on divergence" process
func (*DB) DeleteMetadata ¶
DeleteMetadata removes a metadata key
func (*DB) DeleteSyncState ¶
DeleteSyncState deletes the sync state for a remote
func (*DB) DropSchema ¶
DropSchema drops all pgit tables (use with caution!)
func (*DB) EnsureMetadataTable ¶
EnsureMetadataTable creates the metadata table if it doesn't exist
func (*DB) FileExistsInTree ¶
FileExistsInTree checks if a file exists (is not deleted) in the tree at a commit. This finds the latest version of the file at or before commitID and checks if it's not deleted.
func (*DB) FileRefExists ¶
FileRefExists checks if a file ref exists at a specific commit.
func (*DB) FindCommitByPartialID ¶
FindCommitByPartialID finds a commit by partial ID match. Returns the commit if exactly one match is found. Returns nil if no match is found. Returns an error if multiple matches are found (ambiguous).
func (*DB) FindCommonAncestor ¶
FindCommonAncestor finds the common ancestor between two commits
func (*DB) GetAllCommits ¶
GetAllCommits retrieves all commits ordered by ID (ULID = time order)
func (*DB) GetAllPaths ¶
GetAllPaths returns all unique file paths in the repository. This is very fast as it queries the small pgit_paths table.
func (*DB) GetAllPathsV2 ¶
GetAllPathsV2 retrieves all unique file paths in the repository. This is very fast as it queries the small pgit_paths table. Note: This replaces the old GetAllPaths from blobs.go in schema v2.
func (*DB) GetAllRefs ¶
GetAllRefs retrieves all refs
func (*DB) GetAllSyncStates ¶
GetAllSyncStates retrieves all sync states
func (*DB) GetBlobStats ¶
GetBlobStats returns statistics about blobs using the new schema.
func (*DB) GetBlobsAtCommit ¶
GetBlobsAtCommit retrieves all blobs at a specific commit. This returns only files that were changed in that specific commit. Uses a single query joining file_refs -> paths -> content.
func (*DB) GetBlobsAtCommitMetadata ¶
GetBlobsAtCommitMetadata retrieves all blobs at a specific commit WITHOUT content. This returns only files that were changed in that specific commit (not the full tree).
func (*DB) GetChangedFileRefs ¶
func (db *DB) GetChangedFileRefs(ctx context.Context, fromCommit, toCommit string) ([]*FileRef, error)
GetChangedFileRefs returns file refs that changed between two commits.
func (*DB) GetChangedFileRefsWithPaths ¶
func (db *DB) GetChangedFileRefsWithPaths(ctx context.Context, fromCommit, toCommit string) ([]*FileRefWithPath, error)
GetChangedFileRefsWithPaths returns file refs with paths that changed between two commits.
func (*DB) GetChangedFiles ¶
GetChangedFiles returns files that changed between two commits.
func (*DB) GetChangedFilesMetadata ¶
func (db *DB) GetChangedFilesMetadata(ctx context.Context, fromCommit, toCommit string) ([]*Blob, error)
GetChangedFilesMetadata returns files that changed between two commits WITHOUT content. Use this for operations that only need paths and hashes (e.g., diff --name-only).
func (*DB) GetCommitLog ¶
GetCommitLog retrieves commits starting from HEAD, walking up the parent chain
func (*DB) GetCommitLogFrom ¶
GetCommitLogFrom retrieves commits starting from a specific commit
func (*DB) GetCommitStats ¶
GetCommitStats returns statistics about commits using xpatch.stats() for O(1) performance
func (*DB) GetCommitsBatch ¶
GetCommitsBatch retrieves multiple commits by their IDs in a single query. Returns a map of commit ID to Commit. Missing commits are not included in the map.
func (*DB) GetContent ¶
GetContent retrieves content by (group_id, version_id).
func (*DB) GetContentForFileRef ¶
GetContentForFileRef retrieves content for a file ref. This is a convenience method that combines the file ref lookup with content retrieval.
func (*DB) GetContentsBatch ¶
func (db *DB) GetContentsBatch(ctx context.Context, keys []ContentKey) (map[ContentKey][]byte, error)
GetContentsBatch retrieves multiple contents by their keys. Returns a map of ContentKey -> content bytes. Uses parallel queries per group for faster xpatch decompression.
func (*DB) GetContentsByGroupID ¶
GetContentsByGroupID retrieves all content versions for a group. Returns content ordered by version_id ascending.
func (*DB) GetContentsForFileRefs ¶
func (db *DB) GetContentsForFileRefs(ctx context.Context, refs []*FileRef) (map[ContentKey][]byte, error)
GetContentsForFileRefs retrieves content for multiple file refs. Returns a map of ContentKey -> content bytes.
func (*DB) GetCurrentTree ¶
GetCurrentTree retrieves the tree at HEAD.
func (*DB) GetCurrentTreeMetadata ¶
GetCurrentTreeMetadata retrieves the tree metadata at HEAD without content. Use this for operations that only need paths and hashes.
func (*DB) GetDetailedTableSizes ¶
func (db *DB) GetDetailedTableSizes(ctx context.Context) (*DetailedTableSizes, error)
GetDetailedTableSizes returns sizes for all pgit tables.
func (*DB) GetFileAtCommit ¶
GetFileAtCommit retrieves a file at a specific commit (or the latest version before it). Uses a single query joining paths -> file_refs -> content.
func (*DB) GetFileHistory ¶
GetFileHistory retrieves all versions of a file. Uses a single query joining paths -> file_refs -> content.
func (*DB) GetFileRef ¶
GetFileRef retrieves a specific file reference.
func (*DB) GetFileRefAtCommit ¶
func (db *DB) GetFileRefAtCommit(ctx context.Context, groupID int32, commitID string) (*FileRef, error)
GetFileRefAtCommit retrieves a file ref at or before a specific commit.
func (*DB) GetFileRefHistory ¶
GetFileRefHistory retrieves all versions of a file by group_id.
func (*DB) GetFileRefsAtCommit ¶
GetFileRefsAtCommit retrieves all file refs at a specific commit. This returns only files that were changed in that specific commit.
func (*DB) GetFileRefsAtCommitWithPaths ¶
func (db *DB) GetFileRefsAtCommitWithPaths(ctx context.Context, commitID string) ([]*FileRefWithPath, error)
GetFileRefsAtCommitWithPaths retrieves file refs with resolved paths.
func (*DB) GetGroupIDByPath ¶
GetGroupIDByPath retrieves the group_id for a specific path. Returns 0 and nil error if the path doesn't exist.
func (*DB) GetHeadCommit ¶
GetHeadCommit retrieves the commit that HEAD points to
func (*DB) GetLatestCommitID ¶
GetLatestCommitID returns the ID of the latest commit (by ULID order)
func (*DB) GetMetadata ¶
GetMetadata retrieves a metadata value by key
func (*DB) GetNextVersionID ¶
GetNextVersionID returns the next version_id for a group. This is used when creating new file refs.
func (*DB) GetNextVersionIDTx ¶
GetNextVersionIDTx returns the next version_id within a transaction.
func (*DB) GetOrCreatePath ¶
GetOrCreatePath returns the group_id for a path, creating it if needed. This is the primary method for getting a group_id during blob creation.
func (*DB) GetOrCreatePathTx ¶
GetOrCreatePathTx returns the group_id for a path within a transaction.
func (*DB) GetOrCreatePathsBatch ¶
GetOrCreatePathsBatch handles multiple paths efficiently. Returns a map of path -> group_id.
func (*DB) GetPathsByGroupIDs ¶
GetPathsByGroupIDs retrieves multiple paths by group_ids. Returns a map of group_id -> path.
func (*DB) GetRepoPath ¶
GetRepoPath returns the stored repository path, or empty string if not set
func (*DB) GetRepoStatsFast ¶
GetRepoStatsFast returns repository statistics using xpatch.stats() for O(1) performance. This version supports the new schema v2 with separate tables.
func (*DB) GetSchemaVersion ¶
GetSchemaVersion returns the current schema version from the database. Returns 1 for legacy schemas that don't have a version set.
func (*DB) GetSyncState ¶
GetSyncState retrieves the sync state for a remote
func (*DB) GetTreeAtCommit ¶
GetTreeAtCommit retrieves the full tree (all files) at a commit. Uses a single query with DISTINCT ON to get latest version of each file.
func (*DB) GetTreeMetadataAtCommit ¶
GetTreeMetadataAtCommit retrieves the full tree metadata (all files) at a commit WITHOUT loading content. This is much faster than GetTreeAtCommit when you only need paths and hashes (e.g., for status, ls-tree). The returned Blobs have Content set to nil.
func (*DB) GetTreeRefsAtCommit ¶
GetTreeRefsAtCommit retrieves the full tree (latest version per path <= commitID). This is the core query for getting the state of the repository at a commit.
func (*DB) GetTreeRefsAtCommitWithPaths ¶
func (db *DB) GetTreeRefsAtCommitWithPaths(ctx context.Context, commitID string) ([]*FileRefWithPath, error)
GetTreeRefsAtCommitWithPaths retrieves the full tree with resolved paths. This is a metadata-only query - no content is fetched.
func (*DB) GetXpatchStats ¶
GetXpatchStats retrieves compression statistics for a table
func (*DB) InitSchema ¶
InitSchema creates the pgit schema in the database
func (*DB) IsConnected ¶
IsConnected returns true if the database is connected
func (*DB) IsSchemaV2 ¶
IsSchemaV2 checks if the database uses the new v2 schema. This is useful for code that needs to handle both schemas during migration.
func (*DB) SchemaExists ¶
SchemaExists checks if the pgit schema exists
func (*DB) SearchAllBlobs ¶
SearchAllBlobs retrieves all blobs, optionally filtered by path pattern. DEPRECATED: Use SearchContent instead for better performance. This function loads ALL content into memory which doesn't scale.
func (*DB) SearchContent ¶
func (db *DB) SearchContent(ctx context.Context, opts SearchContentOptions) ([]*SearchContentResult, error)
SearchContent searches file contents. Strategy: 1. Get candidate file refs from refs table (fast, no content) 2. Load content in group_id, version_id order (optimal for xpatch cache) 3. Return results for Go-side regex matching Results are ordered by group_id, version_id for optimal xpatch decompression.
func (*DB) SearchContentAtCommit ¶
func (db *DB) SearchContentAtCommit(ctx context.Context, commitID string, opts SearchContentOptions) ([]*SearchContentResult, error)
SearchContentAtCommit searches file contents at a specific commit. This searches the tree state at that commit (latest version of each file <= commitID). Strategy: 1. Get tree state at commit from refs table (fast, DISTINCT ON) 2. Load content in group_id, version_id order (optimal for xpatch cache) 3. Return results for Go-side regex matching
func (*DB) SetMetadata ¶
SetMetadata sets a metadata key-value pair (upsert)
func (*DB) SetRepoPath ¶
SetRepoPath stores the repository working directory path
func (*DB) SetSchemaVersion ¶
SetSchemaVersion sets the schema version in the database.
func (*DB) SetSyncState ¶
SetSyncState creates or updates the sync state for a remote
type DetailedTableSizes ¶
type DetailedTableSizes struct {
Commits int64
Paths int64
FileRefs int64
Content int64
Refs int64
SyncState int64
Metadata int64
Indexes int64
}
GetDetailedTableSizes returns detailed size information for each table.
type FileRef ¶
type FileRef struct {
GroupID int32
CommitID string
VersionID int32
ContentHash []byte // 16 bytes BLAKE3, nil = deleted
Mode int
IsSymlink bool
SymlinkTarget *string
}
FileRef represents a file reference at a specific commit. This is the metadata-only representation without actual content.
type FileRefWithPath ¶
type FileRefWithPath struct {
Path string
GroupID int32
CommitID string
VersionID int32
ContentHash []byte
Mode int
IsSymlink bool
SymlinkTarget *string
}
FileRefWithPath combines FileRef with resolved path. Used when returning results that need the actual file path.
type Path ¶
Path represents a file path in the path registry. Each unique path gets a unique group_id for efficient storage.
type RepoStats ¶
type RepoStats struct {
// Commit stats
TotalCommits int64
FirstCommitID *string
LastCommitID *string
// File stats (from new tables)
TotalBlobs int64 // Total file refs (from pgit_file_refs)
UniqueFiles int64 // Unique paths (from pgit_paths)
TotalContentSize int64 // Raw content size (from pgit_content via xpatch.stats)
DeletedEntries int64
// Table sizes from PostgreSQL (actual disk usage)
CommitsTableSize int64
PathsTableSize int64 // New in v2
FileRefsTableSize int64 // New in v2
ContentTableSize int64 // New in v2 (replaces BlobsTableSize)
TotalIndexSize int64
// Legacy field for compatibility (sum of paths + file_refs + content)
BlobsTableSize int64
}
RepoStats contains all repository statistics for schema v2.
type SearchContentOptions ¶
type SearchContentOptions struct {
// Pattern is the regex pattern to search for (PostgreSQL regex syntax).
Pattern string
// IgnoreCase enables case-insensitive matching.
IgnoreCase bool
// PathPattern is an optional glob pattern to filter files by path.
PathPattern string
// CommitID limits search to files at or before this commit.
// Empty string means search all versions.
CommitID string
// Limit is the maximum number of matching files to return.
// 0 means no limit.
Limit int
}
SearchContentOptions configures content search behavior.
type SearchContentResult ¶
type SearchContentResult struct {
Path string
GroupID int32
CommitID string
VersionID int32
Content []byte
}
SearchContentResult represents a file that matched the search.
type XpatchStats ¶
type XpatchStats struct {
TotalRows int64
TotalGroups int64
KeyframeCount int64
DeltaCount int64
RawSizeBytes int64
CompressedBytes int64
CompressionRatio float64
CacheHits int64
CacheMisses int64
AvgChainLength float64
}
XpatchStats represents compression statistics from pg-xpatch