-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Add DruidInputSource (replacement for IngestSegmentFirehose) #8982
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
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
65618b0
Add Druid input source and format
jihoonson 0186fef
Inherit dims/metrics from segment
jon-wei 5e20ef5
Add ingest segment firehose reindexing test
jon-wei 11d263d
Remove unnecessary module
jon-wei 1d66b54
Fix unit tests, checkstyle
jon-wei 9459782
Add doc entry
jon-wei b6a6b48
Fix dimensionExclusions handling, add parallel index integration test
jon-wei 9c5e1d8
Add spelling exclusion
jon-wei 32adef5
Address some PR comments
jon-wei 10940a0
Checkstyle
jon-wei 7f31c0f
wip
jon-wei 8b68ff9
Address rest of PR comments
jon-wei 65c0d0d
Address PR comments
jon-wei 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
49 changes: 49 additions & 0 deletions
49
indexing-service/src/main/java/org/apache/druid/guice/IndexingServiceInputSourceModule.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,49 @@ | ||
| /* | ||
| * 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.guice; | ||
|
|
||
| import com.fasterxml.jackson.databind.Module; | ||
| import com.fasterxml.jackson.databind.jsontype.NamedType; | ||
| import com.fasterxml.jackson.databind.module.SimpleModule; | ||
| import com.google.common.collect.ImmutableList; | ||
| import com.google.inject.Binder; | ||
| import org.apache.druid.indexing.input.DruidInputSource; | ||
| import org.apache.druid.initialization.DruidModule; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| public class IndexingServiceInputSourceModule implements DruidModule | ||
| { | ||
| @Override | ||
| public List<? extends Module> getJacksonModules() | ||
| { | ||
| return ImmutableList.<Module>of( | ||
| new SimpleModule("IndexingServiceInputSourceModule") | ||
| .registerSubtypes( | ||
| new NamedType(DruidInputSource.class, "druid") | ||
| ) | ||
| ); | ||
| } | ||
|
|
||
| @Override | ||
| public void configure(Binder binder) | ||
| { | ||
| } | ||
| } |
104 changes: 104 additions & 0 deletions
104
...xing-service/src/main/java/org/apache/druid/indexing/common/ReingestionTimelineUtils.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,104 @@ | ||
| /* | ||
| * 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.indexing.common; | ||
|
|
||
| import com.google.common.collect.BiMap; | ||
| import com.google.common.collect.HashBiMap; | ||
| import com.google.common.collect.Lists; | ||
| import org.apache.druid.timeline.DataSegment; | ||
| import org.apache.druid.timeline.TimelineObjectHolder; | ||
| import org.apache.druid.timeline.partition.PartitionChunk; | ||
|
|
||
| import javax.annotation.Nullable; | ||
| import java.util.List; | ||
| import java.util.Set; | ||
| import java.util.stream.Collectors; | ||
| import java.util.stream.IntStream; | ||
|
|
||
| public class ReingestionTimelineUtils | ||
| { | ||
| /** | ||
| * @param timelineSegments A list of timeline objects, such as that returned by VersionedIntervalTimeline.lookup(). | ||
| * @param excludeDimensions Dimensions to be excluded | ||
| * @return A list of all the unique dimension column names present in the segments within timelineSegments | ||
| */ | ||
| public static List<String> getUniqueDimensions( | ||
| List<TimelineObjectHolder<String, DataSegment>> timelineSegments, | ||
| @Nullable Set<String> excludeDimensions | ||
| ) | ||
| { | ||
| final BiMap<String, Integer> uniqueDims = HashBiMap.create(); | ||
|
|
||
| // Here, we try to retain the order of dimensions as they were specified since the order of dimensions may be | ||
| // optimized for performance. | ||
| // Dimensions are extracted from the recent segments to olders because recent segments are likely to be queried more | ||
| // frequently, and thus the performance should be optimized for recent ones rather than old ones. | ||
|
|
||
| // timelineSegments are sorted in order of interval | ||
| int index = 0; | ||
| for (TimelineObjectHolder<String, DataSegment> timelineHolder : Lists.reverse(timelineSegments)) { | ||
| for (PartitionChunk<DataSegment> chunk : timelineHolder.getObject()) { | ||
| for (String dimension : chunk.getObject().getDimensions()) { | ||
| if (!uniqueDims.containsKey(dimension) && | ||
| (excludeDimensions == null || !excludeDimensions.contains(dimension))) { | ||
| uniqueDims.put(dimension, index++); | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| final BiMap<Integer, String> orderedDims = uniqueDims.inverse(); | ||
| return IntStream.range(0, orderedDims.size()) | ||
| .mapToObj(orderedDims::get) | ||
| .collect(Collectors.toList()); | ||
| } | ||
|
|
||
| /** | ||
| * @param timelineSegments A list of timeline objects, such as that returned by VersionedIntervalTimeline.lookup(). | ||
| * @return A list of all the unique metric column names present in the segments within timelineSegments | ||
| */ | ||
| public static List<String> getUniqueMetrics(List<TimelineObjectHolder<String, DataSegment>> timelineSegments) | ||
| { | ||
| final BiMap<String, Integer> uniqueMetrics = HashBiMap.create(); | ||
|
|
||
| // Here, we try to retain the order of metrics as they were specified. Metrics are extracted from the recent | ||
| // segments to olders. | ||
|
|
||
| // timelineSegments are sorted in order of interval | ||
| int[] index = {0}; | ||
| for (TimelineObjectHolder<String, DataSegment> timelineHolder : Lists.reverse(timelineSegments)) { | ||
| for (PartitionChunk<DataSegment> chunk : timelineHolder.getObject()) { | ||
| for (String metric : chunk.getObject().getMetrics()) { | ||
| uniqueMetrics.computeIfAbsent( | ||
| metric, | ||
| k -> { | ||
| return index[0]++; | ||
| } | ||
| ); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| final BiMap<Integer, String> orderedMetrics = uniqueMetrics.inverse(); | ||
| return IntStream.range(0, orderedMetrics.size()) | ||
| .mapToObj(orderedMetrics::get) | ||
| .collect(Collectors.toList()); | ||
| } | ||
| } |
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
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
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.
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.
nit: It would be nice if either this example or a 2nd example included
dimensions,metrics, andfilterThere 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 a second example with more explanation of what the example specs do