Skip to content

Commit

Permalink
Remove DataSchema equals() and hashcode()
Browse files Browse the repository at this point in the history
  • Loading branch information
jon-wei authored and drcrallen committed May 10, 2016
1 parent 6332bd7 commit f2510cf
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 53 deletions.
36 changes: 0 additions & 36 deletions server/src/main/java/io/druid/segment/indexing/DataSchema.java
Original file line number Diff line number Diff line change
Expand Up @@ -166,42 +166,6 @@ public DataSchema withGranularitySpec(GranularitySpec granularitySpec)
return new DataSchema(dataSource, parser, aggregators, granularitySpec, jsonMapper);
}

@Override
public boolean equals(Object o)
{
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}

DataSchema that = (DataSchema) o;

if (!dataSource.equals(that.dataSource)) {
return false;
}
if (parser != null ? !parser.equals(that.parser) : that.parser != null) {
return false;
}
// Probably incorrect - comparing Object[] arrays with Arrays.equals
if (!Arrays.equals(aggregators, that.aggregators)) {
return false;
}
return granularitySpec.equals(that.granularitySpec);

}

@Override
public int hashCode()
{
int result = dataSource.hashCode();
result = 31 * result + (parser != null ? parser.hashCode() : 0);
result = 31 * result + Arrays.hashCode(aggregators);
result = 31 * result + granularitySpec.hashCode();
return result;
}

@Override
public String toString()
{
Expand Down
34 changes: 17 additions & 17 deletions server/src/test/java/io/druid/segment/indexing/DataSchemaTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import org.junit.Assert;
import org.junit.Test;

import java.util.Arrays;
import java.util.Map;

public class DataSchemaTest
Expand Down Expand Up @@ -191,24 +192,23 @@ public void testSerde() throws Exception
DataSchema.class
);

Assert.assertEquals(actual.getDataSource(), "test");
Assert.assertEquals(
new DataSchema(
"test",
jsonMapper.<Map<String, Object>>convertValue(
new StringInputRowParser(
new JSONParseSpec(
new TimestampSpec("xXx", null, null),
new DimensionsSpec(null, null, null)
)
), new TypeReference<Map<String, Object>>() {}
),
new AggregatorFactory[]{
new DoubleSumAggregatorFactory("metric1", "col1")
},
new ArbitraryGranularitySpec(QueryGranularity.DAY, ImmutableList.of(Interval.parse("2014/2015"))),
jsonMapper
),
actual
actual.getParser().getParseSpec(),
new JSONParseSpec(
new TimestampSpec("xXx", null, null),
new DimensionsSpec(null, Arrays.asList("metric1", "xXx", "col1"), null)
)
);
Assert.assertEquals(
actual.getAggregators(),
new AggregatorFactory[]{
new DoubleSumAggregatorFactory("metric1", "col1")
}
);
Assert.assertEquals(
actual.getGranularitySpec(),
new ArbitraryGranularitySpec(QueryGranularity.DAY, ImmutableList.of(Interval.parse("2014/2015")))
);
}
}

0 comments on commit f2510cf

Please sign in to comment.