Skip to content

Commit

Permalink
Address PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
rjernst committed Jun 15, 2015
1 parent 0ef5a27 commit a08f51e
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -203,12 +203,10 @@ public MappedFieldType clone() {

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof MappedFieldType)) return false;
if (!super.equals(o)) return false;
MappedFieldType fieldType = (MappedFieldType) o;
return Objects.equals(boost, fieldType.boost) &&
Objects.equals(docValues, fieldType.docValues) &&
return boost == fieldType.boost &&
docValues == fieldType.docValues &&
Objects.equals(names, fieldType.names) &&
Objects.equals(indexAnalyzer, fieldType.indexAnalyzer) &&
Objects.equals(searchAnalyzer, fieldType.searchAnalyzer) &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,6 @@ public MappedFieldType clone() {

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof BinaryFieldType)) return false;
if (!super.equals(o)) return false;
BinaryFieldType that = (BinaryFieldType) o;
return Objects.equals(tryUncompressing, that.tryUncompressing);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,17 +237,15 @@ public DateFieldType clone() {

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof DateFieldType)) return false;
if (!super.equals(o)) return false;
DateFieldType that = (DateFieldType) o;
return Objects.equals(dateTimeFormatter.format(), that.dateTimeFormatter.format()) &&
Objects.equals(timeUnit, that.timeUnit);
Objects.equals(timeUnit, that.timeUnit);
}

@Override
public int hashCode() {
return Objects.hash(super.hashCode(), dateTimeFormatter, timeUnit);
return Objects.hash(super.hashCode(), dateTimeFormatter.format(), timeUnit);
}

public FormatDateTimeFormatter dateTimeFormatter() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,16 +314,14 @@ public MappedFieldType clone() {

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof GeoPointFieldType)) return false;
if (!super.equals(o)) return false;
GeoPointFieldType that = (GeoPointFieldType) o;
return java.util.Objects.equals(geohashPrecision, that.geohashPrecision) &&
java.util.Objects.equals(geohashPrefixEnabled, that.geohashPrefixEnabled) &&
java.util.Objects.equals(validateLon, that.validateLon) &&
java.util.Objects.equals(validateLat, that.validateLat) &&
java.util.Objects.equals(normalizeLon, that.normalizeLon) &&
java.util.Objects.equals(normalizeLat, that.normalizeLat) &&
return geohashPrecision == that.geohashPrecision &&
geohashPrefixEnabled == that.geohashPrefixEnabled &&
validateLon == that.validateLon &&
validateLat == that.validateLat &&
normalizeLon == that.normalizeLon &&
normalizeLat == that.normalizeLat &&
java.util.Objects.equals(geohashFieldType, that.geohashFieldType) &&
java.util.Objects.equals(latFieldType, that.latFieldType) &&
java.util.Objects.equals(lonFieldType, that.lonFieldType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,17 +208,15 @@ public MappedFieldType clone() {

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof GeoShapeFieldType)) return false;
if (!super.equals(o)) return false;
GeoShapeFieldType that = (GeoShapeFieldType) o;
return Objects.equals(treeLevels, that.treeLevels) &&
Objects.equals(precisionInMeters, that.precisionInMeters) &&
Objects.equals(defaultDistanceErrorPct, that.defaultDistanceErrorPct) &&
return treeLevels == that.treeLevels &&
precisionInMeters == that.precisionInMeters &&
defaultDistanceErrorPct == that.defaultDistanceErrorPct &&
Objects.equals(tree, that.tree) &&
Objects.equals(strategyName, that.strategyName) &&
Objects.equals(distanceErrorPct, that.distanceErrorPct) &&
Objects.equals(orientation, that.orientation);
orientation == that.orientation;
}

@Override
Expand All @@ -229,6 +227,8 @@ public int hashCode() {
@Override
public void freeze() {
super.freeze();
// This is a bit hackish: we need to setup the spatial tree and strategies once the field name is set, which
// must be by the time freeze is called.
SpatialPrefixTree prefixTree;
if ("geohash".equals(tree)) {
prefixTree = new GeohashPrefixTree(ShapeBuilder.SPATIAL_CONTEXT, getLevels(treeLevels, precisionInMeters, Defaults.GEOHASH_LEVELS, true));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,9 @@ protected FieldNamesFieldType(FieldNamesFieldType ref) {

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof FieldNamesFieldType)) return false;
if (!super.equals(o)) return false;
FieldNamesFieldType that = (FieldNamesFieldType) o;
return Objects.equals(enabled, that.enabled);
return enabled == that.enabled;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ protected void modifyProperty(MappedFieldType ft, int propNum) {
BinaryFieldMapper.BinaryFieldType bft = (BinaryFieldMapper.BinaryFieldType)ft;
switch (propNum) {
case 0: bft.setTryUncompressing(!bft.tryUncompressing()); break;
default: super.modifyProperty(ft, numProperties() - propNum - 1);
default: super.modifyProperty(ft, 1 + propNum);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ protected void modifyProperty(MappedFieldType ft, int propNum) {
switch (propNum) {
case 0: dft.setDateTimeFormatter(Joda.forPattern("basic_week_date", Locale.ROOT)); break;
case 1: dft.setTimeUnit(TimeUnit.HOURS); break;
default: super.modifyProperty(ft, numProperties() - propNum - 1);
default: super.modifyProperty(ft, 2 + propNum);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ protected void modifyProperty(MappedFieldType ft, int propNum) {
case 3: gft.setValidateLat(!gft.validateLat()); break;
case 4: gft.setNormalizeLon(!gft.normalizeLon()); break;
case 5: gft.setNormalizeLat(!gft.normalizeLat()); break;
default: super.modifyProperty(ft, numProperties() - propNum - 1);
default: super.modifyProperty(ft, 6 + propNum);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ protected void modifyProperty(MappedFieldType ft, int propNum) {
case 3: gft.setPrecisionInMeters(20); break;
case 4: gft.setDefaultDistanceErrorPct(0.5); break;
case 5: gft.setOrientation(ShapeBuilder.Orientation.LEFT); break;
default: super.modifyProperty(ft, numProperties() - propNum - 1);
default: super.modifyProperty(ft, 6 + propNum);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ protected void modifyProperty(MappedFieldType ft, int propNum) {
FieldNamesFieldMapper.FieldNamesFieldType fnft = (FieldNamesFieldMapper.FieldNamesFieldType)ft;
switch (propNum) {
case 0: fnft.setEnabled(!fnft.isEnabled()); break;
default: super.modifyProperty(ft, numProperties() - propNum - 1);
default: super.modifyProperty(ft, 1 + propNum);
}
}
}

0 comments on commit a08f51e

Please sign in to comment.