Repository navigation
Commit 94fe2d5
ARROW-6093: [Java] reduce branches in algo for first match in VectorRangeSearcher
This is a follow up Jira for the improvement suggested by Francois Saint-Jacques in the PR for
apache#4925
After careful analysis and proof, I found @fsaintjacques 's proposal really works. The idea behind the algorithm is tricky. This PR is the implementation based on @fsaintjacques 's proposal.
The benefit of this implementation:
1. the code is much clearer
2. there is fewer branches, which is beneficial for performance.
The drawback of this implementation:
1. there can be dumb iterations of the main loop. That is, the while loop may run a few more times after the "solution" is found, just to wait for the loop termination condition is satisfied.
However, the time complexity of the algorithm is still O(logn), and the number of dumb iterations can not be large.
Closes apache#5011 from liyafan82/fly_0805_range and squashes the following commits:
f47a2e7 <liyafan82> reduce branches in algo for first match in VectorRangeSearcher
Authored-by: liyafan82 <fan_li_ya@foxmail.com>
Signed-off-by: Micah Kornfield <emkornfield@gmail.com>1 parent 6006a7d commit 94fe2d5
2 files changed
Lines changed: 36 additions & 48 deletions
File tree
- java/algorithm/src
- main/java/org/apache/arrow/algorithm/search
- test/java/org/apache/arrow/algorithm/search
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| 47 | + | |
| 48 | + | |
47 | 49 | | |
48 | 50 | | |
49 | 51 | | |
| |||
57 | 59 | | |
58 | 60 | | |
59 | 61 | | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
81 | 66 | | |
82 | 67 | | |
83 | | - | |
| 68 | + | |
84 | 69 | | |
85 | 70 | | |
86 | 71 | | |
| |||
97 | 82 | | |
98 | 83 | | |
99 | 84 | | |
| 85 | + | |
| 86 | + | |
100 | 87 | | |
101 | 88 | | |
102 | 89 | | |
| |||
110 | 97 | | |
111 | 98 | | |
112 | 99 | | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
134 | 104 | | |
135 | 105 | | |
136 | | - | |
| 106 | + | |
137 | 107 | | |
138 | 108 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
22 | 25 | | |
23 | 26 | | |
24 | 27 | | |
| |||
28 | 31 | | |
29 | 32 | | |
30 | 33 | | |
| 34 | + | |
| 35 | + | |
31 | 36 | | |
32 | 37 | | |
33 | 38 | | |
34 | 39 | | |
| 40 | + | |
35 | 41 | | |
36 | 42 | | |
37 | 43 | | |
38 | 44 | | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
39 | 51 | | |
40 | 52 | | |
41 | 53 | | |
| |||
49 | 61 | | |
50 | 62 | | |
51 | 63 | | |
52 | | - | |
53 | 64 | | |
54 | 65 | | |
55 | 66 | | |
| |||
79 | 90 | | |
80 | 91 | | |
81 | 92 | | |
82 | | - | |
83 | 93 | | |
84 | 94 | | |
85 | 95 | | |
| |||
114 | 124 | | |
115 | 125 | | |
116 | 126 | | |
117 | | - | |
118 | 127 | | |
119 | 128 | | |
120 | 129 | | |
| |||
144 | 153 | | |
145 | 154 | | |
146 | 155 | | |
147 | | - | |
148 | 156 | | |
149 | 157 | | |
150 | 158 | | |
| |||
175 | 183 | | |
176 | 184 | | |
177 | 185 | | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
178 | 196 | | |
0 commit comments