Presentation is loading. Please wait.

Presentation is loading. Please wait.

BITMAP INDEXES Sai Priya Rama Gopal SJSU ID : 007506408 Class ID: 125.

Similar presentations


Presentation on theme: "BITMAP INDEXES Sai Priya Rama Gopal SJSU ID : 007506408 Class ID: 125."— Presentation transcript:

1 BITMAP INDEXES Sai Priya Rama Gopal SJSU ID : 007506408 Class ID: 125

2 Introduction A bitmap index is a special kind of index that stores the bulk of its data as bit arrays (commonly called "bitmaps"). A bitmap index is a special kind of index that stores the bulk of its data as bit arrays (commonly called "bitmaps"). It answers most queries by performing bitwise logical operations on these bitmaps. It answers most queries by performing bitwise logical operations on these bitmaps. The bitmap index is designed for cases where number of distinct values is low, in other words, the values repeat very frequently. The bitmap index is designed for cases where number of distinct values is low, in other words, the values repeat very frequently.

3 Example Suppose a file consists of records with two fields, F and G, of type integer and string, respectively. The current file has six records, numbered 1 through 6, with the following values in order: Suppose a file consists of records with two fields, F and G, of type integer and string, respectively. The current file has six records, numbered 1 through 6, with the following values in order: NoFG 130FOO 230BAR 340BAZ 450FOO 540BAR 630BAZ

4 Example (contd…) A bitmap index for the first field, F, would have three bit-vectors, each of length 6 as shown in the table. A bitmap index for the first field, F, would have three bit-vectors, each of length 6 as shown in the table. In each case, the 1's indicate in which records the corresponding string appears. In each case, the 1's indicate in which records the corresponding string appears. Table 2 Table 2 ValueVector 30110001 40001010 50000100

5 Example (contd…) A bitmap index for the first field, G, would have three bit-vectors, each of length 6 as shown in the table. A bitmap index for the first field, G, would have three bit-vectors, each of length 6 as shown in the table. In each case, the 1's indicate in which records the corresponding string appears. In each case, the 1's indicate in which records the corresponding string appears. Table 3 Table 3 ValueVector FOO100100 BAR010010 BAZ001001

6 Motivation for Bitmap Indexes Bitmap indexes can help answer range queries. Bitmap indexes can help answer range queries. Example: Example: Given is the data of a jewelry stores. The attributes considered are age and salary. Given is the data of a jewelry stores. The attributes considered are age and salary. Table 4 Table 4 NoAgeSalary 12560 24560 35075 450100 550120 670110 785140 830260 925400 1045350 1150275 1260260

7 Motivation (contd…) A bitmap index for the first field Age, would have seven bit-vectors, each of length 12 as shown in the table. A bitmap index for the first field Age, would have seven bit-vectors, each of length 12 as shown in the table. In each case, the 1's indicate in which records the corresponding string appears. In each case, the 1's indicate in which records the corresponding string appears. Table 5 Table 5 ValueVector 25100000001000 30000000010000 45010000000100 50001110000010 60000000000001 70000001000000 85000000100000

8 Motivation (contd…) A bitmap index for the second field Salary, would have ten bit- vectors, each of length 12 as shown in the table. A bitmap index for the second field Salary, would have ten bit- vectors, each of length 12 as shown in the table. In each case, the 1's indicate in which records the corresponding string appears. In each case, the 1's indicate in which records the corresponding string appears. Table 5 ValueVector 60110000000000 75001000000000 100000100000000 110000001000000 120000010000000 140000000100000 260000000010001 275000000000010 350000000000100 400000000001000

9 Motivation (contd…) Suppose we want to find the jewelry buyers with an age in the range 45-55 and a salary in the range 100-200. Suppose we want to find the jewelry buyers with an age in the range 45-55 and a salary in the range 100-200. We first find the bit-vectors for the age values in this range; in this example there are only two: 010000000100 and 001110000010, for 45 and 50, respectively. If we take their bitwise OR, we have a new bit-vector with 1 in position i if and only if the i th record has an age in the desired range. We first find the bit-vectors for the age values in this range; in this example there are only two: 010000000100 and 001110000010, for 45 and 50, respectively. If we take their bitwise OR, we have a new bit-vector with 1 in position i if and only if the i th record has an age in the desired range. This bit-vector is 011110000110. This bit-vector is 011110000110.

10 Motivation (contd…) Next, we find the bit-vectors for the salaries between 100 and 200 thousand. Next, we find the bit-vectors for the salaries between 100 and 200 thousand. There are four, corresponding to salaries 100, 110, 120, and 140; their bitwise OR is 000111100000 There are four, corresponding to salaries 100, 110, 120, and 140; their bitwise OR is 000111100000.

11 Motivation (contd…) The last step is to take the bitwise AND of the two bit-vectors we calculated by OR. The last step is to take the bitwise AND of the two bit-vectors we calculated by OR. That is: That is:011110000110 AND000111100000 -----------------------------------000110000000

12 Motivation (contd…) We thus find that only the fourth and fifth records, which are (50,100) and (50,120), are in the desired range. We thus find that only the fourth and fifth records, which are (50,100) and (50,120), are in the desired range.

13 Issues for Bitmap Indexes Managing Bitmap indexes Managing Bitmap indexes Memory requirement. Memory requirement.

14 Managing Bitmap indexes Finding Bit-Vectors Finding Bit-Vectors Finding Records Finding Records Handling modifications to the data file. Handling modifications to the data file. – Record numbers must remain fixed once assigned. – Changes to the data file require the bitmap index to change as well.


Download ppt "BITMAP INDEXES Sai Priya Rama Gopal SJSU ID : 007506408 Class ID: 125."

Similar presentations


Ads by Google