Documentation
¶
Index ¶
- Constants
- Variables
- func ByteSliceToByteArrayObj(store *dstore.Store, oldObj *object.Obj, b []byte) (*object.Obj, error)
- func ByteSliceToIntObj(store *dstore.Store, oldObj *object.Obj, b []byte) (*object.Obj, error)
- func ByteSliceToObj(store *dstore.Store, oldObj *object.Obj, b []byte, objType object.ObjectType) (*object.Obj, error)
- func ByteSliceToStringObj(store *dstore.Store, oldObj *object.Obj, b []byte) (*object.Obj, error)
- func DecodeDeqEntry(xb []byte) (x string, entryLen int)
- func Encode(value interface{}, isSimple bool) []byte
- func EncodeDeqEntry(x string) []byte
- func EncodeDeqEntryInPlace(x string, buf []byte)
- func EncodeDeqInt(v int64) []byte
- func EncodeDeqIntInPlace(v int64, buf []byte)
- func EncodeDeqStr(x string) []byte
- func EncodeDeqStrInPlace(x string, buf []byte)
- func EvalAUTH(args []string, c *comm.Client) []byte
- func GetEncodeDeqEntrySize(x string) uint64
- func GetEncodeDeqIntSize(v int64) uint64
- func GetEncodeDeqStrSize(x string) uint64
- func IsInt64(v interface{}) bool
- func IsString(v interface{}) bool
- type Bloom
- func CreateOrReplaceBloomFilter(key string, opts *BloomOpts, store *dstore.Store) *Bloom
- func DeserializeBloom(buf *bytes.Reader) (*Bloom, error)
- func GetBloomFilter(key string, store *dstore.Store) (*Bloom, error)
- func GetOrCreateBloomFilter(key string, store *dstore.Store, opts *BloomOpts) (*Bloom, error)
- func NewBloomFilter(opts *BloomOpts) *Bloom
- type BloomOpts
- type ByteArray
- type CountMinSketch
- type CountMinSketchOpts
- type Deque
- func (q *Deque) GetLength() int64
- func (q *Deque) LInsert(pivot, element, beforeAfter string) (int64, error)
- func (q *Deque) LPop() (string, error)
- func (q *Deque) LPush(x string)
- func (q *Deque) LRange(start, stop int64) ([]string, error)
- func (q *Deque) NewIterator() *DequeIterator
- func (q *Deque) RPop() (string, error)
- func (q *Deque) RPush(x string)
- func (q *Deque) Serialize(buf *bytes.Buffer) error
- type DequeBasic
- func (q *DequeBasic) GetLength() int64
- func (q *DequeBasic) LInsert(pivot, element, beforeAfter string) (int64, error)
- func (q *DequeBasic) LPop() (string, error)
- func (q *DequeBasic) LPush(x string)
- func (q *DequeBasic) LRange(start, stop int64) ([]string, error)
- func (q *DequeBasic) NewIterator() *DequeBasicIterator
- func (q *DequeBasic) RPop() (string, error)
- func (q *DequeBasic) RPush(x string)
- type DequeBasicIterator
- type DequeI
- type DequeIterator
- type DiceCmdMeta
- type Eval
- type EvalResponse
- type HashMap
- type KeySpecs
- type RespType
- type String
Constants ¶
const ( BYTE = "BYTE" BIT = "BIT" AND string = "AND" OR string = "OR" XOR string = "XOR" NOT string = "NOT" Ex string = "EX" Px string = "PX" Persist string = "PERSIST" Pxat string = "PXAT" Exat string = "EXAT" XX string = "XX" NX string = "NX" GT string = "GT" LT string = "LT" CH string = "CH" INCR string = "INCR" KeepTTL string = "KEEPTTL" Sync string = "SYNC" Async string = "ASYNC" Help string = "HELP" Memory string = "MEMORY" Count string = "COUNT" GetKeys string = "GETKEYS" GetKeysandFlags string = "GETKEYSANDFLAGS" List string = "LIST" Info string = "INFO" Docs string = "DOCS" WithValues string = "WITHVALUES" WithScores string = "WITHSCORES" WithScore string = "WITHSCORE" REV string = "REV" GET string = "GET" SET string = "SET" INCRBY string = "INCRBY" OVERFLOW string = "OVERFLOW" WRAP string = "WRAP" SAT string = "SAT" FAIL string = "FAIL" SIGNED string = "SIGNED" UNSIGNED string = "UNSIGNED" CAPACITY string = "CAPACITY" SIZE string = "SIZE" FILTERS string = "FILTER" ITEMS string = "ITEMS" EXPANSION string = "EXPANSION" )
const ( Before = "before" After = "after" )
const ( Uninitialized exDurationState = iota Initialized )
const ( IncrBy = "INCRBY" MultBy = "MULTBY" )
const (
CountConst = "COUNT"
)
Variables ¶
var ( PreProcessing = map[string]func([]string, *dstore.Store) *EvalResponse{} DiceCmds = map[string]DiceCmdMeta{} )
var ErrDequeEmpty = errors.New("deque is empty")
var RespEmptyArray = []byte("*0\r\n")
var RespMinusOne = []byte(":-1\r\n")
var RespMinusTwo = []byte(":-2\r\n")
var RespNIL = []byte("$-1\r\n")
var RespOK = []byte("+OK\r\n")
var RespOne = []byte(":1\r\n")
var RespQueued = []byte("+QUEUED\r\n")
var RespZero = []byte(":0\r\n")
var (
TxnCommands map[string]bool
)
Functions ¶
func ByteSliceToByteArrayObj ¶
func ByteSliceToByteArrayObj(store *dstore.Store, oldObj *object.Obj, b []byte) (*object.Obj, error)
ByteSliceToByteArrayObj converts a byte slice to an Obj with a ByteArray value
func ByteSliceToIntObj ¶
ByteSliceToIntObj converts a byte slice to an Obj with an integer value
func ByteSliceToObj ¶
func ByteSliceToObj(store *dstore.Store, oldObj *object.Obj, b []byte, objType object.ObjectType) (*object.Obj, error)
ByteSliceToObj converts a byte slice to an Obj of the specified type and encoding
func ByteSliceToStringObj ¶
ByteSliceToStringObj converts a byte slice to an Obj with a string value
func DecodeDeqEntry ¶
DecodeDeqEntry decode `xb` started from index 0, returns the decoded `x` and the overall length of [enc + data + backlen]. TODO possible optimizations: 1. return the string with the underlying array of `xb` to save memory usage? 2. replace strconv with more efficient/memory-saving implementation
func EncodeDeqEntry ¶
EncodeDeqEntry encodes `x` into an entry of Deque. An entry will be encoded as [enc + data + backlen].
func EncodeDeqEntryInPlace ¶
EncodeDeqEntryInPlace encodes `x` into an entry of Deque in place.
func EncodeDeqInt ¶
func EncodeDeqIntInPlace ¶
func EncodeDeqStr ¶
func EncodeDeqStrInPlace ¶
func EvalAUTH ¶
EvalAUTH returns with an encoded "OK" if the user is authenticated If the user is not authenticated, it returns with an encoded error message TODO: Needs to be removed after http and websocket migrated to the multithreading
func GetEncodeDeqEntrySize ¶
GetEncodeDeqEntrySize returns the number of bytes the encoded `x` will take.
func GetEncodeDeqIntSize ¶
func GetEncodeDeqStrSize ¶
Types ¶
type Bloom ¶
type Bloom struct {
// contains filtered or unexported fields
}
func CreateOrReplaceBloomFilter ¶
CreateOrReplaceBloomFilter creates a new bloom filter with given `opts` and stores it in the kv store. If the bloom filter already exists, it replaces the existing one. If `opts` is nil, it uses the default options.
func GetBloomFilter ¶
GetBloomFilter fetches an existing bloom filter from the kv store and returns the datastructure instance of it. The function also returns diceerrors.ErrKeyNotFound if the key does not exist. It also returns diceerrors.ErrWrongTypeOperation if the object is not a bloom filter.
func GetOrCreateBloomFilter ¶
GetOrCreateBloomFilter fetches an existing bloom filter from the kv store and returns the datastructure instance of it. If it does not exist, it tries to create one with given `opts` and returns it. Note: It also stores it in the kv store.
func NewBloomFilter ¶
newBloomFilter creates and returns a new filter. It is responsible for initializing the underlying bit array.
type ByteArray ¶
type ByteArray struct { Length int64 // contains filtered or unexported fields }
func NewByteArray ¶
NewByteArray initializes a new ByteArray with the given size
func (*ByteArray) IncreaseSize ¶
func (*ByteArray) ResizeIfNecessary ¶
type CountMinSketch ¶
type CountMinSketch struct {
// contains filtered or unexported fields
}
CountMinSketch implements a Count-Min Sketch as described by Cormode and Muthukrishnan in their paper: "An Improved Data Stream Summary: The Count-Min Sketch and its Applications" (http://dimacs.rutgers.edu/~graham/pubs/papers/cm-full.pdf).
A Count-Min Sketch (CMS) is a space-efficient, probabilistic data structure for approximating the frequency of events in a data stream. Instead of using large space like a hash map, it trades accuracy for space by allowing a configurable error margin. Similar to Counting Bloom filters, each item is hashed into multiple buckets, and the item's frequency is estimated by taking the minimum count across those buckets.
CMS is particularly useful for tracking event frequencies in large or unbounded data streams where storing all data or maintaining a counter for each event in memory is infeasible. It provides an efficient solution for real-time processing with minimal memory usage.
func DeserializeCMS ¶
func DeserializeCMS(buffer *bytes.Reader) (*CountMinSketch, error)
deserialize reconstructs a CountMinSketch from a byte slice.
func (*CountMinSketch) DeepCopy ¶
func (c *CountMinSketch) DeepCopy() *CountMinSketch
returns a deep copy of the Count Min Sketch
type CountMinSketchOpts ¶
type CountMinSketchOpts struct {
// contains filtered or unexported fields
}
type Deque ¶
type Deque struct { Length int64 // contains filtered or unexported fields }
func (*Deque) NewIterator ¶
func (q *Deque) NewIterator() *DequeIterator
Creates a new iterator for Deque.
type DequeBasic ¶
type DequeBasic struct { Length int64 // contains filtered or unexported fields }
func NewBasicDeque ¶
func NewBasicDeque() *DequeBasic
func (*DequeBasic) GetLength ¶
func (q *DequeBasic) GetLength() int64
func (*DequeBasic) LInsert ¶
func (q *DequeBasic) LInsert(pivot, element, beforeAfter string) (int64, error)
Inserts element before/after pivot element.
func (*DequeBasic) LPop ¶
func (q *DequeBasic) LPop() (string, error)
LPop pops an element from the left side of the Deque.
func (*DequeBasic) LPush ¶
func (q *DequeBasic) LPush(x string)
LPush pushes `x` into the left side of the Deque.
func (*DequeBasic) LRange ¶
func (q *DequeBasic) LRange(start, stop int64) ([]string, error)
Iterates over the Deque and returns the element in order.
func (*DequeBasic) NewIterator ¶
func (q *DequeBasic) NewIterator() *DequeBasicIterator
func (*DequeBasic) RPop ¶
func (q *DequeBasic) RPop() (string, error)
RPop pops an element from the right side of the Deque.
func (*DequeBasic) RPush ¶
func (q *DequeBasic) RPush(x string)
RPush pushes `x` into the right side of the Deque.
type DequeBasicIterator ¶
type DequeBasicIterator struct {
// contains filtered or unexported fields
}
func (*DequeBasicIterator) HasNext ¶
func (i *DequeBasicIterator) HasNext() bool
func (*DequeBasicIterator) Next ¶
func (i *DequeBasicIterator) Next() (string, error)
type DequeIterator ¶
type DequeIterator struct { CurrentNode *byteListNode ElementsTraversed int64 BufIndex int // contains filtered or unexported fields }
func (*DequeIterator) HasNext ¶
func (i *DequeIterator) HasNext() bool
func (*DequeIterator) Next ¶
func (i *DequeIterator) Next() (string, error)
type DiceCmdMeta ¶
type DiceCmdMeta struct { Name string Info string Eval func([]string, *dstore.Store) []byte Arity int // number of arguments, it is possible to use -N to say >= N KeySpecs SubCommands []string // list of sub-commands supported by the command // IsMigrated indicates whether a command has been migrated to a new evaluation // mechanism. If true, the command uses the newer evaluation logic represented by // the NewEval function. This allows backward compatibility for commands that have // not yet been migrated, ensuring they continue to use the older Eval function. // As part of the transition process, commands can be flagged with IsMigrated to // signal that they are using the updated execution path. IsMigrated bool // NewEval is the newer evaluation function for commands. It follows an updated // execution model that returns an EvalResponse struct, offering more structured // and detailed results, including metadata such as errors and additional info, // instead of just raw bytes. Commands that have been migrated to this new model // will utilize this function for evaluation, allowing for better handling of // complex command execution scenarios and improved response consistency. NewEval func([]string, *dstore.Store) *EvalResponse // StoreObjectEval is a specialized evaluation function for commands that operate on an object. // It is designed for scenarios where the command and subsequent dependent command requires // an object as part of its execution. This function processes the command, // evaluates it based on the provided object, and returns an EvalResponse struct // Commands that involve object manipulation, is not recommended for general use. // Only commands that really requires full object definition to pass across multiple shards // should implement this function. e.g. COPY, RENAME etc StoreObjectEval func(*cmd.DiceDBCmd, *dstore.Store) *EvalResponse }
type Eval ¶
type Eval struct {
// contains filtered or unexported fields
}
func (*Eval) ExecuteCommand ¶
func (e *Eval) ExecuteCommand() *EvalResponse
func (*Eval) PreProcessCommand ¶
func (e *Eval) PreProcessCommand() *EvalResponse
type EvalResponse ¶
type EvalResponse struct { Result interface{} // Result holds the outcome of the Store operation. Currently, it is expected to be of type []byte, but this may change in the future. Error error // Error holds any error that occurred during the operation. If no error, it will be nil. }
EvalResponse represents the response of an evaluation operation for a command from store. It contains the sequence ID, the result of the store operation, and any error encountered during the operation.
type RespType ¶
type RespType int
const ( NIL RespType = iota // Represents an empty or null response. OK // Represents a successful "OK" response. CommandQueued // Represents that a command has been queued for execution. IntegerZero // Represents the integer value zero in RESP format. IntegerOne // Represents the integer value one in RESP format. IntegerNegativeOne // Represents the integer value negative one in RESP format. IntegerNegativeTwo // Represents the integer value negative two in RESP format. EmptyArray // Represents an empty array in RESP format. )