jihoonson commented on a change in pull request #9274: Refactoring some codes around ingestion URL: https://github.com/apache/druid/pull/9274#discussion_r374439218
########## File path: core/src/main/java/org/apache/druid/timeline/partition/SingleDimensionPartialShardSpec.java ########## @@ -0,0 +1,141 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.druid.timeline.partition; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.ObjectMapper; + +import javax.annotation.Nullable; +import java.util.Objects; + +public class SingleDimensionPartialShardSpec implements PartialShardSpec +{ + private final String partitionDimension; + private final int bucketId; + @Nullable + private final String start; + @Nullable + private final String end; + private final int numBuckets; + + @JsonCreator + public SingleDimensionPartialShardSpec( + @JsonProperty("partitionDimension") String partitionDimension, + @JsonProperty("bucketId") int bucketId, + @JsonProperty("start") @Nullable String start, + @JsonProperty("end") @Nullable String end, + @JsonProperty("numBuckets") int numBuckets + ) + { + this.partitionDimension = partitionDimension; + this.bucketId = bucketId; + this.start = start; + this.end = end; + this.numBuckets = numBuckets; + } + + @JsonProperty + public String getPartitionDimension() + { + return partitionDimension; + } + + @JsonProperty + public int getBucketId() + { + return bucketId; + } + + @JsonProperty + @Nullable + public String getStart() + { + return start; + } + + @JsonProperty + @Nullable + public String getEnd() + { + return end; + } + + @JsonProperty + public int getNumBuckets() + { + return numBuckets; + } + + @Override + public ShardSpec complete(ObjectMapper objectMapper, @Nullable ShardSpec specOfPreviousMaxPartitionId) + { + final int partitionId; + if (specOfPreviousMaxPartitionId != null) { + assert specOfPreviousMaxPartitionId instanceof SingleDimensionShardSpec; + final SingleDimensionShardSpec prevSpec = (SingleDimensionShardSpec) specOfPreviousMaxPartitionId; + partitionId = prevSpec.getPartitionNum() + 1; Review comment: This logic will be changed in the follow-up PR. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
