maytasm commented on a change in pull request #10742:
URL: https://github.com/apache/druid/pull/10742#discussion_r557248198
##########
File path:
indexing-service/src/main/java/org/apache/druid/indexing/common/task/AbstractBatchIndexTask.java
##########
@@ -398,22 +375,21 @@ private boolean
tryLockWithDetermineResult(TaskActionClient client, LockGranular
protected boolean tryTimeChunkLock(TaskActionClient client, List<Interval>
intervals) throws IOException
{
- // The given intervals are first converted to align with segment
granularity. This is because,
- // when an overwriting task finds a version for a given input row, it
expects the interval
- // associated to each version to be equal or larger than the time bucket
where the input row falls in.
- // See ParallelIndexSupervisorTask.findVersion().
- final Set<Interval> uniqueIntervals = new HashSet<>();
+
+ // In this case, the intervals to lock must be aligned with
segmentGranularity if it's defined
+ final Iterator<Interval> intervalIterator;
final Granularity segmentGranularity = getSegmentGranularity();
- for (Interval interval : intervals) {
- if (segmentGranularity == null) {
- uniqueIntervals.add(interval);
- } else {
- Iterables.addAll(uniqueIntervals,
segmentGranularity.getIterable(interval));
- }
+ if (segmentGranularity == null) {
+ Set<Interval> uniqueIntervals = new HashSet<>(intervals);
+ ArrayList<Interval> condensedIntervals = JodaUtils.condenseIntervals(()
-> uniqueIntervals.iterator());
+ intervalIterator = condensedIntervals.iterator();
+ } else {
+ IntervalsByGranularity intervalsByGranularity = new
IntervalsByGranularity(intervals, segmentGranularity);
Review comment:
Are we no longer condensing the intervals if segmentGranularity != null?
##########
File path:
indexing-hadoop/src/main/java/org/apache/druid/indexer/HadoopDruidIndexerConfig.java
##########
@@ -314,9 +313,9 @@ public void setShardSpecs(Map<Long, List<HadoopyShardSpec>>
shardSpecs)
public Optional<List<Interval>> getIntervals()
{
- Optional<SortedSet<Interval>> setOptional =
schema.getDataSchema().getGranularitySpec().bucketIntervals();
- if (setOptional.isPresent()) {
- return Optional.of(JodaUtils.condenseIntervals(setOptional.get()));
+ Iterable<Interval> bucketIntervals =
schema.getDataSchema().getGranularitySpec().bucketIntervals();
+ if (bucketIntervals.iterator().hasNext()) {
+ return
Optional.of(JodaUtils.condenseIntervals(schema.getDataSchema().getGranularitySpec().bucketIntervals()));
Review comment:
nit: can reuse bucketIntervals variable here
##########
File path:
server/src/main/java/org/apache/druid/segment/indexing/LookupIntervalBuckets.java
##########
@@ -0,0 +1,68 @@
+/*
+ * 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.segment.indexing;
+
+import com.google.common.base.Optional;
+import com.google.common.collect.Iterators;
+import org.apache.druid.java.util.common.DateTimes;
+import org.apache.druid.java.util.common.guava.Comparators;
+import org.joda.time.DateTime;
+import org.joda.time.Interval;
+
+import java.util.Iterator;
+import java.util.TreeSet;
+
+public class LookupIntervalBuckets
+{
+ private final Iterable<Interval> intervalIterable;
+ private final TreeSet<Interval> intervals;
+
+ public LookupIntervalBuckets(Iterable<Interval> intervalIterable)
Review comment:
Is this class basically something like a lazy load of the TreeSet?
----------------------------------------------------------------
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]