utils

package
v0.0.36 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultCacheSize int = 10000
)

Variables

This section is empty.

Functions

func CalculatePercentile

func CalculatePercentile(latencies []time.Duration, percentile float64) time.Duration

NOTE: Assumes latencies is sorted CalculatePercentile calculates latencies percentile

func CreateFile

func CreateFile(outputDir string, fileName string) (*os.File, error)

func ListAllFiles

func ListAllFiles(dir string) ([]string, error)

func OpenDB

func OpenDB(dir string) (dbm.DB, error)

Opens application db

func PickRandomKVFile

func PickRandomKVFile(inputKVDir string, processedFiles *sync.Map) string

Picks random file from input kv dir and updates processedFiles Map with it

func RandomShuffle

func RandomShuffle(kvPairs []KeyValuePair)

Randomly Shuffle kv pairs once read

func ReadTree

func ReadTree(db dbm.DB, version int, prefix []byte) (*iavl.MutableTree, error)

ReadTree loads an iavl tree from the directory If version is 0, load latest, otherwise, load named version The prefix represents which iavl tree you want to read. The iaviwer will always set a prefix.

func WriteTreeDataToFile

func WriteTreeDataToFile(tree *iavl.MutableTree, filenamePattern string, chunkSize int)

Writes raw key / values from a tree to a file Writes a chunkSize number of keys/values to separate files per module

Types

type KeyValuePair

type KeyValuePair struct {
	Key   []byte `json:"key"`
	Value []byte `json:"value"`
}

func LoadAndShuffleKV

func LoadAndShuffleKV(inputDir string) ([]KeyValuePair, error)

func ReadKVEntriesFromFile

func ReadKVEntriesFromFile(filename string) ([]KeyValuePair, error)

Reads raw keys / values from a file

Jump to

Keyboard shortcuts

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