File size: 1,538 Bytes
287a0bc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package model

import (
	"github.com/chroma/chroma-coordinator/internal/types"
)

type Segment struct {
	ID           types.UniqueID
	Type         string
	Scope        string
	Topic        *string
	CollectionID types.UniqueID
	Metadata     *SegmentMetadata[SegmentMetadataValueType]
	Ts           types.Timestamp
}

type CreateSegment struct {
	ID           types.UniqueID
	Type         string
	Scope        string
	Topic        *string
	CollectionID types.UniqueID
	Metadata     *SegmentMetadata[SegmentMetadataValueType]
	Ts           types.Timestamp
}

type UpdateSegment struct {
	ID              types.UniqueID
	Topic           *string
	ResetTopic      bool
	Collection      *string
	ResetCollection bool
	Metadata        *SegmentMetadata[SegmentMetadataValueType]
	ResetMetadata   bool
	Ts              types.Timestamp
}

type GetSegments struct {
	ID           types.UniqueID
	Type         *string
	Scope        *string
	Topic        *string
	CollectionID types.UniqueID
}

func FilterSegments(segment *Segment, segmentID types.UniqueID, segmentType *string, scope *string, topic *string, collectionID types.UniqueID) bool {
	if segmentID != types.NilUniqueID() && segment.ID != segmentID {
		return false
	}
	if segmentType != nil && segment.Type != *segmentType {
		return false
	}

	if scope != nil && segment.Scope != *scope {
		return false
	}

	if topic != nil && *segment.Topic != *topic {
		return false
	}

	if collectionID != types.NilUniqueID() && segment.CollectionID != collectionID {
		return false
	}
	return true
}