source: trunk/symbol_table/div2_logbase2_group_strms.py @ 2101

Last change on this file since 2101 was 2101, checked in by ksherdy, 7 years ago

Added mixed div2, log2 support. Updated div2 hash strategy to test prepended delimeter.

File size: 1.8 KB
Line 
1import bitutil as pablo
2
3class Groups():
4        starts = 0
5        follows = 0
6        follows_2 = 0
7        follows_4 = 0
8        follows_6 = 0
9        follows_8 = 0
10        follows_16 = 0
11        follows_gte_17 = 0
12
13def Gen_lgth_groups(groups):
14
15        ### Div2 Strategy ###
16        follows_gt_0 = groups.follows
17        follows_mask_1_2 = pablo.Advance(groups.starts) | pablo.Advance(pablo.Advance(groups.starts))
18
19        # Groups symbols of length 1 and length 2
20        groups.follows_2 = follows_gt_0 & follows_mask_1_2
21        follows_gt_2 = follows_gt_0 &~ follows_mask_1_2
22        follows_mask_3_4 = pablo.Advance(pablo.Advance(follows_mask_1_2))
23
24        # Groups symbols of length 3 and length 4
25        groups.follows_4 = follows_gt_2 & follows_mask_3_4
26        follows_gt_4 = follows_gt_2 &~ follows_mask_3_4
27        follows_mask_5_6 = pablo.Advance(pablo.Advance(follows_mask_3_4))
28
29        # Groups symbols of length 5 and length 6
30        groups.follows_6 = follows_gt_4 & follows_mask_5_6
31        follows_gt_6 = follows_gt_4 &~ follows_mask_5_6
32        follows_mask_7_8 = pablo.Advance(pablo.Advance(follows_mask_5_6))
33
34        # Groups symbols of length 7 and length 8
35        groups.follows_8 = follows_gt_6 & follows_mask_7_8
36        follows_gt_8 = follows_gt_6 &~ follows_mask_7_8
37
38        ### Log2 Strategy ###
39        follows_mask_1_8 = follows_mask_1_2 | follows_mask_3_4 | follows_mask_5_6 | follows_mask_7_8
40        # Naive Advance
41        follows_mask_9_16 = pablo.Advance(pablo.Advance(pablo.Advance(pablo.Advance(pablo.Advance(pablo.Advance(pablo.Advance(pablo.Advance(follows_mask_1_8))))))))
42
43        # Groups symbols of length 9 to length 16
44        groups.follows_16 = follows_gt_8 & follows_mask_9_16
45
46        # Advance 32 and Interpose
47        # temp32 = pablo.Advance32 (follows_mask_1_8)
48        # groups.follows_16 = interpose32 (temp, temp32, 8)
49
50        follows_gt_16 = follows_gt_8 &~ follows_mask_9_16
51
52        # Groups symbols of length greater than 16
53        groups.follows_gte_17 = follows_gt_16
54
55def Main(groups):
56        Gen_lgth_groups(groups)
Note: See TracBrowser for help on using the repository browser.