Skip to content

Commit

Permalink
MB-31956 Update protobuf index definition to be collection aware
Browse files Browse the repository at this point in the history
The scope name, scope ID, collection name and collection ID are
added to index definition. The scope ID and collection ID are
encoded as hexadecimal strings

Change-Id: Ieab630de48f6fdc27b71d28109be9889b58ba8c0
  • Loading branch information
varunv-cb committed Jan 8, 2020
1 parent bf2dad2 commit 8490cad
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 2 deletions.
10 changes: 8 additions & 2 deletions secondary/protobuf/projector/index.proto
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ enum PartitionScheme {
RANGE = 5;
}

// Type of Hash scheme for partitioned index
// Type of Hash scheme for partitioned index
enum HashScheme {
CRC32 = 0;
}
Expand Down Expand Up @@ -87,5 +87,11 @@ message IndexDefn {
optional string whereExpression = 10; // where predicate
repeated string partnExpressions = 11; // use expressions to evaluate doc
optional bool retainDeletedXATTR = 12; // index XATTRs of deleted docs
optional HashScheme hashScheme = 13; // hash scheme for partitioned index
optional HashScheme hashScheme = 13; // hash scheme for partitioned index

// Collection specific
optional string scope = 14; // Name of the scope on which index is defined
optional string scopeID = 15; // ID of the scope (base-16 string) on which index is defined
optional string collection = 16; // Name of the collection on which index is defined
optional string collectionID = 17; // ID of the collection (base-16 string) on which index is defined
}
42 changes: 42 additions & 0 deletions secondary/protobuf/projector/projector.go
Original file line number Diff line number Diff line change
Expand Up @@ -840,3 +840,45 @@ func (instance *Instance) GetBucket() (bucket string) {
}
return
}

// GetScope will get the name of the scope in which instance is defined
func (instance *Instance) GetScope() (scope string) {
if val := instance.GetIndexInstance(); val != nil {
return val.GetDefinition().GetScope()
} else {
// TODO: should we panic
}
return
}

// GetScopeID will get the ID of the scope (base-16 string) in which
// instance is defined
func (instance *Instance) GetScopeID() (scopeID string) {
if val := instance.GetIndexInstance(); val != nil {
return val.GetDefinition().GetScopeID()
} else {
// TODO: should we panic
}
return
}

// GetCollection will get the name of the collection in which instance is defined
func (instance *Instance) GetCollection() (collection string) {
if val := instance.GetIndexInstance(); val != nil {
return val.GetDefinition().GetCollection()
} else {
// TODO: should we panic
}
return
}

// GetCollectionID will get the ID of the collection (base-16 string) in which
// instance is defined
func (instance *Instance) GetCollectionID() (collectionID string) {
if val := instance.GetIndexInstance(); val != nil {
return val.GetDefinition().GetCollectionID()
} else {
// TODO: should we panic
}
return
}

0 comments on commit 8490cad

Please sign in to comment.