Skip to content

Commit

Permalink
Fix build error
Browse files Browse the repository at this point in the history
  • Loading branch information
takaaki7 authored and takaaki7 committed Oct 12, 2023
1 parent c339b85 commit 1fb88a3
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,15 @@
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeName;
import com.fasterxml.jackson.annotation.JsonValue;
import com.google.common.base.Preconditions;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.atomic.AtomicLong;
import java.util.function.Function;
import org.apache.druid.java.util.common.Cacheable;
import org.apache.druid.java.util.common.IAE;
import org.apache.druid.java.util.common.StringUtils;
import org.apache.druid.query.planning.DataSourceAnalysis;
import org.apache.druid.segment.SegmentReference;

@JsonTypeName("sampled_table")
public class SampledTableDataSource extends TableDataSource
{
private final SamplingType samplingType;
private final int samplingPercentage;

public enum SamplingType implements Cacheable
{
FIXED_SHARD;
Expand Down Expand Up @@ -88,17 +79,20 @@ public static SampledTableDataSource create(


@JsonProperty
public SamplingType getSamplingType() {
public SamplingType getSamplingType()
{
return samplingType;
}

@JsonProperty
public float getSamplingPercentage() {
public float getSamplingPercentage()
{
return samplingPercentage;
}

@Override
public boolean equals(Object o) {
public boolean equals(Object o)
{
if (this == o) {
return true;
}
Expand All @@ -118,7 +112,8 @@ public boolean equals(Object o) {
}

@Override
public int hashCode() {
public int hashCode()
{
int result = super.hashCode();
result = 31 * result + (samplingType != null ? samplingType.hashCode() : 0);
result = 31 * result + samplingPercentage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,12 @@ public void addCpuNanos(long ns)
addValue(Keys.CPU_CONSUMED_NANOS, ns);
}


public void addSamplingComposition(String samplingComposition)
{
addValue(Keys.SAMPLING_COMPOSITION, samplingComposition);
}

private Object addValue(Key key, Object value)
{
return getDelegate().merge(key, value, key::mergeValues);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ public DataSource getBaseDataSource()
* Note that this can return empty even if {@link #isConcreteAndTableBased()} is true. This happens if the base
* datasource is a {@link UnionDataSource} of {@link TableDataSource}.
*/
public Optional<TableDataSource> getBaseTableDataSource() {
public Optional<TableDataSource> getBaseTableDataSource()
{
if (baseDataSource instanceof TableDataSource) {
return Optional.of((TableDataSource) baseDataSource);
} else if (baseDataSource instanceof SampledTableDataSource) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ private TopNMapFn getMapFn(


final TopNAlgorithm<?, ?> topNAlgorithm;
if (canUsePooledAlgorithm(selector, query, columnCapabilities)) {
if (canUsePooledAlgorithm(selector, query, columnCapabilities)) {
// pool based algorithm selection, if we can
if (selector.isAggregateAllMetrics()) {
// if sorted by dimension we should aggregate all metrics in a single pass, use the regular pooled algorithm for
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@

package org.apache.druid.client;

import static org.apache.druid.query.context.ResponseContext.Keys.SAMPLING_COMPOSITION;

import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.annotations.VisibleForTesting;
Expand Down Expand Up @@ -350,7 +348,7 @@ ClusterQueryResult<T> run(
final Set<SegmentServerSelector> segmentServers = computeSegmentsToQuery(timeline, specificSegments);
Pair<Integer, Integer> ratio = pruneSegmentsForShardSampling(segmentServers);
if (ratio != null) {
responseContext.add(SAMPLING_COMPOSITION, ratio.lhs + "/" + ratio.rhs);
responseContext.addSamplingComposition(ratio.lhs + "/" + ratio.rhs);
}
@Nullable
final byte[] queryCacheKey = cacheKeyManager.computeSegmentLevelQueryCacheKey();
Expand Down Expand Up @@ -512,7 +510,8 @@ private void computeUncoveredIntervals(TimelineLookup<String, ServerSelector> ti
}
}

private Pair<Integer, Integer> pruneSegmentsForShardSampling(final Set<SegmentServerSelector> segments) {
private Pair<Integer, Integer> pruneSegmentsForShardSampling(final Set<SegmentServerSelector> segments)
{
if (query.getDataSource() instanceof SampledTableDataSource) {
if (((SampledTableDataSource) query.getDataSource()).getSamplingType()
== SamplingType.FIXED_SHARD) {
Expand Down

0 comments on commit 1fb88a3

Please sign in to comment.