MCPcopy Create free account
hub / github.com/couchbase/cbft / GetScopeCollectionsFromIndexDef

Function GetScopeCollectionsFromIndexDef

collection_utils.go:297–331  ·  view source on GitHub ↗

----------------------------------------------------------------------------- API to retrieve the scope & unique list of collection names from the provided index definition.

(indexDef *cbgt.IndexDef)

Source from the content-addressed store, hash-verified

295// API to retrieve the scope & unique list of collection names from the
296// provided index definition.
297func GetScopeCollectionsFromIndexDef(indexDef *cbgt.IndexDef) (
298 scope string, collections []string, err error) {
299 if indexDef == nil {
300 return "", nil, fmt.Errorf("no index-def provided")
301 }
302
303 bp := NewBleveParams()
304 if len(indexDef.Params) > 0 {
305 if err = json.Unmarshal([]byte(indexDef.Params), bp); err != nil {
306 return "", nil, err
307 }
308
309 if strings.HasPrefix(bp.DocConfig.Mode, ConfigModeCollPrefix) {
310 if im, ok := bp.Mapping.(*mapping.IndexMappingImpl); ok {
311 var collectionNames []string
312 scope, collectionNames, _, err := getScopeCollTypeMappings(im, false)
313 if err != nil {
314 return "", nil, err
315 }
316
317 uniqueCollections := map[string]struct{}{}
318 for _, coll := range collectionNames {
319 if _, exists := uniqueCollections[coll]; !exists {
320 uniqueCollections[coll] = struct{}{}
321 collections = append(collections, coll)
322 }
323 }
324
325 return scope, collections, nil
326 }
327 }
328 }
329
330 return "_default", []string{"_default"}, nil
331}
332
333func multiCollection(colls []Collection) bool {
334 hash := make(map[string]struct{}, 1)

Callers 5

StatsMethod · 0.85
obtainDestSeqsForIndexFunction · 0.85
limitIndexDefFunction · 0.85

Calls 3

NewBleveParamsFunction · 0.85
getScopeCollTypeMappingsFunction · 0.85
UnmarshalMethod · 0.80

Tested by

no test coverage detected