# HashedIndexType reference

The HashedIndexType is defined in

    type/HashedIndexType.h

. It also allows to specify its only argument, the selection of the key fields, in the constructor, or set it later with a chainable call:

    HashedIndexType(NameSet *key = NULL);
    static HashedIndexType *make(NameSet *key = NULL);
    HashedIndexType *setKey(NameSet *key);

One way or the other, the key has to be set, or a missing key will be detected as an error at the initialization time. Obviously, all the conditions described in the Perl API apply: the key fields must be present in the table's row type, and so on.

The key can be read back using the parent class method

    IndexType::getKey()

. The value returned there is a

    const NameSet*

, telling you that the key NameSet must not be changed afterward.

The check for

    equals()

requires that the key fields are the same (not the exact same NameSet object, but its contents being the same). The check for

    match()

is more tricky and depends on whether the index type has been initialized. The match check of initialized types is correct, while for the uninitialized types it's simplified. This may lead to slightly surprising effects when the two indexes match inside the initialized table types but their uninitialized copies don't. However the comparison of the uninitialized index types is probably not that usable anyway.

The simplified

    match()

check is the same as

    equals()

: the list of key fields must be the same. However this has a tricky effect: if two table types have matching row types with different field names, and the same Hashed indexes differing only in the key field names (following the difference in the row types), these table types will be considered non-matching because their hashed indexes are non-matching.

After the indexes are initialized, they can do a better match check. They can find their table types, and from there the row types. And then compare if the keys refer to the matching fields or not, even if their names are different. The condition then becomes that the key fields are matching in the row type, even if their names are not.

HashedIndexType