use of org.apache.druid.indexer.partitions.HashedPartitionsSpec in project druid by druid-io.
the class DetermineHashedPartitionsJobTest method testDetermineHashedPartitions.
@Test
public void testDetermineHashedPartitions() {
DetermineHashedPartitionsJob determineHashedPartitionsJob = new DetermineHashedPartitionsJob(indexerConfig);
determineHashedPartitionsJob.run();
HashPartitionFunction expectedFunction = ((HashedPartitionsSpec) indexerConfig.getPartitionsSpec()).getPartitionFunction();
Map<Long, List<HadoopyShardSpec>> shardSpecs = indexerConfig.getSchema().getTuningConfig().getShardSpecs();
Assert.assertEquals(expectedNumTimeBuckets, shardSpecs.entrySet().size());
int i = 0;
for (Map.Entry<Long, List<HadoopyShardSpec>> entry : shardSpecs.entrySet()) {
Assert.assertEquals(expectedNumOfShards[i++], entry.getValue().size(), errorMargin);
for (HadoopyShardSpec eachShardSpec : entry.getValue()) {
final HashBasedNumberedShardSpec hashShardSpec = (HashBasedNumberedShardSpec) eachShardSpec.getActualSpec();
Assert.assertEquals(expectedFunction, hashShardSpec.getPartitionFunction());
}
}
}
use of org.apache.druid.indexer.partitions.HashedPartitionsSpec in project druid by druid-io.
the class HadoopIngestionSpecTest method testPartitionsSpecAutoHashed.
@Test
public void testPartitionsSpecAutoHashed() {
final HadoopIngestionSpec schema;
try {
schema = jsonReadWriteRead("{\n" + " \"tuningConfig\": {\n" + " \"type\": \"hadoop\",\n" + " \"partitionsSpec\": {\n" + " \"targetPartitionSize\": 100\n" + " }\n" + " }\n" + "}", HadoopIngestionSpec.class);
} catch (Exception e) {
throw new RuntimeException(e);
}
final PartitionsSpec partitionsSpec = schema.getTuningConfig().getPartitionsSpec();
Assert.assertTrue("isDeterminingPartitions", partitionsSpec.needsDeterminePartitions(true));
Assert.assertEquals("getTargetPartitionSize", 100, partitionsSpec.getMaxRowsPerSegment().intValue());
Assert.assertTrue("partitionSpec", partitionsSpec instanceof HashedPartitionsSpec);
}
use of org.apache.druid.indexer.partitions.HashedPartitionsSpec in project druid by druid-io.
the class NewestSegmentFirstIteratorTest method testFindPartitionsSpecFromConfigWithHashPartitionsSpec.
@Test
public void testFindPartitionsSpecFromConfigWithHashPartitionsSpec() {
final DataSourceCompactionConfig config = new DataSourceCompactionConfig("datasource", null, null, null, null, new UserCompactionTaskQueryTuningConfig(null, null, null, null, new HashedPartitionsSpec(null, 10, ImmutableList.of("dim")), null, null, null, null, null, null, null, null, null, null, null, null), null, null, null, null, null, null);
Assert.assertEquals(new HashedPartitionsSpec(null, 10, ImmutableList.of("dim")), NewestSegmentFirstIterator.findPartitionsSpecFromConfig(ClientCompactionTaskQueryTuningConfig.from(config.getTuningConfig(), config.getMaxRowsPerSegment())));
}
Aggregations