Skip to content

Commit

Permalink
Merge pull request #20 from traveltime-dev/capitalisation
Browse files Browse the repository at this point in the history
Correctly capitalize TravelTime in code
  • Loading branch information
mjanuszkiewicz-tt authored Mar 10, 2023
2 parents dbc3f61 + 7577416 commit 01e8e8e
Show file tree
Hide file tree
Showing 57 changed files with 236 additions and 236 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.traveltime.plugin.solr.cache.RequestCache;
import com.traveltime.plugin.solr.fetcher.ProtoFetcherSingleton;
import com.traveltime.plugin.solr.query.TraveltimeQueryParser;
import com.traveltime.plugin.solr.query.TravelTimeQueryParser;
import org.apache.solr.common.params.SolrParams;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.request.SolrQueryRequest;
Expand All @@ -13,7 +13,7 @@

import static com.traveltime.plugin.solr.query.ParamSource.PARAM_PREFIX;

public class TraveltimeQParserPlugin extends QParserPlugin {
public class TravelTimeQParserPlugin extends QParserPlugin {
private String cacheName = RequestCache.NAME;
private boolean isFilteringDisabled = false;
private String paramPrefix = PARAM_PREFIX;
Expand All @@ -40,7 +40,7 @@ public void init(NamedList args) {

@Override
public QParser createParser(String qstr, SolrParams localParams, SolrParams params, SolrQueryRequest req) {
return new TraveltimeQueryParser(
return new TravelTimeQueryParser(
qstr,
localParams,
params,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.traveltime.plugin.solr.cache;

import com.traveltime.plugin.solr.query.TraveltimeQueryParameters;
import com.traveltime.plugin.solr.query.TravelTimeQueryParameters;

public class ExactRequestCache extends RequestCache<TraveltimeQueryParameters> {
public class ExactRequestCache extends RequestCache<TravelTimeQueryParameters> {
private final Object[] lock = new Object[0];

@Override
public TravelTimes getOrFresh(TraveltimeQueryParameters key) {
public TravelTimes getOrFresh(TravelTimeQueryParameters key) {
TravelTimes result = get(key);
if (result == null) {
synchronized (lock) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.traveltime.plugin.solr.cache;

import com.traveltime.plugin.solr.query.TraveltimeQueryParameters;
import com.traveltime.plugin.solr.query.TravelTimeQueryParameters;
import org.apache.solr.search.CacheRegenerator;

import java.util.Map;

public class FuzzyRequestCache extends RequestCache<TraveltimeQueryParameters> {
public class FuzzyRequestCache extends RequestCache<TravelTimeQueryParameters> {
private final Object[] lock = new Object[0];
private Map<String, String> args;

Expand All @@ -16,8 +16,8 @@ public Object init(Map args, Object persistence, CacheRegenerator regenerator) {
}

@Override
public TravelTimes getOrFresh(TraveltimeQueryParameters key) {
key = new TraveltimeQueryParameters(null, key.getOrigin(), 0, key.getMode(), null);
public TravelTimes getOrFresh(TravelTimeQueryParameters key) {
key = new TravelTimeQueryParameters(null, key.getOrigin(), 0, key.getMode(), null);
TravelTimes result = get(key);
if (result == null) {
synchronized (lock) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import java.util.List;
import java.util.Set;

//Only for use within TraveltimeDelegatingCollector if no cache is set up
//Only for use within TravelTimeDelegatingCollector if no cache is set up
public class UnprotectedTimes extends TravelTimes {
private final Object2IntOpenHashMap<Coordinates> coordsToTimes = new Object2IntOpenHashMap<>();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.traveltime.plugin.solr.fetcher;

import com.traveltime.plugin.solr.query.TraveltimeQueryParameters;
import com.traveltime.plugin.solr.query.TravelTimeQueryParameters;
import com.traveltime.plugin.solr.util.Util;
import com.traveltime.sdk.TravelTimeSDK;
import com.traveltime.sdk.auth.TravelTimeCredentials;
Expand All @@ -20,7 +20,7 @@
import java.util.Arrays;
import java.util.List;

public class ProtoFetcher implements Fetcher<TraveltimeQueryParameters> {
public class ProtoFetcher implements Fetcher<TravelTimeQueryParameters> {
private final TravelTimeSDK api;

private final Logger log = LoggerFactory.getLogger(ProtoFetcher.class);
Expand Down Expand Up @@ -50,7 +50,7 @@ public ProtoFetcher(URI uri, String id, String key) {
}

@Override
public List<Integer> getTimes(TraveltimeQueryParameters params, ArrayList<Coordinates> destinations) {
public List<Integer> getTimes(TravelTimeQueryParameters params, ArrayList<Coordinates> destinations) {
val fastProto = TimeFilterFastProtoRequest
.builder()
.oneToMany(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import java.util.ArrayList;
import java.util.List;

public class TraveltimeDelegatingCollector<Params extends QueryParams> extends DelegatingCollector {
public class TravelTimeDelegatingCollector<Params extends QueryParams> extends DelegatingCollector {
private final LeafReaderContext[] contexts;
private final int[] contextBaseStart;
private final int[] contextBaseEnd;
Expand All @@ -43,7 +43,7 @@ public class TraveltimeDelegatingCollector<Params extends QueryParams> extends D
private SortedNumericDocValues coords;


public TraveltimeDelegatingCollector(int maxDoc, int segments, Params params, float scoreWeight, Fetcher<Params> fetcher, RequestCache<Params> cache, boolean isFilteringDisabled) {
public TravelTimeDelegatingCollector(int maxDoc, int segments, Params params, float scoreWeight, Fetcher<Params> fetcher, RequestCache<Params> cache, boolean isFilteringDisabled) {
this.maxDoc = maxDoc;
this.contexts = new LeafReaderContext[segments];
this.contextBaseStart = new int[segments];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import java.util.function.Function;

@Data
public class TraveltimeQueryParameters implements QueryParams {
public class TravelTimeQueryParameters implements QueryParams {
private final String field;
private final Coordinates origin;
private final int limit;
Expand Down Expand Up @@ -44,41 +44,41 @@ private static <T> T findByNameOrError(String what, String name, Function<String
}
}

public static TraveltimeQueryParameters parse(
public static TravelTimeQueryParameters parse(
IndexSchema schema,
ParamSource params
) throws SyntaxError {
String field = params.getParam(TraveltimeQueryParameters.FIELD);
String field = params.getParam(TravelTimeQueryParameters.FIELD);

val fieldType = schema.getField(field);
if (!(fieldType.getType() instanceof LatLonPointSpatialField)) {
throw new SyntaxError("field[" + field + "] is not a LatLonPointSpatialField");
}

val origin = Util.toGeoPoint(params.getParam(TraveltimeQueryParameters.ORIGIN));
val origin = Util.toGeoPoint(params.getParam(TravelTimeQueryParameters.ORIGIN));

val mode = findByNameOrError(
"transportation mode",
params.getParam(TraveltimeQueryParameters.MODE),
params.getParam(TravelTimeQueryParameters.MODE),
Util::findModeByName
);
val country = findByNameOrError(
"country",
params.getParam(TraveltimeQueryParameters.COUNTRY),
params.getParam(TravelTimeQueryParameters.COUNTRY),
Util::findCountryByName
);

int limit;
try {
limit = Integer.parseInt(params.getParam(TraveltimeQueryParameters.LIMIT));
limit = Integer.parseInt(params.getParam(TravelTimeQueryParameters.LIMIT));
} catch (NumberFormatException e) {
throw new SyntaxError("Couldn't parse traveltime limit as an integer");
}
if (limit <= 0) {
throw new SyntaxError("traveltime limit must be > 0");
}

return new TraveltimeQueryParameters(field, origin, limit, mode, country);
return new TravelTimeQueryParameters(field, origin, limit, mode, country);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
import org.apache.solr.search.QParser;
import org.apache.solr.search.SyntaxError;

public class TraveltimeQueryParser extends QParser {
public class TravelTimeQueryParser extends QParser {
private static final String WEIGHT = "weight";

private final Fetcher<TraveltimeQueryParameters> fetcher;
private final Fetcher<TravelTimeQueryParameters> fetcher;
private final String cacheName;
private final boolean isFilteringDisabled;
private final String paramPrefix;

public TraveltimeQueryParser(String qstr, SolrParams localParams, SolrParams params, SolrQueryRequest req, Fetcher<TraveltimeQueryParameters> fetcher, String cacheName, boolean isFilteringDisabled, String paramPrefix) {
public TravelTimeQueryParser(String qstr, SolrParams localParams, SolrParams params, SolrQueryRequest req, Fetcher<TravelTimeQueryParameters> fetcher, String cacheName, boolean isFilteringDisabled, String paramPrefix) {
super(qstr, localParams, params, req);
this.fetcher = fetcher;
this.cacheName = cacheName;
Expand All @@ -24,7 +24,7 @@ public TraveltimeQueryParser(String qstr, SolrParams localParams, SolrParams par
}

@Override
public TraveltimeSearchQuery<TraveltimeQueryParameters> parse() throws SyntaxError {
public TravelTimeSearchQuery<TravelTimeQueryParameters> parse() throws SyntaxError {
ParamSource paramSource = new ParamSource(paramPrefix, localParams, params);
float weight;
try {
Expand All @@ -35,11 +35,11 @@ public TraveltimeSearchQuery<TraveltimeQueryParameters> parse() throws SyntaxErr
throw new SyntaxError("Couldn't parse traveltime weight as a float");
}
if (weight < 0 || weight > 1) {
throw new SyntaxError("Traveltime weight must be between 0 and 1");
throw new SyntaxError("TravelTime weight must be between 0 and 1");
}

val params = TraveltimeQueryParameters.parse(req.getSchema(), paramSource);
return new TraveltimeSearchQuery<>(params, weight, fetcher, cacheName, isFilteringDisabled);
val params = TravelTimeQueryParameters.parse(req.getSchema(), paramSource);
return new TravelTimeSearchQuery<>(params, weight, fetcher, cacheName, isFilteringDisabled);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
public class TraveltimeSearchQuery<Params extends QueryParams> extends ExtendedQueryBase implements PostFilter {
public class TravelTimeSearchQuery<Params extends QueryParams> extends ExtendedQueryBase implements PostFilter {
private final Params params;
private final float weight;
private final Fetcher<Params> fetcher;
Expand All @@ -50,7 +50,7 @@ public class TraveltimeSearchQuery<Params extends QueryParams> extends ExtendedQ

@Override
public String toString(String field) {
return String.format("TraveltimeSearchQuery(params = %s)", params);
return String.format("TravelTimeSearchQuery(params = %s)", params);
}

@Override
Expand All @@ -59,7 +59,7 @@ public DelegatingCollector getFilterCollector(IndexSearcher indexSearcher) {
RequestCache<Params> cache = (RequestCache<Params>) searcher.getCache(cacheName);
int maxDoc = searcher.maxDoc();
int leafCount = searcher.getTopReaderContext().leaves().size();
return new TraveltimeDelegatingCollector<>(
return new TravelTimeDelegatingCollector<>(
maxDoc,
leafCount,
params,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

@RequiredArgsConstructor
@EqualsAndHashCode(callSuper = false)
public class TraveltimeValueSource<Params extends QueryParams> extends ValueSource {
public class TravelTimeValueSource<Params extends QueryParams> extends ValueSource {
private final Params params;
@EqualsAndHashCode.Exclude
private final TravelTimes cache;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

import static com.traveltime.plugin.solr.query.ParamSource.PARAM_PREFIX;

public class TraveltimeValueSourceParser extends ValueSourceParser {
public class TravelTimeValueSourceParser extends ValueSourceParser {
private String cacheName = RequestCache.NAME;

private String paramPrefix = PARAM_PREFIX;
Expand All @@ -30,7 +30,7 @@ public void init(NamedList args) {
@Override
public ValueSource parse(FunctionQParser fp) throws SyntaxError {
SolrQueryRequest req = fp.getReq();
RequestCache<TraveltimeQueryParameters> cache = (RequestCache<TraveltimeQueryParameters>) req.getSearcher()
RequestCache<TravelTimeQueryParameters> cache = (RequestCache<TravelTimeQueryParameters>) req.getSearcher()
.getCache(cacheName);
if (cache == null) {
throw new SolrException(
Expand All @@ -39,10 +39,10 @@ public ValueSource parse(FunctionQParser fp) throws SyntaxError {
);
}

val queryParameters = TraveltimeQueryParameters.parse(
val queryParameters = TravelTimeQueryParameters.parse(
req.getSchema(),
new ParamSource(paramPrefix, fp.getParams())
);
return new TraveltimeValueSource<>(queryParameters, cache.getOrFresh(queryParameters));
return new TravelTimeValueSource<>(queryParameters, cache.getOrFresh(queryParameters));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.traveltime.plugin.solr.fetcher.Fetcher;
import com.traveltime.plugin.solr.query.ParamSource;
import com.traveltime.plugin.solr.query.TraveltimeSearchQuery;
import com.traveltime.plugin.solr.query.TravelTimeSearchQuery;
import lombok.val;
import org.apache.solr.common.params.SolrParams;
import org.apache.solr.request.SolrQueryRequest;
Expand All @@ -26,7 +26,7 @@ public TimeFilterQueryParser(String qstr, SolrParams localParams, SolrParams par
}

@Override
public TraveltimeSearchQuery<TimeFilterQueryParameters> parse() throws SyntaxError {
public TravelTimeSearchQuery<TimeFilterQueryParameters> parse() throws SyntaxError {
ParamSource paramSource = new ParamSource(paramPrefix, localParams, params);
float weight;
try {
Expand All @@ -37,11 +37,11 @@ public TraveltimeSearchQuery<TimeFilterQueryParameters> parse() throws SyntaxErr
throw new SyntaxError("Couldn't parse traveltime weight as a float");
}
if (weight < 0 || weight > 1) {
throw new SyntaxError("Traveltime weight must be between 0 and 1");
throw new SyntaxError("TravelTime weight must be between 0 and 1");
}

val params = TimeFilterQueryParameters.parse(req.getSchema(), paramSource);
return new TraveltimeSearchQuery<>(params, weight, fetcher, cacheName, isFilteringDisabled);
return new TravelTimeSearchQuery<>(params, weight, fetcher, cacheName, isFilteringDisabled);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.traveltime.plugin.solr.cache.RequestCache;
import com.traveltime.plugin.solr.query.ParamSource;
import com.traveltime.plugin.solr.query.TraveltimeValueSource;
import com.traveltime.plugin.solr.query.TravelTimeValueSource;
import org.apache.lucene.queries.function.ValueSource;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.util.NamedList;
Expand Down Expand Up @@ -44,6 +44,6 @@ public ValueSource parse(FunctionQParser fp) throws SyntaxError {
req.getSchema(),
new ParamSource(paramPrefix, fp.getParams())
);
return new TraveltimeValueSource<>(queryParams, cache.getOrFresh(queryParams));
return new TravelTimeValueSource<>(queryParams, cache.getOrFresh(queryParams));
}
}
Loading

0 comments on commit 01e8e8e

Please sign in to comment.