query

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileResult

type FileResult struct {
	Path          string
	Size          int64
	ModTime       time.Time
	IsDir         bool
	Permissions   uint32
	Hash          string
	SnapshotID    string
	FromHotLayer  bool
	DataRef       string // For hot layer data location
	SymlinkTarget string
}

FileResult represents a file found in a query.

type QueryEngine

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

QueryEngine provides a unified interface for querying both hot and cold layers.

func NewQueryEngine

func NewQueryEngine(store Store) *QueryEngine

NewQueryEngine creates a new query engine.

func (*QueryEngine) FindDuplicateFiles

func (q *QueryEngine) FindDuplicateFiles(snapshotIDs []string, options QueryOptions) (map[string][]FileResult, error)

FindDuplicateFiles finds files with the same hash across snapshots.

func (*QueryEngine) FindFilesChangedBetweenSnapshots

func (q *QueryEngine) FindFilesChangedBetweenSnapshots(oldID, newID string, options QueryOptions) ([]FileResult, error)

FindFilesChangedBetweenSnapshots finds files that changed between two snapshots.

func (*QueryEngine) FindLargestFiles

func (q *QueryEngine) FindLargestFiles(snapshotID string, n int, options QueryOptions) ([]FileResult, error)

FindLargestFiles finds the N largest files in a snapshot.

func (*QueryEngine) FindNewestFiles

func (q *QueryEngine) FindNewestFiles(snapshotID string, n int, options QueryOptions) ([]FileResult, error)

FindNewestFiles finds the N newest files in a snapshot.

func (*QueryEngine) FindOldestFiles

func (q *QueryEngine) FindOldestFiles(snapshotID string, n int, options QueryOptions) ([]FileResult, error)

FindOldestFiles finds the N oldest files in a snapshot.

func (*QueryEngine) QueryAllSnapshots

func (q *QueryEngine) QueryAllSnapshots(options QueryOptions) ([]FileResult, error)

QueryAllSnapshots queries all snapshots using the specified options.

func (*QueryEngine) QueryMultipleSnapshots

func (q *QueryEngine) QueryMultipleSnapshots(snapshotIDs []string, options QueryOptions) ([]FileResult, error)

QueryMultipleSnapshots queries multiple snapshots. It parallelizes the queries for each snapshot.

func (*QueryEngine) QuerySnapshot

func (q *QueryEngine) QuerySnapshot(snapshotID string, options QueryOptions) ([]FileResult, error)

QuerySnapshot queries a snapshot using the specified options. It parallelizes queries to the hot and cold layers.

type QueryOptions

type QueryOptions struct {
	// Pattern is a filepath.Match pattern to filter files by path.
	Pattern string
	// MinSize is the minimum file size in bytes.
	MinSize int64
	// MaxSize is the maximum file size in bytes (0 means no maximum).
	MaxSize int64
	// StartTime is the start of the modification time range.
	StartTime time.Time
	// EndTime is the end of the modification time range.
	EndTime time.Time
	// Hash is a specific hash to match.
	Hash string
	// IsDir filters for directories (true) or files (false), nil means both.
	IsDir *bool
	// IncludeHot determines whether to include results from the hot layer.
	IncludeHot bool
	// IncludeCold determines whether to include results from the cold layer.
	IncludeCold bool
}

QueryOptions represents options for querying snapshots.

func DefaultQueryOptions

func DefaultQueryOptions() QueryOptions

DefaultQueryOptions returns the default query options.

type Store

type Store interface {
	// Core methods needed by the query engine
	GetSnapshot(id string) ([]walker.SnapshotEntry, error)
	ListSnapshots() ([]metadata.SnapshotMetadata, error)
	ComputeDiff(oldID, newID string) ([]serializer.DiffEntry, error)
	FindFilesByPattern(snapshotID, pattern string) (map[string]metadata.FileMetadata, error)
	FindFilesBySize(snapshotID string, minSize, maxSize int64) (map[string]metadata.FileMetadata, error)
	FindFilesByModTime(snapshotID string, startTime, endTime time.Time) (map[string]metadata.FileMetadata, error)
	FindFilesByHash(snapshotID, hash string) (map[string]metadata.FileMetadata, error)
	Close() error
}

Store represents the interface required by the query engine.

Jump to

Keyboard shortcuts

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