![JAR search and dependency download from the Maven repository](/logo.png)
org.apache.druid.segment.indexing.granularity.BaseGranularitySpec Maven / Gradle / Ivy
/*
* 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.granularity;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
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.granularity.Granularities;
import org.apache.druid.java.util.common.granularity.Granularity;
import org.apache.druid.java.util.common.guava.Comparators;
import org.joda.time.DateTime;
import org.joda.time.Interval;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.TreeSet;
public abstract class BaseGranularitySpec implements GranularitySpec
{
public static final Boolean DEFAULT_ROLLUP = Boolean.TRUE;
public static final Granularity DEFAULT_SEGMENT_GRANULARITY = Granularities.DAY;
public static final Granularity DEFAULT_QUERY_GRANULARITY = Granularities.NONE;
protected final List inputIntervals;
protected final Boolean rollup;
public BaseGranularitySpec(List inputIntervals, Boolean rollup)
{
this.inputIntervals = inputIntervals == null ? Collections.emptyList() : inputIntervals;
this.rollup = rollup == null ? DEFAULT_ROLLUP : rollup;
}
@Override
@JsonProperty("intervals")
public List inputIntervals()
{
return inputIntervals;
}
@Override
@JsonProperty("rollup")
public boolean isRollup()
{
return rollup;
}
@Override
public Optional bucketInterval(DateTime dt)
{
return getLookupTableBuckets().bucketInterval(dt);
}
@Override
public TreeSet materializedBucketIntervals()
{
return getLookupTableBuckets().materializedIntervals();
}
protected abstract LookupIntervalBuckets getLookupTableBuckets();
@Override
public Map asMap(ObjectMapper objectMapper)
{
return objectMapper.convertValue(
this,
new TypeReference
© 2015 - 2025 Weber Informatics LLC | Privacy Policy