Artifact 51996b5bf53489e6d01a8c2f382c5d16777c93aac3c0ed9cfb8878f4c51f751a:
- File
internal/sync/sparse_clone_candidates.go
— part of check-in
[065f76e22f]
at
2026-10-21 00:36:41
on branch feat/submanifest-reader
— feat(sync): index prepared sparse clone successors
Prepare verified raw references under explicit byte, card, artifact and index-slot budgets before allocating payload expansions. Use request-local cone spans over a cone-independent range index to skip excluded RID gaps without empty clone continuation pages.
Keep this internal: selected-content reconstruction still uses dense allocation behavior, ordinary pull still scans inventory, and retaining every tree node is not proof of tree-minimal emission. No public wrapper, capability grammar or client continuation changes. (user: [email protected], size: 1851) [annotate] [blame] [check-ins using] [more...]
package sync import ( "github.com/danmestas/go-libfossil/internal/content" libfossil "github.com/danmestas/go-libfossil/internal/fsltype" ) type sparsePreparedProof struct { facts *content.ConeReferenceFacts index *content.ConeSuccessors work content.SuccessorWork } type cloneCandidateRows interface { Next() bool Scan(...any) error Err() error Close() error } // cloneCandidates keeps dense behavior unchanged. The prepared path seeks the // next eligible RID in memory, then performs one indexed blob lookup; excluded // gaps do not become database rows or content reads on the serving path. func (h *handler) cloneCandidates() (cloneCandidateRows, error) { if h.keep != nil && h.keep.indexed != nil { return &sparseCloneRows{handler: h, next: libfossil.FslID(h.cloneSeq)}, nil } return h.repo.DB().Query( "SELECT rid, uuid, size FROM blob WHERE rid >= ? AND rid <= ? AND size >= 0 ORDER BY rid", h.cloneSeq, h.cloneSnapMax, ) } type sparseCloneRows struct { handler *handler next libfossil.FslID current libfossil.FslID err error } func (rows *sparseCloneRows) Next() bool { if rows.next == 0 { return false } if err := rows.handler.ctx.Err(); err != nil { rows.err = err return false } query := rows.handler.keep.indexed last := libfossil.FslID(rows.handler.cloneSnapMax) rows.current = query.Next(rows.next, last) if rows.current == 0 { return false } query.Work.Candidates++ if rows.current == last { rows.next = 0 } else { rows.next = rows.current + 1 } return true } func (rows *sparseCloneRows) Scan(dest ...any) error { return rows.handler.repo.DB().QueryRow( "SELECT rid,uuid,size FROM blob WHERE rid=? AND size>=0", rows.current, ).Scan(dest...) } func (rows *sparseCloneRows) Err() error { return rows.err } func (rows *sparseCloneRows) Close() error { return nil }