Bitmaps (File architecture): Difference between revisions
m (→Example) |
No edit summary |
||
Line 1: | Line 1: | ||
<p>Bit | <p>A Bit Map, as the name implies, is a series of on and off bits which are used to track a condition. These maps are used extensively throughout Model 204 to track sets of records or pages.</p> | ||
== The Workings of a Bit Map == | |||
<p>The [[Page (File Architecture)|page]] size in Model 204 of 6184 bytes contains 6144 'usable' bytes (along with its 40 byte trailer). As such conditions of up to 49152 'things' (usually records but also pages) can be tracked on a single page.</p> | |||
== Usages == | |||
The most common use in Model 204 is to track sets of records: | |||
* Inside both indexing types (hash and B-tree) bit maps are used | |||
* The [[#Table D (File Architecture) Existence Bit Map|Existence Bit Map]] which tracks which records are in use. | |||
* During procedure execution, all found sets are held as bit maps | |||
And, for [[Table E non x'100' (File Architecture)|Table E non FILEORG x'100']] files, large object available pages are tracked as well. | |||
== Manipulating Bit Maps == | == Manipulating Bit Maps == | ||
Once you have conditions represented as bitmaps, the manipulation ('anding' and 'oring') of these sets is straightforward and efficient: | |||
In code which has a find such as: | |||
<p class="code"> | |||
X: In ''filename'' FD COLOR = 'BLUE' | |||
STATE = 'NY' ... | |||
</p> | |||
<p>What is happening (given the implied 'and') is that the sets of records for each criteria are retrieved, and then 'anded' (any bits 'on' on both, are 'on' on the resultant bitmap associated with the label 'X'. </p> | |||
Revision as of 22:46, 11 April 2013
A Bit Map, as the name implies, is a series of on and off bits which are used to track a condition. These maps are used extensively throughout Model 204 to track sets of records or pages.
The Workings of a Bit Map
The page size in Model 204 of 6184 bytes contains 6144 'usable' bytes (along with its 40 byte trailer). As such conditions of up to 49152 'things' (usually records but also pages) can be tracked on a single page.
Usages
The most common use in Model 204 is to track sets of records:
- Inside both indexing types (hash and B-tree) bit maps are used
- The Existence Bit Map which tracks which records are in use.
- During procedure execution, all found sets are held as bit maps
And, for Table E non FILEORG x'100' files, large object available pages are tracked as well.
Manipulating Bit Maps
Once you have conditions represented as bitmaps, the manipulation ('anding' and 'oring') of these sets is straightforward and efficient:
In code which has a find such as:
X: In filename FD COLOR = 'BLUE' STATE = 'NY' ...
What is happening (given the implied 'and') is that the sets of records for each criteria are retrieved, and then 'anded' (any bits 'on' on both, are 'on' on the resultant bitmap associated with the label 'X'.
Example
In this example (which looks at a bit map as used by an index), this is the beginning of the bit map representing the ORD CHAR field value pair COLOR = BLUE for the 3rd segment of a file (which covers IRNs 98304 to 147455).
Based in this, record 98304 does not have an occurrence of COLOR = BLUE, but records 98305 and 98306 do... and so on.