blob: 72064f5d7b44d6a404ae254e64a0d3c360c9585f (
plain)
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
|
package schema
import (
"github.com/seaweedfs/seaweedfs/weed/pb/schema_pb"
)
type Schema struct {
RecordType *schema_pb.RecordType
fieldMap map[string]*schema_pb.Field
}
func NewSchema(recordType *schema_pb.RecordType) (*Schema, error) {
var fieldMap map[string]*schema_pb.Field
for _, field := range recordType.Fields {
fieldMap[field.Name] = field
}
return &Schema{
RecordType: recordType,
fieldMap: fieldMap,
}, nil
}
func (s *Schema) GetField(name string) (*schema_pb.Field, bool) {
field, ok := s.fieldMap[name]
return field, ok
}
|