Skip to content

Commit 26fa2fa

Browse files
committed
docs(gin): clarify v5 history and AdaptiveBucketCount=0 disable sentinel
- Version comment now notes v5 was never released; the in-tree v5 shape was iterated before the wire format was finalised in v6 and v5 payloads are always rejected on decode. Addresses item #4. - WithAdaptiveBucketCount godoc now explains the asymmetry between the option (rejects 0) and the validate() path (accepts 0 as the disable sentinel for struct-literal callers). validate() also carries an inline comment explaining why 0 is permitted there. Addresses item #5.
1 parent 6ca1640 commit 26fa2fa

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

gin.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ const (
1414
// with the target binary. Version history:
1515
// v6: PathEntry.Mode byte + FlagTrigramIndex bit reassignment
1616
// (phase 08 adaptive high-cardinality indexing)
17-
// v5: adaptive string index section + SerializedConfig adaptive fields
17+
// v5: never released; payloads are always rejected. Was an in-tree
18+
// iteration of the adaptive string index section before the wire
19+
// format was finalised in v6.
1820
// v4: earlier pre-OSS format
1921
Version = uint16(6)
2022
)
@@ -412,7 +414,10 @@ func WithAdaptiveCoverageCeiling(ceiling float64) ConfigOption {
412414
}
413415

414416
// WithAdaptiveBucketCount sets the fan-out of the long-tail bucket layer.
415-
// Must be a positive power of two. Zero disables adaptive mode.
417+
// Must be a positive power of two. To disable adaptive mode, omit this
418+
// option (and WithAdaptivePromotedTermCap) or build a GINConfig literal
419+
// with AdaptiveBucketCount/AdaptivePromotedTermCap set to 0; this option
420+
// rejects 0 to keep the builder path explicit.
416421
func WithAdaptiveBucketCount(bucketCount int) ConfigOption {
417422
return func(c *GINConfig) error {
418423
if bucketCount <= 0 {
@@ -479,6 +484,11 @@ func NewGINIndex() *GINIndex {
479484
}
480485

481486
func (c GINConfig) validate() error {
487+
// Zero is the disable sentinel for AdaptivePromotedTermCap and
488+
// AdaptiveBucketCount; AdaptiveEnabled() reports false when either is 0.
489+
// The functional options reject 0 to keep the builder path explicit, but
490+
// validate() must accept 0 so struct-literal callers can disable adaptive
491+
// mode without invoking the options.
482492
if c.AdaptiveMinRGCoverage < 0 {
483493
return errors.New("adaptive min RG coverage must be non-negative")
484494
}

0 commit comments

Comments
 (0)