namegetter

package
v1.4.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 15, 2026 License: MIT Imports: 5 Imported by: 0

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

View Source
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) Add added in v1.4.1

func (rng *PermAffinePrime) Add(string)

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) Len added in v1.4.1

func (rng *PermAffinePrime) Len() int

func (*PermAffinePrime) Names added in v1.4.1

func (rng *PermAffinePrime) Names() []string

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) Add added in v1.4.1

func (rng *PermShuffle) Add(string)

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) Len added in v1.4.1

func (rng *PermShuffle) Len() int

func (*PermShuffle) Names added in v1.4.1

func (rng *PermShuffle) Names() []string

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
}

func (*Random) Add added in v1.4.1

func (rng *Random) Add(objName string)

func (*Random) Init added in v1.4.1

func (rng *Random) Init(names []string, rnd *rand.Rand)

func (*Random) IterBatch added in v1.4.1

func (rng *Random) IterBatch(limit int, yield func(name string) bool)

with-replacement for single Pick(), but strictly unique within a batch

func (*Random) Len added in v1.4.1

func (rng *Random) Len() int

func (*Random) Names added in v1.4.1

func (rng *Random) Names() []string

func (*Random) Pick added in v1.4.1

func (rng *Random) Pick() string

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) Len added in v1.4.1

func (rng *RandomUnique) Len() int

func (*RandomUnique) Names added in v1.4.1

func (rng *RandomUnique) Names() []string

func (*RandomUnique) Pick added in v1.4.1

func (rng *RandomUnique) Pick() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL