refactor method

This commit is contained in:
nishantmonu51 2014-05-05 19:57:32 +05:30
parent 477e01daf7
commit f2725994b7
15 changed files with 18 additions and 24 deletions

View File

@ -762,6 +762,8 @@ public class DeterminePartitionsJob implements Jobby
log.info(" %s", HadoopDruidIndexerConfig.jsonMapper.writeValueAsString(shardSpec));
}
System.out.println(HadoopDruidIndexerConfig.jsonMapper.writeValueAsString(chosenShardSpecs));
try {
HadoopDruidIndexerConfig.jsonMapper
.writerWithType(

View File

@ -39,5 +39,5 @@ public interface DataSource
{
public Iterable<String> getNames();
public String getMetricName();
public String toShortString();
}

View File

@ -24,9 +24,6 @@ package io.druid.query;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeName;
import com.google.common.collect.Lists;
import java.util.List;
@JsonTypeName("query")
public class QueryDataSource implements DataSource
@ -47,9 +44,9 @@ public class QueryDataSource implements DataSource
}
@Override
public String getMetricName()
public String toShortString()
{
return query.getDataSource().getMetricName();
return query.getDataSource().toShortString();
}
@JsonProperty

View File

@ -51,7 +51,7 @@ public class TableDataSource implements DataSource
}
@Override
public String getMetricName()
public String toShortString()
{
return name;
}

View File

@ -27,9 +27,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.base.Function;
import com.google.common.base.Preconditions;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import javax.annotation.Nullable;
import java.util.List;
import java.util.SortedSet;
import java.util.TreeSet;
@ -60,11 +58,11 @@ public class UnionDataSource implements DataSource
}
@Override
public String getMetricName()
public String toShortString()
{
SortedSet<String> str = new TreeSet<>();
for(DataSource ds : dataSources){
str.add(ds.getMetricName());
str.add(ds.toShortString());
}
return str.toString();
}

View File

@ -163,7 +163,7 @@ public class GroupByQueryQueryToolChest extends QueryToolChest<Row, GroupByQuery
}
return new ServiceMetricEvent.Builder()
.setUser2(query.getDataSource().getMetricName())
.setUser2(query.getDataSource().toShortString())
.setUser3(String.format("%,d dims", query.getDimensions().size()))
.setUser4("groupBy")
.setUser5(Joiner.on(",").join(query.getIntervals()))

View File

@ -147,7 +147,7 @@ public class SegmentMetadataQueryQueryToolChest extends QueryToolChest<SegmentAn
}
return new ServiceMetricEvent.Builder()
.setUser2(query.getDataSource().getMetricName())
.setUser2(query.getDataSource().toShortString())
.setUser4(query.getType())
.setUser5(Joiner.on(",").join(query.getIntervals()))
.setUser6(String.valueOf(query.hasFilters()))

View File

@ -121,7 +121,7 @@ public class SearchQueryQueryToolChest extends QueryToolChest<Result<SearchResul
}
return new ServiceMetricEvent.Builder()
.setUser2(query.getDataSource().getMetricName())
.setUser2(query.getDataSource().toShortString())
.setUser4("search")
.setUser5(COMMA_JOIN.join(query.getIntervals()))
.setUser6(String.valueOf(query.hasFilters()))

View File

@ -123,7 +123,7 @@ public class SelectQueryQueryToolChest extends QueryToolChest<Result<SelectResul
}
return new ServiceMetricEvent.Builder()
.setUser2(query.getDataSource().getMetricName())
.setUser2(query.getDataSource().toShortString())
.setUser4("Select")
.setUser5(COMMA_JOIN.join(query.getIntervals()))
.setUser6(String.valueOf(query.hasFilters()))

View File

@ -117,7 +117,7 @@ public class TimeBoundaryQueryQueryToolChest
public ServiceMetricEvent.Builder makeMetricBuilder(TimeBoundaryQuery query)
{
return new ServiceMetricEvent.Builder()
.setUser2(query.getDataSource().getMetricName())
.setUser2(query.getDataSource().toShortString())
.setUser4(query.getType())
.setUser6("false");
}

View File

@ -122,7 +122,7 @@ public class TimeseriesQueryQueryToolChest extends QueryToolChest<Result<Timeser
}
return new ServiceMetricEvent.Builder()
.setUser2(query.getDataSource().getMetricName())
.setUser2(query.getDataSource().toShortString())
.setUser4("timeseries")
.setUser5(COMMA_JOIN.join(query.getIntervals()))
.setUser6(String.valueOf(query.hasFilters()))

View File

@ -138,7 +138,7 @@ public class TopNQueryQueryToolChest extends QueryToolChest<Result<TopNResultVal
}
return new ServiceMetricEvent.Builder()
.setUser2(query.getDataSource().getMetricName())
.setUser2(query.getDataSource().toShortString())
.setUser4(String.format("topN/%s/%s", query.getThreshold(), query.getDimensionSpec().getDimension()))
.setUser5(COMMA_JOIN.join(query.getIntervals()))
.setUser6(String.valueOf(query.hasFilters()))

View File

@ -22,10 +22,7 @@
package io.druid.query;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.base.Function;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.metamx.common.guava.Sequence;
import io.druid.jackson.DefaultObjectMapper;
import io.druid.query.aggregation.AggregatorFactory;
import io.druid.query.aggregation.LongSumAggregatorFactory;
@ -104,7 +101,7 @@ public class DataSourceTest
Lists.newArrayList("ds1", "ds2"),
Lists.newArrayList(dataSource.getNames())
);
Assert.assertEquals(Lists.newArrayList("ds1", "ds2").toString(), dataSource.getMetricName());
Assert.assertEquals(Lists.newArrayList("ds1", "ds2").toString(), dataSource.toShortString());
final DataSource serde = jsonMapper.readValue(jsonMapper.writeValueAsString(dataSource), DataSource.class);
Assert.assertEquals(dataSource, serde);

View File

@ -282,7 +282,7 @@ public class AsyncQueryForwardingServlet extends HttpServlet
emitter.emit(
new ServiceMetricEvent.Builder()
.setUser2(theQuery.getDataSource().getMetricName())
.setUser2(theQuery.getDataSource().toShortString())
.setUser4(theQuery.getType())
.setUser5(COMMA_JOIN.join(theQuery.getIntervals()))
.setUser6(String.valueOf(theQuery.hasFilters()))

View File

@ -131,7 +131,7 @@ public class QueryResource
emitter.emit(
new ServiceMetricEvent.Builder()
.setUser2(query.getDataSource().getMetricName())
.setUser2(query.getDataSource().toShortString())
.setUser4(query.getType())
.setUser5(COMMA_JOIN.join(query.getIntervals()))
.setUser6(String.valueOf(query.hasFilters()))