Make a few class level fields static

This commit converts some final constant instance fields to class
fields.
This commit is contained in:
Koen De Groote 2017-05-12 04:44:31 +02:00 committed by Jason Tedor
parent 7b7e15023a
commit 220bd2de6e
4 changed files with 15 additions and 15 deletions

View File

@ -315,11 +315,11 @@ final class BootstrapChecks {
static class MaxNumberOfThreadsCheck implements BootstrapCheck {
// this should be plenty for machines up to 256 cores
private final long maxNumberOfThreadsThreshold = 1 << 12;
private static final long MAX_NUMBER_OF_THREADS_THRESHOLD = 1 << 12;
@Override
public boolean check() {
return getMaxNumberOfThreads() != -1 && getMaxNumberOfThreads() < maxNumberOfThreadsThreshold;
return getMaxNumberOfThreads() != -1 && getMaxNumberOfThreads() < MAX_NUMBER_OF_THREADS_THRESHOLD;
}
@Override
@ -329,7 +329,7 @@ final class BootstrapChecks {
"max number of threads [%d] for user [%s] is too low, increase to at least [%d]",
getMaxNumberOfThreads(),
BootstrapInfo.getSystemProperties().get("user.name"),
maxNumberOfThreadsThreshold);
MAX_NUMBER_OF_THREADS_THRESHOLD);
}
// visible for testing
@ -369,11 +369,11 @@ final class BootstrapChecks {
static class MaxMapCountCheck implements BootstrapCheck {
private final long limit = 1 << 18;
private static final long LIMIT = 1 << 18;
@Override
public boolean check() {
return getMaxMapCount() != -1 && getMaxMapCount() < limit;
return getMaxMapCount() != -1 && getMaxMapCount() < LIMIT;
}
@Override
@ -382,7 +382,7 @@ final class BootstrapChecks {
Locale.ROOT,
"max virtual memory areas vm.max_map_count [%d] is too low, increase to at least [%d]",
getMaxMapCount(),
limit);
LIMIT);
}
// visible for testing

View File

@ -79,21 +79,21 @@ public abstract class ShapeBuilder extends ToXContentToBytes implements NamedWri
/** It's possible that some geometries in a MULTI* shape might overlap. With the possible exception of GeometryCollection,
* this normally isn't allowed.
*/
protected final boolean multiPolygonMayOverlap = false;
protected static final boolean MULTI_POLYGON_MAY_OVERLAP = false;
/** @see org.locationtech.spatial4j.shape.jts.JtsGeometry#validate() */
protected final boolean autoValidateJtsGeometry = true;
protected static final boolean AUTO_VALIDATE_JTS_GEOMETRY = true;
/** @see org.locationtech.spatial4j.shape.jts.JtsGeometry#index() */
protected final boolean autoIndexJtsGeometry = true;//may want to turn off once SpatialStrategy impls do it.
protected static final boolean AUTO_INDEX_JTS_GEOMETRY = true;//may want to turn off once SpatialStrategy impls do it.
protected ShapeBuilder() {
}
protected JtsGeometry jtsGeometry(Geometry geom) {
//dateline180Check is false because ElasticSearch does it's own dateline wrapping
JtsGeometry jtsGeometry = new JtsGeometry(geom, SPATIAL_CONTEXT, false, multiPolygonMayOverlap);
if (autoValidateJtsGeometry)
JtsGeometry jtsGeometry = new JtsGeometry(geom, SPATIAL_CONTEXT, false, MULTI_POLYGON_MAY_OVERLAP);
if (AUTO_VALIDATE_JTS_GEOMETRY)
jtsGeometry.validate();
if (autoIndexJtsGeometry)
if (AUTO_INDEX_JTS_GEOMETRY)
jtsGeometry.index();
return jtsGeometry;
}

View File

@ -70,7 +70,7 @@ public class RecoveryTarget extends AbstractRefCounted implements RecoveryTarget
private static final AtomicLong idGenerator = new AtomicLong();
private final String RECOVERY_PREFIX = "recovery.";
private static final String RECOVERY_PREFIX = "recovery.";
private final ShardId shardId;
private final long recoveryId;

View File

@ -58,7 +58,7 @@ public final class DirectCandidateGenerator extends CandidateGenerator {
private final TermsEnum termsEnum;
private final IndexReader reader;
private final long dictSize;
private final double logBase = 5;
private static final double LOG_BASE = 5;
private final long frequencyPlateau;
private final Analyzer preFilter;
private final Analyzer postFilter;
@ -189,7 +189,7 @@ public final class DirectCandidateGenerator extends CandidateGenerator {
protected long thresholdFrequency(long termFrequency, long dictionarySize) {
if (termFrequency > 0) {
return max(0, round(termFrequency * (log10(termFrequency - frequencyPlateau) * (1.0 / log10(logBase))) + 1));
return max(0, round(termFrequency * (log10(termFrequency - frequencyPlateau) * (1.0 / log10(LOG_BASE))) + 1));
}
return 0;