Skip to content

Commit

Permalink
0003900: Improve performance of Oracle RAC routing processing
Browse files Browse the repository at this point in the history
  • Loading branch information
mmichalek committed Apr 4, 2019
1 parent 1d2d96b commit 2139c4d
Showing 1 changed file with 20 additions and 6 deletions.
Expand Up @@ -274,12 +274,7 @@ protected boolean process(Data data) {
if (isEachGapQueried) {
okToProcess = true;
} else {
for (DataGap gap : dataGaps) {
if (dataId >= gap.getStartId() && dataId <= gap.getEndId()) {
okToProcess = true;
break;
}
}
okToProcess = isInDataGap(dataId);
}
} else {
while (!okToProcess && currentGap != null && dataId >= currentGap.getStartId()) {
Expand All @@ -298,6 +293,25 @@ protected boolean process(Data data) {
}
return okToProcess;
}

protected boolean isInDataGap(long dataId) {
// binary search algorithm
int start = 0;
int end = dataGaps.size() - 1;
while (start <= end) {
int mid = (start + end) / 2;
DataGap midGap = dataGaps.get(mid);
if (dataId >= midGap.getStartId() && dataId <= midGap.getEndId()) {
return true;
}
if (dataId< midGap.getStartId()) {
end = mid - 1;
} else {
start = mid + 1;
}
}
return false;
}

public Data take() throws InterruptedException {
Data data = null;
Expand Down

0 comments on commit 2139c4d

Please sign in to comment.