Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mjanuszkiewicz-tt committed Aug 29, 2024
1 parent 519ec5c commit 60c2d37
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import it.unimi.dsi.fastutil.longs.Long2IntMap;
import java.io.IOException;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.apache.lucene.search.DocIdSetIterator;
import org.apache.lucene.search.Scorer;
Expand All @@ -17,7 +16,7 @@ public class TraveltimeScorer extends Scorer {
private class TraveltimeFilteredDocs extends DocIdSetIterator {
private final TraveltimeWeight.FilteredIterator backing;

@Getter private long currentValue = 0;
private long currentValue = 0;
private boolean currentValueDirty = true;

private void invalidateCurrentValue() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,18 +121,45 @@ public Scorer scorer(LeafReaderContext context) throws IOException {

val pointToTime = new Long2IntOpenHashMap(valueArray.size());

val results =
protoFetcher.getTimes(
ttQuery.getParams().getOrigin(),
decodedArray,
ttQuery.getParams().getLimit(),
ttQuery.getParams().getMode(),
ttQuery.getParams().getCountry(),
ttQuery.getParams().getRequestType());

for (int index = 0; index < results.size(); index++) {
if (results.get(index) >= 0) {
pointToTime.put(valueArray.getLong(index), results.get(index).intValue());
if (ttQuery.getParams().isIncludeDistance()) {
val pointToDistance = new Long2IntOpenHashMap(valueArray.size());

val mode = Util.unsafeCastToDistanceTransportation(ttQuery.getParams().getMode());

val timeDistance =
protoFetcher.getTimesAndDistances(
ttQuery.getParams().getOrigin(),
decodedArray,
ttQuery.getParams().getLimit(),
mode,
ttQuery.getParams().getCountry(),
ttQuery.getParams().getRequestType());

val times = timeDistance.getLeft();
val distances = timeDistance.getRight();

for (int index = 0; index < times.size(); index++) {
if (times.get(index) >= 0) {
pointToTime.put(valueArray.getLong(index), times.get(index).intValue());
pointToDistance.put(valueArray.getLong(index), distances.get(index).intValue());
}
}

TraveltimeCache.DISTANCE.add(ttQuery.getParams(), pointToDistance);
} else {
val results =
protoFetcher.getTimes(
ttQuery.getParams().getOrigin(),
decodedArray,
ttQuery.getParams().getLimit(),
ttQuery.getParams().getMode(),
ttQuery.getParams().getCountry(),
ttQuery.getParams().getRequestType());

for (int index = 0; index < results.size(); index++) {
if (results.get(index) >= 0) {
pointToTime.put(valueArray.getLong(index), results.get(index).intValue());
}
}
}

Expand Down

0 comments on commit 60c2d37

Please sign in to comment.