# Group

A group is a partition in a file consisting of one or more
linked frames used for storing and retrieving items.

When a file is created it is given a modulo that specifies
how many one-frame groups are initially allocated for this file as
the primary space. The group number is calculated by hashing the item-ID
with the modulo creating an integer remainder in the range zero to
modulo minus one. The group number is added to the file’s base giving
the frame number of the group where the item is stored.

The
hashed to group is sequentially searched to locate a specific item.
By choosing the modulo appropriately, items can usually be located
in a single disk access regardless of the number of items in the file.
Overflow frames are automatically linked to a group to expand its
storage capacity dynamically. Also, these frames become released back
to the overflow pool as the group contracts in size.

Warning: Files can become badly allocated with a group having
many linked frames (even hundreds). In these cases the file should
be reallocated (have its modulo increased), so that if possible, most
groups are single frames.

## See also

- [create-file command](https://d3codex.com/tcl/create-file-command/)
- [Binary files (glossary)](https://d3codex.com/definitions/binary-files-glossary/)
- [Frame](https://d3codex.com/definitions/frame/)
- [group command](https://d3codex.com/tcl/group-command/)
- [Hashing](https://d3codex.com/definitions/hashing/)
- [Linked overflow](https://d3codex.com/definitions/linked-overflow/)
- [Modulo](https://d3codex.com/definitions/modulo-glossary/)
- [Overflow table](https://d3codex.com/definitions/overflow-table/)
- [reallocation](https://d3codex.com/attributedefiningitem/reallocation/)

---
Source: https://d3codex.com/definitions/group/ - part of the D3Codex reference.
