@@ -22,6 +22,7 @@ option java_package = "org.apache.skywalking.banyandb.database.v1";
2222package banyandb.database.v1 ;
2323
2424import "google/protobuf/timestamp.proto" ;
25+ import "validate/validate.proto" ;
2526import "banyandb/v1/banyandb-common.proto" ;
2627import "banyandb/v1/banyandb-model.proto" ;
2728
@@ -32,18 +33,17 @@ enum TagType {
3233 TAG_TYPE_STRING_ARRAY = 3 ;
3334 TAG_TYPE_INT_ARRAY = 4 ;
3435 TAG_TYPE_DATA_BINARY = 5 ;
35- TAG_TYPE_ID = 6 ;
3636}
3737
3838message TagFamilySpec {
39- string name = 1 ;
39+ string name = 1 [ (validate .rules ) .string .min_len = 1 ] ;
4040 // tags defines accepted tags
41- repeated TagSpec tags = 2 ;
41+ repeated TagSpec tags = 2 [ (validate .rules ) .repeated .min_items = 1 ] ;
4242}
4343
4444message TagSpec {
45- string name = 1 ;
46- TagType type = 2 ;
45+ string name = 1 [ (validate .rules ) .string .min_len = 1 ] ;
46+ TagType type = 2 [ (validate .rules ) .enum .defined_only = true ] ;
4747 // indexed_only indicates whether the tag is stored
4848 // True: It's indexed only, but not stored
4949 // False: it's stored and indexed
@@ -53,17 +53,17 @@ message TagSpec {
5353// Stream intends to store streaming data, for example, traces or logs
5454message Stream {
5555 // metadata is the identity of a trace series
56- common.v1.Metadata metadata = 1 ;
56+ common.v1.Metadata metadata = 1 [ (validate .rules ) .message .required = true ] ;
5757 // tag_families
58- repeated TagFamilySpec tag_families = 2 ;
58+ repeated TagFamilySpec tag_families = 2 [ (validate .rules ) .repeated .min_items = 1 ] ;
5959 // entity indicates how to generate a series and shard a stream
60- Entity entity = 3 ;
60+ Entity entity = 3 [ (validate .rules ) .message .required = true ] ;
6161 // updated_at indicates when the stream is updated
6262 google.protobuf.Timestamp updated_at = 4 ;
6363}
6464
6565message Entity {
66- repeated string tag_names = 1 ;
66+ repeated string tag_names = 1 [ (validate .rules ) .repeated .min_items = 1 ] ;
6767}
6868
6969enum FieldType {
@@ -87,25 +87,25 @@ enum CompressionMethod {
8787// FieldSpec is the specification of field
8888message FieldSpec {
8989 // name is the identity of a field
90- string name = 1 ;
90+ string name = 1 [ (validate .rules ) .string .min_len = 1 ] ;
9191 // field_type denotes the type of field value
92- FieldType field_type = 2 ;
92+ FieldType field_type = 2 [ (validate .rules ) .enum .defined_only = true ] ;
9393 // encoding_method indicates how to encode data during writing
94- EncodingMethod encoding_method = 3 ;
94+ EncodingMethod encoding_method = 3 [ (validate .rules ) .enum .defined_only = true ] ;
9595 // compression_method indicates how to compress data during writing
96- CompressionMethod compression_method = 4 ;
96+ CompressionMethod compression_method = 4 [ (validate .rules ) .enum .defined_only = true ] ;
9797}
9898
9999// Measure intends to store data point
100100message Measure {
101101 // metadata is the identity of a measure
102- common.v1.Metadata metadata = 1 ;
102+ common.v1.Metadata metadata = 1 [ (validate .rules ) .message .required = true ] ;
103103 // tag_families are for filter measures
104- repeated TagFamilySpec tag_families = 2 ;
104+ repeated TagFamilySpec tag_families = 2 [ (validate .rules ) .repeated .min_items = 1 ] ;
105105 // fields denote measure values
106106 repeated FieldSpec fields = 3 ;
107107 // entity indicates which tags will be to generate a series and shard a measure
108- Entity entity = 4 ;
108+ Entity entity = 4 [ (validate .rules ) .message .required = true ] ;
109109 // interval indicates how frequently to send a data point
110110 // valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h", "d".
111111 string interval = 5 ;
@@ -116,15 +116,16 @@ message Measure {
116116// TopNAggregation generates offline TopN statistics for a measure's TopN approximation
117117message TopNAggregation {
118118 // metadata is the identity of an aggregation
119- common.v1.Metadata metadata = 1 ;
119+ common.v1.Metadata metadata = 1 [ (validate .rules ) .message .required = true ] ;
120120 // source_measure denotes the data source of this aggregation
121- common.v1.Metadata source_measure = 2 ;
121+ common.v1.Metadata source_measure = 2 [ (validate .rules ) .message .required = true ] ;
122122 // field_name is the name of field used for ranking
123- string field_name = 3 ;
123+ string field_name = 3 [ (validate .rules ) .string .min_len = 1 ] ;
124124 // field_value_sort indicates how to sort fields
125125 // ASC: bottomN
126126 // DESC: topN
127127 // UNSPECIFIED: topN + bottomN
128+ // todo validate plugin exist bug https://github.com/bufbuild/protoc-gen-validate/issues/672
128129 model.v1.Sort field_value_sort = 4 ;
129130 // group_by_tag_names groups data points into statistical counters
130131 repeated string group_by_tag_names = 5 ;
@@ -142,28 +143,20 @@ message TopNAggregation {
142143// IndexRule should bind to a subject through an IndexRuleBinding to generate proper indices.
143144message IndexRule {
144145 // metadata define the rule's identity
145- common.v1.Metadata metadata = 1 ;
146+ common.v1.Metadata metadata = 1 [ (validate .rules ) .message .required = true ] ;
146147 // tags are the combination that refers to an indexed object
147148 // If the elements in tags are more than 1, the object will generate a multi-tag index
148149 // Caveat: All tags in a multi-tag MUST have an identical IndexType
149- repeated string tags = 2 ;
150+ repeated string tags = 2 [ (validate .rules ) .repeated .min_items = 1 ] ;
150151 // Type determine the index structure under the hood
151152 enum Type {
152153 TYPE_UNSPECIFIED = 0 ;
153- TYPE_TREE = 1 ;
154- TYPE_INVERTED = 2 ;
154+ TYPE_INVERTED = 1 ;
155155 }
156156 // type is the IndexType of this IndexObject.
157- Type type = 3 ;
158- enum Location {
159- LOCATION_UNSPECIFIED = 0 ;
160- LOCATION_SERIES = 1 ;
161- LOCATION_GLOBAL = 2 ;
162- }
163- // location indicates where to store index.
164- Location location = 4 ;
157+ Type type = 3 [(validate.rules ) .enum.defined_only = true ];
165158 // updated_at indicates when the IndexRule is updated
166- google.protobuf.Timestamp updated_at = 5 ;
159+ google.protobuf.Timestamp updated_at = 4 ;
167160 enum Analyzer {
168161 ANALYZER_UNSPECIFIED = 0 ;
169162 // Keyword analyzer is a “noop” analyzer which returns the entire input string as a single token.
@@ -176,32 +169,33 @@ message IndexRule {
176169 ANALYZER_SIMPLE = 3 ;
177170 }
178171 // analyzer analyzes tag value to support the full-text searching for TYPE_INVERTED indices.
179- Analyzer analyzer = 6 ;
172+ Analyzer analyzer = 5 ;
180173}
181174
182175// Subject defines which stream or measure would generate indices
183176message Subject {
184177 // catalog is where the subject belongs to
178+ // todo validate plugin exist bug https://github.com/bufbuild/protoc-gen-validate/issues/672
185179 common.v1.Catalog catalog = 1 ;
186180 // name refers to a stream or measure in a particular catalog
187- string name = 2 ;
181+ string name = 2 [ (validate .rules ) .string .min_len = 1 ] ;
188182}
189183
190184// IndexRuleBinding is a bridge to connect severalIndexRules to a subject
191185// This binding is valid between begin_at_nanoseconds and expire_at_nanoseconds, that provides flexible strategies
192186// to control how to generate time series indices.
193187message IndexRuleBinding {
194188 // metadata is the identity of this binding
195- common.v1.Metadata metadata = 1 ;
189+ common.v1.Metadata metadata = 1 [ (validate .rules ) .message .required = true ] ;
196190 // rules refers to the IndexRule
197- repeated string rules = 2 ;
191+ repeated string rules = 2 [ (validate .rules ) .repeated .min_items = 1 ] ;
198192 // subject indicates the subject of binding action
199- Subject subject = 3 ;
193+ Subject subject = 3 [ (validate .rules ) .message .required = true ] ;
200194 // begin_at_nanoseconds is the timestamp, after which the binding will be active
201- google.protobuf.Timestamp begin_at = 4 ;
195+ google.protobuf.Timestamp begin_at = 4 [ (validate .rules ) .timestamp .required = true ] ;
202196 // expire_at_nanoseconds it the timestamp, after which the binding will be inactive
203197 // expire_at_nanoseconds must be larger than begin_at_nanoseconds
204- google.protobuf.Timestamp expire_at = 5 ;
198+ google.protobuf.Timestamp expire_at = 5 [ (validate .rules ) .timestamp .required = true ] ;
205199 // updated_at indicates when the IndexRuleBinding is updated
206200 google.protobuf.Timestamp updated_at = 6 ;
207201}
0 commit comments