MCPcopy Create free account
hub / github.com/ByteStorage/FlyDB / XLen

Method XLen

structure/stream.go:331–347  ·  view source on GitHub ↗

XLen returns the number of elements in a given stream. It takes the name of the stream as an argument and returns the number of elements in the stream. Parameters: name: The name of the stream. Returns: int: The number of elements (messages) in the stream. error: An error if any occurred duri

(name string)

Source from the content-addressed store, hash-verified

329// - It retrieves the messages from s.streams.Messages.
330// - It returns the number of messages in the stream.
331func (s *StreamStructure) XLen(name string) (int, error) {
332 // Get the stream
333 encodedStreams, err := s.db.Get([]byte(name))
334 if err != nil {
335 return 0, err
336 }
337
338 // Decode the streams
339 if err = s.decodeStreams(encodedStreams, s.streams); err != nil {
340 return 0, err
341 }
342
343 // Get the messages
344 messages := s.streams.Messages
345
346 return len(messages), nil
347}
348
349// XRange returns the messages in the stream.
350// It takes the name of the stream, the start index, and the stop index as arguments,

Callers 1

TestStreamStructure_XLenFunction · 0.80

Calls 2

decodeStreamsMethod · 0.95
GetMethod · 0.65

Tested by 1

TestStreamStructure_XLenFunction · 0.64