utils

package
v0.0.54 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2025 License: Apache-2.0 Imports: 19 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 ContractSizeEntry

type ContractSizeEntry struct {
	Address   string `json:"address"`
	TotalSize uint64 `json:"total_size"`
	KeyCount  uint64 `json:"key_count"`
}

ContractSizeEntry represents individual contract size data

type DynamoDBClient

type DynamoDBClient struct {
	// contains filtered or unexported fields
}

DynamoDBClient wraps the DynamoDB service with common operations

func NewDynamoDBClient

func NewDynamoDBClient(tableName, awsRegion string) (*DynamoDBClient, error)

NewDynamoDBClient creates a new DynamoDB client

func (*DynamoDBClient) ExportMultipleAnalyses

func (d *DynamoDBClient) ExportMultipleAnalyses(analyses []*StateSizeAnalysis) error

ExportMultipleAnalyses exports multiple analyses sequentially

func (*DynamoDBClient) ExportStateSizeAnalysis

func (d *DynamoDBClient) ExportStateSizeAnalysis(analysis *StateSizeAnalysis) error

ExportStateSizeAnalysis exports a single module analysis to DynamoDB

func (*DynamoDBClient) UpdateLatestHeightIfGreater

func (d *DynamoDBClient) UpdateLatestHeightIfGreater(metadataTable string, height int64) (bool, error)

UpdateLatestHeightIfGreater keeps exactly one item in the metadata table using the schema: Partition key: keyname (S). Numeric attribute: height (N) stores the latest height. Upserts the row keyname = "latest_height" and sets height = :h only if missing or lower.

type KeyValuePair

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

func LoadAndShuffleKV

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

func ReadKVEntriesFromFile

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

Reads raw keys / values from a file

type PrefixSize

type PrefixSize struct {
	KeySize   uint64 `json:"key_size"`
	ValueSize uint64 `json:"value_size"`
	TotalSize uint64 `json:"total_size"`
	KeyCount  uint64 `json:"key_count"`
}

PrefixSize is a helper structure kept for completeness (unused here)

type StateSizeAnalysis

type StateSizeAnalysis struct {
	BlockHeight       int64  `json:"block_height" dynamodbav:"block_height"`
	ModuleName        string `json:"module_name" dynamodbav:"module_name"`
	TotalNumKeys      uint64 `json:"total_num_keys" dynamodbav:"total_num_keys"`
	TotalKeySize      uint64 `json:"total_key_size" dynamodbav:"total_key_size"`
	TotalValueSize    uint64 `json:"total_value_size" dynamodbav:"total_value_size"`
	TotalSize         uint64 `json:"total_size" dynamodbav:"total_size"`
	PrefixBreakdown   string `json:"prefix_breakdown" dynamodbav:"prefix_breakdown"`
	ContractBreakdown string `json:"contract_breakdown" dynamodbav:"contract_breakdown"`
}

StateSizeAnalysis represents the analysis data to be stored in DynamoDB

Jump to

Keyboard shortcuts

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