mirror of https://github.com/apache/druid.git
refactor method
This commit is contained in:
parent
477e01daf7
commit
f2725994b7
|
@ -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(
|
||||
|
|
|
@ -39,5 +39,5 @@ public interface DataSource
|
|||
{
|
||||
public Iterable<String> getNames();
|
||||
|
||||
public String getMetricName();
|
||||
public String toShortString();
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -51,7 +51,7 @@ public class TableDataSource implements DataSource
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getMetricName()
|
||||
public String toShortString()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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()))
|
||||
|
|
|
@ -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()))
|
||||
|
|
|
@ -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()))
|
||||
|
|
|
@ -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()))
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
|
|
|
@ -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()))
|
||||
|
|
|
@ -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()))
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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()))
|
||||
|
|
|
@ -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()))
|
||||
|
|
Loading…
Reference in New Issue