summaryrefslogtreecommitdiff
path: root/src/mongo/db/query/index_entry.h
diff options
context:
space:
mode:
authorDavid Storch <david.storch@10gen.com>2018-08-22 18:44:59 -0400
committerDavid Storch <david.storch@10gen.com>2018-09-05 17:46:49 -0400
commitdf8b812c2b41635197c500577283929b1116efd7 (patch)
tree5c211c06e46c7b563481be4e58dd40d6477f875a /src/mongo/db/query/index_entry.h
parentb231de1297d81e08efcd3eb510f322fd719dd42f (diff)
downloadmongo-df8b812c2b41635197c500577283929b1116efd7.tar.gz
SERVER-36109 Provide planner with multikey metadata for $** indexes.
Diffstat (limited to 'src/mongo/db/query/index_entry.h')
-rw-r--r--src/mongo/db/query/index_entry.h27
1 files changed, 25 insertions, 2 deletions
diff --git a/src/mongo/db/query/index_entry.h b/src/mongo/db/query/index_entry.h
index 60e9c84b341..c032b47d785 100644
--- a/src/mongo/db/query/index_entry.h
+++ b/src/mongo/db/query/index_entry.h
@@ -28,8 +28,10 @@
#pragma once
+#include <set>
#include <string>
+#include "mongo/db/field_ref.h"
#include "mongo/db/index/multikey_paths.h"
#include "mongo/db/index_names.h"
#include "mongo/db/jsobj.h"
@@ -93,9 +95,10 @@ struct IndexEntry {
* Use this constructor if you're making an IndexEntry from the catalog.
*/
IndexEntry(const BSONObj& kp,
- const std::string& accessMethod,
+ IndexType type,
bool mk,
const MultikeyPaths& mkp,
+ std::set<FieldRef> multikeyPathSet,
bool sp,
bool unq,
Identifier ident,
@@ -105,13 +108,16 @@ struct IndexEntry {
: keyPattern(kp),
multikey(mk),
multikeyPaths(mkp),
+ multikeyPathSet(std::move(multikeyPathSet)),
sparse(sp),
unique(unq),
identifier(std::move(ident)),
filterExpr(fe),
infoObj(io),
+ type(type),
collator(ci) {
- type = IndexNames::nameToType(accessMethod);
+ // The caller must not supply multikey metadata in two different formats.
+ invariant(multikeyPaths.empty() || multikeyPathSet.empty());
}
/**
@@ -148,6 +154,11 @@ struct IndexEntry {
type = IndexNames::nameToType(IndexNames::findPluginName(keyPattern));
}
+ ~IndexEntry() {
+ // An IndexEntry should never have both formats of multikey metadata simultaneously.
+ invariant(multikeyPaths.empty() || multikeyPathSet.empty());
+ }
+
/**
* Returns true if 'indexedField' has any multikey components. For example, returns true if this
* index has a multikey component "a", and 'indexedField' is "a.b". Illegal to call unless
@@ -174,8 +185,20 @@ struct IndexEntry {
// index key pattern. Each element in the vector is an ordered set of positions (starting at 0)
// into the corresponding indexed field that represent what prefixes of the indexed field cause
// the index to be multikey.
+ //
+ // An IndexEntry may either represent multikey metadata as a fixed-size MultikeyPaths vector, or
+ // as an arbitrarily large set of field refs, but not both. That is, either 'multikeyPaths' or
+ // 'multikeyPathSet' must be empty.
MultikeyPaths multikeyPaths;
+ // A set of multikey paths. Used instead of 'multikeyPaths' when there could be arbitrarily many
+ // multikey paths associated with this index entry.
+ //
+ // An IndexEntry may either represent multikey metadata as a fixed-size MultikeyPaths vector, or
+ // as an arbitrarily large set of field refs, but not both. That is, either 'multikeyPaths' or
+ // 'multikeyPathSet' must be empty.
+ std::set<FieldRef> multikeyPathSet;
+
bool sparse;
bool unique;