-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Stateful auto compaction #8573
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
jihoonson
merged 14 commits into
apache:master
from
jihoonson:stateful-compaction-master
Oct 16, 2019
Merged
Stateful auto compaction #8573
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
93b10d0
Stateful auto compaction
jihoonson 8e7d326
javaodc
jihoonson b511b5b
add removed test back
jihoonson b2d0489
fix test
jihoonson 8958062
adding indexSpec to compactionState
jihoonson 33e20a7
fix build
jihoonson 4fde410
add lastCompactionState
jihoonson e7a7994
Merge branch 'master' of github.com:apache/incubator-druid into state…
jihoonson c9bfed9
address comments
jihoonson 8fe8297
extract CompactionState
jihoonson 47dca61
fix doc
jihoonson 8000b41
fix build and test
jihoonson 47df972
Add a task context to store compaction state; add javadoc
jihoonson fba9e04
fix it test
jihoonson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
97 changes: 97 additions & 0 deletions
97
core/src/main/java/org/apache/druid/timeline/CompactionState.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| /* | ||
| * 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; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonCreator; | ||
| import com.fasterxml.jackson.annotation.JsonProperty; | ||
| import org.apache.druid.indexer.partitions.PartitionsSpec; | ||
|
|
||
| import java.util.Map; | ||
| import java.util.Objects; | ||
|
|
||
| /** | ||
| * This class describes what compaction task spec was used to create a given segment. | ||
| * The compaction task is a task that reads Druid segments and overwrites them with new ones. Since this task always | ||
| * reads segments in the same order, the same task spec will always create the same set of segments | ||
| * (not same segment ID, but same content). | ||
| * | ||
| * Note that this class doesn't include all fields in the compaction task spec. Only the configurations that can | ||
| * affect the content of segment should be included. | ||
| * | ||
| * @see DataSegment#lastCompactionState | ||
| */ | ||
| public class CompactionState | ||
| { | ||
| private final PartitionsSpec partitionsSpec; | ||
| // org.apache.druid.segment.IndexSpec cannot be used here because it's in the 'processing' module which | ||
| // has a dependency on the 'core' module where this class is. | ||
| private final Map<String, Object> indexSpec; | ||
|
|
||
| @JsonCreator | ||
| public CompactionState( | ||
| @JsonProperty("partitionsSpec") PartitionsSpec partitionsSpec, | ||
| @JsonProperty("indexSpec") Map<String, Object> indexSpec | ||
| ) | ||
| { | ||
| this.partitionsSpec = partitionsSpec; | ||
| this.indexSpec = indexSpec; | ||
| } | ||
|
|
||
| @JsonProperty | ||
| public PartitionsSpec getPartitionsSpec() | ||
| { | ||
| return partitionsSpec; | ||
| } | ||
|
|
||
| @JsonProperty | ||
| public Map<String, Object> getIndexSpec() | ||
| { | ||
| return indexSpec; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean equals(Object o) | ||
| { | ||
| if (this == o) { | ||
| return true; | ||
| } | ||
| if (o == null || getClass() != o.getClass()) { | ||
| return false; | ||
| } | ||
| CompactionState that = (CompactionState) o; | ||
| return Objects.equals(partitionsSpec, that.partitionsSpec) && | ||
| Objects.equals(indexSpec, that.indexSpec); | ||
| } | ||
|
|
||
| @Override | ||
| public int hashCode() | ||
| { | ||
| return Objects.hash(partitionsSpec, indexSpec); | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() | ||
| { | ||
| return "CompactionState{" + | ||
| "partitionsSpec=" + partitionsSpec + | ||
| ", indexSpec=" + indexSpec + | ||
| '}'; | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please add javadoc for this class describing what this is, why it has the field it does ...(I know there is some discussion in proposal, but it would be very non-obvious for someone reading the code) and what guarantees it provides ... e.g. something like if a
CompactionTaskis run with parameters matching here then row distribution in segments created would be exactly same.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added javadoc. Please take a look if it's enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks.