Documentation
¶
Index ¶
- Constants
- func DimensionName(d int) string
- func ParseDimension(s string) (int, error)
- type Bools
- type CommonSitestMatrix
- type ConfiguredDimension
- type ConfiguredDimensions
- func (c *ConfiguredDimensions) GetOrCreateSingleVectorStore(vec Vector) *IntSets
- func (c *ConfiguredDimensions) Init() error
- func (c *ConfiguredDimensions) IsSingleVector() bool
- func (c *ConfiguredDimensions) ResolveNames(v Vector) types.Strings3
- func (c *ConfiguredDimensions) ResolveVector(names types.Strings3) Vector
- type Dimension
- type DimensionInfo
- type IntSets
- func (s *IntSets) Complement(ss ...VectorProvider) VectorStore
- func (s *IntSets) DifferenceCardinality(other *IntSets) Vector
- func (s *IntSets) EqualsVector(other VectorProvider) bool
- func (s *IntSets) ForEachVector(yield func(v Vector) bool) bool
- func (s *IntSets) HasAnyVector(v VectorProvider) bool
- func (s *IntSets) HasLanguage(lang int) bool
- func (s *IntSets) HasRole(role int) bool
- func (s *IntSets) HasVector(v Vector) bool
- func (s *IntSets) HasVersion(ver int) bool
- func (s *IntSets) Hash() (uint64, error)
- func (s *IntSets) Intersects(other *IntSets) bool
- func (s *IntSets) IsSuperSet(other *IntSets) bool
- func (s *IntSets) KeysSorted() ([]int, []int, []int)
- func (s *IntSets) LenVectors() int
- func (s *IntSets) MustHash() uint64
- func (s *IntSets) String() string
- func (s *IntSets) ToVectorStoreMap() *vectorStoreMap
- func (s *IntSets) VectorSample() Vector
- func (s *IntSets) Vectors() []Vector
- func (s *IntSets) WithLanguageIndices(i int) VectorStore
- type IntSetsBuilder
- func (b *IntSetsBuilder) Build() *IntSets
- func (s *IntSetsBuilder) WithAllIfNotSet() *IntSetsBuilder
- func (b *IntSetsBuilder) WithConfig(cfg IntSetsConfig) *IntSetsBuilder
- func (s *IntSetsBuilder) WithDefaultsAndAllLanguagesIfNotSet() *IntSetsBuilder
- func (s *IntSetsBuilder) WithDefaultsIfNotSet() *IntSetsBuilder
- func (s *IntSetsBuilder) WithDimensionsFromOtherIfNotSet(other VectorIterator) *IntSetsBuilder
- func (s *IntSetsBuilder) WithLanguageIndices(idxs ...int) *IntSetsBuilder
- func (b *IntSetsBuilder) WithSets(languages, versions, roles *maps.OrderedIntSet) *IntSetsBuilder
- type IntSetsConfig
- type IntSetsConfigApplyDefaults
- type Sites
- type StringSlices
- type ToVectorStoreProvider
- type Vector
- func (v1 Vector) Compare(v2 Vector) int
- func (v1 Vector) Distance(v2 Vector) int
- func (v1 Vector) EqualsVector(other VectorProvider) bool
- func (v1 Vector) ForEachVector(yield func(v Vector) bool) bool
- func (v1 Vector) HasAnyVector(vp VectorProvider) bool
- func (v1 Vector) HasVector(v2 Vector) bool
- func (v1 Vector) IsFirst() bool
- func (v1 Vector) Language() int
- func (v1 Vector) LenVectors() int
- func (v1 Vector) Role() int
- func (v1 Vector) VectorSample() Vector
- func (v1 Vector) Version() int
- func (v1 Vector) Weight() int
- type VectorIterator
- type VectorProvider
- type VectorStore
- type Vectors
Constants ¶
const ( // Dimensions in the Hugo build matrix. // These can be used as indices into the Vector type. Language int = iota Version Role )
Variables ¶
This section is empty.
Functions ¶
func DimensionName ¶
func ParseDimension ¶
Types ¶
type Bools ¶
type Bools [3]bool
Bools holds boolean values for each dimension in the Hugo build matrix.
type CommonSitestMatrix ¶
type CommonSitestMatrix struct {
DefaultSite VectorStore
}
type ConfiguredDimension ¶
type ConfiguredDimensions ¶
type ConfiguredDimensions struct {
ConfiguredLanguages ConfiguredDimension
ConfiguredVersions ConfiguredDimension
ConfiguredRoles ConfiguredDimension
CommonSitesMatrix CommonSitestMatrix
// contains filtered or unexported fields
}
ConfiguredDimensions holds the configured dimensions for the site matrix.
func NewTestingDimensions ¶
func NewTestingDimensions(languages, versions, roles []string) *ConfiguredDimensions
NewTestingDimensions creates a new ConfiguredDimensions for testing.
func (*ConfiguredDimensions) GetOrCreateSingleVectorStore ¶
func (c *ConfiguredDimensions) GetOrCreateSingleVectorStore(vec Vector) *IntSets
GetOrCreateSingleVectorStore returns a VectorStore for the given vector.
func (*ConfiguredDimensions) Init ¶
func (c *ConfiguredDimensions) Init() error
func (*ConfiguredDimensions) IsSingleVector ¶
func (c *ConfiguredDimensions) IsSingleVector() bool
func (*ConfiguredDimensions) ResolveNames ¶
func (c *ConfiguredDimensions) ResolveNames(v Vector) types.Strings3
func (*ConfiguredDimensions) ResolveVector ¶
func (c *ConfiguredDimensions) ResolveVector(names types.Strings3) Vector
type DimensionInfo ¶
type DimensionInfo interface {
// The name. This corresponds to the key in the config, e.g. "en", "v1.2.3", "guest".
Name() string
// Whether this is the default value for this dimension.
IsDefault() bool
}
Common information provided by all of language, version and role.
type IntSets ¶
type IntSets struct {
// contains filtered or unexported fields
}
IntSets holds the ordered sets of integers for the dimensions, which is used for fast membership testing of files, resources and pages.
func (*IntSets) Complement ¶
func (s *IntSets) Complement(ss ...VectorProvider) VectorStore
Complement returns a new VectorStore that contains all vectors in s that are not in any of ss.
func (*IntSets) DifferenceCardinality ¶
func (*IntSets) EqualsVector ¶
func (s *IntSets) EqualsVector(other VectorProvider) bool
func (*IntSets) ForEachVector ¶
The reason we don't use iter.Seq is https://github.com/golang/go/issues/69015 This is 60% faster and allocation free. The yield function should return false to stop iteration.
func (*IntSets) HasAnyVector ¶
func (s *IntSets) HasAnyVector(v VectorProvider) bool
func (*IntSets) HasLanguage ¶
func (*IntSets) HasVersion ¶
func (*IntSets) Intersects ¶
func (*IntSets) IsSuperSet ¶
func (*IntSets) LenVectors ¶
LenVectors returns the total number of vectors represented by the IntSets. This is the Cartesian product of the lengths of the individual sets. This will be 0 if s is nil or any of the sets is empty.
func (*IntSets) ToVectorStoreMap ¶
func (s *IntSets) ToVectorStoreMap() *vectorStoreMap
func (*IntSets) VectorSample ¶
func (*IntSets) WithLanguageIndices ¶
func (s *IntSets) WithLanguageIndices(i int) VectorStore
WithLanguageIndices replaces the current language set with a single language index.
type IntSetsBuilder ¶
type IntSetsBuilder struct {
// Set when a Glob (e.g. "en") filter is provided but no matches are found.
GlobFilterMisses Bools
// contains filtered or unexported fields
}
func NewIntSetsBuilder ¶
func NewIntSetsBuilder(cfg *ConfiguredDimensions) *IntSetsBuilder
func (*IntSetsBuilder) Build ¶
func (b *IntSetsBuilder) Build() *IntSets
func (*IntSetsBuilder) WithAllIfNotSet ¶
func (s *IntSetsBuilder) WithAllIfNotSet() *IntSetsBuilder
func (*IntSetsBuilder) WithConfig ¶
func (b *IntSetsBuilder) WithConfig(cfg IntSetsConfig) *IntSetsBuilder
func (*IntSetsBuilder) WithDefaultsAndAllLanguagesIfNotSet ¶
func (s *IntSetsBuilder) WithDefaultsAndAllLanguagesIfNotSet() *IntSetsBuilder
func (*IntSetsBuilder) WithDefaultsIfNotSet ¶
func (s *IntSetsBuilder) WithDefaultsIfNotSet() *IntSetsBuilder
func (*IntSetsBuilder) WithDimensionsFromOtherIfNotSet ¶
func (s *IntSetsBuilder) WithDimensionsFromOtherIfNotSet(other VectorIterator) *IntSetsBuilder
func (*IntSetsBuilder) WithLanguageIndices ¶
func (s *IntSetsBuilder) WithLanguageIndices(idxs ...int) *IntSetsBuilder
func (*IntSetsBuilder) WithSets ¶
func (b *IntSetsBuilder) WithSets(languages, versions, roles *maps.OrderedIntSet) *IntSetsBuilder
type IntSetsConfig ¶
type IntSetsConfig struct {
ApplyDefaults IntSetsConfigApplyDefaults
Globs StringSlices
}
type IntSetsConfigApplyDefaults ¶
type IntSetsConfigApplyDefaults int
const ( IntSetsConfigApplyDefaultsNone IntSetsConfigApplyDefaults = iota IntSetsConfigApplyDefaultsIfNotSet IntSetsConfigApplyDefaultsAndAllLanguagesIfNotSet )
type Sites ¶
type Sites struct {
// Matrix defines what sites to build this content for.
Matrix StringSlices `mapstructure:"matrix" json:"matrix"`
// Complements defines what sites to complement with this content.
Complements StringSlices `mapstructure:"complements" json:"complements"`
}
Sites holds configuration about which sites a file/content/page/resource belongs to.
func (*Sites) SetFromParamsIfNotSet ¶
type StringSlices ¶
type StringSlices struct {
Languages []string `mapstructure:"languages" json:"languages"`
Versions []string `mapstructure:"versions" json:"versions"`
Roles []string `mapstructure:"roles" json:"roles"`
}
StringSlices holds slices of Glob patterns for languages, versions, and roles.
func (StringSlices) Equal ¶
func (d StringSlices) Equal(other StringSlices) bool
func (StringSlices) IsZero ¶
func (d StringSlices) IsZero() bool
func (*StringSlices) SetFromParamsIfNotSet ¶
func (d *StringSlices) SetFromParamsIfNotSet(params maps.Params)
type ToVectorStoreProvider ¶
type ToVectorStoreProvider interface {
ToVectorStore() VectorStore
}
type Vector ¶
type Vector [3]int
Vector represents a site vector in the Hugo sites matrix from the three dimensions: Language, Version and Role. This is a fixed-size array for performance reasons (for one, it can be used as map key).
func (Vector) Compare ¶
Compare returns -1 if v1 is less than v2, 0 if they are equal, and 1 if v1 is greater than v2. This adds a implicit weighting to the dimensions, where the first dimension is the most important, but this is just used for sorting to get stable output.
func (Vector) Distance ¶
Distance returns the distance between v1 and v2 using the first dimension that is different.
func (Vector) EqualsVector ¶
func (v1 Vector) EqualsVector(other VectorProvider) bool
func (Vector) HasAnyVector ¶
func (v1 Vector) HasAnyVector(vp VectorProvider) bool
func (Vector) IsFirst ¶
IsFirst returns true if this is the first vector in the matrix, i.e. all dimensions are 0.
func (Vector) LenVectors ¶
func (Vector) VectorSample ¶
type VectorIterator ¶
type VectorIterator interface {
// ForEachVector iterates over all vectors in the provider.
// It returns false if the iteration was stopped early.
ForEachVector(func(v Vector) bool) bool
// LenVectors returns the number of vectors in the provider.
LenVectors() int
// VectorSample returns one of the vectors in the provider, usually the first or the only one.
// This will panic if the provider is empty.
VectorSample() Vector
}
type VectorProvider ¶
type VectorProvider interface {
VectorIterator
// HasVector returns true if the given vector is contained in the provider.
// Used for membership testing of files, resources and pages.
HasVector(HasAnyVectorv Vector) bool
// HasAnyVector returns true if any of the vectors in the provider matches any of the vectors in v.
HasAnyVector(v VectorProvider) bool
// Equals returns true if this provider is equal to the other provider.
EqualsVector(other VectorProvider) bool
}
type VectorStore ¶
type VectorStore interface {
VectorProvider
Complement(...VectorProvider) VectorStore
WithLanguageIndices(i int) VectorStore
HasLanguage(lang int) bool
HasVersion(version int) bool
HasRole(role int) bool
MustHash() uint64
// Used in tests.
KeysSorted() ([]int, []int, []int)
Vectors() []Vector
}
func NewWeightedVectorStore ¶
func NewWeightedVectorStore(vs VectorStore, weight int) VectorStore
func VectorIteratorToStore ¶
func VectorIteratorToStore(vi VectorIterator) VectorStore
type Vectors ¶
type Vectors map[Vector]struct{}
func (Vectors) LenVectors ¶
func (Vectors) ToVectorStore ¶
func (vs Vectors) ToVectorStore() VectorStore
func (Vectors) VectorSample ¶
VectorSample returns one of the vectors in the set.