Documentation
¶
Overview ¶
Package namegetter is a utility to provide random object and archived file names to aisloader
- Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved.
Package namegetter is a utility to provide random object and archived file names to aisloader ¶
* Copyright (c) 2018-2025, NVIDIA CORPORATION. All rights reserved.
Index ¶
- Constants
- type Basic
- type PermAffinePrime
- func (rng *PermAffinePrime) Add(string)
- func (pp *PermAffinePrime) Init(names []string, rnd *rand.Rand)
- func (pp *PermAffinePrime) IterBatch(limit int, yield func(name string) bool)
- func (rng *PermAffinePrime) Len() int
- func (rng *PermAffinePrime) Names() []string
- func (pp *PermAffinePrime) Pick() string
- type PermShuffle
- type Random
- type RandomUnique
Constants ¶
const AffineMinN = 10 // avoid tiny datasets and related corners
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Basic ¶ added in v1.4.1
type Basic interface {
Init(names []string, rnd *rand.Rand)
// when mixed read/write
// `Random` and `RandomUnique` implement Add()
Add(objName string)
// pick a random name
Pick() string
// iterate over a batch of up to `limit` unique names
// - calls yield(name) for each selected name
// - if yield returns false, iteration stops early
// - if fewer names are available than limit, fewer names are yielded
IterBatch(limit int, yield func(name string) bool)
// all known names and the number of thereof
// (note: both methods not thread-safe)
Names() []string
Len() int
}
base interface for read-only name selection
type PermAffinePrime ¶ added in v1.4.1
type PermAffinePrime struct {
// contains filtered or unexported fields
}
epoch-based affine sequence over nextPrimeGE(n); each epoch emits exactly n unique indices; IterBatch never crosses epochs, so duplicates within a single batch are impossible
func (*PermAffinePrime) Init ¶ added in v1.4.1
func (pp *PermAffinePrime) Init(names []string, rnd *rand.Rand)
Init: ensure n>0 and p>=2 once
func (*PermAffinePrime) IterBatch ¶ added in v1.4.1
func (pp *PermAffinePrime) IterBatch(limit int, yield func(name string) bool)
epoch-based affine sequence over nextPrimeGE(n); each epoch emits exactly n unique indices NOTE: - may straddle epoch boundaries; in that case, - a single batch can contain duplicates (tail of previous epoch + head of the next); - unlikely though if the dataset size >> batch size
func (*PermAffinePrime) Pick ¶ added in v1.4.1
func (pp *PermAffinePrime) Pick() string
Pick: increment y with add+wrap; no mul/mod in the hot path
type PermShuffle ¶ added in v1.4.1
type PermShuffle struct {
// contains filtered or unexported fields
}
PermShuffle generates repeated random permutations of an open interval [0..n) NOTE: IterBatch can cross a permutation boundary - if that happens the yielded batch (of names) may contain duplicates (extended comment below)
func (*PermShuffle) Init ¶ added in v1.4.1
func (rng *PermShuffle) Init(names []string, rnd *rand.Rand)
func (*PermShuffle) IterBatch ¶ added in v1.4.1
func (rng *PermShuffle) IterBatch(limit int, yield func(name string) bool)
consecutive window with pre-generated wrap
func (*PermShuffle) Pick ¶ added in v1.4.1
func (rng *PermShuffle) Pick() string
type Random ¶ added in v1.4.1
type Random struct {
// contains filtered or unexported fields
}
type RandomUnique ¶ added in v1.4.1
type RandomUnique struct {
// contains filtered or unexported fields
}
func (*RandomUnique) Add ¶ added in v1.4.1
func (rng *RandomUnique) Add(objName string)
func (*RandomUnique) Init ¶ added in v1.4.1
func (rng *RandomUnique) Init(names []string, rnd *rand.Rand)
func (*RandomUnique) IterBatch ¶ added in v1.4.1
func (rng *RandomUnique) IterBatch(limit int, yield func(name string) bool)
strictly unique within the yielded batch; still advances the epoch tracker
func (*RandomUnique) Pick ¶ added in v1.4.1
func (rng *RandomUnique) Pick() string