review comments & pom changes

This commit is contained in:
nishantmonu51 2014-07-10 11:48:46 +05:30
parent 36fc85736c
commit fa43049240
3 changed files with 17 additions and 13 deletions

View File

@ -36,17 +36,16 @@ import com.google.inject.Binder;
import com.google.inject.Injector;
import com.google.inject.Key;
import com.google.inject.Module;
import com.metamx.common.ISE;
import com.metamx.common.guava.FunctionalIterable;
import com.metamx.common.logger.Logger;
import io.druid.common.utils.JodaUtils;
import io.druid.data.input.InputRow;
import io.druid.data.input.impl.StringInputRowParser;
import io.druid.guice.GuiceInjectors;
import io.druid.guice.JsonConfigProvider;
import io.druid.guice.annotations.Self;
import io.druid.indexer.partitions.PartitionsSpec;
import io.druid.indexer.path.PathSpec;
import io.druid.guice.GuiceInjectors;
import io.druid.initialization.Initialization;
import io.druid.segment.column.ColumnConfig;
import io.druid.segment.indexing.granularity.GranularitySpec;
@ -63,7 +62,6 @@ import org.joda.time.DateTime;
import org.joda.time.Interval;
import org.joda.time.format.ISODateTimeFormat;
import javax.annotation.Nullable;
import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
@ -194,9 +192,8 @@ public class HadoopDruidIndexerConfig
Lists.transform(
entry.getValue(), new Function<HadoopyShardSpec, ShardSpec>()
{
@Nullable
@Override
public ShardSpec apply(@Nullable HadoopyShardSpec input)
public ShardSpec apply(HadoopyShardSpec input)
{
return input.getActualSpec();
}

View File

@ -41,7 +41,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<metamx.java-util.version>0.26.5</metamx.java-util.version>
<apache.curator.version>2.5.0</apache.curator.version>
<druid.api.version>0.2.4</druid.api.version>
<druid.api.version>0.2.5</druid.api.version>
</properties>
<modules>

View File

@ -25,14 +25,14 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.api.client.repackaged.com.google.common.base.Throwables;
import com.google.common.collect.ImmutableMap;
import com.google.common.hash.HashFunction;
import com.google.common.hash.Hashing;
import io.druid.data.input.InputRow;
import io.druid.data.input.Rows;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
public class HashBasedNumberedShardSpec extends NumberedShardSpec
{
@ -79,18 +79,25 @@ public class HashBasedNumberedShardSpec extends NumberedShardSpec
@Override
public ShardSpecLookup getLookup(final List<ShardSpec> shardSpecs)
{
final ImmutableMap.Builder<Integer, ShardSpec> shardSpecsMapBuilder = ImmutableMap.builder();
for (ShardSpec spec : shardSpecs) {
shardSpecsMapBuilder.put(spec.getPartitionNum(), spec);
// Sort on basis of partitionNumber
Collections.sort(
shardSpecs, new Comparator<ShardSpec>()
{
@Override
public int compare(ShardSpec o1, ShardSpec o2)
{
return Integer.compare(o1.getPartitionNum(), o2.getPartitionNum());
}
}
final Map<Integer, ShardSpec> shardSpecMap = shardSpecsMapBuilder.build();
);
return new ShardSpecLookup()
{
@Override
public ShardSpec getShardSpec(InputRow row)
{
return shardSpecMap.get((long) hash(row) % getPartitions());
int index = (int) ((long) hash(row)) % getPartitions();
return shardSpecs.get(index);
}
};
}