idx

package
v1.0.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 9, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CollectionIndexCatalog

type CollectionIndexCatalog struct {
	// contains filtered or unexported fields
}

CollectionIndexCatalog stores the current view of all indexes of a single collection.

type IndexCatalog

type IndexCatalog struct {
	sync.Mutex
	// contains filtered or unexported fields
}

IndexCatalog stores the current view of all indexes in all databases.

func NewIndexCatalog

func NewIndexCatalog() *IndexCatalog

NewIndexCatalog inits an IndexCatalog

func (*IndexCatalog) AddIndex

func (i *IndexCatalog) AddIndex(database, collection string, index *IndexDocument)

AddIndex stores the given index into the index catalog. An example index:

{
	"v": 2,
	"key": {
		"lastModifiedDate": 1
	},
	"name": "lastModifiedDate_1",
	"ns": "test.eventlog"
}

func (*IndexCatalog) AddIndexes

func (i *IndexCatalog) AddIndexes(database, collection string, indexes []*IndexDocument)

AddIndexes stores the given indexes into the index catalog.

func (*IndexCatalog) CollMod

func (i *IndexCatalog) CollMod(database, collection string, indexModValue interface{}) error

CollMod, updates the corresponding TTL index if the given collModCmd updates the "expireAfterSeconds" or "hiddne" fields. For example,

{
 "collMod": "sessions",
 "index": {"keyPattern": {"lastAccess": 1}, "expireAfterSeconds": 3600}}
}

or,

{
 "collMod": "sessions",
 "index": {"name": "lastAccess_1", "expireAfterSeconds": 3600}}
}

func (*IndexCatalog) DeleteIndexes

func (i *IndexCatalog) DeleteIndexes(database, collection string, dropCmd bson.D) error

DeleteIndexes removes indexes from the index catalog. dropCmd may be, {"deleteIndexes": "eventlog", "index": "*"} or, {"deleteIndexes": "eventlog", "index": "name_1"}

func (*IndexCatalog) DropCollection

func (i *IndexCatalog) DropCollection(database, collection string)

DropCollection removes a collection from the index catalog.

func (*IndexCatalog) DropDatabase

func (i *IndexCatalog) DropDatabase(database string)

DropDatabase removes a database from the index catalog.

func (*IndexCatalog) GetIndex

func (i *IndexCatalog) GetIndex(database, collection, indexName string) *IndexDocument

GetIndex returns an IndexDocument for a given index name

func (*IndexCatalog) GetIndexByIndexMod

func (i *IndexCatalog) GetIndexByIndexMod(database, collection string, indexMod bson.D) (*IndexDocument, error)

GetIndexByIndexMod returns an index that matches the name or key pattern specified in a collMod command.

func (*IndexCatalog) GetIndexes

func (i *IndexCatalog) GetIndexes(database, collection string) []*IndexDocument

GetIndexes returns all the indexes for the given collection. When the collection has a non-simple collation an explicit simple collation must be added to the indexes with no "collation field. Otherwise, the index will wrongfully inherit the collections's collation. This is necessary because indexes with the simple collation do not have a "collation" field in the getIndexes output.

func (*IndexCatalog) Namespaces

func (i *IndexCatalog) Namespaces() (namespaces []options.Namespace)

Namespaces returns all the namespaces in the IndexCatalog

func (*IndexCatalog) Queue

func (i *IndexCatalog) Queue() *NamespaceQueue

Queue returns a namespace queue of the current namespaces in the index catalog.

func (*IndexCatalog) SetCollation

func (i *IndexCatalog) SetCollation(database, collection string, simpleCollation bool)

SetCollation sets if a collection has a simple collation

func (*IndexCatalog) String

func (i *IndexCatalog) String() string

String formats the IndexCatalog for debugging purposes

type IndexDocument

type IndexDocument struct {
	Options                 bson.M `bson:",inline"`
	Key                     bson.D `bson:"key"`
	PartialFilterExpression bson.D `bson:"partialFilterExpression,omitempty"`
}

IndexDocument holds information about a collection's index.

func NewIndexDocumentFromD

func NewIndexDocumentFromD(doc bson.D) (*IndexDocument, error)

NewIndexDocumentFromD converts a bson.D index spec into an IndexDocument

type NamespaceQueue

type NamespaceQueue struct {
	// contains filtered or unexported fields
}

NamespaceQueue is a goroutine-safe queue of namespaces

func (*NamespaceQueue) Pop

func (q *NamespaceQueue) Pop() *options.Namespace

Pop removes the next element from the queue and returns it. It is goroutine-safe.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL