Documentation
¶
Index ¶
- func CalculateFileSHA256(content []byte) string
- func DoWorkList[T any, R any](list []T, work func(T) R) []R
- func ExtractPathFromURI(uri string) string
- func FormatSignatureString(info SignatureInfo) string
- func GetFileContentFromGit(gitRootPath, filePath string) ([]byte, error)
- func GetLastCommitForFile(repoPath, filePath string) (string, error)
- func GetRelativePath(repoPath, filePath string) (string, error)
- func IsFileModified(gitInfo *GitInfo, filePath string) bool
- func NormalizeSignatureForEmbedding(info SignatureInfo) string
- func Ptr[T any](v T) *T
- func ReadFileOptimized(repoPath, filePath string, useHead bool, gitInfo *GitInfo) ([]byte, error)
- func ShouldSkipDirectory(path string) bool
- func ShouldSkipFile(filePath string, repo *config.Repository) bool
- func ToRelativePath(rootPath, fullPath string) string
- func ToUri(path, rootPath string) (string, error)
- func WalkDirTree(root string, walkFn WalkFunc, skipPath SkipFunc, logger *zap.Logger, ...) error
- type BloomFilterManager
- func (bfm *BloomFilterManager) Add(repoName string, data string) error
- func (bfm *BloomFilterManager) Clear(repoName string)
- func (bfm *BloomFilterManager) ClearAll()
- func (bfm *BloomFilterManager) Delete(repoName string) error
- func (bfm *BloomFilterManager) GetOrCreateFilter(repoName string) (*bloom.BloomFilter, error)
- func (bfm *BloomFilterManager) Save(repoName string) error
- func (bfm *BloomFilterManager) SaveAll() error
- func (bfm *BloomFilterManager) Test(repoName string, data string) (bool, error)
- type ExecutorPool
- type GitInfo
- type ParameterInfo
- type SafeMap
- type SignatureInfo
- func BuildSignatureInfo(className, methodName, returnType string, paramNames, paramTypes []string) SignatureInfo
- func ParseGoSignature(signature, methodName, className string) SignatureInfo
- func ParseJavaScriptSignature(signature, methodName, className string) SignatureInfo
- func ParseJavaSignature(signature, methodName, className string) SignatureInfo
- func ParsePythonSignature(signature, methodName, className string) SignatureInfo
- func ParseSignatureByLanguage(signature, methodName, className, language string) SignatureInfo
- type SkipFunc
- type WalkFunc
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CalculateFileSHA256 ¶
CalculateFileSHA256 calculates the SHA256 hash of file content
func DoWorkList ¶
func ExtractPathFromURI ¶
func FormatSignatureString ¶
func FormatSignatureString(info SignatureInfo) string
FormatSignatureString creates a human-readable signature string Example: "User findByEmail(String email)"
func GetFileContentFromGit ¶
GetFileContentFromGit retrieves file content from git HEAD Returns error if file is not tracked by git gitRootPath should be the git repository root (from GitInfo.GitRootPath)
func GetLastCommitForFile ¶
GetLastCommitForFile gets the commit SHA of the last commit that modified a file
func GetRelativePath ¶
GetRelativePath returns the relative path of a file from the repository root
func IsFileModified ¶
IsFileModified checks if a file is modified compared to HEAD
func NormalizeSignatureForEmbedding ¶
func NormalizeSignatureForEmbedding(info SignatureInfo) string
NormalizeSignatureForEmbedding converts a method signature into a normalized text representation optimized for embedding-based semantic search.
Example:
Input: class=UserService, method=findByEmail, params=[(email, String)], returns=User Output: "UserService find By Email String email returns User"
func ReadFileOptimized ¶
ReadFileOptimized reads file content, using git HEAD if useHead is true and file is unmodified In HEAD mode, untracked files are skipped (returns nil content with error)
func ShouldSkipDirectory ¶
ShouldSkipDirectory checks if a directory should be skipped during traversal
func ShouldSkipFile ¶
func ShouldSkipFile(filePath string, repo *config.Repository) bool
ShouldSkipFile checks if a file should be skipped during indexing This includes special files like Dockerfiles, lock files, build artifacts, etc. If repo is provided and SkipOtherLanguages is true, only files matching the repo language are processed
func ToRelativePath ¶
func WalkDirTree ¶
func WalkDirTree(root string, walkFn WalkFunc, skipPath SkipFunc, logger *zap.Logger, gcThreshold int64, numThreads int) error
Walk traverses a directory tree concurrently, calling walkFn for each file and directory. Unlike filepath.Walk, this implementation does not guarantee any particular ordering of children directories and files. gcThreshold controls how often to trigger GC (every N files). Set to 0 to disable. Uses 2 worker goroutines to process files concurrently.
Types ¶
type BloomFilterManager ¶
type BloomFilterManager struct {
// contains filtered or unexported fields
}
BloomFilterManager manages bloom filters for repositories with disk persistence
func NewBloomFilterManager ¶
func NewBloomFilterManager(cfg config.BloomFilterConfig, logger *zap.Logger) (*BloomFilterManager, error)
NewBloomFilterManager creates a new bloom filter manager
func (*BloomFilterManager) Add ¶
func (bfm *BloomFilterManager) Add(repoName string, data string) error
Add adds data to the bloom filter for a repository
func (*BloomFilterManager) Clear ¶
func (bfm *BloomFilterManager) Clear(repoName string)
Clear removes the bloom filter for a repository from memory
func (*BloomFilterManager) ClearAll ¶
func (bfm *BloomFilterManager) ClearAll()
ClearAll removes all bloom filters from memory
func (*BloomFilterManager) Delete ¶
func (bfm *BloomFilterManager) Delete(repoName string) error
Delete removes the bloom filter for a repository from both memory and disk
func (*BloomFilterManager) GetOrCreateFilter ¶
func (bfm *BloomFilterManager) GetOrCreateFilter(repoName string) (*bloom.BloomFilter, error)
GetOrCreateFilter gets or creates a bloom filter for a repository
func (*BloomFilterManager) Save ¶
func (bfm *BloomFilterManager) Save(repoName string) error
Save persists the bloom filter for a repository to disk
func (*BloomFilterManager) SaveAll ¶
func (bfm *BloomFilterManager) SaveAll() error
SaveAll persists all bloom filters to disk
type ExecutorPool ¶
type ExecutorPool[T any] struct { // contains filtered or unexported fields }
Example ¶
var processedCount int64
pool := NewExecutorPool(3, 10, func(data string) {
fmt.Printf("Processing: %s\n", data)
atomic.AddInt64(&processedCount, 1)
time.Sleep(100 * time.Millisecond)
})
tasks := []string{"task1", "task2", "task3", "task4", "task5"}
for _, task := range tasks {
pool.Submit(task)
}
pool.Close()
fmt.Printf("Total processed: %d\n", atomic.LoadInt64(&processedCount))
func NewExecutorPool ¶
func NewExecutorPool[T any](maxConcurrent int, bufferSize int, workerFunc func(T)) *ExecutorPool[T]
func (*ExecutorPool[T]) Close ¶
func (p *ExecutorPool[T]) Close()
func (*ExecutorPool[T]) Submit ¶
func (p *ExecutorPool[T]) Submit(item T)
type GitInfo ¶
type GitInfo struct {
HeadCommitSHA string
HeadCommitMsg string
ModifiedFiles map[string]bool // Set of files modified compared to HEAD (absolute paths)
GitRootPath string // Absolute path to git repository root
IsGitRepo bool
}
GitInfo contains git repository information
func GetGitInfo ¶
GetGitInfo retrieves git information for a repository path
type ParameterInfo ¶
ParameterInfo holds parameter details
type SafeMap ¶
type SafeMap[V any] struct { // contains filtered or unexported fields }
func NewSafeMap ¶
type SignatureInfo ¶
type SignatureInfo struct {
ClassName string
MethodName string
Parameters []ParameterInfo
ReturnType string
ParameterTypes []string
ParameterNames []string
}
SignatureInfo holds parsed method signature information
func BuildSignatureInfo ¶
func BuildSignatureInfo(className, methodName, returnType string, paramNames, paramTypes []string) SignatureInfo
BuildSignatureInfo creates a SignatureInfo from raw components
func ParseGoSignature ¶
func ParseGoSignature(signature, methodName, className string) SignatureInfo
ParseGoSignature parses a Go function signature string to extract components Example: "FindByEmail(email string) *User" -> SignatureInfo
func ParseJavaScriptSignature ¶
func ParseJavaScriptSignature(signature, methodName, className string) SignatureInfo
ParseJavaScriptSignature parses a JavaScript/TypeScript function signature Example: "findByEmail(email: string): User" -> SignatureInfo
func ParseJavaSignature ¶
func ParseJavaSignature(signature, methodName, className string) SignatureInfo
ParseJavaSignature parses a Java method signature string to extract components Example: "public User findByEmail(String email)" -> SignatureInfo
func ParsePythonSignature ¶
func ParsePythonSignature(signature, methodName, className string) SignatureInfo
ParsePythonSignature parses a Python function signature string to extract components Example: "find_by_email(email: str) -> User" -> SignatureInfo
func ParseSignatureByLanguage ¶
func ParseSignatureByLanguage(signature, methodName, className, language string) SignatureInfo
ParseSignatureByLanguage parses a signature string based on the language