SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.
Go blob-storagecloud-drivedistributed-file-systemdistributed-storageerasure-codingfusehadoop-hdfshdfskuberneteslancelancedbobject-storageposixs3s3-storageseaweedfstiered-file-systemvector-search
Create schema.go
chrislu6f80dbdfe5ca
diff --git a/weed/mq/schema/schema.go b/weed/mq/schema/schema.gonew file mode 100644index 0000000000..5cb7a8df11--- /dev/null+++ b/weed/mq/schema/schema.go@@ -0,0 +1,32 @@+package schema++import (+ "fmt"+ "github.com/seaweedfs/seaweedfs/weed/pb/schema_pb"+)++type Schema struct {+ RecordType *schema_pb.RecordType+ indexedFields []*schema_pb.Field+}++func NewSchema(recordType *schema_pb.RecordType) (*Schema, error) {+ var indexedFields []*schema_pb.Field+ var largestIndex int32+ for _, field := range recordType.Fields {+ if field.Index > largestIndex {+ largestIndex = field.Index+ }+ if field.Index < 0 {+ return nil, fmt.Errorf("field %s index %d is negative", field.Name, field.Index)+ }+ }+ indexedFields = make([]*schema_pb.Field, largestIndex+1)+ for _, field := range recordType.Fields {+ indexedFields[field.Index] = field+ }+ return &Schema{+ RecordType: recordType,+ indexedFields: indexedFields,+ }, nil+}