db

package
v2.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MetaKeyRepoPath = "repo_path"
)

Metadata keys

View Source
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

func SetDefault

func SetDefault(db *DB)

SetDefault sets the default database instance

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.

func (*Blob) IsDeleted

func (b *Blob) IsDeleted() bool

IsDeleted returns true if this blob represents a deletion.

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

type Content struct {
	GroupID   int32
	VersionID int32
	Content   []byte
}

Content represents file content stored in the content table. Content is delta-compressed by xpatch, grouped by group_id.

type ContentKey

type ContentKey struct {
	GroupID   int32
	VersionID int32
}

ContentKey is used for batch lookups.

type DB

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

DB holds the database connection pool

func Connect

func Connect(ctx context.Context, url string) (*DB, error)

Connect establishes a connection to the database with a full connection pool

func ConnectLite added in v2.1.0

func ConnectLite(ctx context.Context, url string) (*DB, error)

ConnectLite establishes a lightweight connection (single connection, no pool) Use this for quick operations like metadata lookups

func Default

func Default() *DB

Default returns the default database instance

func (*DB) Begin

func (db *DB) Begin(ctx context.Context) (pgx.Tx, error)

Begin starts a transaction

func (*DB) BeginTx

func (db *DB) BeginTx(ctx context.Context, opts pgx.TxOptions) (pgx.Tx, error)

BeginTx starts a transaction with options

func (*DB) BlobExists

func (db *DB) BlobExists(ctx context.Context, path, commitID string) (bool, error)

BlobExists checks if a blob exists at a specific commit.

func (*DB) Close

func (db *DB) Close()

Close closes the database connection

func (*DB) CommitExists

func (db *DB) CommitExists(ctx context.Context, id string) (bool, error)

CommitExists checks if a commit exists

func (*DB) ContentExists

func (db *DB) ContentExists(ctx context.Context, groupID, versionID int32) (bool, error)

ContentExists checks if content exists for a specific (group_id, version_id).

func (*DB) CountBlobs

func (db *DB) CountBlobs(ctx context.Context) (int64, error)

CountBlobs returns the total number of blob versions (file refs).

func (*DB) CountCommits

func (db *DB) CountCommits(ctx context.Context) (int, error)

CountCommits returns the total number of commits

func (*DB) CountContents

func (db *DB) CountContents(ctx context.Context) (int64, error)

CountContents returns the total number of content entries.

func (*DB) CountFileRefs

func (db *DB) CountFileRefs(ctx context.Context) (int64, error)

CountFileRefs returns the total number of file refs.

func (*DB) CountPaths

func (db *DB) CountPaths(ctx context.Context) (int64, error)

CountPaths returns the number of unique paths in the repository.

func (*DB) CreateBlob

func (db *DB) CreateBlob(ctx context.Context, b *Blob) error

CreateBlob inserts a new blob into the database. This writes to pgit_paths, pgit_file_refs, and pgit_content tables.

func (*DB) CreateBlobs

func (db *DB) CreateBlobs(ctx context.Context, blobs []*Blob) error

CreateBlobs inserts multiple blobs efficiently. Blobs should be pre-sorted by path for optimal delta compression.

func (*DB) CreateCommit

func (db *DB) CreateCommit(ctx context.Context, c *Commit) error

CreateCommit inserts a new commit into the database

func (*DB) CreateCommitsBatch

func (db *DB) CreateCommitsBatch(ctx context.Context, commits []*Commit) error

CreateCommitsBatch inserts multiple commits using pgx.CopyFrom for speed Commits must be in order (parents before children)

func (*DB) CreateContent

func (db *DB) CreateContent(ctx context.Context, c *Content) error

CreateContent inserts content into the content table.

func (*DB) CreateContentBatch

func (db *DB) CreateContentBatch(ctx context.Context, contents []*Content) error

CreateContentBatch inserts multiple content entries using COPY for speed. This is optimized for bulk imports.

func (*DB) CreateContentTx

func (db *DB) CreateContentTx(ctx context.Context, tx pgx.Tx, c *Content) error

CreateContentTx inserts content within a transaction.

func (*DB) CreateFileRef

func (db *DB) CreateFileRef(ctx context.Context, ref *FileRef) error

CreateFileRef inserts a new file reference.

func (*DB) CreateFileRefTx

func (db *DB) CreateFileRefTx(ctx context.Context, tx pgx.Tx, ref *FileRef) error

CreateFileRefTx inserts a new file reference within a transaction.

func (*DB) CreateFileRefsBatch

func (db *DB) CreateFileRefsBatch(ctx context.Context, refs []*FileRef) error

CreateFileRefsBatch inserts multiple file references using COPY for speed.

func (*DB) DeleteCommitsAfter

func (db *DB) DeleteCommitsAfter(ctx context.Context, commitID string) error

DeleteCommitsAfter deletes all commits after (and including) the given commit ID This is used during the "rebuild on divergence" process

func (*DB) DeleteMetadata

func (db *DB) DeleteMetadata(ctx context.Context, key string) error

DeleteMetadata removes a metadata key

func (*DB) DeleteRef

func (db *DB) DeleteRef(ctx context.Context, name string) error

DeleteRef deletes a ref

func (*DB) DeleteSyncState

func (db *DB) DeleteSyncState(ctx context.Context, remoteName string) error

DeleteSyncState deletes the sync state for a remote

func (*DB) DropSchema

func (db *DB) DropSchema(ctx context.Context) error

DropSchema drops all pgit tables (use with caution!)

func (*DB) EnsureMetadataTable

func (db *DB) EnsureMetadataTable(ctx context.Context) error

EnsureMetadataTable creates the metadata table if it doesn't exist

func (*DB) Exec

func (db *DB) Exec(ctx context.Context, sql string, args ...any) error

Exec executes a query without returning rows

func (*DB) FileExistsInTree

func (db *DB) FileExistsInTree(ctx context.Context, path, commitID string) (bool, error)

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

func (db *DB) FileRefExists(ctx context.Context, groupID int32, commitID string) (bool, error)

FileRefExists checks if a file ref exists at a specific commit.

func (*DB) FindCommitByPartialID

func (db *DB) FindCommitByPartialID(ctx context.Context, partialID string) (*Commit, error)

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

func (db *DB) FindCommonAncestor(ctx context.Context, commitA, commitB string) (string, error)

FindCommonAncestor finds the common ancestor between two commits

func (*DB) GetAllCommits

func (db *DB) GetAllCommits(ctx context.Context) ([]*Commit, error)

GetAllCommits retrieves all commits ordered by ID (ULID = time order)

func (*DB) GetAllPaths

func (db *DB) GetAllPaths(ctx context.Context) ([]string, error)

GetAllPaths returns all unique file paths in the repository. This is very fast as it queries the small pgit_paths table.

func (*DB) GetAllPathsV2

func (db *DB) GetAllPathsV2(ctx context.Context) ([]string, error)

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

func (db *DB) GetAllRefs(ctx context.Context) ([]*Ref, error)

GetAllRefs retrieves all refs

func (*DB) GetAllSyncStates

func (db *DB) GetAllSyncStates(ctx context.Context) ([]*SyncState, error)

GetAllSyncStates retrieves all sync states

func (*DB) GetBlob

func (db *DB) GetBlob(ctx context.Context, path, commitID string) (*Blob, error)

GetBlob retrieves a specific blob by path and commit.

func (*DB) GetBlobStats

func (db *DB) GetBlobStats(ctx context.Context) (map[string]interface{}, error)

GetBlobStats returns statistics about blobs using the new schema.

func (*DB) GetBlobsAtCommit

func (db *DB) GetBlobsAtCommit(ctx context.Context, commitID string) ([]*Blob, error)

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

func (db *DB) GetBlobsAtCommitMetadata(ctx context.Context, commitID string) ([]*Blob, error)

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

func (db *DB) GetChangedFiles(ctx context.Context, fromCommit, toCommit string) ([]*Blob, error)

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

func (db *DB) GetCommit(ctx context.Context, id string) (*Commit, error)

GetCommit retrieves a commit by ID

func (*DB) GetCommitLog

func (db *DB) GetCommitLog(ctx context.Context, limit int) ([]*Commit, error)

GetCommitLog retrieves commits starting from HEAD, walking up the parent chain

func (*DB) GetCommitLogFrom

func (db *DB) GetCommitLogFrom(ctx context.Context, commitID string, limit int) ([]*Commit, error)

GetCommitLogFrom retrieves commits starting from a specific commit

func (*DB) GetCommitStats

func (db *DB) GetCommitStats(ctx context.Context) (map[string]interface{}, error)

GetCommitStats returns statistics about commits using xpatch.stats() for O(1) performance

func (*DB) GetCommitsBatch

func (db *DB) GetCommitsBatch(ctx context.Context, ids []string) (map[string]*Commit, error)

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

func (db *DB) GetContent(ctx context.Context, groupID, versionID int32) ([]byte, error)

GetContent retrieves content by (group_id, version_id).

func (*DB) GetContentForFileRef

func (db *DB) GetContentForFileRef(ctx context.Context, ref *FileRef) ([]byte, error)

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

func (db *DB) GetContentsByGroupID(ctx context.Context, groupID int32) ([]*Content, error)

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

func (db *DB) GetCurrentTree(ctx context.Context) ([]*Blob, error)

GetCurrentTree retrieves the tree at HEAD.

func (*DB) GetCurrentTreeMetadata

func (db *DB) GetCurrentTreeMetadata(ctx context.Context) ([]*Blob, error)

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

func (db *DB) GetFileAtCommit(ctx context.Context, path, commitID string) (*Blob, error)

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

func (db *DB) GetFileHistory(ctx context.Context, path string) ([]*Blob, error)

GetFileHistory retrieves all versions of a file. Uses a single query joining paths -> file_refs -> content.

func (*DB) GetFileRef

func (db *DB) GetFileRef(ctx context.Context, groupID int32, commitID string) (*FileRef, error)

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

func (db *DB) GetFileRefHistory(ctx context.Context, groupID int32) ([]*FileRef, error)

GetFileRefHistory retrieves all versions of a file by group_id.

func (*DB) GetFileRefsAtCommit

func (db *DB) GetFileRefsAtCommit(ctx context.Context, commitID string) ([]*FileRef, error)

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

func (db *DB) GetGroupIDByPath(ctx context.Context, path string) (int32, error)

GetGroupIDByPath retrieves the group_id for a specific path. Returns 0 and nil error if the path doesn't exist.

func (*DB) GetHead

func (db *DB) GetHead(ctx context.Context) (string, error)

GetHead returns the HEAD commit ID

func (*DB) GetHeadCommit

func (db *DB) GetHeadCommit(ctx context.Context) (*Commit, error)

GetHeadCommit retrieves the commit that HEAD points to

func (*DB) GetLatestCommitID

func (db *DB) GetLatestCommitID(ctx context.Context) (string, error)

GetLatestCommitID returns the ID of the latest commit (by ULID order)

func (*DB) GetMetadata

func (db *DB) GetMetadata(ctx context.Context, key string) (string, error)

GetMetadata retrieves a metadata value by key

func (*DB) GetNextVersionID

func (db *DB) GetNextVersionID(ctx context.Context, groupID int32) (int32, error)

GetNextVersionID returns the next version_id for a group. This is used when creating new file refs.

func (*DB) GetNextVersionIDTx

func (db *DB) GetNextVersionIDTx(ctx context.Context, tx pgx.Tx, groupID int32) (int32, error)

GetNextVersionIDTx returns the next version_id within a transaction.

func (*DB) GetOrCreatePath

func (db *DB) GetOrCreatePath(ctx context.Context, path string) (int32, error)

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

func (db *DB) GetOrCreatePathTx(ctx context.Context, tx pgx.Tx, path string) (int32, error)

GetOrCreatePathTx returns the group_id for a path within a transaction.

func (*DB) GetOrCreatePathsBatch

func (db *DB) GetOrCreatePathsBatch(ctx context.Context, paths []string) (map[string]int32, error)

GetOrCreatePathsBatch handles multiple paths efficiently. Returns a map of path -> group_id.

func (*DB) GetPath

func (db *DB) GetPath(ctx context.Context, groupID int32) (string, error)

GetPath retrieves a path by group_id.

func (*DB) GetPathsByGroupIDs

func (db *DB) GetPathsByGroupIDs(ctx context.Context, groupIDs []int32) (map[int32]string, error)

GetPathsByGroupIDs retrieves multiple paths by group_ids. Returns a map of group_id -> path.

func (*DB) GetRef

func (db *DB) GetRef(ctx context.Context, name string) (*Ref, error)

GetRef retrieves a ref by name

func (*DB) GetRepoPath

func (db *DB) GetRepoPath(ctx context.Context) string

GetRepoPath returns the stored repository path, or empty string if not set

func (*DB) GetRepoStatsFast

func (db *DB) GetRepoStatsFast(ctx context.Context) (*RepoStats, error)

GetRepoStatsFast returns repository statistics using xpatch.stats() for O(1) performance. This version supports the new schema v2 with separate tables.

func (*DB) GetSchemaVersion

func (db *DB) GetSchemaVersion(ctx context.Context) (int, error)

GetSchemaVersion returns the current schema version from the database. Returns 1 for legacy schemas that don't have a version set.

func (*DB) GetSyncState

func (db *DB) GetSyncState(ctx context.Context, remoteName string) (*SyncState, error)

GetSyncState retrieves the sync state for a remote

func (*DB) GetTreeAtCommit

func (db *DB) GetTreeAtCommit(ctx context.Context, commitID string) ([]*Blob, error)

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

func (db *DB) GetTreeMetadataAtCommit(ctx context.Context, commitID string) ([]*Blob, error)

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

func (db *DB) GetTreeRefsAtCommit(ctx context.Context, commitID string) ([]*FileRef, error)

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

func (db *DB) GetXpatchStats(ctx context.Context, tableName string) (*XpatchStats, error)

GetXpatchStats retrieves compression statistics for a table

func (*DB) InitSchema

func (db *DB) InitSchema(ctx context.Context) error

InitSchema creates the pgit schema in the database

func (*DB) IsConnected

func (db *DB) IsConnected() bool

IsConnected returns true if the database is connected

func (*DB) IsSchemaV2

func (db *DB) IsSchemaV2(ctx context.Context) (bool, error)

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

func (db *DB) Ping(ctx context.Context) error

Ping tests the database connection

func (*DB) Pool

func (db *DB) Pool() *pgxpool.Pool

Pool returns the underlying connection pool

func (*DB) Query

func (db *DB) Query(ctx context.Context, sql string, args ...any) (pgx.Rows, error)

Query executes a query and returns rows

func (*DB) QueryRow

func (db *DB) QueryRow(ctx context.Context, sql string, args ...any) pgx.Row

QueryRow executes a query and returns a single row

func (*DB) RefExists

func (db *DB) RefExists(ctx context.Context, name string) (bool, error)

RefExists checks if a ref exists

func (*DB) SchemaExists

func (db *DB) SchemaExists(ctx context.Context) (bool, error)

SchemaExists checks if the pgit schema exists

func (*DB) SearchAllBlobs

func (db *DB) SearchAllBlobs(ctx context.Context, pathPattern string) ([]*Blob, error)

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

func (db *DB) SetHead(ctx context.Context, commitID string) error

SetHead sets the HEAD to point to a commit

func (*DB) SetMetadata

func (db *DB) SetMetadata(ctx context.Context, key, value string) error

SetMetadata sets a metadata key-value pair (upsert)

func (*DB) SetRef

func (db *DB) SetRef(ctx context.Context, name, commitID string) error

SetRef creates or updates a ref

func (*DB) SetRepoPath

func (db *DB) SetRepoPath(ctx context.Context, path string) error

SetRepoPath stores the repository working directory path

func (*DB) SetSchemaVersion

func (db *DB) SetSchemaVersion(ctx context.Context, version int) error

SetSchemaVersion sets the schema version in the database.

func (*DB) SetSyncState

func (db *DB) SetSyncState(ctx context.Context, remoteName string, lastCommitID *string) error

SetSyncState creates or updates the sync state for a remote

func (*DB) URL

func (db *DB) URL() string

URL returns the connection URL

func (*DB) WithTx

func (db *DB) WithTx(ctx context.Context, fn func(tx pgx.Tx) error) error

WithTx executes a function within a transaction

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

type Path struct {
	GroupID int32
	Path    string
}

Path represents a file path in the path registry. Each unique path gets a unique group_id for efficient storage.

type Ref

type Ref struct {
	Name     string
	CommitID string
}

Ref represents a named reference to a commit

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 SyncState

type SyncState struct {
	RemoteName   string
	LastCommitID *string
	SyncedAt     time.Time
}

SyncState represents the sync state with a remote

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

Jump to

Keyboard shortcuts

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