feat(adapter): add passthrough adapter for unchanged vectors

This commit is contained in:
2026-04-11 20:57:44 +02:00
parent 5c070e441e
commit c5608bf5cd
4 changed files with 57 additions and 32 deletions

View File

@@ -41,6 +41,17 @@ type Adapter interface {
TargetDim() int
}
// passthroughAdapter returns the input vector unchanged.
type passthroughAdapter struct{}
func (passthroughAdapter) Adapt(vec []float32) ([]float32, error) { return vec, nil }
func (passthroughAdapter) SourceDim() int { return 0 }
func (passthroughAdapter) TargetDim() int { return 0 }
// NewPassthrough returns an Adapter that returns vectors unchanged.
// Use when no dimension adaptation is needed.
func NewPassthrough() Adapter { return passthroughAdapter{} }
// NewTruncate returns a TruncateAdapter for Matryoshka-style or simple truncation/padding.
// t controls which end is dropped when downscaling; p controls which end is padded when upscaling.
func NewTruncate(sourceDim, targetDim int, t TruncateMode, p PadMode) (Adapter, error) {