package redis

import (
	
	

	
)

type ProbabilisticCmdable interface {
	BFAdd(ctx context.Context, key string, element interface{}) *BoolCmd
	BFCard(ctx context.Context, key string) *IntCmd
	BFExists(ctx context.Context, key string, element interface{}) *BoolCmd
	BFInfo(ctx context.Context, key string) *BFInfoCmd
	BFInfoArg(ctx context.Context, key, option string) *BFInfoCmd
	BFInfoCapacity(ctx context.Context, key string) *BFInfoCmd
	BFInfoSize(ctx context.Context, key string) *BFInfoCmd
	BFInfoFilters(ctx context.Context, key string) *BFInfoCmd
	BFInfoItems(ctx context.Context, key string) *BFInfoCmd
	BFInfoExpansion(ctx context.Context, key string) *BFInfoCmd
	BFInsert(ctx context.Context, key string, options *BFInsertOptions, elements ...interface{}) *BoolSliceCmd
	BFMAdd(ctx context.Context, key string, elements ...interface{}) *BoolSliceCmd
	BFMExists(ctx context.Context, key string, elements ...interface{}) *BoolSliceCmd
	BFReserve(ctx context.Context, key string, errorRate float64, capacity int64) *StatusCmd
	BFReserveExpansion(ctx context.Context, key string, errorRate float64, capacity, expansion int64) *StatusCmd
	BFReserveNonScaling(ctx context.Context, key string, errorRate float64, capacity int64) *StatusCmd
	BFReserveWithArgs(ctx context.Context, key string, options *BFReserveOptions) *StatusCmd
	BFScanDump(ctx context.Context, key string, iterator int64) *ScanDumpCmd
	BFLoadChunk(ctx context.Context, key string, iterator int64, data interface{}) *StatusCmd

	CFAdd(ctx context.Context, key string, element interface{}) *BoolCmd
	CFAddNX(ctx context.Context, key string, element interface{}) *BoolCmd
	CFCount(ctx context.Context, key string, element interface{}) *IntCmd
	CFDel(ctx context.Context, key string, element interface{}) *BoolCmd
	CFExists(ctx context.Context, key string, element interface{}) *BoolCmd
	CFInfo(ctx context.Context, key string) *CFInfoCmd
	CFInsert(ctx context.Context, key string, options *CFInsertOptions, elements ...interface{}) *BoolSliceCmd
	CFInsertNX(ctx context.Context, key string, options *CFInsertOptions, elements ...interface{}) *IntSliceCmd
	CFMExists(ctx context.Context, key string, elements ...interface{}) *BoolSliceCmd
	CFReserve(ctx context.Context, key string, capacity int64) *StatusCmd
	CFReserveWithArgs(ctx context.Context, key string, options *CFReserveOptions) *StatusCmd
	CFReserveExpansion(ctx context.Context, key string, capacity int64, expansion int64) *StatusCmd
	CFReserveBucketSize(ctx context.Context, key string, capacity int64, bucketsize int64) *StatusCmd
	CFReserveMaxIterations(ctx context.Context, key string, capacity int64, maxiterations int64) *StatusCmd
	CFScanDump(ctx context.Context, key string, iterator int64) *ScanDumpCmd
	CFLoadChunk(ctx context.Context, key string, iterator int64, data interface{}) *StatusCmd

	CMSIncrBy(ctx context.Context, key string, elements ...interface{}) *IntSliceCmd
	CMSInfo(ctx context.Context, key string) *CMSInfoCmd
	CMSInitByDim(ctx context.Context, key string, width, height int64) *StatusCmd
	CMSInitByProb(ctx context.Context, key string, errorRate, probability float64) *StatusCmd
	CMSMerge(ctx context.Context, destKey string, sourceKeys ...string) *StatusCmd
	CMSMergeWithWeight(ctx context.Context, destKey string, sourceKeys map[string]int64) *StatusCmd
	CMSQuery(ctx context.Context, key string, elements ...interface{}) *IntSliceCmd

	TopKAdd(ctx context.Context, key string, elements ...interface{}) *StringSliceCmd
	TopKCount(ctx context.Context, key string, elements ...interface{}) *IntSliceCmd
	TopKIncrBy(ctx context.Context, key string, elements ...interface{}) *StringSliceCmd
	TopKInfo(ctx context.Context, key string) *TopKInfoCmd
	TopKList(ctx context.Context, key string) *StringSliceCmd
	TopKListWithCount(ctx context.Context, key string) *MapStringIntCmd
	TopKQuery(ctx context.Context, key string, elements ...interface{}) *BoolSliceCmd
	TopKReserve(ctx context.Context, key string, k int64) *StatusCmd
	TopKReserveWithOptions(ctx context.Context, key string, k int64, width, depth int64, decay float64) *StatusCmd

	TDigestAdd(ctx context.Context, key string, elements ...float64) *StatusCmd
	TDigestByRank(ctx context.Context, key string, rank ...uint64) *FloatSliceCmd
	TDigestByRevRank(ctx context.Context, key string, rank ...uint64) *FloatSliceCmd
	TDigestCDF(ctx context.Context, key string, elements ...float64) *FloatSliceCmd
	TDigestCreate(ctx context.Context, key string) *StatusCmd
	TDigestCreateWithCompression(ctx context.Context, key string, compression int64) *StatusCmd
	TDigestInfo(ctx context.Context, key string) *TDigestInfoCmd
	TDigestMax(ctx context.Context, key string) *FloatCmd
	TDigestMin(ctx context.Context, key string) *FloatCmd
	TDigestMerge(ctx context.Context, destKey string, options *TDigestMergeOptions, sourceKeys ...string) *StatusCmd
	TDigestQuantile(ctx context.Context, key string, elements ...float64) *FloatSliceCmd
	TDigestRank(ctx context.Context, key string, values ...float64) *IntSliceCmd
	TDigestReset(ctx context.Context, key string) *StatusCmd
	TDigestRevRank(ctx context.Context, key string, values ...float64) *IntSliceCmd
	TDigestTrimmedMean(ctx context.Context, key string, lowCutQuantile, highCutQuantile float64) *FloatCmd
}

type BFInsertOptions struct {
	Capacity   int64
	Error      float64
	Expansion  int64
	NonScaling bool
	NoCreate   bool
}

type BFReserveOptions struct {
	Capacity   int64
	Error      float64
	Expansion  int64
	NonScaling bool
}

type CFReserveOptions struct {
	Capacity      int64
	BucketSize    int64
	MaxIterations int64
	Expansion     int64
}

type CFInsertOptions struct {
	Capacity int64
	NoCreate bool
}

// -------------------------------------------
// Bloom filter commands
//-------------------------------------------

// BFReserve creates an empty Bloom filter with a single sub-filter
// for the initial specified capacity and with an upper bound error_rate.
// For more information - https://redis.io/commands/bf.reserve/
func ( cmdable) ( context.Context,  string,  float64,  int64) *StatusCmd {
	 := []interface{}{"BF.RESERVE", , , }
	 := NewStatusCmd(, ...)
	_ = (, )
	return 
}

// BFReserveExpansion creates an empty Bloom filter with a single sub-filter
// for the initial specified capacity and with an upper bound error_rate.
// This function also allows for specifying an expansion rate for the filter.
// For more information - https://redis.io/commands/bf.reserve/
func ( cmdable) ( context.Context,  string,  float64, ,  int64) *StatusCmd {
	 := []interface{}{"BF.RESERVE", , , , "EXPANSION", }
	 := NewStatusCmd(, ...)
	_ = (, )
	return 
}

// BFReserveNonScaling creates an empty Bloom filter with a single sub-filter
// for the initial specified capacity and with an upper bound error_rate.
// This function also allows for specifying that the filter should not scale.
// For more information - https://redis.io/commands/bf.reserve/
func ( cmdable) ( context.Context,  string,  float64,  int64) *StatusCmd {
	 := []interface{}{"BF.RESERVE", , , , "NONSCALING"}
	 := NewStatusCmd(, ...)
	_ = (, )
	return 
}

// BFReserveWithArgs creates an empty Bloom filter with a single sub-filter
// for the initial specified capacity and with an upper bound error_rate.
// This function also allows for specifying additional options such as expansion rate and non-scaling behavior.
// For more information - https://redis.io/commands/bf.reserve/
func ( cmdable) ( context.Context,  string,  *BFReserveOptions) *StatusCmd {
	 := []interface{}{"BF.RESERVE", }
	if  != nil {
		 = append(, .Error, .Capacity)
		if .Expansion != 0 {
			 = append(, "EXPANSION", .Expansion)
		}
		if .NonScaling {
			 = append(, "NONSCALING")
		}
	}
	 := NewStatusCmd(, ...)
	_ = (, )
	return 
}

// BFAdd adds an item to a Bloom filter.
// For more information - https://redis.io/commands/bf.add/
func ( cmdable) ( context.Context,  string,  interface{}) *BoolCmd {
	 := []interface{}{"BF.ADD", , }
	 := NewBoolCmd(, ...)
	_ = (, )
	return 
}

// BFCard returns the cardinality of a Bloom filter -
// number of items that were added to a Bloom filter and detected as unique
// (items that caused at least one bit to be set in at least one sub-filter).
// For more information - https://redis.io/commands/bf.card/
func ( cmdable) ( context.Context,  string) *IntCmd {
	 := []interface{}{"BF.CARD", }
	 := NewIntCmd(, ...)
	_ = (, )
	return 
}

// BFExists determines whether a given item was added to a Bloom filter.
// For more information - https://redis.io/commands/bf.exists/
func ( cmdable) ( context.Context,  string,  interface{}) *BoolCmd {
	 := []interface{}{"BF.EXISTS", , }
	 := NewBoolCmd(, ...)
	_ = (, )
	return 
}

// BFLoadChunk restores a Bloom filter previously saved using BF.SCANDUMP.
// For more information - https://redis.io/commands/bf.loadchunk/
func ( cmdable) ( context.Context,  string,  int64,  interface{}) *StatusCmd {
	 := []interface{}{"BF.LOADCHUNK", , , }
	 := NewStatusCmd(, ...)
	_ = (, )
	return 
}

// Begins an incremental save of the Bloom filter.
// This command is useful for large Bloom filters that cannot fit into the DUMP and RESTORE model.
// For more information - https://redis.io/commands/bf.scandump/
func ( cmdable) ( context.Context,  string,  int64) *ScanDumpCmd {
	 := []interface{}{"BF.SCANDUMP", , }
	 := newScanDumpCmd(, ...)
	_ = (, )
	return 
}

type ScanDump struct {
	Iter int64
	Data string
}

type ScanDumpCmd struct {
	baseCmd

	val ScanDump
}

func newScanDumpCmd( context.Context,  ...interface{}) *ScanDumpCmd {
	return &ScanDumpCmd{
		baseCmd: baseCmd{
			ctx:     ,
			args:    ,
			cmdType: CmdTypeScanDump,
		},
	}
}

func ( *ScanDumpCmd) () string {
	.await()
	return cmdString(, .val)
}

func ( *ScanDumpCmd) ( ScanDump) {
	.val = 
}

func ( *ScanDumpCmd) () (ScanDump, error) {
	.await()
	return .val, .err
}

func ( *ScanDumpCmd) () ScanDump {
	.await()
	return .val
}

func ( *ScanDumpCmd) ( *proto.Reader) ( error) {
	,  := .ReadMapLen()
	if  != nil {
		return 
	}
	.val = ScanDump{}
	for  := 0;  < ; ++ {
		,  := .ReadInt()
		if  != nil {
			return 
		}
		,  := .ReadString()
		if  != nil {
			return 
		}
		.val.Data = 
		.val.Iter = 

	}

	return nil
}

func ( *ScanDumpCmd) () Cmder {
	return &ScanDumpCmd{
		baseCmd: .cloneBaseCmd(),
		val:     .val, // ScanDump is a simple struct, can be copied directly
	}
}

// Returns information about a Bloom filter.
// For more information - https://redis.io/commands/bf.info/
func ( cmdable) ( context.Context,  string) *BFInfoCmd {
	 := []interface{}{"BF.INFO", }
	 := NewBFInfoCmd(, ...)
	_ = (, )
	return 
}

type BFInfo struct {
	Capacity      int64
	Size          int64
	Filters       int64
	ItemsInserted int64
	ExpansionRate int64
}

type BFInfoCmd struct {
	baseCmd

	val BFInfo
}

func ( context.Context,  ...interface{}) *BFInfoCmd {
	return &BFInfoCmd{
		baseCmd: baseCmd{
			ctx:     ,
			args:    ,
			cmdType: CmdTypeBFInfo,
		},
	}
}

func ( *BFInfoCmd) ( BFInfo) {
	.val = 
}

func ( *BFInfoCmd) () string {
	.await()
	return cmdString(, .val)
}

func ( *BFInfoCmd) () BFInfo {
	.await()
	return .val
}

func ( *BFInfoCmd) () (BFInfo, error) {
	.await()
	return .val, .err
}

func ( *BFInfoCmd) ( *proto.Reader) ( error) {
	 := BFInfo{}

	// Create a mapping from key names to pointers of struct fields
	 := map[string]*int64{
		"Capacity":                 &.Capacity,
		"CAPACITY":                 &.Capacity,
		"Size":                     &.Size,
		"SIZE":                     &.Size,
		"Number of filters":        &.Filters,
		"FILTERS":                  &.Filters,
		"Number of items inserted": &.ItemsInserted,
		"ITEMS":                    &.ItemsInserted,
		"Expansion rate":           &.ExpansionRate,
		"EXPANSION":                &.ExpansionRate,
	}

	// Helper function to read and assign a value based on the key.
	// Unknown keys are drained and skipped when skipUnknown is set so that
	// fields added by newer servers don't break the parser.
	 := func( string,  bool) error {
		,  := []
		if ! {
			if  {
				return .DiscardNext()
			}
			return fmt.Errorf("redis: BLOOM.INFO unexpected key %s", )
		}

		// Read the integer and assign to the field via pointer dereferencing
		,  := .ReadInt()
		if  != nil {
			return 
		}
		* = 
		return nil
	}

	,  := .PeekReplyType()
	if  != nil {
		return 
	}

	if len(.args) > 2 &&  == proto.RespArray {
		,  := .ReadArrayLen()
		if  != nil {
			return 
		}
		if ,  := .args[2].(string);  &&  == 1 {
			if  := (, false);  != nil {
				return 
			}
		} else {
			return fmt.Errorf("redis: BLOOM.INFO invalid argument key type")
		}
	} else {
		,  := .ReadMapLen()
		if  != nil {
			return 
		}
		for  := 0;  < ; ++ {
			,  := .ReadString()
			if  != nil {
				return 
			}
			if  := (, true);  != nil {
				return 
			}
		}
	}

	.val = 
	return nil
}

func ( *BFInfoCmd) () Cmder {
	return &BFInfoCmd{
		baseCmd: .cloneBaseCmd(),
		val:     .val, // BFInfo is a simple struct, can be copied directly
	}
}

// BFInfoCapacity returns information about the capacity of a Bloom filter.
// For more information - https://redis.io/commands/bf.info/
func ( cmdable) ( context.Context,  string) *BFInfoCmd {
	return .BFInfoArg(, , "CAPACITY")
}

// BFInfoSize returns information about the size of a Bloom filter.
// For more information - https://redis.io/commands/bf.info/
func ( cmdable) ( context.Context,  string) *BFInfoCmd {
	return .BFInfoArg(, , "SIZE")
}

// BFInfoFilters returns information about the filters of a Bloom filter.
// For more information - https://redis.io/commands/bf.info/
func ( cmdable) ( context.Context,  string) *BFInfoCmd {
	return .BFInfoArg(, , "FILTERS")
}

// BFInfoItems returns information about the items of a Bloom filter.
// For more information - https://redis.io/commands/bf.info/
func ( cmdable) ( context.Context,  string) *BFInfoCmd {
	return .BFInfoArg(, , "ITEMS")
}

// BFInfoExpansion returns information about the expansion rate of a Bloom filter.
// For more information - https://redis.io/commands/bf.info/
func ( cmdable) ( context.Context,  string) *BFInfoCmd {
	return .BFInfoArg(, , "EXPANSION")
}

// BFInfoArg returns information about a specific option of a Bloom filter.
// For more information - https://redis.io/commands/bf.info/
func ( cmdable) ( context.Context, ,  string) *BFInfoCmd {
	 := []interface{}{"BF.INFO", , }
	 := NewBFInfoCmd(, ...)
	_ = (, )
	return 
}

// BFInsert inserts elements into a Bloom filter.
// This function also allows for specifying additional options such as:
// capacity, error rate, expansion rate, and non-scaling behavior.
// For more information - https://redis.io/commands/bf.insert/
func ( cmdable) ( context.Context,  string,  *BFInsertOptions,  ...interface{}) *BoolSliceCmd {
	 := []interface{}{"BF.INSERT", }
	if  != nil {
		if .Capacity != 0 {
			 = append(, "CAPACITY", .Capacity)
		}
		if .Error != 0 {
			 = append(, "ERROR", .Error)
		}
		if .Expansion != 0 {
			 = append(, "EXPANSION", .Expansion)
		}
		if .NoCreate {
			 = append(, "NOCREATE")
		}
		if .NonScaling {
			 = append(, "NONSCALING")
		}
	}
	 = append(, "ITEMS")
	 = append(, ...)

	 := NewBoolSliceCmd(, ...)
	_ = (, )
	return 
}

// BFMAdd adds multiple elements to a Bloom filter.
// Returns an array of booleans indicating whether each element was added to the filter or not.
// For more information - https://redis.io/commands/bf.madd/
func ( cmdable) ( context.Context,  string,  ...interface{}) *BoolSliceCmd {
	 := []interface{}{"BF.MADD", }
	 = append(, ...)
	 := NewBoolSliceCmd(, ...)
	_ = (, )
	return 
}

// BFMExists check if multiple elements exist in a Bloom filter.
// Returns an array of booleans indicating whether each element exists in the filter or not.
// For more information - https://redis.io/commands/bf.mexists/
func ( cmdable) ( context.Context,  string,  ...interface{}) *BoolSliceCmd {
	 := []interface{}{"BF.MEXISTS", }
	 = append(, ...)

	 := NewBoolSliceCmd(, ...)
	_ = (, )
	return 
}

// -------------------------------------------
// Cuckoo filter commands
//-------------------------------------------

// CFReserve creates an empty Cuckoo filter with the specified capacity.
// For more information - https://redis.io/commands/cf.reserve/
func ( cmdable) ( context.Context,  string,  int64) *StatusCmd {
	 := []interface{}{"CF.RESERVE", , }
	 := NewStatusCmd(, ...)
	_ = (, )
	return 
}

// CFReserveExpansion creates an empty Cuckoo filter with the specified capacity and expansion rate.
// For more information - https://redis.io/commands/cf.reserve/
func ( cmdable) ( context.Context,  string,  int64,  int64) *StatusCmd {
	 := []interface{}{"CF.RESERVE", , , "EXPANSION", }
	 := NewStatusCmd(, ...)
	_ = (, )
	return 
}

// CFReserveBucketSize creates an empty Cuckoo filter with the specified capacity and bucket size.
// For more information - https://redis.io/commands/cf.reserve/
func ( cmdable) ( context.Context,  string,  int64,  int64) *StatusCmd {
	 := []interface{}{"CF.RESERVE", , , "BUCKETSIZE", }
	 := NewStatusCmd(, ...)
	_ = (, )
	return 
}

// CFReserveMaxIterations creates an empty Cuckoo filter with the specified capacity and maximum number of iterations.
// For more information - https://redis.io/commands/cf.reserve/
func ( cmdable) ( context.Context,  string,  int64,  int64) *StatusCmd {
	 := []interface{}{"CF.RESERVE", , , "MAXITERATIONS", }
	 := NewStatusCmd(, ...)
	_ = (, )
	return 
}

// CFReserveWithArgs creates an empty Cuckoo filter with the specified options.
// This function allows for specifying additional options such as bucket size and maximum number of iterations.
// For more information - https://redis.io/commands/cf.reserve/
func ( cmdable) ( context.Context,  string,  *CFReserveOptions) *StatusCmd {
	 := []interface{}{"CF.RESERVE", , .Capacity}
	if .BucketSize != 0 {
		 = append(, "BUCKETSIZE", .BucketSize)
	}
	if .MaxIterations != 0 {
		 = append(, "MAXITERATIONS", .MaxIterations)
	}
	if .Expansion != 0 {
		 = append(, "EXPANSION", .Expansion)
	}
	 := NewStatusCmd(, ...)
	_ = (, )
	return 
}

// CFAdd adds an element to a Cuckoo filter.
// Returns true if the element was added to the filter or false if it already exists in the filter.
// For more information - https://redis.io/commands/cf.add/
func ( cmdable) ( context.Context,  string,  interface{}) *BoolCmd {
	 := []interface{}{"CF.ADD", , }
	 := NewBoolCmd(, ...)
	_ = (, )
	return 
}

// CFAddNX adds an element to a Cuckoo filter only if it does not already exist in the filter.
// Returns true if the element was added to the filter or false if it already exists in the filter.
// For more information - https://redis.io/commands/cf.addnx/
func ( cmdable) ( context.Context,  string,  interface{}) *BoolCmd {
	 := []interface{}{"CF.ADDNX", , }
	 := NewBoolCmd(, ...)
	_ = (, )
	return 
}

// CFCount returns an estimate of the number of times an element may be in a Cuckoo Filter.
// For more information - https://redis.io/commands/cf.count/
func ( cmdable) ( context.Context,  string,  interface{}) *IntCmd {
	 := []interface{}{"CF.COUNT", , }
	 := NewIntCmd(, ...)
	_ = (, )
	return 
}

// CFDel deletes an item once from the cuckoo filter.
// For more information - https://redis.io/commands/cf.del/
func ( cmdable) ( context.Context,  string,  interface{}) *BoolCmd {
	 := []interface{}{"CF.DEL", , }
	 := NewBoolCmd(, ...)
	_ = (, )
	return 
}

// CFExists determines whether an item may exist in the Cuckoo Filter or not.
// For more information - https://redis.io/commands/cf.exists/
func ( cmdable) ( context.Context,  string,  interface{}) *BoolCmd {
	 := []interface{}{"CF.EXISTS", , }
	 := NewBoolCmd(, ...)
	_ = (, )
	return 
}

// CFLoadChunk restores a filter previously saved using SCANDUMP.
// For more information - https://redis.io/commands/cf.loadchunk/
func ( cmdable) ( context.Context,  string,  int64,  interface{}) *StatusCmd {
	 := []interface{}{"CF.LOADCHUNK", , , }
	 := NewStatusCmd(, ...)
	_ = (, )
	return 
}

// CFScanDump begins an incremental save of the cuckoo filter.
// For more information - https://redis.io/commands/cf.scandump/
func ( cmdable) ( context.Context,  string,  int64) *ScanDumpCmd {
	 := []interface{}{"CF.SCANDUMP", , }
	 := newScanDumpCmd(, ...)
	_ = (, )
	return 
}

type CFInfo struct {
	Size             int64
	NumBuckets       int64
	NumFilters       int64
	NumItemsInserted int64
	NumItemsDeleted  int64
	BucketSize       int64
	ExpansionRate    int64
	MaxIteration     int64
}

type CFInfoCmd struct {
	baseCmd

	val CFInfo
}

func ( context.Context,  ...interface{}) *CFInfoCmd {
	return &CFInfoCmd{
		baseCmd: baseCmd{
			ctx:     ,
			args:    ,
			cmdType: CmdTypeCFInfo,
		},
	}
}

func ( *CFInfoCmd) ( CFInfo) {
	.val = 
}

func ( *CFInfoCmd) () string {
	.await()
	return cmdString(, .val)
}

func ( *CFInfoCmd) () CFInfo {
	.await()
	return .val
}

func ( *CFInfoCmd) () (CFInfo, error) {
	.await()
	return .val, .err
}

func ( *CFInfoCmd) ( *proto.Reader) ( error) {
	,  := .ReadMapLen()
	if  != nil {
		return 
	}

	var  string
	var  CFInfo
	for  := 0;  < ; ++ {
		,  = .ReadString()
		if  != nil {
			return 
		}

		switch  {
		case "Size":
			.Size,  = .ReadInt()
		case "Number of buckets":
			.NumBuckets,  = .ReadInt()
		case "Number of filters":
			.NumFilters,  = .ReadInt()
		case "Number of items inserted":
			.NumItemsInserted,  = .ReadInt()
		case "Number of items deleted":
			.NumItemsDeleted,  = .ReadInt()
		case "Bucket size":
			.BucketSize,  = .ReadInt()
		case "Expansion rate":
			.ExpansionRate,  = .ReadInt()
		case "Max iterations":
			.MaxIteration,  = .ReadInt()

		default:
			// skip unknown fields so newer servers don't break the parser
			 = .DiscardNext()
		}

		if  != nil {
			return 
		}
	}

	.val = 
	return nil
}

func ( *CFInfoCmd) () Cmder {
	return &CFInfoCmd{
		baseCmd: .cloneBaseCmd(),
		val:     .val, // CFInfo is a simple struct, can be copied directly
	}
}

// CFInfo returns information about a Cuckoo filter.
// For more information - https://redis.io/commands/cf.info/
func ( cmdable) ( context.Context,  string) *CFInfoCmd {
	 := []interface{}{"CF.INFO", }
	 := NewCFInfoCmd(, ...)
	_ = (, )
	return 
}

// CFInsert inserts elements into a Cuckoo filter.
// This function also allows for specifying additional options such as capacity, error rate, expansion rate, and non-scaling behavior.
// Returns an array of booleans indicating whether each element was added to the filter or not.
// For more information - https://redis.io/commands/cf.insert/
func ( cmdable) ( context.Context,  string,  *CFInsertOptions,  ...interface{}) *BoolSliceCmd {
	 := []interface{}{"CF.INSERT", }
	 = .getCfInsertWithArgs(, , ...)

	 := NewBoolSliceCmd(, ...)
	_ = (, )
	return 
}

// CFInsertNX inserts elements into a Cuckoo filter only if they do not already exist in the filter.
// This function also allows for specifying additional options such as:
// capacity, error rate, expansion rate, and non-scaling behavior.
// Returns an array of integers indicating whether each element was added to the filter or not.
// For more information - https://redis.io/commands/cf.insertnx/
func ( cmdable) ( context.Context,  string,  *CFInsertOptions,  ...interface{}) *IntSliceCmd {
	 := []interface{}{"CF.INSERTNX", }
	 = .getCfInsertWithArgs(, , ...)

	 := NewIntSliceCmd(, ...)
	_ = (, )
	return 
}

func ( cmdable) ( []interface{},  *CFInsertOptions,  ...interface{}) []interface{} {
	if  != nil {
		if .Capacity != 0 {
			 = append(, "CAPACITY", .Capacity)
		}
		if .NoCreate {
			 = append(, "NOCREATE")
		}
	}
	 = append(, "ITEMS")
	 = append(, ...)

	return 
}

// CFMExists check if multiple elements exist in a Cuckoo filter.
// Returns an array of booleans indicating whether each element exists in the filter or not.
// For more information - https://redis.io/commands/cf.mexists/
func ( cmdable) ( context.Context,  string,  ...interface{}) *BoolSliceCmd {
	 := []interface{}{"CF.MEXISTS", }
	 = append(, ...)
	 := NewBoolSliceCmd(, ...)
	_ = (, )
	return 
}

// -------------------------------------------
// CMS commands
//-------------------------------------------

// CMSIncrBy increments the count of one or more items in a Count-Min Sketch filter.
// Returns an array of integers representing the updated count of each item.
// For more information - https://redis.io/commands/cms.incrby/
func ( cmdable) ( context.Context,  string,  ...interface{}) *IntSliceCmd {
	 := make([]interface{}, 2, 2+len())
	[0] = "CMS.INCRBY"
	[1] = 
	 = appendArgs(, )

	 := NewIntSliceCmd(, ...)
	_ = (, )
	return 
}

type CMSInfo struct {
	Width int64
	Depth int64
	Count int64
	// CellSize is the size in bytes of each counter (1, 2, 4 or 8).
	// Reported since Redis 8.12, alongside the CELL_SIZE option of
	// CMS.INITBYDIM / CMS.INITBYPROB; zero on older servers.
	CellSize int64
}

type CMSInfoCmd struct {
	baseCmd

	val CMSInfo
}

func ( context.Context,  ...interface{}) *CMSInfoCmd {
	return &CMSInfoCmd{
		baseCmd: baseCmd{
			ctx:     ,
			args:    ,
			cmdType: CmdTypeCMSInfo,
		},
	}
}

func ( *CMSInfoCmd) ( CMSInfo) {
	.val = 
}

func ( *CMSInfoCmd) () string {
	.await()
	return cmdString(, .val)
}

func ( *CMSInfoCmd) () CMSInfo {
	.await()
	return .val
}

func ( *CMSInfoCmd) () (CMSInfo, error) {
	.await()
	return .val, .err
}

func ( *CMSInfoCmd) ( *proto.Reader) ( error) {
	,  := .ReadMapLen()
	if  != nil {
		return 
	}

	var  string
	var  CMSInfo
	for  := 0;  < ; ++ {
		,  = .ReadString()
		if  != nil {
			return 
		}

		switch  {
		case "width":
			.Width,  = .ReadInt()
		case "depth":
			.Depth,  = .ReadInt()
		case "count":
			.Count,  = .ReadInt()
		case "cell_size":
			.CellSize,  = .ReadInt()
		default:
			// skip unknown fields so newer servers don't break the parser
			 = .DiscardNext()
		}

		if  != nil {
			return 
		}
	}

	.val = 
	return nil
}

func ( *CMSInfoCmd) () Cmder {
	return &CMSInfoCmd{
		baseCmd: .cloneBaseCmd(),
		val:     .val, // CMSInfo is a simple struct, can be copied directly
	}
}

// CMSInfo returns information about a Count-Min Sketch filter.
// For more information - https://redis.io/commands/cms.info/
func ( cmdable) ( context.Context,  string) *CMSInfoCmd {
	 := []interface{}{"CMS.INFO", }
	 := NewCMSInfoCmd(, ...)
	_ = (, )
	return 
}

// CMSInitByDim creates an empty Count-Min Sketch filter with the specified dimensions.
// For more information - https://redis.io/commands/cms.initbydim/
func ( cmdable) ( context.Context,  string, ,  int64) *StatusCmd {
	 := []interface{}{"CMS.INITBYDIM", , , }
	 := NewStatusCmd(, ...)
	_ = (, )
	return 
}

// CMSInitByProb creates an empty Count-Min Sketch filter with the specified error rate and probability.
// For more information - https://redis.io/commands/cms.initbyprob/
func ( cmdable) ( context.Context,  string, ,  float64) *StatusCmd {
	 := []interface{}{"CMS.INITBYPROB", , , }
	 := NewStatusCmd(, ...)
	_ = (, )
	return 
}

// CMSMerge merges multiple Count-Min Sketch filters into a single filter.
// The destination filter must not exist and will be created with the dimensions of the first source filter.
// The number of items in each source filter must be equal.
// Returns OK on success or an error if the filters could not be merged.
// For more information - https://redis.io/commands/cms.merge/
func ( cmdable) ( context.Context,  string,  ...string) *StatusCmd {
	 := []interface{}{"CMS.MERGE", , len()}
	for ,  := range  {
		 = append(, )
	}
	 := NewStatusCmd(, ...)
	_ = (, )
	return 
}

// CMSMergeWithWeight merges multiple Count-Min Sketch filters into a single filter with weights for each source filter.
// The destination filter must not exist and will be created with the dimensions of the first source filter.
// The number of items in each source filter must be equal.
// Returns OK on success or an error if the filters could not be merged.
// For more information - https://redis.io/commands/cms.merge/
func ( cmdable) ( context.Context,  string,  map[string]int64) *StatusCmd {
	 := make([]interface{}, 0, 4+(len()*2+1))
	 = append(, "CMS.MERGE", , len())

	if len() > 0 {
		 := make([]interface{}, len())
		 := make([]interface{}, len())

		 := 0
		for ,  := range  {
			[] = 
			[] = 
			++
		}

		 = append(, ...)
		 = append(, "WEIGHTS")
		 = append(, ...)
	}

	 := NewStatusCmd(, ...)
	_ = (, )
	return 
}

// CMSQuery returns count for item(s).
// For more information - https://redis.io/commands/cms.query/
func ( cmdable) ( context.Context,  string,  ...interface{}) *IntSliceCmd {
	 := []interface{}{"CMS.QUERY", }
	 = append(, ...)
	 := NewIntSliceCmd(, ...)
	_ = (, )
	return 
}

// -------------------------------------------
// TopK commands
//--------------------------------------------

// TopKAdd adds one or more elements to a Top-K filter.
// Returns an array of strings representing the items that were removed from the filter, if any.
// For more information - https://redis.io/commands/topk.add/
func ( cmdable) ( context.Context,  string,  ...interface{}) *StringSliceCmd {
	 := make([]interface{}, 2, 2+len())
	[0] = "TOPK.ADD"
	[1] = 
	 = appendArgs(, )

	 := NewStringSliceCmd(, ...)
	_ = (, )
	return 
}

// TopKReserve creates an empty Top-K filter with the specified number of top items to keep.
// For more information - https://redis.io/commands/topk.reserve/
func ( cmdable) ( context.Context,  string,  int64) *StatusCmd {
	 := []interface{}{"TOPK.RESERVE", , }

	 := NewStatusCmd(, ...)
	_ = (, )
	return 
}

// TopKReserveWithOptions creates an empty Top-K filter with the specified number of top items to keep and additional options.
// This function allows for specifying additional options such as width, depth and decay.
// For more information - https://redis.io/commands/topk.reserve/
func ( cmdable) ( context.Context,  string,  int64, ,  int64,  float64) *StatusCmd {
	 := []interface{}{"TOPK.RESERVE", , , , , }

	 := NewStatusCmd(, ...)
	_ = (, )
	return 
}

type TopKInfo struct {
	K     int64
	Width int64
	Depth int64
	Decay float64
}

type TopKInfoCmd struct {
	baseCmd

	val TopKInfo
}

func ( context.Context,  ...interface{}) *TopKInfoCmd {
	return &TopKInfoCmd{
		baseCmd: baseCmd{
			ctx:     ,
			args:    ,
			cmdType: CmdTypeTopKInfo,
		},
	}
}

func ( *TopKInfoCmd) ( TopKInfo) {
	.val = 
}

func ( *TopKInfoCmd) () string {
	.await()
	return cmdString(, .val)
}

func ( *TopKInfoCmd) () TopKInfo {
	.await()
	return .val
}

func ( *TopKInfoCmd) () (TopKInfo, error) {
	.await()
	return .val, .err
}

func ( *TopKInfoCmd) ( *proto.Reader) ( error) {
	,  := .ReadMapLen()
	if  != nil {
		return 
	}

	var  string
	var  TopKInfo
	for  := 0;  < ; ++ {
		,  = .ReadString()
		if  != nil {
			return 
		}

		switch  {
		case "k":
			.K,  = .ReadInt()
		case "width":
			.Width,  = .ReadInt()
		case "depth":
			.Depth,  = .ReadInt()
		case "decay":
			.Decay,  = .ReadFloat()
		default:
			// skip unknown fields so newer servers don't break the parser
			 = .DiscardNext()
		}

		if  != nil {
			return 
		}
	}

	.val = 
	return nil
}

func ( *TopKInfoCmd) () Cmder {
	return &TopKInfoCmd{
		baseCmd: .cloneBaseCmd(),
		val:     .val, // TopKInfo is a simple struct, can be copied directly
	}
}

// TopKInfo returns information about a Top-K filter.
// For more information - https://redis.io/commands/topk.info/
func ( cmdable) ( context.Context,  string) *TopKInfoCmd {
	 := []interface{}{"TOPK.INFO", }

	 := NewTopKInfoCmd(, ...)
	_ = (, )
	return 
}

// TopKQuery check if multiple elements exist in a Top-K filter.
// Returns an array of booleans indicating whether each element exists in the filter or not.
// For more information - https://redis.io/commands/topk.query/
func ( cmdable) ( context.Context,  string,  ...interface{}) *BoolSliceCmd {
	 := make([]interface{}, 2, 2+len())
	[0] = "TOPK.QUERY"
	[1] = 
	 = appendArgs(, )

	 := NewBoolSliceCmd(, ...)
	_ = (, )
	return 
}

// TopKCount returns an estimate of the number of times an item may be in a Top-K filter.
// For more information - https://redis.io/commands/topk.count/
func ( cmdable) ( context.Context,  string,  ...interface{}) *IntSliceCmd {
	 := make([]interface{}, 2, 2+len())
	[0] = "TOPK.COUNT"
	[1] = 
	 = appendArgs(, )

	 := NewIntSliceCmd(, ...)
	_ = (, )
	return 
}

// TopKIncrBy increases the count of one or more items in a Top-K filter.
// For more information - https://redis.io/commands/topk.incrby/
func ( cmdable) ( context.Context,  string,  ...interface{}) *StringSliceCmd {
	 := make([]interface{}, 2, 2+len())
	[0] = "TOPK.INCRBY"
	[1] = 
	 = appendArgs(, )

	 := NewStringSliceCmd(, ...)
	_ = (, )
	return 
}

// TopKList returns all items in Top-K list.
// For more information - https://redis.io/commands/topk.list/
func ( cmdable) ( context.Context,  string) *StringSliceCmd {
	 := []interface{}{"TOPK.LIST", }

	 := NewStringSliceCmd(, ...)
	_ = (, )
	return 
}

// TopKListWithCount returns all items in Top-K list with their respective count.
// For more information - https://redis.io/commands/topk.list/
func ( cmdable) ( context.Context,  string) *MapStringIntCmd {
	 := []interface{}{"TOPK.LIST", , "WITHCOUNT"}

	 := NewMapStringIntCmd(, ...)
	_ = (, )
	return 
}

// -------------------------------------------
// t-digest commands
// --------------------------------------------

// TDigestAdd adds one or more elements to a t-Digest data structure.
// Returns OK on success or an error if the operation could not be completed.
// For more information - https://redis.io/commands/tdigest.add/
func ( cmdable) ( context.Context,  string,  ...float64) *StatusCmd {
	 := make([]interface{}, 2+len())
	[0] = "TDIGEST.ADD"
	[1] = 

	for ,  := range  {
		[2+] = 
	}

	 := NewStatusCmd(, ...)
	_ = (, )
	return 
}

// TDigestByRank returns an array of values from a t-Digest data structure based on their rank.
// The rank of an element is its position in the sorted list of all elements in the t-Digest.
// Returns an array of floats representing the values at the specified ranks or an error if the operation could not be completed.
// For more information - https://redis.io/commands/tdigest.byrank/
func ( cmdable) ( context.Context,  string,  ...uint64) *FloatSliceCmd {
	 := make([]interface{}, 2+len())
	[0] = "TDIGEST.BYRANK"
	[1] = 

	for ,  := range  {
		[2+] = 
	}

	 := NewFloatSliceCmd(, ...)
	_ = (, )
	return 
}

// TDigestByRevRank returns an array of values from a t-Digest data structure based on their reverse rank.
// The reverse rank of an element is its position in the sorted list of all elements in the t-Digest when sorted in descending order.
// Returns an array of floats representing the values at the specified ranks or an error if the operation could not be completed.
// For more information - https://redis.io/commands/tdigest.byrevrank/
func ( cmdable) ( context.Context,  string,  ...uint64) *FloatSliceCmd {
	 := make([]interface{}, 2+len())
	[0] = "TDIGEST.BYREVRANK"
	[1] = 

	for ,  := range  {
		[2+] = 
	}

	 := NewFloatSliceCmd(, ...)
	_ = (, )
	return 
}

// TDigestCDF returns an array of cumulative distribution function (CDF) values for one or more elements in a t-Digest data structure.
// The CDF value for an element is the fraction of all elements in the t-Digest that are less than or equal to it.
// Returns an array of floats representing the CDF values for each element or an error if the operation could not be completed.
// For more information - https://redis.io/commands/tdigest.cdf/
func ( cmdable) ( context.Context,  string,  ...float64) *FloatSliceCmd {
	 := make([]interface{}, 2+len())
	[0] = "TDIGEST.CDF"
	[1] = 

	for ,  := range  {
		[2+] = 
	}

	 := NewFloatSliceCmd(, ...)
	_ = (, )
	return 
}

// TDigestCreate creates an empty t-Digest data structure with default parameters.
// Returns OK on success or an error if the operation could not be completed.
// For more information - https://redis.io/commands/tdigest.create/
func ( cmdable) ( context.Context,  string) *StatusCmd {
	 := []interface{}{"TDIGEST.CREATE", }

	 := NewStatusCmd(, ...)
	_ = (, )
	return 
}

// TDigestCreateWithCompression creates an empty t-Digest data structure with a specified compression parameter.
// The compression parameter controls the accuracy and memory usage of the t-Digest.
// Returns OK on success or an error if the operation could not be completed.
// For more information - https://redis.io/commands/tdigest.create/
func ( cmdable) ( context.Context,  string,  int64) *StatusCmd {
	 := []interface{}{"TDIGEST.CREATE", , "COMPRESSION", }

	 := NewStatusCmd(, ...)
	_ = (, )
	return 
}

type TDigestInfo struct {
	Compression       int64
	Capacity          int64
	MergedNodes       int64
	UnmergedNodes     int64
	MergedWeight      int64
	UnmergedWeight    int64
	Observations      int64
	TotalCompressions int64
	MemoryUsage       int64
}

type TDigestInfoCmd struct {
	baseCmd

	val TDigestInfo
}

func ( context.Context,  ...interface{}) *TDigestInfoCmd {
	return &TDigestInfoCmd{
		baseCmd: baseCmd{
			ctx:     ,
			args:    ,
			cmdType: CmdTypeTDigestInfo,
		},
	}
}

func ( *TDigestInfoCmd) ( TDigestInfo) {
	.val = 
}

func ( *TDigestInfoCmd) () string {
	.await()
	return cmdString(, .val)
}

func ( *TDigestInfoCmd) () TDigestInfo {
	.await()
	return .val
}

func ( *TDigestInfoCmd) () (TDigestInfo, error) {
	.await()
	return .val, .err
}

func ( *TDigestInfoCmd) ( *proto.Reader) ( error) {
	,  := .ReadMapLen()
	if  != nil {
		return 
	}

	var  string
	var  TDigestInfo
	for  := 0;  < ; ++ {
		,  = .ReadString()
		if  != nil {
			return 
		}

		switch  {
		case "Compression":
			.Compression,  = .ReadInt()
		case "Capacity":
			.Capacity,  = .ReadInt()
		case "Merged nodes":
			.MergedNodes,  = .ReadInt()
		case "Unmerged nodes":
			.UnmergedNodes,  = .ReadInt()
		case "Merged weight":
			.MergedWeight,  = .ReadInt()
		case "Unmerged weight":
			.UnmergedWeight,  = .ReadInt()
		case "Observations":
			.Observations,  = .ReadInt()
		case "Total compressions":
			.TotalCompressions,  = .ReadInt()
		case "Memory usage":
			.MemoryUsage,  = .ReadInt()
		default:
			// skip unknown fields so newer servers don't break the parser
			 = .DiscardNext()
		}

		if  != nil {
			return 
		}
	}

	.val = 
	return nil
}

func ( *TDigestInfoCmd) () Cmder {
	return &TDigestInfoCmd{
		baseCmd: .cloneBaseCmd(),
		val:     .val, // TDigestInfo is a simple struct, can be copied directly
	}
}

// TDigestInfo returns information about a t-Digest data structure.
// For more information - https://redis.io/commands/tdigest.info/
func ( cmdable) ( context.Context,  string) *TDigestInfoCmd {
	 := []interface{}{"TDIGEST.INFO", }

	 := NewTDigestInfoCmd(, ...)
	_ = (, )
	return 
}

// TDigestMax returns the maximum value from a t-Digest data structure.
// For more information - https://redis.io/commands/tdigest.max/
func ( cmdable) ( context.Context,  string) *FloatCmd {
	 := []interface{}{"TDIGEST.MAX", }

	 := NewFloatCmd(, ...)
	_ = (, )
	return 
}

type TDigestMergeOptions struct {
	Compression int64
	Override    bool
}

// TDigestMerge merges multiple t-Digest data structures into a single t-Digest.
// This function also allows for specifying additional options such as compression and override behavior.
// Returns OK on success or an error if the operation could not be completed.
// For more information - https://redis.io/commands/tdigest.merge/
func ( cmdable) ( context.Context,  string,  *TDigestMergeOptions,  ...string) *StatusCmd {
	 := []interface{}{"TDIGEST.MERGE", , len()}

	for ,  := range  {
		 = append(, )
	}

	if  != nil {
		if .Compression != 0 {
			 = append(, "COMPRESSION", .Compression)
		}
		if .Override {
			 = append(, "OVERRIDE")
		}
	}

	 := NewStatusCmd(, ...)
	_ = (, )
	return 
}

// TDigestMin returns the minimum value from a t-Digest data structure.
// For more information - https://redis.io/commands/tdigest.min/
func ( cmdable) ( context.Context,  string) *FloatCmd {
	 := []interface{}{"TDIGEST.MIN", }

	 := NewFloatCmd(, ...)
	_ = (, )
	return 
}

// TDigestQuantile returns an array of quantile values for one or more elements in a t-Digest data structure.
// The quantile value for an element is the fraction of all elements in the t-Digest that are less than or equal to it.
// Returns an array of floats representing the quantile values for each element or an error if the operation could not be completed.
// For more information - https://redis.io/commands/tdigest.quantile/
func ( cmdable) ( context.Context,  string,  ...float64) *FloatSliceCmd {
	 := make([]interface{}, 2+len())
	[0] = "TDIGEST.QUANTILE"
	[1] = 

	for ,  := range  {
		[2+] = 
	}

	 := NewFloatSliceCmd(, ...)
	_ = (, )
	return 
}

// TDigestRank returns an array of rank values for one or more elements in a t-Digest data structure.
// The rank of an element is its position in the sorted list of all elements in the t-Digest.
// Returns an array of integers representing the rank values for each element or an error if the operation could not be completed.
// For more information - https://redis.io/commands/tdigest.rank/
func ( cmdable) ( context.Context,  string,  ...float64) *IntSliceCmd {
	 := make([]interface{}, 2+len())
	[0] = "TDIGEST.RANK"
	[1] = 

	for ,  := range  {
		[+2] = 
	}

	 := NewIntSliceCmd(, ...)
	_ = (, )
	return 
}

// TDigestReset resets a t-Digest data structure to its initial state.
// Returns OK on success or an error if the operation could not be completed.
// For more information - https://redis.io/commands/tdigest.reset/
func ( cmdable) ( context.Context,  string) *StatusCmd {
	 := []interface{}{"TDIGEST.RESET", }

	 := NewStatusCmd(, ...)
	_ = (, )
	return 
}

// TDigestRevRank returns an array of reverse rank values for one or more elements in a t-Digest data structure.
// The reverse rank of an element is its position in the sorted list of all elements in the t-Digest when sorted in descending order.
// Returns an array of integers representing the reverse rank values for each element or an error if the operation could not be completed.
// For more information - https://redis.io/commands/tdigest.revrank/
func ( cmdable) ( context.Context,  string,  ...float64) *IntSliceCmd {
	 := make([]interface{}, 2+len())
	[0] = "TDIGEST.REVRANK"
	[1] = 

	for ,  := range  {
		[2+] = 
	}

	 := NewIntSliceCmd(, ...)
	_ = (, )
	return 
}

// TDigestTrimmedMean returns the trimmed mean value from a t-Digest data structure.
// The trimmed mean is calculated by removing a specified fraction of the highest and lowest values from the t-Digest and then calculating the mean of the remaining values.
// Returns a float representing the trimmed mean value or an error if the operation could not be completed.
// For more information - https://redis.io/commands/tdigest.trimmed_mean/
func ( cmdable) ( context.Context,  string, ,  float64) *FloatCmd {
	 := []interface{}{"TDIGEST.TRIMMED_MEAN", , , }

	 := NewFloatCmd(, ...)
	_ = (, )
	return 
}