diff --git a/.idea/misc.xml b/.idea/misc.xml index 41f0d62b854..9d0b0220e00 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -40,26 +40,35 @@ diff --git a/api/src/main/java/org/apache/druid/data/input/Row.java b/api/src/main/java/org/apache/druid/data/input/Row.java index c757e0821d9..c45dac27163 100644 --- a/api/src/main/java/org/apache/druid/data/input/Row.java +++ b/api/src/main/java/org/apache/druid/data/input/Row.java @@ -24,6 +24,7 @@ import com.fasterxml.jackson.annotation.JsonTypeInfo; import org.apache.druid.guice.annotations.PublicApi; import org.joda.time.DateTime; +import javax.annotation.Nullable; import java.util.List; /** @@ -71,6 +72,7 @@ public interface Row extends Comparable * * @return the value of the provided column name */ + @Nullable Object getRaw(String dimension); /** @@ -79,5 +81,6 @@ public interface Row extends Comparable * 1. If the column is absent in the row, numeric zero is returned, rather than null. * 2. If the column has string value, an attempt is made to parse this value as a number. */ + @Nullable Number getMetric(String metric); } diff --git a/api/src/main/java/org/apache/druid/data/input/Rows.java b/api/src/main/java/org/apache/druid/data/input/Rows.java index a1aedfff75c..c73b2bbec38 100644 --- a/api/src/main/java/org/apache/druid/data/input/Rows.java +++ b/api/src/main/java/org/apache/druid/data/input/Rows.java @@ -28,17 +28,16 @@ import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.java.util.common.parsers.ParseException; import javax.annotation.Nullable; -import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.stream.Collectors; /** */ public class Rows { - public static final Long LONG_ZERO = 0L; /** * @param timeStamp rollup up timestamp to be used to create group key @@ -55,10 +54,7 @@ public class Rows dims.put(dim, dimValues); } } - return ImmutableList.of( - timeStamp, - dims - ); + return ImmutableList.of(timeStamp, dims); } /** @@ -70,14 +66,7 @@ public class Rows return Collections.emptyList(); } else if (inputValue instanceof List) { // guava's toString function fails on null objects, so please do not use it - final List values = (List) inputValue; - - final List retVal = new ArrayList<>(values.size()); - for (Object val : values) { - retVal.add(String.valueOf(val)); - } - - return retVal; + return ((List) inputValue).stream().map(String::valueOf).collect(Collectors.toList()); } else { return Collections.singletonList(String.valueOf(inputValue)); } diff --git a/api/src/main/java/org/apache/druid/data/input/impl/AbstractTextFilesFirehoseFactory.java b/api/src/main/java/org/apache/druid/data/input/impl/AbstractTextFilesFirehoseFactory.java index c40ff2feec5..c53c9883c63 100644 --- a/api/src/main/java/org/apache/druid/data/input/impl/AbstractTextFilesFirehoseFactory.java +++ b/api/src/main/java/org/apache/druid/data/input/impl/AbstractTextFilesFirehoseFactory.java @@ -22,12 +22,12 @@ package org.apache.druid.data.input.impl; import com.google.common.base.Preconditions; import com.google.common.base.Throwables; import com.google.common.collect.ImmutableList; +import org.apache.commons.io.IOUtils; +import org.apache.commons.io.LineIterator; import org.apache.druid.data.input.FiniteFirehoseFactory; import org.apache.druid.data.input.Firehose; import org.apache.druid.data.input.InputSplit; import org.apache.druid.java.util.common.logger.Logger; -import org.apache.commons.io.IOUtils; -import org.apache.commons.io.LineIterator; import java.io.File; import java.io.IOException; diff --git a/api/src/main/java/org/apache/druid/data/input/impl/FileIteratingFirehose.java b/api/src/main/java/org/apache/druid/data/input/impl/FileIteratingFirehose.java index a546f361f33..6b75ed04729 100644 --- a/api/src/main/java/org/apache/druid/data/input/impl/FileIteratingFirehose.java +++ b/api/src/main/java/org/apache/druid/data/input/impl/FileIteratingFirehose.java @@ -19,10 +19,10 @@ package org.apache.druid.data.input.impl; +import org.apache.commons.io.LineIterator; import org.apache.druid.data.input.Firehose; import org.apache.druid.data.input.InputRow; import org.apache.druid.utils.Runnables; -import org.apache.commons.io.LineIterator; import javax.annotation.Nullable; import java.io.Closeable; @@ -101,24 +101,9 @@ public class FileIteratingFirehose implements Firehose @Override public void close() throws IOException { - try { - if (lineIterator != null) { - lineIterator.close(); - } - } - catch (Throwable t) { - try { - if (closer != null) { - closer.close(); - } - } - catch (Exception e) { - t.addSuppressed(e); - } - throw t; - } - if (closer != null) { - closer.close(); + try (Closeable ignore = closer; + Closeable ignore2 = lineIterator != null ? lineIterator::close : null) { + // close both via try-with-resources } } } diff --git a/api/src/main/java/org/apache/druid/data/input/impl/prefetch/Fetcher.java b/api/src/main/java/org/apache/druid/data/input/impl/prefetch/Fetcher.java index 85276ea96d7..7d3138e2912 100644 --- a/api/src/main/java/org/apache/druid/data/input/impl/prefetch/Fetcher.java +++ b/api/src/main/java/org/apache/druid/data/input/impl/prefetch/Fetcher.java @@ -28,6 +28,8 @@ import javax.annotation.Nullable; import java.io.Closeable; import java.io.File; import java.io.IOException; +import java.util.ArrayDeque; +import java.util.Deque; import java.util.Iterator; import java.util.List; import java.util.NoSuchElementException; @@ -62,7 +64,7 @@ public abstract class Fetcher implements Iterator> // This is updated when a file is successfully fetched, a fetched file is deleted, or a fetched file is // cached. private final AtomicLong fetchedBytes = new AtomicLong(0); - private Future fetchFuture; + private final Deque> fetchFutures = new ArrayDeque<>(); private PrefetchConfig prefetchConfig; // nextFetchIndex indicates which object should be downloaded when fetch is triggered. @@ -103,12 +105,13 @@ public abstract class Fetcher implements Iterator> */ private void fetchIfNeeded(long remainingBytes) { - if ((fetchFuture == null || fetchFuture.isDone()) + if ((fetchFutures.isEmpty() || fetchFutures.peekLast().isDone()) && remainingBytes <= prefetchConfig.getPrefetchTriggerBytes()) { - fetchFuture = fetchExecutor.submit(() -> { + Future fetchFuture = fetchExecutor.submit(() -> { fetch(); return null; }); + fetchFutures.add(fetchFuture); } } @@ -180,12 +183,17 @@ public abstract class Fetcher implements Iterator> private void checkFetchException(boolean wait) { try { - if (wait) { - fetchFuture.get(prefetchConfig.getFetchTimeout(), TimeUnit.MILLISECONDS); - fetchFuture = null; - } else if (fetchFuture != null && fetchFuture.isDone()) { - fetchFuture.get(); - fetchFuture = null; + for (Future fetchFuture; (fetchFuture = fetchFutures.poll()) != null; ) { + if (wait) { + fetchFuture.get(prefetchConfig.getFetchTimeout(), TimeUnit.MILLISECONDS); + } else { + if (fetchFuture.isDone()) { + fetchFuture.get(); + } else { + fetchFutures.addFirst(fetchFuture); + break; + } + } } } catch (InterruptedException | ExecutionException e) { diff --git a/api/src/main/java/org/apache/druid/data/input/impl/prefetch/FileFetcher.java b/api/src/main/java/org/apache/druid/data/input/impl/prefetch/FileFetcher.java index ac31aeb4cef..2bdf6b79bb6 100644 --- a/api/src/main/java/org/apache/druid/data/input/impl/prefetch/FileFetcher.java +++ b/api/src/main/java/org/apache/druid/data/input/impl/prefetch/FileFetcher.java @@ -20,10 +20,9 @@ package org.apache.druid.data.input.impl.prefetch; import com.google.common.base.Predicate; - +import org.apache.commons.io.IOUtils; import org.apache.druid.java.util.common.RetryUtils; import org.apache.druid.java.util.common.StringUtils; -import org.apache.commons.io.IOUtils; import javax.annotation.Nullable; import java.io.Closeable; @@ -33,7 +32,6 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.List; - import java.util.concurrent.ExecutorService; /** diff --git a/api/src/main/java/org/apache/druid/data/input/impl/prefetch/PrefetchSqlFirehoseFactory.java b/api/src/main/java/org/apache/druid/data/input/impl/prefetch/PrefetchSqlFirehoseFactory.java index 4cf70b293c7..4ae948fc6e7 100644 --- a/api/src/main/java/org/apache/druid/data/input/impl/prefetch/PrefetchSqlFirehoseFactory.java +++ b/api/src/main/java/org/apache/druid/data/input/impl/prefetch/PrefetchSqlFirehoseFactory.java @@ -21,9 +21,11 @@ package org.apache.druid.data.input.impl.prefetch; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; +import org.apache.commons.io.LineIterator; import org.apache.druid.data.input.Firehose; import org.apache.druid.data.input.FirehoseFactory; import org.apache.druid.data.input.impl.InputRowParser; @@ -31,8 +33,6 @@ import org.apache.druid.data.input.impl.SqlFirehose; import org.apache.druid.java.util.common.ISE; import org.apache.druid.java.util.common.concurrent.Execs; import org.apache.druid.java.util.common.logger.Logger; -import com.fasterxml.jackson.databind.ObjectMapper; -import org.apache.commons.io.LineIterator; import javax.annotation.Nullable; import java.io.File; diff --git a/api/src/main/java/org/apache/druid/data/input/impl/prefetch/PrefetchableTextFilesFirehoseFactory.java b/api/src/main/java/org/apache/druid/data/input/impl/prefetch/PrefetchableTextFilesFirehoseFactory.java index 901b5d635c9..2a0d917ff05 100644 --- a/api/src/main/java/org/apache/druid/data/input/impl/prefetch/PrefetchableTextFilesFirehoseFactory.java +++ b/api/src/main/java/org/apache/druid/data/input/impl/prefetch/PrefetchableTextFilesFirehoseFactory.java @@ -24,6 +24,7 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Preconditions; import com.google.common.base.Predicate; import com.google.common.collect.ImmutableList; +import org.apache.commons.io.LineIterator; import org.apache.druid.data.input.Firehose; import org.apache.druid.data.input.impl.AbstractTextFilesFirehoseFactory; import org.apache.druid.data.input.impl.FileIteratingFirehose; @@ -31,7 +32,6 @@ import org.apache.druid.data.input.impl.StringInputRowParser; import org.apache.druid.java.util.common.ISE; import org.apache.druid.java.util.common.concurrent.Execs; import org.apache.druid.java.util.common.logger.Logger; -import org.apache.commons.io.LineIterator; import javax.annotation.Nullable; import java.io.Closeable; @@ -221,21 +221,24 @@ public abstract class PrefetchableTextFilesFirehoseFactory } final OpenedObject openedObject = fetcher.next(); - final InputStream stream; try { - stream = wrapObjectStream( - openedObject.getObject(), - openedObject.getObjectStream() + return new ResourceCloseableLineIterator( + new InputStreamReader( + wrapObjectStream(openedObject.getObject(), openedObject.getObjectStream()), + StandardCharsets.UTF_8 + ), + openedObject.getResourceCloser() ); } catch (IOException e) { + try { + openedObject.getResourceCloser().close(); + } + catch (Throwable t) { + e.addSuppressed(t); + } throw new RuntimeException(e); } - - return new ResourceCloseableLineIterator( - new InputStreamReader(stream, StandardCharsets.UTF_8), - openedObject.getResourceCloser() - ); } }, firehoseParser, @@ -288,9 +291,8 @@ public abstract class PrefetchableTextFilesFirehoseFactory @Override public void close() { - super.close(); - try { - resourceCloser.close(); + try (Closeable ignore = this.resourceCloser) { + super.close(); } catch (IOException e) { throw new RuntimeException(e); diff --git a/api/src/main/java/org/apache/druid/timeline/DataSegment.java b/api/src/main/java/org/apache/druid/timeline/DataSegment.java index b1b8c33a273..8a18f9df68d 100644 --- a/api/src/main/java/org/apache/druid/timeline/DataSegment.java +++ b/api/src/main/java/org/apache/druid/timeline/DataSegment.java @@ -32,6 +32,7 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.Interner; import com.google.common.collect.Interners; import com.google.inject.Inject; +import it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap; import org.apache.druid.guice.annotations.PublicApi; import org.apache.druid.jackson.CommaListJoinDeserializer; import org.apache.druid.jackson.CommaListJoinSerializer; @@ -39,7 +40,6 @@ import org.apache.druid.java.util.common.granularity.Granularities; import org.apache.druid.query.SegmentDescriptor; import org.apache.druid.timeline.partition.NoneShardSpec; import org.apache.druid.timeline.partition.ShardSpec; -import it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap; import org.joda.time.DateTime; import org.joda.time.Interval; diff --git a/api/src/test/java/org/apache/druid/data/input/impl/FileIteratingFirehoseTest.java b/api/src/test/java/org/apache/druid/data/input/impl/FileIteratingFirehoseTest.java index 92a94384d41..94a9dc3fcc5 100644 --- a/api/src/test/java/org/apache/druid/data/input/impl/FileIteratingFirehoseTest.java +++ b/api/src/test/java/org/apache/druid/data/input/impl/FileIteratingFirehoseTest.java @@ -22,8 +22,8 @@ package org.apache.druid.data.input.impl; import com.google.common.base.Joiner; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; -import org.apache.druid.data.input.InputRow; import org.apache.commons.io.LineIterator; +import org.apache.druid.data.input.InputRow; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/api/src/test/java/org/apache/druid/data/input/impl/JSONLowercaseParseSpecTest.java b/api/src/test/java/org/apache/druid/data/input/impl/JSONLowercaseParseSpecTest.java index 9727244d7c6..87b52e8d093 100644 --- a/api/src/test/java/org/apache/druid/data/input/impl/JSONLowercaseParseSpecTest.java +++ b/api/src/test/java/org/apache/druid/data/input/impl/JSONLowercaseParseSpecTest.java @@ -20,8 +20,8 @@ package org.apache.druid.data.input.impl; import com.google.common.collect.Lists; -import org.apache.druid.java.util.common.parsers.Parser; import junit.framework.Assert; +import org.apache.druid.java.util.common.parsers.Parser; import org.junit.Test; import java.util.Arrays; diff --git a/api/src/test/java/org/apache/druid/data/input/impl/SqlFirehoseTest.java b/api/src/test/java/org/apache/druid/data/input/impl/SqlFirehoseTest.java index 579a142277c..1ebfd531c08 100644 --- a/api/src/test/java/org/apache/druid/data/input/impl/SqlFirehoseTest.java +++ b/api/src/test/java/org/apache/druid/data/input/impl/SqlFirehoseTest.java @@ -26,9 +26,9 @@ import com.fasterxml.jackson.dataformat.smile.SmileFactory; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; +import org.apache.commons.io.FileUtils; import org.apache.druid.data.input.InputRow; import org.apache.druid.data.input.impl.prefetch.JsonIterator; -import org.apache.commons.io.FileUtils; import org.junit.After; import org.junit.Assert; import org.junit.Before; diff --git a/api/src/test/java/org/apache/druid/data/input/impl/prefetch/PrefetchableTextFilesFirehoseFactoryTest.java b/api/src/test/java/org/apache/druid/data/input/impl/prefetch/PrefetchableTextFilesFirehoseFactoryTest.java index 09bde1e2f78..9c3508e8e0d 100644 --- a/api/src/test/java/org/apache/druid/data/input/impl/prefetch/PrefetchableTextFilesFirehoseFactoryTest.java +++ b/api/src/test/java/org/apache/druid/data/input/impl/prefetch/PrefetchableTextFilesFirehoseFactoryTest.java @@ -23,6 +23,8 @@ import com.google.common.base.Preconditions; import com.google.common.base.Predicate; import com.google.common.collect.Lists; import com.google.common.io.CountingOutputStream; +import org.apache.commons.io.FileUtils; +import org.apache.commons.io.filefilter.TrueFileFilter; import org.apache.druid.data.input.FiniteFirehoseFactory; import org.apache.druid.data.input.Firehose; import org.apache.druid.data.input.InputSplit; @@ -34,15 +36,14 @@ import org.apache.druid.data.input.impl.TimestampSpec; import org.apache.druid.java.util.common.DateTimes; import org.apache.druid.java.util.common.RetryUtils; import org.apache.druid.java.util.common.StringUtils; -import org.apache.commons.io.FileUtils; -import org.apache.commons.io.filefilter.TrueFileFilter; import org.hamcrest.CoreMatchers; -import org.junit.AfterClass; import org.junit.Assert; import org.junit.BeforeClass; +import org.junit.ClassRule; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; +import org.junit.rules.TemporaryFolder; import java.io.BufferedWriter; import java.io.File; @@ -62,8 +63,6 @@ import java.util.concurrent.TimeoutException; public class PrefetchableTextFilesFirehoseFactoryTest { - private static final List FIREHOSE_TMP_DIRS = new ArrayList<>(); - private static File TEST_DIR; private static long FILE_SIZE = -1; private static final StringInputRowParser parser = new StringInputRowParser( @@ -86,16 +85,17 @@ public class PrefetchableTextFilesFirehoseFactoryTest StandardCharsets.UTF_8.name() ); + @ClassRule + public static TemporaryFolder tempDir = new TemporaryFolder(); + private static File TEST_DIR; + @Rule public ExpectedException expectedException = ExpectedException.none(); @BeforeClass public static void setup() throws IOException { - TEST_DIR = File.createTempFile(PrefetchableTextFilesFirehoseFactoryTest.class.getSimpleName(), "testDir"); - FileUtils.forceDelete(TEST_DIR); - FileUtils.forceMkdir(TEST_DIR); - + TEST_DIR = tempDir.newFolder(); for (int i = 0; i < 100; i++) { try ( CountingOutputStream cos = new CountingOutputStream( @@ -118,16 +118,6 @@ public class PrefetchableTextFilesFirehoseFactoryTest } } - @AfterClass - public static void teardown() throws IOException - { - FileUtils.forceDelete(TEST_DIR); - for (File dir : FIREHOSE_TMP_DIRS) { - FileUtils.forceDelete(dir); - } - FIREHOSE_TMP_DIRS.clear(); // cleanup after ourselves (resolve issue with retries) - } - private static void assertResult(List rows) { Assert.assertEquals(10000, rows.size()); @@ -161,16 +151,9 @@ public class PrefetchableTextFilesFirehoseFactoryTest Assert.assertEquals(expectedNumFiles, files.length); } - private static File createFirehoseTmpDir(String dirSuffix) throws IOException + private static File createFirehoseTmpDir(String dirPrefix) throws IOException { - final File firehoseTempDir = File.createTempFile( - PrefetchableTextFilesFirehoseFactoryTest.class.getSimpleName(), - dirSuffix - ); - FileUtils.forceDelete(firehoseTempDir); - FileUtils.forceMkdir(firehoseTempDir); - FIREHOSE_TMP_DIRS.add(firehoseTempDir); - return firehoseTempDir; + return Files.createTempDirectory(tempDir.getRoot().toPath(), dirPrefix).toFile(); } @Test @@ -413,6 +396,7 @@ public class PrefetchableTextFilesFirehoseFactoryTest 1024, cacheCapacity, fetchCapacity, + 60_000, // fetch timeout 3, 0, 0, @@ -521,7 +505,7 @@ public class PrefetchableTextFilesFirehoseFactoryTest long prefetchTriggerThreshold, long maxCacheCapacityBytes, long maxFetchCapacityBytes, - long timeout, + long fetchTimeout, int maxRetry, int numOpenExceptions, int maxConnectionResets, @@ -532,7 +516,7 @@ public class PrefetchableTextFilesFirehoseFactoryTest maxCacheCapacityBytes, maxFetchCapacityBytes, prefetchTriggerThreshold, - timeout, + fetchTimeout, maxRetry ); this.numOpenExceptions = numOpenExceptions; diff --git a/benchmarks/src/main/java/org/apache/druid/benchmark/BoundFilterBenchmark.java b/benchmarks/src/main/java/org/apache/druid/benchmark/BoundFilterBenchmark.java index ca8f8fed1ec..682491789b4 100644 --- a/benchmarks/src/main/java/org/apache/druid/benchmark/BoundFilterBenchmark.java +++ b/benchmarks/src/main/java/org/apache/druid/benchmark/BoundFilterBenchmark.java @@ -33,8 +33,8 @@ import org.apache.druid.query.filter.BoundDimFilter; import org.apache.druid.query.ordering.StringComparators; import org.apache.druid.segment.column.BitmapIndex; import org.apache.druid.segment.data.BitmapSerdeFactory; +import org.apache.druid.segment.data.CloseableIndexed; import org.apache.druid.segment.data.GenericIndexed; -import org.apache.druid.segment.data.Indexed; import org.apache.druid.segment.data.RoaringBitmapSerdeFactory; import org.apache.druid.segment.filter.BoundFilter; import org.apache.druid.segment.serde.BitmapIndexColumnPartSupplier; @@ -158,17 +158,7 @@ public class BoundFilterBenchmark final BitmapSerdeFactory serdeFactory = new RoaringBitmapSerdeFactory(null); final List ints = generateInts(); final GenericIndexed dictionary = GenericIndexed.fromIterable( - FluentIterable.from(ints) - .transform( - new Function() - { - @Override - public String apply(Integer i) - { - return i.toString(); - } - } - ), + FluentIterable.from(ints).transform(i -> i.toString()), GenericIndexed.STRING_STRATEGY ); final BitmapIndex bitmapIndex = new BitmapIndexColumnPartSupplier( @@ -194,7 +184,7 @@ public class BoundFilterBenchmark selector = new BitmapIndexSelector() { @Override - public Indexed getDimensionValues(String dimension) + public CloseableIndexed getDimensionValues(String dimension) { return dictionary; } diff --git a/benchmarks/src/main/java/org/apache/druid/benchmark/CompressedColumnarIntsBenchmark.java b/benchmarks/src/main/java/org/apache/druid/benchmark/CompressedColumnarIntsBenchmark.java index a9f3b72e1aa..32dd6f23b7c 100644 --- a/benchmarks/src/main/java/org/apache/druid/benchmark/CompressedColumnarIntsBenchmark.java +++ b/benchmarks/src/main/java/org/apache/druid/benchmark/CompressedColumnarIntsBenchmark.java @@ -19,6 +19,7 @@ package org.apache.druid.benchmark; +import it.unimi.dsi.fastutil.ints.IntArrayList; import org.apache.druid.java.util.common.io.Closer; import org.apache.druid.segment.data.ColumnarInts; import org.apache.druid.segment.data.CompressedVSizeColumnarIntsSupplier; @@ -26,7 +27,6 @@ import org.apache.druid.segment.data.CompressionStrategy; import org.apache.druid.segment.data.IndexedInts; import org.apache.druid.segment.data.VSizeColumnarInts; import org.apache.druid.segment.data.WritableSupplier; -import it.unimi.dsi.fastutil.ints.IntArrayList; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Mode; diff --git a/benchmarks/src/main/java/org/apache/druid/benchmark/DimensionPredicateFilterBenchmark.java b/benchmarks/src/main/java/org/apache/druid/benchmark/DimensionPredicateFilterBenchmark.java index 01135952c6d..fc9c969e9ea 100644 --- a/benchmarks/src/main/java/org/apache/druid/benchmark/DimensionPredicateFilterBenchmark.java +++ b/benchmarks/src/main/java/org/apache/druid/benchmark/DimensionPredicateFilterBenchmark.java @@ -35,8 +35,8 @@ import org.apache.druid.query.filter.DruidLongPredicate; import org.apache.druid.query.filter.DruidPredicateFactory; import org.apache.druid.segment.column.BitmapIndex; import org.apache.druid.segment.data.BitmapSerdeFactory; +import org.apache.druid.segment.data.CloseableIndexed; import org.apache.druid.segment.data.GenericIndexed; -import org.apache.druid.segment.data.Indexed; import org.apache.druid.segment.data.RoaringBitmapSerdeFactory; import org.apache.druid.segment.filter.DimensionPredicateFilter; import org.apache.druid.segment.serde.BitmapIndexColumnPartSupplier; @@ -155,7 +155,7 @@ public class DimensionPredicateFilterBenchmark selector = new BitmapIndexSelector() { @Override - public Indexed getDimensionValues(String dimension) + public CloseableIndexed getDimensionValues(String dimension) { return dictionary; } diff --git a/benchmarks/src/main/java/org/apache/druid/benchmark/ExpressionSelectorBenchmark.java b/benchmarks/src/main/java/org/apache/druid/benchmark/ExpressionSelectorBenchmark.java index 05a7ba7e1c2..5b6d8a3d9c7 100644 --- a/benchmarks/src/main/java/org/apache/druid/benchmark/ExpressionSelectorBenchmark.java +++ b/benchmarks/src/main/java/org/apache/druid/benchmark/ExpressionSelectorBenchmark.java @@ -37,7 +37,7 @@ import org.apache.druid.segment.DimensionSelector; import org.apache.druid.segment.QueryableIndex; import org.apache.druid.segment.QueryableIndexStorageAdapter; import org.apache.druid.segment.VirtualColumns; -import org.apache.druid.segment.column.Column; +import org.apache.druid.segment.column.ColumnHolder; import org.apache.druid.segment.column.ValueType; import org.apache.druid.segment.virtual.ExpressionVirtualColumn; import org.apache.druid.timeline.DataSegment; @@ -175,7 +175,7 @@ public class ExpressionSelectorBenchmark .getColumnSelectorFactory() .makeDimensionSelector( new ExtractionDimensionSpec( - Column.TIME_COLUMN_NAME, + ColumnHolder.TIME_COLUMN_NAME, "v", new TimeFormatExtractionFn(null, null, null, Granularities.HOUR, true) ) diff --git a/benchmarks/src/main/java/org/apache/druid/benchmark/FilterPartitionBenchmark.java b/benchmarks/src/main/java/org/apache/druid/benchmark/FilterPartitionBenchmark.java index 6a01efd413e..3a6df5b7b8c 100644 --- a/benchmarks/src/main/java/org/apache/druid/benchmark/FilterPartitionBenchmark.java +++ b/benchmarks/src/main/java/org/apache/druid/benchmark/FilterPartitionBenchmark.java @@ -62,8 +62,8 @@ import org.apache.druid.segment.QueryableIndex; import org.apache.druid.segment.QueryableIndexStorageAdapter; import org.apache.druid.segment.StorageAdapter; import org.apache.druid.segment.VirtualColumns; -import org.apache.druid.segment.column.Column; import org.apache.druid.segment.column.ColumnConfig; +import org.apache.druid.segment.column.ColumnHolder; import org.apache.druid.segment.data.IndexedInts; import org.apache.druid.segment.filter.AndFilter; import org.apache.druid.segment.filter.BoundFilter; @@ -185,7 +185,7 @@ public class FilterPartitionBenchmark Interval interval = schemaInfo.getDataInterval(); timeFilterNone = new BoundFilter(new BoundDimFilter( - Column.TIME_COLUMN_NAME, + ColumnHolder.TIME_COLUMN_NAME, String.valueOf(Long.MAX_VALUE), String.valueOf(Long.MAX_VALUE), true, @@ -197,7 +197,7 @@ public class FilterPartitionBenchmark long halfEnd = (interval.getEndMillis() + interval.getStartMillis()) / 2; timeFilterHalf = new BoundFilter(new BoundDimFilter( - Column.TIME_COLUMN_NAME, + ColumnHolder.TIME_COLUMN_NAME, String.valueOf(interval.getStartMillis()), String.valueOf(halfEnd), true, @@ -208,7 +208,7 @@ public class FilterPartitionBenchmark )); timeFilterAll = new BoundFilter(new BoundDimFilter( - Column.TIME_COLUMN_NAME, + ColumnHolder.TIME_COLUMN_NAME, String.valueOf(interval.getStartMillis()), String.valueOf(interval.getEndMillis()), true, diff --git a/benchmarks/src/main/java/org/apache/druid/benchmark/GenericIndexedBenchmark.java b/benchmarks/src/main/java/org/apache/druid/benchmark/GenericIndexedBenchmark.java index 4a5fb7c4d9e..8998090f790 100644 --- a/benchmarks/src/main/java/org/apache/druid/benchmark/GenericIndexedBenchmark.java +++ b/benchmarks/src/main/java/org/apache/druid/benchmark/GenericIndexedBenchmark.java @@ -23,10 +23,10 @@ import com.google.common.io.Files; import com.google.common.primitives.Ints; import org.apache.druid.java.util.common.io.smoosh.FileSmoosher; import org.apache.druid.java.util.common.io.smoosh.SmooshedFileMapper; -import org.apache.druid.segment.writeout.OffHeapMemorySegmentWriteOutMedium; import org.apache.druid.segment.data.GenericIndexed; import org.apache.druid.segment.data.GenericIndexedWriter; import org.apache.druid.segment.data.ObjectStrategy; +import org.apache.druid.segment.writeout.OffHeapMemorySegmentWriteOutMedium; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; @@ -65,7 +65,7 @@ public class GenericIndexedBenchmark static final ObjectStrategy byteArrayStrategy = new ObjectStrategy() { @Override - public Class getClazz() + public Class getClazz() { return byte[].class; } diff --git a/benchmarks/src/main/java/org/apache/druid/benchmark/LikeFilterBenchmark.java b/benchmarks/src/main/java/org/apache/druid/benchmark/LikeFilterBenchmark.java index cf49b86edbd..ce445ca16ed 100644 --- a/benchmarks/src/main/java/org/apache/druid/benchmark/LikeFilterBenchmark.java +++ b/benchmarks/src/main/java/org/apache/druid/benchmark/LikeFilterBenchmark.java @@ -35,8 +35,8 @@ import org.apache.druid.query.filter.SelectorDimFilter; import org.apache.druid.query.ordering.StringComparators; import org.apache.druid.segment.column.BitmapIndex; import org.apache.druid.segment.data.BitmapSerdeFactory; +import org.apache.druid.segment.data.CloseableIndexed; import org.apache.druid.segment.data.GenericIndexed; -import org.apache.druid.segment.data.Indexed; import org.apache.druid.segment.data.RoaringBitmapSerdeFactory; import org.apache.druid.segment.serde.BitmapIndexColumnPartSupplier; import org.openjdk.jmh.annotations.Benchmark; @@ -155,7 +155,7 @@ public class LikeFilterBenchmark selector = new BitmapIndexSelector() { @Override - public Indexed getDimensionValues(String dimension) + public CloseableIndexed getDimensionValues(String dimension) { return dictionary; } diff --git a/benchmarks/src/main/java/org/apache/druid/benchmark/MergeSequenceBenchmark.java b/benchmarks/src/main/java/org/apache/druid/benchmark/MergeSequenceBenchmark.java index 8a96b85836e..cc203fb5de4 100644 --- a/benchmarks/src/main/java/org/apache/druid/benchmark/MergeSequenceBenchmark.java +++ b/benchmarks/src/main/java/org/apache/druid/benchmark/MergeSequenceBenchmark.java @@ -22,12 +22,10 @@ package org.apache.druid.benchmark; import com.google.common.collect.Lists; import com.google.common.collect.Ordering; import com.google.common.primitives.Ints; - import org.apache.druid.java.util.common.guava.Accumulator; import org.apache.druid.java.util.common.guava.MergeSequence; import org.apache.druid.java.util.common.guava.Sequence; import org.apache.druid.java.util.common.guava.Sequences; - import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Mode; diff --git a/benchmarks/src/main/java/org/apache/druid/benchmark/RegexMatchBenchmark.java b/benchmarks/src/main/java/org/apache/druid/benchmark/RegexMatchBenchmark.java index 2b6e892df82..eafeafcbd5c 100644 --- a/benchmarks/src/main/java/org/apache/druid/benchmark/RegexMatchBenchmark.java +++ b/benchmarks/src/main/java/org/apache/druid/benchmark/RegexMatchBenchmark.java @@ -37,7 +37,6 @@ import org.openjdk.jmh.infra.Blackhole; import java.io.IOException; import java.util.ArrayList; import java.util.List; - import java.util.UUID; import java.util.concurrent.TimeUnit; import java.util.regex.Matcher; diff --git a/benchmarks/src/main/java/org/apache/druid/benchmark/TimeParseBenchmark.java b/benchmarks/src/main/java/org/apache/druid/benchmark/TimeParseBenchmark.java index 8759448c886..280461a756c 100644 --- a/benchmarks/src/main/java/org/apache/druid/benchmark/TimeParseBenchmark.java +++ b/benchmarks/src/main/java/org/apache/druid/benchmark/TimeParseBenchmark.java @@ -19,9 +19,7 @@ package org.apache.druid.benchmark; import com.google.common.base.Function; - import org.apache.druid.java.util.common.parsers.TimestampParser; - import org.joda.time.DateTime; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; diff --git a/benchmarks/src/main/java/org/apache/druid/benchmark/datagen/BenchmarkColumnValueGenerator.java b/benchmarks/src/main/java/org/apache/druid/benchmark/datagen/BenchmarkColumnValueGenerator.java index c712badb918..e94a9703598 100644 --- a/benchmarks/src/main/java/org/apache/druid/benchmark/datagen/BenchmarkColumnValueGenerator.java +++ b/benchmarks/src/main/java/org/apache/druid/benchmark/datagen/BenchmarkColumnValueGenerator.java @@ -19,7 +19,6 @@ package org.apache.druid.benchmark.datagen; -import org.apache.druid.segment.column.ValueType; import org.apache.commons.math3.distribution.AbstractIntegerDistribution; import org.apache.commons.math3.distribution.AbstractRealDistribution; import org.apache.commons.math3.distribution.EnumeratedDistribution; @@ -27,6 +26,7 @@ import org.apache.commons.math3.distribution.NormalDistribution; import org.apache.commons.math3.distribution.UniformRealDistribution; import org.apache.commons.math3.distribution.ZipfDistribution; import org.apache.commons.math3.util.Pair; +import org.apache.druid.segment.column.ValueType; import java.io.Serializable; import java.util.ArrayList; diff --git a/benchmarks/src/main/java/org/apache/druid/benchmark/package-info.java b/benchmarks/src/main/java/org/apache/druid/benchmark/package-info.java new file mode 100644 index 00000000000..fd2306feef4 --- /dev/null +++ b/benchmarks/src/main/java/org/apache/druid/benchmark/package-info.java @@ -0,0 +1,23 @@ +/* + * 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. + */ + +@EverythingIsNonnullByDefault +package org.apache.druid.benchmark; + +import org.apache.druid.annotations.EverythingIsNonnullByDefault; diff --git a/benchmarks/src/main/java/org/apache/druid/benchmark/query/SqlBenchmark.java b/benchmarks/src/main/java/org/apache/druid/benchmark/query/SqlBenchmark.java index e762db7e2cf..3fde0194828 100644 --- a/benchmarks/src/main/java/org/apache/druid/benchmark/query/SqlBenchmark.java +++ b/benchmarks/src/main/java/org/apache/druid/benchmark/query/SqlBenchmark.java @@ -21,6 +21,7 @@ package org.apache.druid.benchmark.query; import com.google.common.collect.Maps; import com.google.common.io.Files; +import org.apache.commons.io.FileUtils; import org.apache.druid.benchmark.datagen.BenchmarkSchemaInfo; import org.apache.druid.benchmark.datagen.BenchmarkSchemas; import org.apache.druid.benchmark.datagen.SegmentGenerator; @@ -47,7 +48,6 @@ import org.apache.druid.sql.calcite.util.CalciteTests; import org.apache.druid.sql.calcite.util.SpecificSegmentsQuerySegmentWalker; import org.apache.druid.timeline.DataSegment; import org.apache.druid.timeline.partition.LinearShardSpec; -import org.apache.commons.io.FileUtils; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; diff --git a/benchmarks/src/main/java/org/apache/druid/benchmark/query/TimeseriesBenchmark.java b/benchmarks/src/main/java/org/apache/druid/benchmark/query/TimeseriesBenchmark.java index 5d9066532af..287db1acf34 100644 --- a/benchmarks/src/main/java/org/apache/druid/benchmark/query/TimeseriesBenchmark.java +++ b/benchmarks/src/main/java/org/apache/druid/benchmark/query/TimeseriesBenchmark.java @@ -68,8 +68,8 @@ import org.apache.druid.segment.IndexMergerV9; import org.apache.druid.segment.IndexSpec; import org.apache.druid.segment.QueryableIndex; import org.apache.druid.segment.QueryableIndexSegment; -import org.apache.druid.segment.column.Column; import org.apache.druid.segment.column.ColumnConfig; +import org.apache.druid.segment.column.ColumnHolder; import org.apache.druid.segment.incremental.IncrementalIndex; import org.apache.druid.segment.serde.ComplexMetrics; import org.apache.druid.segment.writeout.OffHeapMemorySegmentWriteOutMediumFactory; @@ -178,7 +178,7 @@ public class TimeseriesBenchmark List queryAggs = new ArrayList<>(); LongSumAggregatorFactory lsaf = new LongSumAggregatorFactory("sumLongSequential", "sumLongSequential"); - BoundDimFilter timeFilter = new BoundDimFilter(Column.TIME_COLUMN_NAME, "200000", "300000", false, false, null, null, + BoundDimFilter timeFilter = new BoundDimFilter(ColumnHolder.TIME_COLUMN_NAME, "200000", "300000", false, false, null, null, StringComparators.NUMERIC); queryAggs.add(new FilteredAggregatorFactory(lsaf, timeFilter)); @@ -198,7 +198,7 @@ public class TimeseriesBenchmark List queryAggs = new ArrayList<>(); LongSumAggregatorFactory lsaf = new LongSumAggregatorFactory("sumLongSequential", "sumLongSequential"); - BoundDimFilter timeFilter = new BoundDimFilter(Column.TIME_COLUMN_NAME, "200000", "300000", false, false, null, null, + BoundDimFilter timeFilter = new BoundDimFilter(ColumnHolder.TIME_COLUMN_NAME, "200000", "300000", false, false, null, null, StringComparators.ALPHANUMERIC); queryAggs.add(new FilteredAggregatorFactory(lsaf, timeFilter)); diff --git a/benchmarks/src/main/java/org/apache/druid/benchmark/query/timecompare/TimeCompareBenchmark.java b/benchmarks/src/main/java/org/apache/druid/benchmark/query/timecompare/TimeCompareBenchmark.java index 36b450278cc..0604ec45f9b 100644 --- a/benchmarks/src/main/java/org/apache/druid/benchmark/query/timecompare/TimeCompareBenchmark.java +++ b/benchmarks/src/main/java/org/apache/druid/benchmark/query/timecompare/TimeCompareBenchmark.java @@ -71,8 +71,8 @@ import org.apache.druid.segment.IndexMergerV9; import org.apache.druid.segment.IndexSpec; import org.apache.druid.segment.QueryableIndex; import org.apache.druid.segment.QueryableIndexSegment; -import org.apache.druid.segment.column.Column; import org.apache.druid.segment.column.ColumnConfig; +import org.apache.druid.segment.column.ColumnHolder; import org.apache.druid.segment.incremental.IncrementalIndex; import org.apache.druid.segment.serde.ComplexMetrics; import org.apache.druid.segment.writeout.OffHeapMemorySegmentWriteOutMediumFactory; @@ -197,7 +197,7 @@ public class TimeCompareBenchmark "sumLongSequential", "sumLongSequential" ), new IntervalDimFilter( - Column.TIME_COLUMN_NAME, + ColumnHolder.TIME_COLUMN_NAME, Collections.singletonList(recent), null ) @@ -209,7 +209,7 @@ public class TimeCompareBenchmark "_cmp_sumLongSequential", "sumLongSequential" ), new IntervalDimFilter( - Column.TIME_COLUMN_NAME, + ColumnHolder.TIME_COLUMN_NAME, Collections.singletonList(previous), null ) @@ -247,7 +247,7 @@ public class TimeCompareBenchmark "sumLongSequential", "sumLongSequential" ), new IntervalDimFilter( - Column.TIME_COLUMN_NAME, + ColumnHolder.TIME_COLUMN_NAME, Collections.singletonList(recent), null ) @@ -259,7 +259,7 @@ public class TimeCompareBenchmark "_cmp_sumLongSequential", "sumLongSequential" ), new IntervalDimFilter( - Column.TIME_COLUMN_NAME, + ColumnHolder.TIME_COLUMN_NAME, Collections.singletonList(previous), null ) diff --git a/benchmarks/src/test/java/org/apache/druid/benchmark/FlattenJSONBenchmarkUtilTest.java b/benchmarks/src/test/java/org/apache/druid/benchmark/FlattenJSONBenchmarkUtilTest.java index 07f21dfa4b6..a81e07cfde1 100644 --- a/benchmarks/src/test/java/org/apache/druid/benchmark/FlattenJSONBenchmarkUtilTest.java +++ b/benchmarks/src/test/java/org/apache/druid/benchmark/FlattenJSONBenchmarkUtilTest.java @@ -19,11 +19,10 @@ package org.apache.druid.benchmark; +import org.apache.druid.java.util.common.parsers.Parser; import org.junit.Assert; import org.junit.Test; -import org.apache.druid.java.util.common.parsers.Parser; - import java.util.Map; public class FlattenJSONBenchmarkUtilTest diff --git a/common/src/main/java/org/apache/druid/collections/CombiningIterator.java b/common/src/main/java/org/apache/druid/collections/CombiningIterator.java index 0aea4bd78b0..8ae59907f81 100644 --- a/common/src/main/java/org/apache/druid/collections/CombiningIterator.java +++ b/common/src/main/java/org/apache/druid/collections/CombiningIterator.java @@ -21,7 +21,6 @@ package org.apache.druid.collections; import com.google.common.collect.Iterators; import com.google.common.collect.PeekingIterator; - import org.apache.druid.java.util.common.guava.nary.BinaryFn; import java.util.Comparator; diff --git a/common/src/main/java/org/apache/druid/collections/OrderedMergeIterator.java b/common/src/main/java/org/apache/druid/collections/OrderedMergeIterator.java index e9cd61ae573..bb2cea426e5 100644 --- a/common/src/main/java/org/apache/druid/collections/OrderedMergeIterator.java +++ b/common/src/main/java/org/apache/druid/collections/OrderedMergeIterator.java @@ -23,7 +23,6 @@ import com.google.common.base.Function; import com.google.common.base.Predicate; import com.google.common.collect.Iterators; import com.google.common.collect.PeekingIterator; - import org.apache.druid.java.util.common.guava.FunctionalIterator; import java.util.Comparator; diff --git a/common/src/main/java/org/apache/druid/collections/OrderedMergeSequence.java b/common/src/main/java/org/apache/druid/collections/OrderedMergeSequence.java index 7f6a79eba63..7c861a9b5c2 100644 --- a/common/src/main/java/org/apache/druid/collections/OrderedMergeSequence.java +++ b/common/src/main/java/org/apache/druid/collections/OrderedMergeSequence.java @@ -22,7 +22,6 @@ package org.apache.druid.collections; import com.google.common.base.Function; import com.google.common.base.Throwables; import com.google.common.collect.Ordering; -import org.apache.druid.java.util.common.io.Closer; import org.apache.druid.java.util.common.guava.Accumulator; import org.apache.druid.java.util.common.guava.CloseQuietly; import org.apache.druid.java.util.common.guava.Sequence; @@ -30,6 +29,7 @@ import org.apache.druid.java.util.common.guava.Yielder; import org.apache.druid.java.util.common.guava.Yielders; import org.apache.druid.java.util.common.guava.YieldingAccumulator; import org.apache.druid.java.util.common.guava.YieldingAccumulators; +import org.apache.druid.java.util.common.io.Closer; import java.io.IOException; import java.util.PriorityQueue; diff --git a/common/src/main/java/org/apache/druid/guice/ConfigProvider.java b/common/src/main/java/org/apache/druid/guice/ConfigProvider.java index 4059d5947e3..a6ca07b4299 100644 --- a/common/src/main/java/org/apache/druid/guice/ConfigProvider.java +++ b/common/src/main/java/org/apache/druid/guice/ConfigProvider.java @@ -23,9 +23,7 @@ import com.google.common.base.Preconditions; import com.google.inject.Binder; import com.google.inject.Inject; import com.google.inject.Provider; - import org.apache.druid.java.util.common.logger.Logger; - import org.skife.config.ConfigurationObjectFactory; import java.util.Map; diff --git a/common/src/main/java/org/apache/druid/guice/GuiceAnnotationIntrospector.java b/common/src/main/java/org/apache/druid/guice/GuiceAnnotationIntrospector.java index 275987f3313..7862c977ee2 100644 --- a/common/src/main/java/org/apache/druid/guice/GuiceAnnotationIntrospector.java +++ b/common/src/main/java/org/apache/druid/guice/GuiceAnnotationIntrospector.java @@ -25,7 +25,6 @@ import com.fasterxml.jackson.databind.introspect.AnnotatedMethod; import com.fasterxml.jackson.databind.introspect.NopAnnotationIntrospector; import com.google.inject.BindingAnnotation; import com.google.inject.Key; - import org.apache.druid.java.util.common.IAE; import java.lang.annotation.Annotation; diff --git a/common/src/main/java/org/apache/druid/guice/GuiceInjectableValues.java b/common/src/main/java/org/apache/druid/guice/GuiceInjectableValues.java index 48da9a1d561..f7071c9246e 100644 --- a/common/src/main/java/org/apache/druid/guice/GuiceInjectableValues.java +++ b/common/src/main/java/org/apache/druid/guice/GuiceInjectableValues.java @@ -24,7 +24,6 @@ import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.InjectableValues; import com.google.inject.Injector; import com.google.inject.Key; - import org.apache.druid.java.util.common.IAE; /** diff --git a/common/src/main/java/org/apache/druid/math/expr/ExprListenerImpl.java b/common/src/main/java/org/apache/druid/math/expr/ExprListenerImpl.java index c559a4da31e..8b33224867d 100644 --- a/common/src/main/java/org/apache/druid/math/expr/ExprListenerImpl.java +++ b/common/src/main/java/org/apache/druid/math/expr/ExprListenerImpl.java @@ -19,13 +19,13 @@ package org.apache.druid.math.expr; +import org.antlr.v4.runtime.tree.ParseTree; +import org.antlr.v4.runtime.tree.TerminalNode; +import org.apache.commons.lang.StringEscapeUtils; import org.apache.druid.annotations.UsedInGeneratedCode; import org.apache.druid.java.util.common.RE; import org.apache.druid.math.expr.antlr.ExprBaseListener; import org.apache.druid.math.expr.antlr.ExprParser; -import org.antlr.v4.runtime.tree.ParseTree; -import org.antlr.v4.runtime.tree.TerminalNode; -import org.apache.commons.lang.StringEscapeUtils; import java.util.ArrayList; import java.util.Collections; diff --git a/common/src/main/java/org/apache/druid/math/expr/Parser.java b/common/src/main/java/org/apache/druid/math/expr/Parser.java index 2d3b96fc94a..9c11d2bc71b 100644 --- a/common/src/main/java/org/apache/druid/math/expr/Parser.java +++ b/common/src/main/java/org/apache/druid/math/expr/Parser.java @@ -26,14 +26,14 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.Sets; -import org.apache.druid.java.util.common.StringUtils; -import org.apache.druid.java.util.common.logger.Logger; -import org.apache.druid.math.expr.antlr.ExprLexer; -import org.apache.druid.math.expr.antlr.ExprParser; import org.antlr.v4.runtime.ANTLRInputStream; import org.antlr.v4.runtime.CommonTokenStream; import org.antlr.v4.runtime.tree.ParseTree; import org.antlr.v4.runtime.tree.ParseTreeWalker; +import org.apache.druid.java.util.common.StringUtils; +import org.apache.druid.java.util.common.logger.Logger; +import org.apache.druid.math.expr.antlr.ExprLexer; +import org.apache.druid.math.expr.antlr.ExprParser; import javax.annotation.Nullable; import java.lang.reflect.Modifier; diff --git a/common/src/test/java/org/apache/druid/common/utils/LogTest.java b/common/src/test/java/org/apache/druid/common/utils/LogTest.java index cfce5bd9168..365bc690f95 100644 --- a/common/src/test/java/org/apache/druid/common/utils/LogTest.java +++ b/common/src/test/java/org/apache/druid/common/utils/LogTest.java @@ -19,14 +19,13 @@ package org.apache.druid.common.utils; +import org.apache.druid.java.util.common.ISE; +import org.apache.druid.java.util.common.logger.Logger; import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; -import org.apache.druid.java.util.common.ISE; -import org.apache.druid.java.util.common.logger.Logger; - // The issue here is that parameters to the logging system are evaluated eagerly // So CPU or resource heavy clauses in the log parameters get evaluated even if there is no debug logging public class LogTest diff --git a/common/src/test/java/org/apache/druid/common/utils/PropUtilsTest.java b/common/src/test/java/org/apache/druid/common/utils/PropUtilsTest.java index 97eddf2e282..08dada217d5 100644 --- a/common/src/test/java/org/apache/druid/common/utils/PropUtilsTest.java +++ b/common/src/test/java/org/apache/druid/common/utils/PropUtilsTest.java @@ -19,11 +19,10 @@ package org.apache.druid.common.utils; +import org.apache.druid.java.util.common.ISE; import org.junit.Assert; import org.junit.Test; -import org.apache.druid.java.util.common.ISE; - import java.util.Properties; public class PropUtilsTest diff --git a/common/src/test/java/org/apache/druid/common/utils/SocketUtilTest.java b/common/src/test/java/org/apache/druid/common/utils/SocketUtilTest.java index c3952a8db9e..928d7c87996 100644 --- a/common/src/test/java/org/apache/druid/common/utils/SocketUtilTest.java +++ b/common/src/test/java/org/apache/druid/common/utils/SocketUtilTest.java @@ -19,12 +19,11 @@ package org.apache.druid.common.utils; +import org.apache.druid.java.util.common.ISE; import org.hamcrest.number.OrderingComparison; import org.junit.Assert; import org.junit.Test; -import org.apache.druid.java.util.common.ISE; - public class SocketUtilTest { private final int MAX_PORT = 0xffff; diff --git a/common/src/test/java/org/apache/druid/concurrent/ExecsTest.java b/common/src/test/java/org/apache/druid/concurrent/ExecsTest.java index 02120c2f71a..cedd99dcdd7 100644 --- a/common/src/test/java/org/apache/druid/concurrent/ExecsTest.java +++ b/common/src/test/java/org/apache/druid/concurrent/ExecsTest.java @@ -21,10 +21,8 @@ package org.apache.druid.concurrent; import com.google.common.base.Throwables; import com.google.common.util.concurrent.ThreadFactoryBuilder; - import org.apache.druid.java.util.common.concurrent.Execs; import org.apache.druid.java.util.common.logger.Logger; - import org.junit.Assert; import org.junit.Test; diff --git a/common/src/test/java/org/apache/druid/guice/LifecycleScopeTest.java b/common/src/test/java/org/apache/druid/guice/LifecycleScopeTest.java index da199c2efd8..237e0165fe4 100644 --- a/common/src/test/java/org/apache/druid/guice/LifecycleScopeTest.java +++ b/common/src/test/java/org/apache/druid/guice/LifecycleScopeTest.java @@ -23,11 +23,9 @@ import com.google.inject.Binder; import com.google.inject.Guice; import com.google.inject.Injector; import com.google.inject.Module; - import org.apache.druid.java.util.common.lifecycle.Lifecycle; import org.apache.druid.java.util.common.lifecycle.LifecycleStart; import org.apache.druid.java.util.common.lifecycle.LifecycleStop; - import org.junit.Assert; import org.junit.Test; diff --git a/common/src/test/java/org/apache/druid/testing/DeadlockDetectingFailOnTimeout.java b/common/src/test/java/org/apache/druid/testing/DeadlockDetectingFailOnTimeout.java new file mode 100644 index 00000000000..ecb27110122 --- /dev/null +++ b/common/src/test/java/org/apache/druid/testing/DeadlockDetectingFailOnTimeout.java @@ -0,0 +1,302 @@ +/* + * 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.testing; + +import org.junit.runners.model.MultipleFailureException; +import org.junit.runners.model.Statement; +import org.junit.runners.model.TestTimedOutException; + +import javax.annotation.Nullable; +import java.lang.management.ManagementFactory; +import java.lang.management.ThreadInfo; +import java.lang.management.ThreadMXBean; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Objects; +import java.util.concurrent.Callable; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.FutureTask; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +/** + * This class is based on {@link org.junit.internal.runners.statements.FailOnTimeout}, additionally deadlocked + * threads are detected. + */ +final class DeadlockDetectingFailOnTimeout extends Statement +{ + private final Statement originalStatement; + private final TimeUnit timeUnit; + private final long timeout; + + DeadlockDetectingFailOnTimeout(long timeout, TimeUnit timeoutUnit, Statement statement) + { + originalStatement = statement; + this.timeout = timeout; + timeUnit = timeoutUnit; + } + + @Override + public void evaluate() throws Throwable + { + CallableStatement callable = new CallableStatement(); + FutureTask task = new FutureTask<>(callable); + ThreadGroup threadGroup = new ThreadGroup("FailOnTimeoutGroup"); + Thread thread = new Thread(threadGroup, task, "Time-limited test"); + try { + thread.setDaemon(true); + thread.start(); + callable.awaitStarted(); + Throwable throwable = getResult(task, thread); + if (throwable != null) { + throw throwable; + } + } + finally { + try { + thread.join(1); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + } + try { + threadGroup.destroy(); + } + catch (IllegalThreadStateException e) { + // If a thread from the group is still alive, the ThreadGroup cannot be destroyed. + // Swallow the exception to keep the same behavior prior to this change. + } + } + } + + /** + * Wait for the test task, returning the exception thrown by the test if the + * test failed, an exception indicating a timeout if the test timed out, or + * {@code null} if the test passed. + */ + private Throwable getResult(FutureTask task, Thread thread) + { + try { + if (timeout > 0) { + return task.get(timeout, timeUnit); + } else { + return task.get(); + } + } + catch (InterruptedException e) { + return e; // caller will re-throw; no need to call Thread.interrupt() + } + catch (ExecutionException e) { + // test failed; have caller re-throw the exception thrown by the test + return e.getCause(); + } + catch (TimeoutException e) { + return createTimeoutException(thread); + } + } + + private Exception createTimeoutException(Thread thread) + { + StackTraceElement[] stackTrace = thread.getStackTrace(); + Exception currThreadException = new TestTimedOutException(timeout, timeUnit); + if (stackTrace != null) { + currThreadException.setStackTrace(stackTrace); + thread.interrupt(); + } + Exception stuckThreadException = getStuckThreadException(thread); + Exception deadlockException = getDeadlockedThreadsException(); + if (stuckThreadException != null || deadlockException != null) { + List exceptions = Stream + .of(currThreadException, stuckThreadException, deadlockException) + .filter(Objects::nonNull) + .collect(Collectors.toList()); + return new MultipleFailureException(exceptions); + } else { + return currThreadException; + } + } + + /** + * Retrieves the stack trace for a given thread. + * + * @param thread The thread whose stack is to be retrieved. + * + * @return The stack trace; returns a zero-length array if the thread has + * terminated or the stack cannot be retrieved for some other reason. + */ + private StackTraceElement[] getStackTrace(Thread thread) + { + try { + return thread.getStackTrace(); + } + catch (SecurityException e) { + return new StackTraceElement[0]; + } + } + + @Nullable + private Exception getStuckThreadException(Thread mainThread) + { + final Thread stuckThread = getStuckThread(mainThread); + if (stuckThread == null) { + return null; + } + Exception stuckThreadException = new Exception("Appears to be stuck in thread " + stuckThread.getName()); + stuckThreadException.setStackTrace(getStackTrace(stuckThread)); + return stuckThreadException; + } + + /** + * Determines whether the test appears to be stuck in some thread other than + * the "main thread" (the one created to run the test). This feature is experimental. + * Behavior may change after the 4.12 release in response to feedback. + * + * @param mainThread The main thread created by {@code evaluate()} + * + * @return The thread which appears to be causing the problem, if different from + * {@code mainThread}, or {@code null} if the main thread appears to be the + * problem or if the thread cannot be determined. The return value is never equal + * to {@code mainThread}. + */ + private Thread getStuckThread(Thread mainThread) + { + List threadsInGroup = getThreadsInGroup(mainThread.getThreadGroup()); + if (threadsInGroup.isEmpty()) { + return null; + } + + // Now that we have all the threads in the test's thread group: Assume that + // any thread we're "stuck" in is RUNNABLE. Look for all RUNNABLE threads. + // If just one, we return that (unless it equals threadMain). If there's more + // than one, pick the one that's using the most CPU time, if this feature is + // supported. + Thread stuckThread = null; + long maxCpuTime = 0; + for (Thread thread : threadsInGroup) { + if (thread.getState() == Thread.State.RUNNABLE) { + long threadCpuTime = cpuTime(thread); + if (stuckThread == null || threadCpuTime > maxCpuTime) { + stuckThread = thread; + maxCpuTime = threadCpuTime; + } + } + } + return (stuckThread == mainThread) ? null : stuckThread; + } + + /** + * Returns all active threads belonging to a thread group. + * + * @param group The thread group. + * + * @return The active threads in the thread group. The result should be a + * complete list of the active threads at some point in time. Returns an empty list + * if this cannot be determined, e.g. because new threads are being created at an + * extremely fast rate. + */ + private List getThreadsInGroup(ThreadGroup group) + { + final int activeThreadCount = group.activeCount(); // this is just an estimate + int threadArraySize = Math.max(activeThreadCount * 2, 100); + for (int loopCount = 0; loopCount < 5; loopCount++) { + Thread[] threads = new Thread[threadArraySize]; + int enumCount = group.enumerate(threads); + if (enumCount < threadArraySize) { + return Arrays.asList(threads).subList(0, enumCount); + } + // if there are too many threads to fit into the array, enumerate's result + // is >= the array's length; therefore we can't trust that it returned all + // the threads. Try again. + threadArraySize += 100; + } + // threads are proliferating too fast for us. Bail before we get into + // trouble. + return Collections.emptyList(); + } + + /** + * Returns the CPU time used by a thread, if possible. + * + * @param thr The thread to query. + * + * @return The CPU time used by {@code thr}, or 0 if it cannot be determined. + */ + private long cpuTime(Thread thr) + { + ThreadMXBean mxBean = ManagementFactory.getThreadMXBean(); + if (mxBean.isThreadCpuTimeSupported()) { + try { + return mxBean.getThreadCpuTime(thr.getId()); + } + catch (UnsupportedOperationException ignore) { + // fall through + } + } + return 0; + } + + @Nullable + private Exception getDeadlockedThreadsException() + { + final ThreadMXBean threadMXBean = ManagementFactory.getThreadMXBean(); + final long[] deadlockedThreadIds = threadMXBean.findDeadlockedThreads(); + if (deadlockedThreadIds == null) { + return null; + } + Exception deadlockException = new Exception("Deadlocked threads:"); + for (long deadlockedThreadId : deadlockedThreadIds) { + ThreadInfo threadInfo = threadMXBean.getThreadInfo(deadlockedThreadId); + Exception threadException = new Exception(threadInfo.getThreadName() + " at " + threadInfo.getLockName()); + threadException.setStackTrace(threadInfo.getStackTrace()); + deadlockException.addSuppressed(threadException); + } + return deadlockException; + } + + private class CallableStatement implements Callable + { + private final CountDownLatch startLatch = new CountDownLatch(1); + + @Override + public Throwable call() throws Exception + { + try { + startLatch.countDown(); + originalStatement.evaluate(); + } + catch (Exception e) { + throw e; + } + catch (Throwable e) { + return e; + } + return null; + } + + public void awaitStarted() throws InterruptedException + { + startLatch.await(); + } + } +} diff --git a/common/src/test/java/org/apache/druid/testing/DeadlockDetectingTimeout.java b/common/src/test/java/org/apache/druid/testing/DeadlockDetectingTimeout.java new file mode 100644 index 00000000000..cae3b0082fc --- /dev/null +++ b/common/src/test/java/org/apache/druid/testing/DeadlockDetectingTimeout.java @@ -0,0 +1,47 @@ +/* + * 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.testing; + +import org.junit.rules.TestRule; +import org.junit.runner.Description; +import org.junit.runners.model.Statement; + +import java.util.concurrent.TimeUnit; + +/** + * This Rule is based on {@link org.junit.rules.Timeout}, additionally deadlocked threads are detected. + */ +public final class DeadlockDetectingTimeout implements TestRule +{ + private final long timeout; + private final TimeUnit timeoutUnit; + + public DeadlockDetectingTimeout(long timeout, TimeUnit timeoutUnit) + { + this.timeout = timeout; + this.timeoutUnit = timeoutUnit; + } + + @Override + public Statement apply(Statement base, Description description) + { + return new DeadlockDetectingFailOnTimeout(timeout, timeoutUnit, base); + } +} diff --git a/examples/src/main/java/org/apache/druid/examples/wikipedia/WikipediaIrcDecoder.java b/examples/src/main/java/org/apache/druid/examples/wikipedia/WikipediaIrcDecoder.java index af792c7058b..fcd38f092c3 100644 --- a/examples/src/main/java/org/apache/druid/examples/wikipedia/WikipediaIrcDecoder.java +++ b/examples/src/main/java/org/apache/druid/examples/wikipedia/WikipediaIrcDecoder.java @@ -27,12 +27,10 @@ import com.google.common.collect.Maps; import com.maxmind.geoip2.DatabaseReader; import com.maxmind.geoip2.exception.GeoIp2Exception; import com.maxmind.geoip2.model.Omni; - +import org.apache.commons.io.FileUtils; import org.apache.druid.data.input.InputRow; import org.apache.druid.data.input.Row; import org.apache.druid.java.util.common.logger.Logger; - -import org.apache.commons.io.FileUtils; import org.joda.time.DateTime; import java.io.File; diff --git a/extendedset/src/main/java/org/apache/druid/extendedset/intset/ImmutableConciseSet.java b/extendedset/src/main/java/org/apache/druid/extendedset/intset/ImmutableConciseSet.java index a97d3c2d7d5..06f53c8774e 100755 --- a/extendedset/src/main/java/org/apache/druid/extendedset/intset/ImmutableConciseSet.java +++ b/extendedset/src/main/java/org/apache/druid/extendedset/intset/ImmutableConciseSet.java @@ -794,13 +794,6 @@ public class ImmutableConciseSet this.size = 0; } - public ImmutableConciseSet(ByteBuffer byteBuffer) - { - this.words = byteBuffer.asIntBuffer(); - this.lastWordIndex = words.capacity() - 1; - this.size = calcSize(); - } - public ImmutableConciseSet(IntBuffer buffer) { this.words = buffer; diff --git a/extendedset/src/test/java/org/apache/druid/extendedset/intset/ImmutableConciseSetTest.java b/extendedset/src/test/java/org/apache/druid/extendedset/intset/ImmutableConciseSetTest.java index 1ab8bc65b21..b7d25bdfac9 100755 --- a/extendedset/src/test/java/org/apache/druid/extendedset/intset/ImmutableConciseSetTest.java +++ b/extendedset/src/test/java/org/apache/druid/extendedset/intset/ImmutableConciseSetTest.java @@ -20,8 +20,8 @@ package org.apache.druid.extendedset.intset; import com.google.common.collect.Lists; -import org.apache.druid.java.util.common.StringUtils; import junit.framework.Assert; +import org.apache.druid.java.util.common.StringUtils; import org.junit.Test; import java.nio.IntBuffer; diff --git a/extensions-contrib/ambari-metrics-emitter/src/main/java/org/apache/druid/emitter/ambari/metrics/AmbariMetricsEmitterModule.java b/extensions-contrib/ambari-metrics-emitter/src/main/java/org/apache/druid/emitter/ambari/metrics/AmbariMetricsEmitterModule.java index 4723c233169..d85812ed3dd 100644 --- a/extensions-contrib/ambari-metrics-emitter/src/main/java/org/apache/druid/emitter/ambari/metrics/AmbariMetricsEmitterModule.java +++ b/extensions-contrib/ambari-metrics-emitter/src/main/java/org/apache/druid/emitter/ambari/metrics/AmbariMetricsEmitterModule.java @@ -28,10 +28,10 @@ import com.google.inject.Key; import com.google.inject.Provides; import com.google.inject.name.Named; import com.google.inject.name.Names; -import org.apache.druid.java.util.emitter.core.Emitter; import org.apache.druid.guice.JsonConfigProvider; import org.apache.druid.guice.ManageLifecycle; import org.apache.druid.initialization.DruidModule; +import org.apache.druid.java.util.emitter.core.Emitter; import java.util.Collections; import java.util.List; diff --git a/extensions-contrib/ambari-metrics-emitter/src/main/java/org/apache/druid/emitter/ambari/metrics/WhiteListBasedDruidToTimelineEventConverter.java b/extensions-contrib/ambari-metrics-emitter/src/main/java/org/apache/druid/emitter/ambari/metrics/WhiteListBasedDruidToTimelineEventConverter.java index 12e6008adb4..f204b22f54d 100644 --- a/extensions-contrib/ambari-metrics-emitter/src/main/java/org/apache/druid/emitter/ambari/metrics/WhiteListBasedDruidToTimelineEventConverter.java +++ b/extensions-contrib/ambari-metrics-emitter/src/main/java/org/apache/druid/emitter/ambari/metrics/WhiteListBasedDruidToTimelineEventConverter.java @@ -33,8 +33,8 @@ import com.google.common.collect.ImmutableSortedMap; import com.google.common.io.CharStreams; import com.google.common.io.Files; import org.apache.druid.java.util.common.ISE; -import org.apache.druid.java.util.emitter.service.ServiceMetricEvent; import org.apache.druid.java.util.common.logger.Logger; +import org.apache.druid.java.util.emitter.service.ServiceMetricEvent; import org.apache.hadoop.metrics2.sink.timeline.TimelineMetric; import java.io.File; diff --git a/extensions-contrib/ambari-metrics-emitter/src/test/java/org/apache/druid/emitter/ambari/metrics/WhiteListBasedDruidToTimelineEventConverterTest.java b/extensions-contrib/ambari-metrics-emitter/src/test/java/org/apache/druid/emitter/ambari/metrics/WhiteListBasedDruidToTimelineEventConverterTest.java index 4ed5ab0e049..a45ef9552ab 100644 --- a/extensions-contrib/ambari-metrics-emitter/src/test/java/org/apache/druid/emitter/ambari/metrics/WhiteListBasedDruidToTimelineEventConverterTest.java +++ b/extensions-contrib/ambari-metrics-emitter/src/test/java/org/apache/druid/emitter/ambari/metrics/WhiteListBasedDruidToTimelineEventConverterTest.java @@ -20,13 +20,13 @@ package org.apache.druid.emitter.ambari.metrics; import com.google.common.collect.Maps; +import junitparams.JUnitParamsRunner; +import junitparams.Parameters; +import org.apache.commons.io.IOUtils; import org.apache.druid.annotations.UsedByJUnitParamsRunner; import org.apache.druid.jackson.DefaultObjectMapper; import org.apache.druid.java.util.common.DateTimes; import org.apache.druid.java.util.emitter.service.ServiceMetricEvent; -import junitparams.JUnitParamsRunner; -import junitparams.Parameters; -import org.apache.commons.io.IOUtils; import org.apache.hadoop.metrics2.sink.timeline.TimelineMetric; import org.easymock.EasyMock; import org.joda.time.DateTime; diff --git a/extensions-contrib/azure-extensions/src/main/java/org/apache/druid/storage/azure/AzureDataSegmentPuller.java b/extensions-contrib/azure-extensions/src/main/java/org/apache/druid/storage/azure/AzureDataSegmentPuller.java index 0eb04121329..835011f5a21 100644 --- a/extensions-contrib/azure-extensions/src/main/java/org/apache/druid/storage/azure/AzureDataSegmentPuller.java +++ b/extensions-contrib/azure-extensions/src/main/java/org/apache/druid/storage/azure/AzureDataSegmentPuller.java @@ -21,10 +21,10 @@ package org.apache.druid.storage.azure; import com.google.common.io.ByteSource; import com.google.inject.Inject; +import org.apache.commons.io.FileUtils; import org.apache.druid.java.util.common.CompressionUtils; import org.apache.druid.java.util.common.logger.Logger; import org.apache.druid.segment.loading.SegmentLoadingException; -import org.apache.commons.io.FileUtils; import java.io.File; import java.io.IOException; diff --git a/extensions-contrib/azure-extensions/src/test/java/org/apache/druid/storage/azure/AzureTaskLogsTest.java b/extensions-contrib/azure-extensions/src/test/java/org/apache/druid/storage/azure/AzureTaskLogsTest.java index fb57da385a8..ce134e9c2ec 100644 --- a/extensions-contrib/azure-extensions/src/test/java/org/apache/druid/storage/azure/AzureTaskLogsTest.java +++ b/extensions-contrib/azure-extensions/src/test/java/org/apache/druid/storage/azure/AzureTaskLogsTest.java @@ -22,9 +22,9 @@ package org.apache.druid.storage.azure; import com.google.common.base.Optional; import com.google.common.io.ByteSource; import com.google.common.io.Files; -import org.apache.druid.java.util.common.StringUtils; import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; +import org.apache.druid.java.util.common.StringUtils; import org.easymock.EasyMockSupport; import org.junit.Assert; import org.junit.Before; diff --git a/extensions-contrib/distinctcount/src/main/java/org/apache/druid/query/aggregation/distinctcount/DistinctCountAggregatorFactory.java b/extensions-contrib/distinctcount/src/main/java/org/apache/druid/query/aggregation/distinctcount/DistinctCountAggregatorFactory.java index 7b5e3c17242..65d5187733a 100644 --- a/extensions-contrib/distinctcount/src/main/java/org/apache/druid/query/aggregation/distinctcount/DistinctCountAggregatorFactory.java +++ b/extensions-contrib/distinctcount/src/main/java/org/apache/druid/query/aggregation/distinctcount/DistinctCountAggregatorFactory.java @@ -24,13 +24,13 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.google.common.base.Preconditions; import com.google.common.primitives.Longs; import org.apache.druid.java.util.common.StringUtils; +import org.apache.druid.query.aggregation.AggregateCombiner; import org.apache.druid.query.aggregation.Aggregator; import org.apache.druid.query.aggregation.AggregatorFactory; import org.apache.druid.query.aggregation.AggregatorUtil; import org.apache.druid.query.aggregation.BufferAggregator; -import org.apache.druid.query.aggregation.LongSumAggregatorFactory; import org.apache.druid.query.aggregation.LongSumAggregateCombiner; -import org.apache.druid.query.aggregation.AggregateCombiner; +import org.apache.druid.query.aggregation.LongSumAggregatorFactory; import org.apache.druid.query.dimension.DefaultDimensionSpec; import org.apache.druid.segment.ColumnSelectorFactory; import org.apache.druid.segment.DimensionSelector; diff --git a/extensions-contrib/distinctcount/src/main/java/org/apache/druid/query/aggregation/distinctcount/DistinctCountBufferAggregator.java b/extensions-contrib/distinctcount/src/main/java/org/apache/druid/query/aggregation/distinctcount/DistinctCountBufferAggregator.java index 1c10788a00c..0b1ebf556d6 100644 --- a/extensions-contrib/distinctcount/src/main/java/org/apache/druid/query/aggregation/distinctcount/DistinctCountBufferAggregator.java +++ b/extensions-contrib/distinctcount/src/main/java/org/apache/druid/query/aggregation/distinctcount/DistinctCountBufferAggregator.java @@ -19,14 +19,14 @@ package org.apache.druid.query.aggregation.distinctcount; +import it.unimi.dsi.fastutil.ints.Int2ObjectMap; +import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import org.apache.druid.collections.bitmap.MutableBitmap; import org.apache.druid.collections.bitmap.WrappedRoaringBitmap; import org.apache.druid.query.aggregation.BufferAggregator; import org.apache.druid.query.monomorphicprocessing.RuntimeShapeInspector; import org.apache.druid.segment.DimensionSelector; import org.apache.druid.segment.data.IndexedInts; -import it.unimi.dsi.fastutil.ints.Int2ObjectMap; -import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import java.nio.ByteBuffer; diff --git a/extensions-contrib/google-extensions/src/test/java/org/apache/druid/storage/google/GoogleDataSegmentPullerTest.java b/extensions-contrib/google-extensions/src/test/java/org/apache/druid/storage/google/GoogleDataSegmentPullerTest.java index 4c193120dea..d6f1a0bb99b 100644 --- a/extensions-contrib/google-extensions/src/test/java/org/apache/druid/storage/google/GoogleDataSegmentPullerTest.java +++ b/extensions-contrib/google-extensions/src/test/java/org/apache/druid/storage/google/GoogleDataSegmentPullerTest.java @@ -22,8 +22,8 @@ package org.apache.druid.storage.google; import com.google.api.client.googleapis.json.GoogleJsonResponseException; import com.google.api.client.googleapis.testing.json.GoogleJsonResponseExceptionFactoryTesting; import com.google.api.client.json.jackson2.JacksonFactory; -import org.apache.druid.segment.loading.SegmentLoadingException; import org.apache.commons.io.FileUtils; +import org.apache.druid.segment.loading.SegmentLoadingException; import org.easymock.EasyMock; import org.easymock.EasyMockSupport; import org.junit.Test; diff --git a/extensions-contrib/google-extensions/src/test/java/org/apache/druid/storage/google/GoogleTaskLogsTest.java b/extensions-contrib/google-extensions/src/test/java/org/apache/druid/storage/google/GoogleTaskLogsTest.java index 2478301b204..edb768ba76d 100644 --- a/extensions-contrib/google-extensions/src/test/java/org/apache/druid/storage/google/GoogleTaskLogsTest.java +++ b/extensions-contrib/google-extensions/src/test/java/org/apache/druid/storage/google/GoogleTaskLogsTest.java @@ -23,9 +23,9 @@ import com.google.api.client.http.InputStreamContent; import com.google.common.base.Optional; import com.google.common.io.ByteSource; import com.google.common.io.Files; -import org.apache.druid.java.util.common.StringUtils; import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; +import org.apache.druid.java.util.common.StringUtils; import org.easymock.EasyMock; import org.easymock.EasyMockSupport; import org.junit.Assert; diff --git a/extensions-contrib/graphite-emitter/src/main/java/org/apache/druid/emitter/graphite/GraphiteEmitterModule.java b/extensions-contrib/graphite-emitter/src/main/java/org/apache/druid/emitter/graphite/GraphiteEmitterModule.java index cb31c1fdb63..1978b0a58be 100644 --- a/extensions-contrib/graphite-emitter/src/main/java/org/apache/druid/emitter/graphite/GraphiteEmitterModule.java +++ b/extensions-contrib/graphite-emitter/src/main/java/org/apache/druid/emitter/graphite/GraphiteEmitterModule.java @@ -29,10 +29,10 @@ import com.google.inject.Key; import com.google.inject.Provides; import com.google.inject.name.Named; import com.google.inject.name.Names; -import org.apache.druid.java.util.emitter.core.Emitter; import org.apache.druid.guice.JsonConfigProvider; import org.apache.druid.guice.ManageLifecycle; import org.apache.druid.initialization.DruidModule; +import org.apache.druid.java.util.emitter.core.Emitter; import java.util.Collections; import java.util.List; diff --git a/extensions-contrib/graphite-emitter/src/test/java/org/apache/druid/emitter/graphite/WhiteListBasedConverterTest.java b/extensions-contrib/graphite-emitter/src/test/java/org/apache/druid/emitter/graphite/WhiteListBasedConverterTest.java index 2bb0f3e2bfb..ed91e0cccdb 100644 --- a/extensions-contrib/graphite-emitter/src/test/java/org/apache/druid/emitter/graphite/WhiteListBasedConverterTest.java +++ b/extensions-contrib/graphite-emitter/src/test/java/org/apache/druid/emitter/graphite/WhiteListBasedConverterTest.java @@ -20,13 +20,13 @@ package org.apache.druid.emitter.graphite; import com.google.common.collect.Maps; +import junitparams.JUnitParamsRunner; +import junitparams.Parameters; +import org.apache.commons.io.IOUtils; import org.apache.druid.annotations.UsedByJUnitParamsRunner; import org.apache.druid.jackson.DefaultObjectMapper; import org.apache.druid.java.util.common.DateTimes; import org.apache.druid.java.util.emitter.service.ServiceMetricEvent; -import junitparams.JUnitParamsRunner; -import junitparams.Parameters; -import org.apache.commons.io.IOUtils; import org.easymock.EasyMock; import org.joda.time.DateTime; import org.junit.Assert; diff --git a/extensions-contrib/influx-extensions/src/main/java/org/apache/druid/data/input/influx/InfluxParser.java b/extensions-contrib/influx-extensions/src/main/java/org/apache/druid/data/input/influx/InfluxParser.java index 8d598028417..db3705da65e 100644 --- a/extensions-contrib/influx-extensions/src/main/java/org/apache/druid/data/input/influx/InfluxParser.java +++ b/extensions-contrib/influx-extensions/src/main/java/org/apache/druid/data/input/influx/InfluxParser.java @@ -19,12 +19,12 @@ package org.apache.druid.data.input.influx; import com.google.common.collect.ImmutableList; -import org.apache.druid.java.util.common.parsers.ParseException; -import org.apache.druid.java.util.common.parsers.Parser; import org.antlr.v4.runtime.ANTLRInputStream; import org.antlr.v4.runtime.CharStream; import org.antlr.v4.runtime.CommonTokenStream; import org.antlr.v4.runtime.TokenStream; +import org.apache.druid.java.util.common.parsers.ParseException; +import org.apache.druid.java.util.common.parsers.Parser; import javax.annotation.Nullable; import java.util.LinkedHashMap; diff --git a/extensions-contrib/influx-extensions/src/test/java/org/apache/druid/data/input/influx/InfluxParserTest.java b/extensions-contrib/influx-extensions/src/test/java/org/apache/druid/data/input/influx/InfluxParserTest.java index 44374243b6a..b14b8bd5909 100644 --- a/extensions-contrib/influx-extensions/src/test/java/org/apache/druid/data/input/influx/InfluxParserTest.java +++ b/extensions-contrib/influx-extensions/src/test/java/org/apache/druid/data/input/influx/InfluxParserTest.java @@ -21,11 +21,11 @@ package org.apache.druid.data.input.influx; import com.google.common.collect.Lists; import com.google.common.collect.Sets; +import junitparams.JUnitParamsRunner; +import junitparams.Parameters; import org.apache.druid.java.util.common.Pair; import org.apache.druid.java.util.common.parsers.ParseException; import org.apache.druid.java.util.common.parsers.Parser; -import junitparams.JUnitParamsRunner; -import junitparams.Parameters; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/extensions-contrib/kafka-eight-simpleConsumer/src/main/java/org/apache/druid/firehose/kafka/KafkaSimpleConsumer.java b/extensions-contrib/kafka-eight-simpleConsumer/src/main/java/org/apache/druid/firehose/kafka/KafkaSimpleConsumer.java index d2a063d21bd..54b2af2ce57 100644 --- a/extensions-contrib/kafka-eight-simpleConsumer/src/main/java/org/apache/druid/firehose/kafka/KafkaSimpleConsumer.java +++ b/extensions-contrib/kafka-eight-simpleConsumer/src/main/java/org/apache/druid/firehose/kafka/KafkaSimpleConsumer.java @@ -23,10 +23,6 @@ import com.google.common.base.Function; import com.google.common.base.Preconditions; import com.google.common.base.Predicate; import com.google.common.net.HostAndPort; - -import org.apache.druid.java.util.common.StringUtils; -import org.apache.druid.java.util.common.guava.FunctionalIterable; -import org.apache.druid.java.util.common.logger.Logger; import kafka.api.FetchRequest; import kafka.api.FetchRequestBuilder; import kafka.api.PartitionOffsetRequestInfo; @@ -42,6 +38,9 @@ import kafka.javaapi.TopicMetadataRequest; import kafka.javaapi.TopicMetadataResponse; import kafka.javaapi.consumer.SimpleConsumer; import kafka.message.MessageAndOffset; +import org.apache.druid.java.util.common.StringUtils; +import org.apache.druid.java.util.common.guava.FunctionalIterable; +import org.apache.druid.java.util.common.logger.Logger; import java.nio.ByteBuffer; import java.util.ArrayList; diff --git a/extensions-contrib/kafka-emitter/src/main/java/org/apache/druid/emitter/kafka/KafkaEmitterModule.java b/extensions-contrib/kafka-emitter/src/main/java/org/apache/druid/emitter/kafka/KafkaEmitterModule.java index cc484b66405..795d723d10b 100644 --- a/extensions-contrib/kafka-emitter/src/main/java/org/apache/druid/emitter/kafka/KafkaEmitterModule.java +++ b/extensions-contrib/kafka-emitter/src/main/java/org/apache/druid/emitter/kafka/KafkaEmitterModule.java @@ -24,10 +24,10 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.google.inject.Binder; import com.google.inject.Provides; import com.google.inject.name.Named; -import org.apache.druid.java.util.emitter.core.Emitter; import org.apache.druid.guice.JsonConfigProvider; import org.apache.druid.guice.ManageLifecycle; import org.apache.druid.initialization.DruidModule; +import org.apache.druid.java.util.emitter.core.Emitter; import java.util.Collections; import java.util.List; diff --git a/extensions-contrib/materialized-view-maintenance/src/main/java/org/apache/druid/indexing/materializedview/DerivativeDataSourceMetadata.java b/extensions-contrib/materialized-view-maintenance/src/main/java/org/apache/druid/indexing/materializedview/DerivativeDataSourceMetadata.java index e7318f796e5..89d3c8c36ce 100644 --- a/extensions-contrib/materialized-view-maintenance/src/main/java/org/apache/druid/indexing/materializedview/DerivativeDataSourceMetadata.java +++ b/extensions-contrib/materialized-view-maintenance/src/main/java/org/apache/druid/indexing/materializedview/DerivativeDataSourceMetadata.java @@ -22,8 +22,8 @@ package org.apache.druid.indexing.materializedview; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.google.common.base.Preconditions; -import com.google.common.collect.Sets; import com.google.common.base.Strings; +import com.google.common.collect.Sets; import org.apache.druid.indexing.overlord.DataSourceMetadata; import java.util.Objects; diff --git a/extensions-contrib/materialized-view-maintenance/src/main/java/org/apache/druid/indexing/materializedview/MaterializedViewSupervisorSpec.java b/extensions-contrib/materialized-view-maintenance/src/main/java/org/apache/druid/indexing/materializedview/MaterializedViewSupervisorSpec.java index 29904a47635..f6f824c3f07 100644 --- a/extensions-contrib/materialized-view-maintenance/src/main/java/org/apache/druid/indexing/materializedview/MaterializedViewSupervisorSpec.java +++ b/extensions-contrib/materialized-view-maintenance/src/main/java/org/apache/druid/indexing/materializedview/MaterializedViewSupervisorSpec.java @@ -23,10 +23,11 @@ import com.fasterxml.jackson.annotation.JacksonInject; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.base.Preconditions; +import com.google.common.base.Strings; import com.google.common.collect.ImmutableList; import com.google.common.collect.Maps; import com.google.common.collect.Sets; -import com.google.common.base.Strings; +import org.apache.commons.codec.digest.DigestUtils; import org.apache.druid.data.input.impl.DimensionSchema; import org.apache.druid.data.input.impl.DimensionsSpec; import org.apache.druid.indexer.HadoopIOConfig; @@ -51,7 +52,6 @@ import org.apache.druid.segment.realtime.firehose.ChatHandlerProvider; import org.apache.druid.segment.transform.TransformSpec; import org.apache.druid.server.security.AuthorizerMapper; import org.apache.druid.timeline.DataSegment; -import org.apache.commons.codec.digest.DigestUtils; import org.joda.time.Interval; import java.util.List; diff --git a/extensions-contrib/materialized-view-maintenance/src/test/java/org/apache/druid/indexing/materializedview/MaterializedViewSupervisorSpecTest.java b/extensions-contrib/materialized-view-maintenance/src/test/java/org/apache/druid/indexing/materializedview/MaterializedViewSupervisorSpecTest.java index 40da151f1d4..97d5dba62c0 100644 --- a/extensions-contrib/materialized-view-maintenance/src/test/java/org/apache/druid/indexing/materializedview/MaterializedViewSupervisorSpecTest.java +++ b/extensions-contrib/materialized-view-maintenance/src/test/java/org/apache/druid/indexing/materializedview/MaterializedViewSupervisorSpecTest.java @@ -40,16 +40,17 @@ import org.apache.druid.segment.TestHelper; import org.apache.druid.segment.realtime.firehose.ChatHandlerProvider; import org.apache.druid.segment.realtime.firehose.NoopChatHandlerProvider; import org.apache.druid.server.security.AuthorizerMapper; -import static org.easymock.EasyMock.createMock; +import org.hamcrest.CoreMatchers; import org.junit.Assert; import org.junit.Before; -import org.junit.Test; -import org.hamcrest.CoreMatchers; import org.junit.Rule; +import org.junit.Test; import org.junit.rules.ExpectedException; import java.io.IOException; +import static org.easymock.EasyMock.createMock; + public class MaterializedViewSupervisorSpecTest { @Rule diff --git a/extensions-contrib/materialized-view-maintenance/src/test/java/org/apache/druid/indexing/materializedview/MaterializedViewSupervisorTest.java b/extensions-contrib/materialized-view-maintenance/src/test/java/org/apache/druid/indexing/materializedview/MaterializedViewSupervisorTest.java index 4ece1f0c926..505c2665475 100644 --- a/extensions-contrib/materialized-view-maintenance/src/test/java/org/apache/druid/indexing/materializedview/MaterializedViewSupervisorTest.java +++ b/extensions-contrib/materialized-view-maintenance/src/test/java/org/apache/druid/indexing/materializedview/MaterializedViewSupervisorTest.java @@ -46,15 +46,13 @@ import org.apache.druid.segment.realtime.firehose.ChatHandlerProvider; import org.apache.druid.server.security.AuthorizerMapper; import org.apache.druid.timeline.DataSegment; import org.apache.druid.timeline.partition.HashBasedNumberedShardSpec; -import static org.easymock.EasyMock.expect; - import org.easymock.EasyMock; -import org.easymock.IAnswer; import org.joda.time.Interval; import org.junit.Assert; import org.junit.Before; import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; import java.io.IOException; import java.util.Collections; @@ -64,7 +62,7 @@ import java.util.Set; import java.util.SortedMap; import static org.easymock.EasyMock.createMock; -import org.junit.rules.ExpectedException; +import static org.easymock.EasyMock.expect; public class MaterializedViewSupervisorTest { @@ -85,7 +83,7 @@ public class MaterializedViewSupervisorTest private ObjectMapper objectMapper = TestHelper.makeJsonMapper(); @Before - public void setUp() throws IOException + public void setUp() { derbyConnector = derbyConnectorRule.getConnector(); derbyConnector.createDataSourceTable(); @@ -180,7 +178,7 @@ public class MaterializedViewSupervisorTest @Test - public void testSuspendedDoesntRun() throws IOException + public void testSuspendedDoesntRun() { MaterializedViewSupervisorSpec suspended = new MaterializedViewSupervisorSpec( "base", @@ -208,10 +206,12 @@ public class MaterializedViewSupervisorTest // mock IndexerSQLMetadataStorageCoordinator to ensure that getDataSourceMetadata is not called // which will be true if truly suspended, since this is the first operation of the 'run' method otherwise IndexerSQLMetadataStorageCoordinator mock = createMock(IndexerSQLMetadataStorageCoordinator.class); - expect(mock.getDataSourceMetadata(suspended.getDataSourceName())).andAnswer((IAnswer) () -> { - Assert.fail(); - return null; - }).anyTimes(); + expect(mock.getDataSourceMetadata(suspended.getDataSourceName())) + .andAnswer(() -> { + Assert.fail(); + return null; + }) + .anyTimes(); EasyMock.replay(mock); supervisor.run(); diff --git a/extensions-contrib/materialized-view-selection/src/main/java/org/apache/druid/query/materializedview/DerivativeDataSourceManager.java b/extensions-contrib/materialized-view-selection/src/main/java/org/apache/druid/query/materializedview/DerivativeDataSourceManager.java index 31679e96767..606132c871d 100644 --- a/extensions-contrib/materialized-view-selection/src/main/java/org/apache/druid/query/materializedview/DerivativeDataSourceManager.java +++ b/extensions-contrib/materialized-view-selection/src/main/java/org/apache/druid/query/materializedview/DerivativeDataSourceManager.java @@ -29,10 +29,8 @@ import com.google.common.util.concurrent.ListeningScheduledExecutorService; import com.google.common.util.concurrent.MoreExecutors; import com.google.inject.Inject; import org.apache.druid.guice.ManageLifecycleLast; -import org.apache.druid.indexing.overlord.DataSourceMetadata; -import org.apache.druid.metadata.MetadataStorageTablesConfig; -import org.apache.druid.metadata.SQLMetadataConnector; import org.apache.druid.indexing.materializedview.DerivativeDataSourceMetadata; +import org.apache.druid.indexing.overlord.DataSourceMetadata; import org.apache.druid.java.util.common.DateTimes; import org.apache.druid.java.util.common.Intervals; import org.apache.druid.java.util.common.Pair; @@ -41,6 +39,8 @@ import org.apache.druid.java.util.common.concurrent.Execs; import org.apache.druid.java.util.common.lifecycle.LifecycleStart; import org.apache.druid.java.util.common.lifecycle.LifecycleStop; import org.apache.druid.java.util.emitter.EmittingLogger; +import org.apache.druid.metadata.MetadataStorageTablesConfig; +import org.apache.druid.metadata.SQLMetadataConnector; import org.apache.druid.timeline.DataSegment; import org.joda.time.Duration; import org.joda.time.Interval; diff --git a/extensions-contrib/materialized-view-selection/src/test/java/org/apache/druid/query/materializedview/DatasourceOptimizerTest.java b/extensions-contrib/materialized-view-selection/src/test/java/org/apache/druid/query/materializedview/DatasourceOptimizerTest.java index 2c0786c875d..50e571e6df6 100644 --- a/extensions-contrib/materialized-view-selection/src/test/java/org/apache/druid/query/materializedview/DatasourceOptimizerTest.java +++ b/extensions-contrib/materialized-view-selection/src/test/java/org/apache/druid/query/materializedview/DatasourceOptimizerTest.java @@ -41,7 +41,6 @@ import org.apache.druid.java.util.http.client.HttpClient; import org.apache.druid.metadata.IndexerSQLMetadataStorageCoordinator; import org.apache.druid.metadata.TestDerbyConnector; import org.apache.druid.query.Query; -import static org.apache.druid.query.QueryRunnerTestHelper.allGran; import org.apache.druid.query.QueryToolChestWarehouse; import org.apache.druid.query.QueryWatcher; import org.apache.druid.query.aggregation.LongSumAggregatorFactory; @@ -69,6 +68,8 @@ import java.util.Set; import java.util.concurrent.Executor; import java.util.concurrent.TimeUnit; +import static org.apache.druid.query.QueryRunnerTestHelper.allGran; + public class DatasourceOptimizerTest extends CuratorTestBase { @Rule diff --git a/extensions-contrib/materialized-view-selection/src/test/java/org/apache/druid/query/materializedview/MaterializedViewQueryTest.java b/extensions-contrib/materialized-view-selection/src/test/java/org/apache/druid/query/materializedview/MaterializedViewQueryTest.java index 39c0c8276fa..4d65b75808d 100644 --- a/extensions-contrib/materialized-view-selection/src/test/java/org/apache/druid/query/materializedview/MaterializedViewQueryTest.java +++ b/extensions-contrib/materialized-view-selection/src/test/java/org/apache/druid/query/materializedview/MaterializedViewQueryTest.java @@ -26,13 +26,6 @@ import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import org.apache.druid.math.expr.ExprMacroTable; import org.apache.druid.query.Query; -import static org.apache.druid.query.QueryRunnerTestHelper.addRowsIndexConstant; -import static org.apache.druid.query.QueryRunnerTestHelper.allGran; -import static org.apache.druid.query.QueryRunnerTestHelper.commonDoubleAggregators; -import static org.apache.druid.query.QueryRunnerTestHelper.dataSource; -import static org.apache.druid.query.QueryRunnerTestHelper.fullOnInterval; -import static org.apache.druid.query.QueryRunnerTestHelper.indexMetric; -import static org.apache.druid.query.QueryRunnerTestHelper.marketDimension; import org.apache.druid.query.TableDataSource; import org.apache.druid.query.aggregation.DoubleMaxAggregatorFactory; import org.apache.druid.query.aggregation.DoubleMinAggregatorFactory; @@ -48,6 +41,14 @@ import org.junit.Test; import java.io.IOException; import java.util.Collections; +import static org.apache.druid.query.QueryRunnerTestHelper.addRowsIndexConstant; +import static org.apache.druid.query.QueryRunnerTestHelper.allGran; +import static org.apache.druid.query.QueryRunnerTestHelper.commonDoubleAggregators; +import static org.apache.druid.query.QueryRunnerTestHelper.dataSource; +import static org.apache.druid.query.QueryRunnerTestHelper.fullOnInterval; +import static org.apache.druid.query.QueryRunnerTestHelper.indexMetric; +import static org.apache.druid.query.QueryRunnerTestHelper.marketDimension; + public class MaterializedViewQueryTest { private static final ObjectMapper jsonMapper = TestHelper.makeJsonMapper(); diff --git a/extensions-contrib/opentsdb-emitter/src/main/java/org/apache/druid/emitter/opentsdb/EventConverter.java b/extensions-contrib/opentsdb-emitter/src/main/java/org/apache/druid/emitter/opentsdb/EventConverter.java index c29045722ab..633d189b9dc 100644 --- a/extensions-contrib/opentsdb-emitter/src/main/java/org/apache/druid/emitter/opentsdb/EventConverter.java +++ b/extensions-contrib/opentsdb-emitter/src/main/java/org/apache/druid/emitter/opentsdb/EventConverter.java @@ -22,9 +22,9 @@ package org.apache.druid.emitter.opentsdb; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.base.Strings; -import org.apache.druid.java.util.emitter.service.ServiceMetricEvent; import org.apache.druid.java.util.common.ISE; import org.apache.druid.java.util.common.logger.Logger; +import org.apache.druid.java.util.emitter.service.ServiceMetricEvent; import java.io.File; import java.io.FileInputStream; diff --git a/extensions-contrib/opentsdb-emitter/src/main/java/org/apache/druid/emitter/opentsdb/OpentsdbEmitterModule.java b/extensions-contrib/opentsdb-emitter/src/main/java/org/apache/druid/emitter/opentsdb/OpentsdbEmitterModule.java index 7f6b017e055..b107161fe8e 100644 --- a/extensions-contrib/opentsdb-emitter/src/main/java/org/apache/druid/emitter/opentsdb/OpentsdbEmitterModule.java +++ b/extensions-contrib/opentsdb-emitter/src/main/java/org/apache/druid/emitter/opentsdb/OpentsdbEmitterModule.java @@ -24,10 +24,10 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.google.inject.Binder; import com.google.inject.Provides; import com.google.inject.name.Named; -import org.apache.druid.java.util.emitter.core.Emitter; import org.apache.druid.guice.JsonConfigProvider; import org.apache.druid.guice.ManageLifecycle; import org.apache.druid.initialization.DruidModule; +import org.apache.druid.java.util.emitter.core.Emitter; import java.util.Collections; import java.util.List; diff --git a/extensions-contrib/parquet-extensions/src/main/java/org/apache/druid/data/input/parquet/GenericRecordAsMap.java b/extensions-contrib/parquet-extensions/src/main/java/org/apache/druid/data/input/parquet/GenericRecordAsMap.java index c876349f599..b7acc12ebe2 100644 --- a/extensions-contrib/parquet-extensions/src/main/java/org/apache/druid/data/input/parquet/GenericRecordAsMap.java +++ b/extensions-contrib/parquet-extensions/src/main/java/org/apache/druid/data/input/parquet/GenericRecordAsMap.java @@ -19,9 +19,9 @@ package org.apache.druid.data.input.parquet; import com.google.common.base.Preconditions; -import org.apache.druid.java.util.common.StringUtils; import org.apache.avro.generic.GenericRecord; import org.apache.avro.util.Utf8; +import org.apache.druid.java.util.common.StringUtils; import java.nio.ByteBuffer; import java.util.Arrays; diff --git a/extensions-contrib/parquet-extensions/src/main/java/org/apache/druid/data/input/parquet/ParquetHadoopInputRowParser.java b/extensions-contrib/parquet-extensions/src/main/java/org/apache/druid/data/input/parquet/ParquetHadoopInputRowParser.java index e10a19f53aa..e592212f6f4 100755 --- a/extensions-contrib/parquet-extensions/src/main/java/org/apache/druid/data/input/parquet/ParquetHadoopInputRowParser.java +++ b/extensions-contrib/parquet-extensions/src/main/java/org/apache/druid/data/input/parquet/ParquetHadoopInputRowParser.java @@ -22,6 +22,10 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; +import org.apache.avro.LogicalType; +import org.apache.avro.LogicalTypes; +import org.apache.avro.Schema; +import org.apache.avro.generic.GenericRecord; import org.apache.druid.data.input.InputRow; import org.apache.druid.data.input.MapBasedInputRow; import org.apache.druid.data.input.impl.DimensionSchema; @@ -29,10 +33,6 @@ import org.apache.druid.data.input.impl.InputRowParser; import org.apache.druid.data.input.impl.ParseSpec; import org.apache.druid.data.input.impl.TimestampSpec; import org.apache.druid.java.util.common.DateTimes; -import org.apache.avro.LogicalType; -import org.apache.avro.LogicalTypes; -import org.apache.avro.Schema; -import org.apache.avro.generic.GenericRecord; import org.joda.time.DateTime; import javax.annotation.Nullable; diff --git a/extensions-contrib/parquet-extensions/src/main/java/org/apache/parquet/avro/DruidParquetReadSupport.java b/extensions-contrib/parquet-extensions/src/main/java/org/apache/parquet/avro/DruidParquetReadSupport.java index e232ed56bd5..be98ffe361a 100755 --- a/extensions-contrib/parquet-extensions/src/main/java/org/apache/parquet/avro/DruidParquetReadSupport.java +++ b/extensions-contrib/parquet-extensions/src/main/java/org/apache/parquet/avro/DruidParquetReadSupport.java @@ -23,11 +23,11 @@ package org.apache.parquet.avro; import com.google.common.collect.Lists; import com.google.common.collect.Sets; +import org.apache.avro.Schema; +import org.apache.avro.generic.GenericRecord; import org.apache.druid.data.input.impl.DimensionSchema; import org.apache.druid.indexer.HadoopDruidIndexerConfig; import org.apache.druid.query.aggregation.AggregatorFactory; -import org.apache.avro.Schema; -import org.apache.avro.generic.GenericRecord; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.util.ReflectionUtils; import org.apache.parquet.hadoop.api.InitContext; diff --git a/extensions-contrib/parquet-extensions/src/test/java/org/apache/druid/data/input/parquet/DruidParquetInputTest.java b/extensions-contrib/parquet-extensions/src/test/java/org/apache/druid/data/input/parquet/DruidParquetInputTest.java index c7d3176a19a..8b3ff2e09fa 100644 --- a/extensions-contrib/parquet-extensions/src/test/java/org/apache/druid/data/input/parquet/DruidParquetInputTest.java +++ b/extensions-contrib/parquet-extensions/src/test/java/org/apache/druid/data/input/parquet/DruidParquetInputTest.java @@ -19,12 +19,12 @@ package org.apache.druid.data.input.parquet; import com.google.common.collect.Lists; +import org.apache.avro.generic.GenericRecord; +import org.apache.avro.util.Utf8; import org.apache.druid.data.input.InputRow; import org.apache.druid.data.input.impl.InputRowParser; import org.apache.druid.indexer.HadoopDruidIndexerConfig; import org.apache.druid.indexer.path.StaticPathSpec; -import org.apache.avro.generic.GenericRecord; -import org.apache.avro.util.Utf8; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.Path; import org.apache.hadoop.mapreduce.Job; diff --git a/extensions-contrib/rabbitmq/src/main/java/org/apache/druid/firehose/rabbitmq/RabbitMQFirehoseFactory.java b/extensions-contrib/rabbitmq/src/main/java/org/apache/druid/firehose/rabbitmq/RabbitMQFirehoseFactory.java index 6870fc2878d..f2b3bda48ad 100644 --- a/extensions-contrib/rabbitmq/src/main/java/org/apache/druid/firehose/rabbitmq/RabbitMQFirehoseFactory.java +++ b/extensions-contrib/rabbitmq/src/main/java/org/apache/druid/firehose/rabbitmq/RabbitMQFirehoseFactory.java @@ -30,16 +30,16 @@ import com.rabbitmq.client.Envelope; import com.rabbitmq.client.QueueingConsumer.Delivery; import com.rabbitmq.client.ShutdownListener; import com.rabbitmq.client.ShutdownSignalException; -import org.apache.druid.data.input.Firehose; -import org.apache.druid.data.input.FirehoseFactory; -import org.apache.druid.data.input.InputRow; -import org.apache.druid.data.input.impl.InputRowParser; -import org.apache.druid.java.util.common.logger.Logger; import net.jodah.lyra.ConnectionOptions; import net.jodah.lyra.Connections; import net.jodah.lyra.config.Config; import net.jodah.lyra.retry.RetryPolicy; import net.jodah.lyra.util.Duration; +import org.apache.druid.data.input.Firehose; +import org.apache.druid.data.input.FirehoseFactory; +import org.apache.druid.data.input.InputRow; +import org.apache.druid.data.input.impl.InputRowParser; +import org.apache.druid.java.util.common.logger.Logger; import javax.annotation.Nullable; import java.io.File; diff --git a/extensions-contrib/rabbitmq/src/test/java/org/apache/druid/examples/rabbitmq/RabbitMQProducerMain.java b/extensions-contrib/rabbitmq/src/test/java/org/apache/druid/examples/rabbitmq/RabbitMQProducerMain.java index 8a8026b9e5e..78c4c220995 100644 --- a/extensions-contrib/rabbitmq/src/test/java/org/apache/druid/examples/rabbitmq/RabbitMQProducerMain.java +++ b/extensions-contrib/rabbitmq/src/test/java/org/apache/druid/examples/rabbitmq/RabbitMQProducerMain.java @@ -22,7 +22,6 @@ package org.apache.druid.examples.rabbitmq; import com.rabbitmq.client.Channel; import com.rabbitmq.client.Connection; import com.rabbitmq.client.ConnectionFactory; -import org.apache.druid.java.util.common.StringUtils; import org.apache.commons.cli.BasicParser; import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.HelpFormatter; @@ -30,6 +29,7 @@ import org.apache.commons.cli.Option; import org.apache.commons.cli.OptionBuilder; import org.apache.commons.cli.Options; import org.apache.commons.cli.ParseException; +import org.apache.druid.java.util.common.StringUtils; import java.text.SimpleDateFormat; import java.util.ArrayList; diff --git a/extensions-contrib/redis-cache/src/main/java/org/apache/druid/client/cache/RedisCache.java b/extensions-contrib/redis-cache/src/main/java/org/apache/druid/client/cache/RedisCache.java index 33145fb86ab..bf9fb42c400 100644 --- a/extensions-contrib/redis-cache/src/main/java/org/apache/druid/client/cache/RedisCache.java +++ b/extensions-contrib/redis-cache/src/main/java/org/apache/druid/client/cache/RedisCache.java @@ -21,15 +21,14 @@ package org.apache.druid.client.cache; import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.Lists; +import org.apache.druid.java.util.common.logger.Logger; import org.apache.druid.java.util.emitter.service.ServiceEmitter; import org.apache.druid.java.util.emitter.service.ServiceMetricEvent; -import org.apache.druid.java.util.common.logger.Logger; import redis.clients.jedis.Jedis; import redis.clients.jedis.JedisPool; import redis.clients.jedis.JedisPoolConfig; import redis.clients.jedis.exceptions.JedisException; - import java.util.HashMap; import java.util.List; import java.util.Map; diff --git a/extensions-contrib/sqlserver-metadata-storage/src/main/java/org/apache/druid/metadata/storage/sqlserver/SQLServerConnector.java b/extensions-contrib/sqlserver-metadata-storage/src/main/java/org/apache/druid/metadata/storage/sqlserver/SQLServerConnector.java index 1a758b6fe30..783daed4c8c 100644 --- a/extensions-contrib/sqlserver-metadata-storage/src/main/java/org/apache/druid/metadata/storage/sqlserver/SQLServerConnector.java +++ b/extensions-contrib/sqlserver-metadata-storage/src/main/java/org/apache/druid/metadata/storage/sqlserver/SQLServerConnector.java @@ -20,12 +20,12 @@ package org.apache.druid.metadata.storage.sqlserver; import com.google.common.base.Supplier; import com.google.inject.Inject; +import org.apache.commons.dbcp2.BasicDataSource; import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.java.util.common.logger.Logger; import org.apache.druid.metadata.MetadataStorageConnectorConfig; import org.apache.druid.metadata.MetadataStorageTablesConfig; import org.apache.druid.metadata.SQLMetadataConnector; -import org.apache.commons.dbcp2.BasicDataSource; import org.skife.jdbi.v2.Binding; import org.skife.jdbi.v2.ColonPrefixNamedParamStatementRewriter; import org.skife.jdbi.v2.DBI; diff --git a/extensions-contrib/sqlserver-metadata-storage/src/test/java/org/apache/druid/metadata/storage/sqlserver/CustomStatementRewriterTest.java b/extensions-contrib/sqlserver-metadata-storage/src/test/java/org/apache/druid/metadata/storage/sqlserver/CustomStatementRewriterTest.java index 4f5c49635a3..3b71ceb9308 100644 --- a/extensions-contrib/sqlserver-metadata-storage/src/test/java/org/apache/druid/metadata/storage/sqlserver/CustomStatementRewriterTest.java +++ b/extensions-contrib/sqlserver-metadata-storage/src/test/java/org/apache/druid/metadata/storage/sqlserver/CustomStatementRewriterTest.java @@ -18,6 +18,8 @@ */ package org.apache.druid.metadata.storage.sqlserver; +import junit.framework.Assert; +import org.apache.druid.metadata.storage.sqlserver.SQLServerConnector.CustomStatementRewriter; import org.junit.Before; import org.junit.Test; import org.skife.jdbi.v2.Binding; @@ -25,9 +27,6 @@ import org.skife.jdbi.v2.StatementContext; import org.skife.jdbi.v2.exceptions.UnableToCreateStatementException; import org.skife.jdbi.v2.tweak.RewrittenStatement; -import org.apache.druid.metadata.storage.sqlserver.SQLServerConnector.CustomStatementRewriter; -import junit.framework.Assert; - @SuppressWarnings("nls") public class CustomStatementRewriterTest { diff --git a/extensions-contrib/statsd-emitter/src/main/java/org/apache/druid/emitter/statsd/DimensionConverter.java b/extensions-contrib/statsd-emitter/src/main/java/org/apache/druid/emitter/statsd/DimensionConverter.java index 5ce5c10d4f4..89eb0f340e4 100644 --- a/extensions-contrib/statsd-emitter/src/main/java/org/apache/druid/emitter/statsd/DimensionConverter.java +++ b/extensions-contrib/statsd-emitter/src/main/java/org/apache/druid/emitter/statsd/DimensionConverter.java @@ -23,7 +23,6 @@ import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.base.Strings; import com.google.common.collect.ImmutableList; - import org.apache.druid.java.util.common.ISE; import org.apache.druid.java.util.common.logger.Logger; diff --git a/extensions-contrib/statsd-emitter/src/main/java/org/apache/druid/emitter/statsd/StatsDEmitterModule.java b/extensions-contrib/statsd-emitter/src/main/java/org/apache/druid/emitter/statsd/StatsDEmitterModule.java index 93c4404a949..0af90124f63 100644 --- a/extensions-contrib/statsd-emitter/src/main/java/org/apache/druid/emitter/statsd/StatsDEmitterModule.java +++ b/extensions-contrib/statsd-emitter/src/main/java/org/apache/druid/emitter/statsd/StatsDEmitterModule.java @@ -24,10 +24,10 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.google.inject.Binder; import com.google.inject.Provides; import com.google.inject.name.Named; -import org.apache.druid.java.util.emitter.core.Emitter; import org.apache.druid.guice.JsonConfigProvider; import org.apache.druid.guice.ManageLifecycle; import org.apache.druid.initialization.DruidModule; +import org.apache.druid.java.util.emitter.core.Emitter; import java.util.Collections; import java.util.List; diff --git a/extensions-contrib/statsd-emitter/src/test/java/org/apache/druid/emitter/statsd/StatsDEmitterTest.java b/extensions-contrib/statsd-emitter/src/test/java/org/apache/druid/emitter/statsd/StatsDEmitterTest.java index 08792963f50..2346661c77f 100644 --- a/extensions-contrib/statsd-emitter/src/test/java/org/apache/druid/emitter/statsd/StatsDEmitterTest.java +++ b/extensions-contrib/statsd-emitter/src/test/java/org/apache/druid/emitter/statsd/StatsDEmitterTest.java @@ -20,9 +20,9 @@ package org.apache.druid.emitter.statsd; import com.fasterxml.jackson.databind.ObjectMapper; -import org.apache.druid.java.util.emitter.service.ServiceMetricEvent; import com.timgroup.statsd.StatsDClient; import org.apache.druid.java.util.common.DateTimes; +import org.apache.druid.java.util.emitter.service.ServiceMetricEvent; import org.junit.Test; import static org.easymock.EasyMock.createMock; diff --git a/extensions-contrib/thrift-extensions/src/main/java/org/apache/druid/data/input/thrift/ThriftInputRowParser.java b/extensions-contrib/thrift-extensions/src/main/java/org/apache/druid/data/input/thrift/ThriftInputRowParser.java index 30bea875d0e..740b888ee78 100644 --- a/extensions-contrib/thrift-extensions/src/main/java/org/apache/druid/data/input/thrift/ThriftInputRowParser.java +++ b/extensions-contrib/thrift-extensions/src/main/java/org/apache/druid/data/input/thrift/ThriftInputRowParser.java @@ -23,12 +23,12 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; -import org.apache.druid.java.util.common.IAE; import com.twitter.elephantbird.mapreduce.io.ThriftWritable; import org.apache.druid.data.input.InputRow; import org.apache.druid.data.input.MapBasedInputRow; import org.apache.druid.data.input.impl.InputRowParser; import org.apache.druid.data.input.impl.ParseSpec; +import org.apache.druid.java.util.common.IAE; import org.apache.druid.java.util.common.parsers.Parser; import org.apache.hadoop.io.BytesWritable; import org.apache.thrift.TBase; diff --git a/extensions-contrib/thrift-extensions/src/test/java/org/apache/druid/data/input/thrift/ThriftInputRowParserTest.java b/extensions-contrib/thrift-extensions/src/test/java/org/apache/druid/data/input/thrift/ThriftInputRowParserTest.java index 4633ff63086..6816f6454ab 100644 --- a/extensions-contrib/thrift-extensions/src/test/java/org/apache/druid/data/input/thrift/ThriftInputRowParserTest.java +++ b/extensions-contrib/thrift-extensions/src/test/java/org/apache/druid/data/input/thrift/ThriftInputRowParserTest.java @@ -21,6 +21,7 @@ package org.apache.druid.data.input.thrift; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; +import org.apache.commons.codec.binary.Base64; import org.apache.druid.data.input.InputRow; import org.apache.druid.data.input.impl.DimensionsSpec; import org.apache.druid.data.input.impl.JSONParseSpec; @@ -32,7 +33,6 @@ import org.apache.druid.java.util.common.parsers.JSONPathFieldSpec; import org.apache.druid.java.util.common.parsers.JSONPathFieldType; import org.apache.druid.java.util.common.parsers.JSONPathSpec; import org.apache.druid.js.JavaScriptConfig; -import org.apache.commons.codec.binary.Base64; import org.apache.hadoop.io.BytesWritable; import org.apache.thrift.TSerializer; import org.apache.thrift.protocol.TBinaryProtocol; diff --git a/extensions-core/avro-extensions/src/main/java/org/apache/druid/data/input/AvroHadoopInputRowParser.java b/extensions-core/avro-extensions/src/main/java/org/apache/druid/data/input/AvroHadoopInputRowParser.java index 4fb26031549..19de982b974 100644 --- a/extensions-core/avro-extensions/src/main/java/org/apache/druid/data/input/AvroHadoopInputRowParser.java +++ b/extensions-core/avro-extensions/src/main/java/org/apache/druid/data/input/AvroHadoopInputRowParser.java @@ -20,11 +20,11 @@ package org.apache.druid.data.input; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; +import org.apache.avro.generic.GenericRecord; import org.apache.druid.data.input.avro.AvroParsers; import org.apache.druid.data.input.impl.InputRowParser; import org.apache.druid.data.input.impl.ParseSpec; import org.apache.druid.java.util.common.parsers.ObjectFlattener; -import org.apache.avro.generic.GenericRecord; import java.util.List; diff --git a/extensions-core/avro-extensions/src/main/java/org/apache/druid/data/input/AvroStreamInputRowParser.java b/extensions-core/avro-extensions/src/main/java/org/apache/druid/data/input/AvroStreamInputRowParser.java index 90dbe95ec44..ab5c2d36547 100644 --- a/extensions-core/avro-extensions/src/main/java/org/apache/druid/data/input/AvroStreamInputRowParser.java +++ b/extensions-core/avro-extensions/src/main/java/org/apache/druid/data/input/AvroStreamInputRowParser.java @@ -21,11 +21,11 @@ package org.apache.druid.data.input; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.google.common.base.Preconditions; +import org.apache.avro.generic.GenericRecord; import org.apache.druid.data.input.avro.AvroBytesDecoder; import org.apache.druid.data.input.avro.AvroParsers; import org.apache.druid.data.input.impl.ParseSpec; import org.apache.druid.java.util.common.parsers.ObjectFlattener; -import org.apache.avro.generic.GenericRecord; import java.nio.ByteBuffer; import java.util.List; diff --git a/extensions-core/avro-extensions/src/main/java/org/apache/druid/data/input/avro/AvroFlattenerMaker.java b/extensions-core/avro-extensions/src/main/java/org/apache/druid/data/input/avro/AvroFlattenerMaker.java index c2261f5dd89..a10b21d3742 100644 --- a/extensions-core/avro-extensions/src/main/java/org/apache/druid/data/input/avro/AvroFlattenerMaker.java +++ b/extensions-core/avro-extensions/src/main/java/org/apache/druid/data/input/avro/AvroFlattenerMaker.java @@ -23,12 +23,12 @@ import com.google.common.collect.Lists; import com.jayway.jsonpath.Configuration; import com.jayway.jsonpath.JsonPath; import com.jayway.jsonpath.Option; -import org.apache.druid.java.util.common.StringUtils; -import org.apache.druid.java.util.common.parsers.ObjectFlatteners; import org.apache.avro.Schema; import org.apache.avro.generic.GenericData; import org.apache.avro.generic.GenericRecord; import org.apache.avro.util.Utf8; +import org.apache.druid.java.util.common.StringUtils; +import org.apache.druid.java.util.common.parsers.ObjectFlatteners; import java.nio.ByteBuffer; import java.util.Arrays; diff --git a/extensions-core/avro-extensions/src/main/java/org/apache/druid/data/input/avro/AvroParsers.java b/extensions-core/avro-extensions/src/main/java/org/apache/druid/data/input/avro/AvroParsers.java index cc37efb886f..1adb4bf827e 100644 --- a/extensions-core/avro-extensions/src/main/java/org/apache/druid/data/input/avro/AvroParsers.java +++ b/extensions-core/avro-extensions/src/main/java/org/apache/druid/data/input/avro/AvroParsers.java @@ -19,13 +19,13 @@ package org.apache.druid.data.input.avro; +import org.apache.avro.generic.GenericRecord; import org.apache.druid.data.input.InputRow; import org.apache.druid.data.input.impl.MapInputRowParser; import org.apache.druid.data.input.impl.ParseSpec; import org.apache.druid.java.util.common.parsers.JSONPathSpec; import org.apache.druid.java.util.common.parsers.ObjectFlattener; import org.apache.druid.java.util.common.parsers.ObjectFlatteners; -import org.apache.avro.generic.GenericRecord; import java.util.List; diff --git a/extensions-core/avro-extensions/src/main/java/org/apache/druid/data/input/avro/AvroValueInputFormat.java b/extensions-core/avro-extensions/src/main/java/org/apache/druid/data/input/avro/AvroValueInputFormat.java index e0d5af3e843..457eb2e365a 100644 --- a/extensions-core/avro-extensions/src/main/java/org/apache/druid/data/input/avro/AvroValueInputFormat.java +++ b/extensions-core/avro-extensions/src/main/java/org/apache/druid/data/input/avro/AvroValueInputFormat.java @@ -18,11 +18,11 @@ */ package org.apache.druid.data.input.avro; -import org.apache.druid.java.util.common.logger.Logger; import org.apache.avro.Schema; import org.apache.avro.generic.GenericRecord; import org.apache.avro.mapreduce.AvroJob; import org.apache.commons.lang.StringUtils; +import org.apache.druid.java.util.common.logger.Logger; import org.apache.hadoop.fs.FSDataInputStream; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; diff --git a/extensions-core/avro-extensions/src/main/java/org/apache/druid/data/input/avro/InlineSchemaAvroBytesDecoder.java b/extensions-core/avro-extensions/src/main/java/org/apache/druid/data/input/avro/InlineSchemaAvroBytesDecoder.java index c8256785f42..01bf930f985 100644 --- a/extensions-core/avro-extensions/src/main/java/org/apache/druid/data/input/avro/InlineSchemaAvroBytesDecoder.java +++ b/extensions-core/avro-extensions/src/main/java/org/apache/druid/data/input/avro/InlineSchemaAvroBytesDecoder.java @@ -25,15 +25,15 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Preconditions; -import org.apache.druid.guice.annotations.Json; -import org.apache.druid.java.util.common.logger.Logger; -import org.apache.druid.java.util.common.parsers.ParseException; import org.apache.avro.Schema; import org.apache.avro.generic.GenericDatumReader; import org.apache.avro.generic.GenericRecord; import org.apache.avro.io.DatumReader; import org.apache.avro.io.DecoderFactory; import org.apache.avro.util.ByteBufferInputStream; +import org.apache.druid.guice.annotations.Json; +import org.apache.druid.java.util.common.logger.Logger; +import org.apache.druid.java.util.common.parsers.ParseException; import java.io.EOFException; import java.nio.ByteBuffer; diff --git a/extensions-core/avro-extensions/src/main/java/org/apache/druid/data/input/avro/InlineSchemasAvroBytesDecoder.java b/extensions-core/avro-extensions/src/main/java/org/apache/druid/data/input/avro/InlineSchemasAvroBytesDecoder.java index 6cee9feb12b..65fc04539b8 100644 --- a/extensions-core/avro-extensions/src/main/java/org/apache/druid/data/input/avro/InlineSchemasAvroBytesDecoder.java +++ b/extensions-core/avro-extensions/src/main/java/org/apache/druid/data/input/avro/InlineSchemasAvroBytesDecoder.java @@ -25,15 +25,15 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Preconditions; -import org.apache.druid.guice.annotations.Json; -import org.apache.druid.java.util.common.logger.Logger; -import org.apache.druid.java.util.common.parsers.ParseException; import org.apache.avro.Schema; import org.apache.avro.generic.GenericDatumReader; import org.apache.avro.generic.GenericRecord; import org.apache.avro.io.DatumReader; import org.apache.avro.io.DecoderFactory; import org.apache.avro.util.ByteBufferInputStream; +import org.apache.druid.guice.annotations.Json; +import org.apache.druid.java.util.common.logger.Logger; +import org.apache.druid.java.util.common.parsers.ParseException; import java.io.EOFException; import java.nio.ByteBuffer; diff --git a/extensions-core/avro-extensions/src/main/java/org/apache/druid/data/input/avro/SchemaRegistryBasedAvroBytesDecoder.java b/extensions-core/avro-extensions/src/main/java/org/apache/druid/data/input/avro/SchemaRegistryBasedAvroBytesDecoder.java index 0c29aaf6e2c..0f8e4ce272d 100644 --- a/extensions-core/avro-extensions/src/main/java/org/apache/druid/data/input/avro/SchemaRegistryBasedAvroBytesDecoder.java +++ b/extensions-core/avro-extensions/src/main/java/org/apache/druid/data/input/avro/SchemaRegistryBasedAvroBytesDecoder.java @@ -23,12 +23,12 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.google.common.annotations.VisibleForTesting; import io.confluent.kafka.schemaregistry.client.CachedSchemaRegistryClient; import io.confluent.kafka.schemaregistry.client.SchemaRegistryClient; -import org.apache.druid.java.util.common.parsers.ParseException; import org.apache.avro.Schema; import org.apache.avro.generic.GenericDatumReader; import org.apache.avro.generic.GenericRecord; import org.apache.avro.io.DatumReader; import org.apache.avro.io.DecoderFactory; +import org.apache.druid.java.util.common.parsers.ParseException; import java.nio.ByteBuffer; diff --git a/extensions-core/avro-extensions/src/main/java/org/apache/druid/data/input/avro/SchemaRepoBasedAvroBytesDecoder.java b/extensions-core/avro-extensions/src/main/java/org/apache/druid/data/input/avro/SchemaRepoBasedAvroBytesDecoder.java index bfaaebc617e..bc6ea7decb5 100644 --- a/extensions-core/avro-extensions/src/main/java/org/apache/druid/data/input/avro/SchemaRepoBasedAvroBytesDecoder.java +++ b/extensions-core/avro-extensions/src/main/java/org/apache/druid/data/input/avro/SchemaRepoBasedAvroBytesDecoder.java @@ -20,15 +20,15 @@ package org.apache.druid.data.input.avro; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; -import org.apache.druid.data.input.schemarepo.SubjectAndIdConverter; -import org.apache.druid.java.util.common.Pair; -import org.apache.druid.java.util.common.parsers.ParseException; import org.apache.avro.Schema; import org.apache.avro.generic.GenericDatumReader; import org.apache.avro.generic.GenericRecord; import org.apache.avro.io.DatumReader; import org.apache.avro.io.DecoderFactory; import org.apache.avro.util.ByteBufferInputStream; +import org.apache.druid.data.input.schemarepo.SubjectAndIdConverter; +import org.apache.druid.java.util.common.Pair; +import org.apache.druid.java.util.common.parsers.ParseException; import org.schemarepo.Repository; import org.schemarepo.api.TypedSchemaRepository; import org.schemarepo.api.converter.AvroSchemaConverter; diff --git a/extensions-core/avro-extensions/src/test/java/org/apache/druid/data/input/AvroHadoopInputRowParserTest.java b/extensions-core/avro-extensions/src/test/java/org/apache/druid/data/input/AvroHadoopInputRowParserTest.java index 250c24b22aa..72ddb413122 100644 --- a/extensions-core/avro-extensions/src/test/java/org/apache/druid/data/input/AvroHadoopInputRowParserTest.java +++ b/extensions-core/avro-extensions/src/test/java/org/apache/druid/data/input/AvroHadoopInputRowParserTest.java @@ -22,8 +22,6 @@ import com.fasterxml.jackson.databind.Module; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.io.Closeables; import com.google.common.io.Files; -import org.apache.druid.data.input.avro.AvroExtensionsModule; -import org.apache.druid.java.util.common.StringUtils; import org.apache.avro.file.DataFileReader; import org.apache.avro.file.DataFileWriter; import org.apache.avro.file.FileReader; @@ -31,6 +29,8 @@ import org.apache.avro.generic.GenericDatumReader; import org.apache.avro.generic.GenericRecord; import org.apache.avro.specific.SpecificDatumWriter; import org.apache.commons.io.FileUtils; +import org.apache.druid.data.input.avro.AvroExtensionsModule; +import org.apache.druid.java.util.common.StringUtils; import org.apache.pig.ExecType; import org.apache.pig.PigServer; import org.apache.pig.backend.executionengine.ExecJob; diff --git a/extensions-core/avro-extensions/src/test/java/org/apache/druid/data/input/AvroStreamInputRowParserTest.java b/extensions-core/avro-extensions/src/test/java/org/apache/druid/data/input/AvroStreamInputRowParserTest.java index 79834ca18c1..6301880718d 100644 --- a/extensions-core/avro-extensions/src/test/java/org/apache/druid/data/input/AvroStreamInputRowParserTest.java +++ b/extensions-core/avro-extensions/src/test/java/org/apache/druid/data/input/AvroStreamInputRowParserTest.java @@ -27,6 +27,11 @@ import com.google.common.base.Splitter; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; import com.google.common.collect.Maps; +import org.apache.avro.Schema; +import org.apache.avro.generic.GenericRecord; +import org.apache.avro.io.DatumWriter; +import org.apache.avro.io.EncoderFactory; +import org.apache.avro.specific.SpecificDatumWriter; import org.apache.druid.data.input.avro.AvroExtensionsModule; import org.apache.druid.data.input.avro.AvroParseSpec; import org.apache.druid.data.input.avro.SchemaRepoBasedAvroBytesDecoder; @@ -37,11 +42,6 @@ import org.apache.druid.data.input.schemarepo.Avro1124SubjectAndIdConverter; import org.apache.druid.java.util.common.parsers.JSONPathFieldSpec; import org.apache.druid.java.util.common.parsers.JSONPathFieldType; import org.apache.druid.java.util.common.parsers.JSONPathSpec; -import org.apache.avro.Schema; -import org.apache.avro.generic.GenericRecord; -import org.apache.avro.io.DatumWriter; -import org.apache.avro.io.EncoderFactory; -import org.apache.avro.specific.SpecificDatumWriter; import org.joda.time.DateTime; import org.joda.time.chrono.ISOChronology; import org.junit.Before; diff --git a/extensions-core/avro-extensions/src/test/java/org/apache/druid/data/input/avro/InlineSchemaAvroBytesDecoderTest.java b/extensions-core/avro-extensions/src/test/java/org/apache/druid/data/input/avro/InlineSchemaAvroBytesDecoderTest.java index c334946b298..00b68b9a963 100644 --- a/extensions-core/avro-extensions/src/test/java/org/apache/druid/data/input/avro/InlineSchemaAvroBytesDecoderTest.java +++ b/extensions-core/avro-extensions/src/test/java/org/apache/druid/data/input/avro/InlineSchemaAvroBytesDecoderTest.java @@ -21,14 +21,14 @@ package org.apache.druid.data.input.avro; import com.fasterxml.jackson.databind.InjectableValues; import com.fasterxml.jackson.databind.ObjectMapper; -import org.apache.druid.data.input.AvroStreamInputRowParserTest; -import org.apache.druid.data.input.SomeAvroDatum; -import org.apache.druid.jackson.DefaultObjectMapper; import org.apache.avro.Schema; import org.apache.avro.generic.GenericRecord; import org.apache.avro.io.DatumWriter; import org.apache.avro.io.EncoderFactory; import org.apache.avro.specific.SpecificDatumWriter; +import org.apache.druid.data.input.AvroStreamInputRowParserTest; +import org.apache.druid.data.input.SomeAvroDatum; +import org.apache.druid.jackson.DefaultObjectMapper; import org.junit.Assert; import org.junit.Test; diff --git a/extensions-core/avro-extensions/src/test/java/org/apache/druid/data/input/avro/InlineSchemasAvroBytesDecoderTest.java b/extensions-core/avro-extensions/src/test/java/org/apache/druid/data/input/avro/InlineSchemasAvroBytesDecoderTest.java index 808f42fd770..23e581f5bb1 100644 --- a/extensions-core/avro-extensions/src/test/java/org/apache/druid/data/input/avro/InlineSchemasAvroBytesDecoderTest.java +++ b/extensions-core/avro-extensions/src/test/java/org/apache/druid/data/input/avro/InlineSchemasAvroBytesDecoderTest.java @@ -22,14 +22,14 @@ package org.apache.druid.data.input.avro; import com.fasterxml.jackson.databind.InjectableValues; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.collect.ImmutableMap; -import org.apache.druid.data.input.AvroStreamInputRowParserTest; -import org.apache.druid.data.input.SomeAvroDatum; -import org.apache.druid.jackson.DefaultObjectMapper; import org.apache.avro.Schema; import org.apache.avro.generic.GenericRecord; import org.apache.avro.io.DatumWriter; import org.apache.avro.io.EncoderFactory; import org.apache.avro.specific.SpecificDatumWriter; +import org.apache.druid.data.input.AvroStreamInputRowParserTest; +import org.apache.druid.data.input.SomeAvroDatum; +import org.apache.druid.jackson.DefaultObjectMapper; import org.junit.Assert; import org.junit.Test; diff --git a/extensions-core/avro-extensions/src/test/java/org/apache/druid/data/input/avro/SchemaRegistryBasedAvroBytesDecoderTest.java b/extensions-core/avro-extensions/src/test/java/org/apache/druid/data/input/avro/SchemaRegistryBasedAvroBytesDecoderTest.java index 8eaf793a586..911819d63f3 100644 --- a/extensions-core/avro-extensions/src/test/java/org/apache/druid/data/input/avro/SchemaRegistryBasedAvroBytesDecoderTest.java +++ b/extensions-core/avro-extensions/src/test/java/org/apache/druid/data/input/avro/SchemaRegistryBasedAvroBytesDecoderTest.java @@ -20,14 +20,14 @@ package org.apache.druid.data.input.avro; import io.confluent.kafka.schemaregistry.client.SchemaRegistryClient; -import org.apache.druid.data.input.AvroStreamInputRowParserTest; -import org.apache.druid.data.input.SomeAvroDatum; -import org.apache.druid.java.util.common.parsers.ParseException; import org.apache.avro.Schema; import org.apache.avro.generic.GenericRecord; import org.apache.avro.io.DatumWriter; import org.apache.avro.io.EncoderFactory; import org.apache.avro.specific.SpecificDatumWriter; +import org.apache.druid.data.input.AvroStreamInputRowParserTest; +import org.apache.druid.data.input.SomeAvroDatum; +import org.apache.druid.java.util.common.parsers.ParseException; import org.junit.Assert; import org.junit.Before; import org.junit.Test; diff --git a/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/RawInputValueExtractor.java b/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/RawInputValueExtractor.java index ca724a6144e..8c4a2d42efc 100644 --- a/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/RawInputValueExtractor.java +++ b/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/RawInputValueExtractor.java @@ -24,16 +24,15 @@ import org.apache.druid.segment.serde.ComplexMetricExtractor; public class RawInputValueExtractor implements ComplexMetricExtractor { - private static final RawInputValueExtractor EXTRACTOR = new RawInputValueExtractor(); - private RawInputValueExtractor() {} - public static RawInputValueExtractor getInstance() { return EXTRACTOR; } + private RawInputValueExtractor() {} + @Override public Class extractedClass() { diff --git a/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/hll/HllSketchMergeComplexMetricSerde.java b/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/hll/HllSketchMergeComplexMetricSerde.java index cf75eb60c0a..62c02e35488 100644 --- a/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/hll/HllSketchMergeComplexMetricSerde.java +++ b/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/hll/HllSketchMergeComplexMetricSerde.java @@ -19,14 +19,9 @@ package org.apache.druid.query.aggregation.datasketches.hll; -import java.nio.ByteBuffer; -import java.nio.charset.StandardCharsets; - -import org.apache.commons.codec.binary.Base64; - import com.yahoo.memory.Memory; import com.yahoo.sketches.hll.HllSketch; - +import org.apache.commons.codec.binary.Base64; import org.apache.druid.data.input.InputRow; import org.apache.druid.java.util.common.IAE; import org.apache.druid.segment.GenericColumnSerializer; @@ -39,6 +34,9 @@ import org.apache.druid.segment.serde.ComplexMetricSerde; import org.apache.druid.segment.serde.LargeColumnSupportedComplexColumnSerializer; import org.apache.druid.segment.writeout.SegmentWriteOutMedium; +import java.nio.ByteBuffer; +import java.nio.charset.StandardCharsets; + public class HllSketchMergeComplexMetricSerde extends ComplexMetricSerde { @@ -80,7 +78,7 @@ public class HllSketchMergeComplexMetricSerde extends ComplexMetricSerde @Override public void deserializeColumn(final ByteBuffer buf, final ColumnBuilder columnBuilder) { - columnBuilder.setComplexColumn( + columnBuilder.setComplexColumnSupplier( new ComplexColumnPartSupplier( getTypeName(), GenericIndexed.read(buf, HllSketchObjectStrategy.STRATEGY, columnBuilder.getFileMapper()) diff --git a/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/package-info.java b/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/package-info.java new file mode 100644 index 00000000000..dbdc3427627 --- /dev/null +++ b/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/package-info.java @@ -0,0 +1,23 @@ +/* + * 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. + */ + +@EverythingIsNonnullByDefault +package org.apache.druid.query.aggregation.datasketches; + +import org.apache.druid.annotations.EverythingIsNonnullByDefault; diff --git a/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/quantiles/DoublesSketchAggregatorFactory.java b/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/quantiles/DoublesSketchAggregatorFactory.java index 331cd1bb394..80f286b4e39 100644 --- a/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/quantiles/DoublesSketchAggregatorFactory.java +++ b/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/quantiles/DoublesSketchAggregatorFactory.java @@ -21,11 +21,10 @@ package org.apache.druid.query.aggregation.datasketches.quantiles; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; -import org.apache.druid.java.util.common.IAE; import com.yahoo.sketches.Util; import com.yahoo.sketches.quantiles.DoublesSketch; import com.yahoo.sketches.quantiles.DoublesUnion; - +import org.apache.druid.java.util.common.IAE; import org.apache.druid.query.aggregation.Aggregator; import org.apache.druid.query.aggregation.AggregatorFactory; import org.apache.druid.query.aggregation.AggregatorFactoryNotMergeableException; @@ -44,6 +43,8 @@ import java.util.Objects; public class DoublesSketchAggregatorFactory extends AggregatorFactory { + public static final Comparator COMPARATOR = + Comparator.nullsFirst(Comparator.comparingLong(DoublesSketch::getN)); private static final int DEFAULT_K = 128; @@ -121,15 +122,6 @@ public class DoublesSketchAggregatorFactory extends AggregatorFactory return DoublesSketchOperations.deserialize(object); } - public static final Comparator COMPARATOR = new Comparator() - { - @Override - public int compare(DoublesSketch a, DoublesSketch b) - { - return Long.compare(a.getN(), b.getN()); - } - }; - @Override public Comparator getComparator() { diff --git a/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/quantiles/DoublesSketchBuildAggregator.java b/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/quantiles/DoublesSketchBuildAggregator.java index 2f28e5dcf4f..6d121b5a159 100644 --- a/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/quantiles/DoublesSketchBuildAggregator.java +++ b/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/quantiles/DoublesSketchBuildAggregator.java @@ -20,7 +20,6 @@ package org.apache.druid.query.aggregation.datasketches.quantiles; import com.yahoo.sketches.quantiles.UpdateDoublesSketch; - import org.apache.druid.query.aggregation.Aggregator; import org.apache.druid.segment.ColumnValueSelector; diff --git a/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/quantiles/DoublesSketchBuildBufferAggregator.java b/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/quantiles/DoublesSketchBuildBufferAggregator.java index 27b117884e8..48cd62213ee 100644 --- a/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/quantiles/DoublesSketchBuildBufferAggregator.java +++ b/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/quantiles/DoublesSketchBuildBufferAggregator.java @@ -19,17 +19,16 @@ package org.apache.druid.query.aggregation.datasketches.quantiles; -import java.nio.ByteBuffer; -import java.util.IdentityHashMap; - import com.yahoo.memory.WritableMemory; import com.yahoo.sketches.quantiles.UpdateDoublesSketch; - +import it.unimi.dsi.fastutil.ints.Int2ObjectMap; +import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import org.apache.druid.query.aggregation.BufferAggregator; import org.apache.druid.query.monomorphicprocessing.RuntimeShapeInspector; import org.apache.druid.segment.ColumnValueSelector; -import it.unimi.dsi.fastutil.ints.Int2ObjectMap; -import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; + +import java.nio.ByteBuffer; +import java.util.IdentityHashMap; public class DoublesSketchBuildBufferAggregator implements BufferAggregator { diff --git a/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/quantiles/DoublesSketchComplexMetricSerde.java b/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/quantiles/DoublesSketchComplexMetricSerde.java index 801cf5ba420..d2ca2378d56 100644 --- a/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/quantiles/DoublesSketchComplexMetricSerde.java +++ b/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/quantiles/DoublesSketchComplexMetricSerde.java @@ -104,7 +104,7 @@ public class DoublesSketchComplexMetricSerde extends ComplexMetricSerde public void deserializeColumn(final ByteBuffer buffer, final ColumnBuilder builder) { final GenericIndexed column = GenericIndexed.read(buffer, strategy, builder.getFileMapper()); - builder.setComplexColumn(new ComplexColumnPartSupplier(getTypeName(), column)); + builder.setComplexColumnSupplier(new ComplexColumnPartSupplier(getTypeName(), column)); } // support large columns diff --git a/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/quantiles/DoublesSketchJsonSerializer.java b/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/quantiles/DoublesSketchJsonSerializer.java index bfb4b2629b7..c7f93c73f57 100644 --- a/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/quantiles/DoublesSketchJsonSerializer.java +++ b/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/quantiles/DoublesSketchJsonSerializer.java @@ -19,13 +19,13 @@ package org.apache.druid.query.aggregation.datasketches.quantiles; -import java.io.IOException; - import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.JsonSerializer; import com.fasterxml.jackson.databind.SerializerProvider; import com.yahoo.sketches.quantiles.DoublesSketch; +import java.io.IOException; + public class DoublesSketchJsonSerializer extends JsonSerializer { diff --git a/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/quantiles/DoublesSketchMergeAggregator.java b/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/quantiles/DoublesSketchMergeAggregator.java index d4e5b95544a..325a6f23f10 100644 --- a/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/quantiles/DoublesSketchMergeAggregator.java +++ b/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/quantiles/DoublesSketchMergeAggregator.java @@ -21,7 +21,6 @@ package org.apache.druid.query.aggregation.datasketches.quantiles; import com.yahoo.sketches.quantiles.DoublesSketch; import com.yahoo.sketches.quantiles.DoublesUnion; - import org.apache.druid.query.aggregation.Aggregator; import org.apache.druid.segment.ColumnValueSelector; diff --git a/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/quantiles/DoublesSketchMergeBufferAggregator.java b/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/quantiles/DoublesSketchMergeBufferAggregator.java index 0b99b579733..337c1d744cd 100644 --- a/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/quantiles/DoublesSketchMergeBufferAggregator.java +++ b/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/quantiles/DoublesSketchMergeBufferAggregator.java @@ -23,11 +23,11 @@ import com.yahoo.memory.WritableMemory; import com.yahoo.sketches.quantiles.DoublesSketch; import com.yahoo.sketches.quantiles.DoublesUnion; import com.yahoo.sketches.quantiles.DoublesUnionBuilder; +import it.unimi.dsi.fastutil.ints.Int2ObjectMap; +import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import org.apache.druid.query.aggregation.BufferAggregator; import org.apache.druid.query.monomorphicprocessing.RuntimeShapeInspector; import org.apache.druid.segment.ColumnValueSelector; -import it.unimi.dsi.fastutil.ints.Int2ObjectMap; -import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import java.nio.ByteBuffer; import java.util.IdentityHashMap; diff --git a/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/quantiles/DoublesSketchNoOpBufferAggregator.java b/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/quantiles/DoublesSketchNoOpBufferAggregator.java index 5f0eb9f2937..fe2348c6005 100644 --- a/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/quantiles/DoublesSketchNoOpBufferAggregator.java +++ b/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/quantiles/DoublesSketchNoOpBufferAggregator.java @@ -19,11 +19,11 @@ package org.apache.druid.query.aggregation.datasketches.quantiles; -import java.nio.ByteBuffer; - import org.apache.druid.query.aggregation.BufferAggregator; import org.apache.druid.query.monomorphicprocessing.RuntimeShapeInspector; +import java.nio.ByteBuffer; + public class DoublesSketchNoOpBufferAggregator implements BufferAggregator { diff --git a/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/quantiles/DoublesSketchObjectStrategy.java b/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/quantiles/DoublesSketchObjectStrategy.java index 0b2ee3eccab..aa66f272bd9 100644 --- a/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/quantiles/DoublesSketchObjectStrategy.java +++ b/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/quantiles/DoublesSketchObjectStrategy.java @@ -19,18 +19,16 @@ package org.apache.druid.query.aggregation.datasketches.quantiles; -import java.nio.ByteBuffer; - import com.yahoo.memory.Memory; import com.yahoo.sketches.quantiles.DoublesSketch; - +import it.unimi.dsi.fastutil.bytes.ByteArrays; import org.apache.druid.segment.data.ObjectStrategy; +import java.nio.ByteBuffer; + public class DoublesSketchObjectStrategy implements ObjectStrategy { - private static final byte[] EMPTY_BYTES = new byte[] {}; - @Override public int compare(final DoublesSketch s1, final DoublesSketch s2) { @@ -47,7 +45,7 @@ public class DoublesSketchObjectStrategy implements ObjectStrategy getClazz() + public Class getClazz() { return DoublesSketch.class; } @@ -56,7 +54,7 @@ public class DoublesSketchObjectStrategy implements ObjectStrategy getExtractor() { return RawInputValueExtractor.getInstance(); } diff --git a/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/theta/SketchConstantPostAggregator.java b/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/theta/SketchConstantPostAggregator.java index a67ea96a1f4..3186fcec03a 100644 --- a/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/theta/SketchConstantPostAggregator.java +++ b/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/theta/SketchConstantPostAggregator.java @@ -19,22 +19,20 @@ package org.apache.druid.query.aggregation.datasketches.theta; -import java.util.Collections; -import java.util.Comparator; -import java.util.Map; -import java.util.Set; - -import org.apache.commons.codec.digest.DigestUtils; - import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.google.common.base.Preconditions; - +import org.apache.commons.codec.digest.DigestUtils; import org.apache.druid.query.aggregation.AggregatorFactory; import org.apache.druid.query.aggregation.PostAggregator; import org.apache.druid.query.aggregation.post.PostAggregatorIds; import org.apache.druid.query.cache.CacheKeyBuilder; +import java.util.Collections; +import java.util.Comparator; +import java.util.Map; +import java.util.Set; + /** */ public class SketchConstantPostAggregator implements PostAggregator diff --git a/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/theta/SketchHolder.java b/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/theta/SketchHolder.java index 53661585477..1b5b2bb3a00 100644 --- a/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/theta/SketchHolder.java +++ b/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/theta/SketchHolder.java @@ -31,10 +31,10 @@ import com.yahoo.sketches.theta.SetOperation; import com.yahoo.sketches.theta.Sketch; import com.yahoo.sketches.theta.Sketches; import com.yahoo.sketches.theta.Union; +import org.apache.commons.codec.binary.Base64; import org.apache.druid.java.util.common.IAE; import org.apache.druid.java.util.common.ISE; import org.apache.druid.java.util.common.StringUtils; -import org.apache.commons.codec.binary.Base64; import java.util.Arrays; import java.util.Comparator; diff --git a/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/theta/SketchObjectStrategy.java b/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/theta/SketchHolderObjectStrategy.java similarity index 69% rename from extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/theta/SketchObjectStrategy.java rename to extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/theta/SketchHolderObjectStrategy.java index c8df8cf2ad3..539b572738c 100644 --- a/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/theta/SketchObjectStrategy.java +++ b/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/theta/SketchHolderObjectStrategy.java @@ -21,30 +21,29 @@ package org.apache.druid.query.aggregation.datasketches.theta; import com.yahoo.memory.Memory; import com.yahoo.sketches.theta.Sketch; -import org.apache.druid.java.util.common.IAE; +import it.unimi.dsi.fastutil.bytes.ByteArrays; import org.apache.druid.segment.data.ObjectStrategy; +import javax.annotation.Nullable; import java.nio.ByteBuffer; -public class SketchObjectStrategy implements ObjectStrategy +public class SketchHolderObjectStrategy implements ObjectStrategy { - private static final byte[] EMPTY_BYTES = new byte[]{}; - @Override - public int compare(Object s1, Object s2) + public int compare(SketchHolder s1, SketchHolder s2) { return SketchHolder.COMPARATOR.compare(s1, s2); } @Override - public Class getClazz() + public Class getClazz() { - return Object.class; + return SketchHolder.class; } @Override - public Object fromByteBuffer(ByteBuffer buffer, int numBytes) + public SketchHolder fromByteBuffer(ByteBuffer buffer, int numBytes) { if (numBytes == 0) { return SketchHolder.EMPTY; @@ -54,18 +53,16 @@ public class SketchObjectStrategy implements ObjectStrategy } @Override - public byte[] toBytes(Object obj) + public byte[] toBytes(@Nullable SketchHolder obj) { - if (obj instanceof SketchHolder) { - Sketch sketch = ((SketchHolder) obj).getSketch(); + if (obj != null) { + Sketch sketch = obj.getSketch(); if (sketch.isEmpty()) { - return EMPTY_BYTES; + return ByteArrays.EMPTY_ARRAY; } return sketch.toByteArray(); - } else if (obj == null) { - return EMPTY_BYTES; } else { - throw new IAE("Unknown class[%s], toString[%s]", obj.getClass(), obj); + return ByteArrays.EMPTY_ARRAY; } } } diff --git a/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/theta/SketchMergeComplexMetricSerde.java b/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/theta/SketchMergeComplexMetricSerde.java index f53b4f744d9..a824312c0ef 100644 --- a/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/theta/SketchMergeComplexMetricSerde.java +++ b/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/theta/SketchMergeComplexMetricSerde.java @@ -19,9 +19,7 @@ package org.apache.druid.query.aggregation.datasketches.theta; -import com.yahoo.sketches.theta.Sketch; import org.apache.druid.data.input.InputRow; -import org.apache.druid.segment.writeout.SegmentWriteOutMedium; import org.apache.druid.segment.GenericColumnSerializer; import org.apache.druid.segment.column.ColumnBuilder; import org.apache.druid.segment.data.GenericIndexed; @@ -30,12 +28,14 @@ import org.apache.druid.segment.serde.ComplexColumnPartSupplier; import org.apache.druid.segment.serde.ComplexMetricExtractor; import org.apache.druid.segment.serde.ComplexMetricSerde; import org.apache.druid.segment.serde.LargeColumnSupportedComplexColumnSerializer; +import org.apache.druid.segment.writeout.SegmentWriteOutMedium; +import javax.annotation.Nullable; import java.nio.ByteBuffer; public class SketchMergeComplexMetricSerde extends ComplexMetricSerde { - private SketchObjectStrategy strategy = new SketchObjectStrategy(); + private SketchHolderObjectStrategy strategy = new SketchHolderObjectStrategy(); @Override public String getTypeName() @@ -44,24 +44,22 @@ public class SketchMergeComplexMetricSerde extends ComplexMetricSerde } @Override - public ComplexMetricExtractor getExtractor() + public ComplexMetricExtractor getExtractor() { - return new ComplexMetricExtractor() + return new ComplexMetricExtractor() { @Override - public Class extractedClass() + public Class extractedClass() { - return Object.class; + return SketchHolder.class; } @Override - public Object extractValue(InputRow inputRow, String metricName) + @Nullable + public SketchHolder extractValue(InputRow inputRow, String metricName) { final Object object = inputRow.getRaw(metricName); - if (object == null) { - return object; - } - return SketchHolder.deserialize(object); + return object == null ? null : SketchHolder.deserialize(object); } }; } @@ -69,12 +67,12 @@ public class SketchMergeComplexMetricSerde extends ComplexMetricSerde @Override public void deserializeColumn(ByteBuffer buffer, ColumnBuilder builder) { - GenericIndexed ge = GenericIndexed.read(buffer, strategy, builder.getFileMapper()); - builder.setComplexColumn(new ComplexColumnPartSupplier(getTypeName(), ge)); + GenericIndexed ge = GenericIndexed.read(buffer, strategy, builder.getFileMapper()); + builder.setComplexColumnSupplier(new ComplexColumnPartSupplier(getTypeName(), ge)); } @Override - public ObjectStrategy getObjectStrategy() + public ObjectStrategy getObjectStrategy() { return strategy; } diff --git a/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/theta/package-info.java b/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/theta/package-info.java new file mode 100644 index 00000000000..455401378c4 --- /dev/null +++ b/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/theta/package-info.java @@ -0,0 +1,23 @@ +/* + * 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. + */ + +@EverythingIsNonnullByDefault +package org.apache.druid.query.aggregation.datasketches.theta; + +import org.apache.druid.annotations.EverythingIsNonnullByDefault; diff --git a/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchAggregatorFactory.java b/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchAggregatorFactory.java index 5bc90e4bddf..8168fddf5d3 100644 --- a/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchAggregatorFactory.java +++ b/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchAggregatorFactory.java @@ -19,18 +19,13 @@ package org.apache.druid.query.aggregation.datasketches.tuple; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; -import java.util.Objects; - -import javax.annotation.Nullable; - import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.google.common.base.Preconditions; - +import com.yahoo.sketches.Util; +import com.yahoo.sketches.tuple.ArrayOfDoublesSetOperationBuilder; +import com.yahoo.sketches.tuple.ArrayOfDoublesSketch; +import com.yahoo.sketches.tuple.ArrayOfDoublesUnion; import org.apache.druid.java.util.common.IAE; import org.apache.druid.query.aggregation.AggregateCombiner; import org.apache.druid.query.aggregation.Aggregator; @@ -48,10 +43,12 @@ import org.apache.druid.segment.DimensionSelector; import org.apache.druid.segment.DimensionSelectorUtils; import org.apache.druid.segment.NilColumnValueSelector; -import com.yahoo.sketches.Util; -import com.yahoo.sketches.tuple.ArrayOfDoublesSketch; -import com.yahoo.sketches.tuple.ArrayOfDoublesUnion; -import com.yahoo.sketches.tuple.ArrayOfDoublesSetOperationBuilder; +import javax.annotation.Nullable; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; +import java.util.Objects; public class ArrayOfDoublesSketchAggregatorFactory extends AggregatorFactory { diff --git a/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchJsonSerializer.java b/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchJsonSerializer.java index 2de36fff6a6..b1637068b92 100644 --- a/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchJsonSerializer.java +++ b/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchJsonSerializer.java @@ -19,14 +19,14 @@ package org.apache.druid.query.aggregation.datasketches.tuple; -import java.io.IOException; - import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonSerializer; import com.fasterxml.jackson.databind.SerializerProvider; import com.yahoo.sketches.tuple.ArrayOfDoublesSketch; +import java.io.IOException; + public class ArrayOfDoublesSketchJsonSerializer extends JsonSerializer { diff --git a/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchMergeComplexMetricSerde.java b/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchMergeComplexMetricSerde.java index 212befb277b..ef87db39e63 100644 --- a/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchMergeComplexMetricSerde.java +++ b/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchMergeComplexMetricSerde.java @@ -19,8 +19,7 @@ package org.apache.druid.query.aggregation.datasketches.tuple; -import java.nio.ByteBuffer; - +import com.yahoo.sketches.tuple.ArrayOfDoublesSketch; import org.apache.druid.data.input.InputRow; import org.apache.druid.segment.GenericColumnSerializer; import org.apache.druid.segment.column.ColumnBuilder; @@ -32,7 +31,7 @@ import org.apache.druid.segment.serde.ComplexMetricSerde; import org.apache.druid.segment.serde.LargeColumnSupportedComplexColumnSerializer; import org.apache.druid.segment.writeout.SegmentWriteOutMedium; -import com.yahoo.sketches.tuple.ArrayOfDoublesSketch; +import java.nio.ByteBuffer; public class ArrayOfDoublesSketchMergeComplexMetricSerde extends ComplexMetricSerde { @@ -70,7 +69,7 @@ public class ArrayOfDoublesSketchMergeComplexMetricSerde extends ComplexMetricSe public void deserializeColumn(final ByteBuffer buffer, final ColumnBuilder builder) { final GenericIndexed ge = GenericIndexed.read(buffer, ArrayOfDoublesSketchObjectStrategy.STRATEGY); - builder.setComplexColumn(new ComplexColumnPartSupplier(getTypeName(), ge)); + builder.setComplexColumnSupplier(new ComplexColumnPartSupplier(getTypeName(), ge)); } @Override @@ -79,7 +78,6 @@ public class ArrayOfDoublesSketchMergeComplexMetricSerde extends ComplexMetricSe return ArrayOfDoublesSketchObjectStrategy.STRATEGY; } - // support large columns @Override public GenericColumnSerializer getSerializer(final SegmentWriteOutMedium segmentWriteOutMedium, final String column) { diff --git a/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchModule.java b/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchModule.java index 7f4ce283c12..3b704a395c0 100644 --- a/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchModule.java +++ b/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchModule.java @@ -19,19 +19,17 @@ package org.apache.druid.query.aggregation.datasketches.tuple; -import java.util.Collections; -import java.util.List; - import com.fasterxml.jackson.databind.Module; import com.fasterxml.jackson.databind.jsontype.NamedType; import com.fasterxml.jackson.databind.module.SimpleModule; import com.google.inject.Binder; - import com.yahoo.sketches.tuple.ArrayOfDoublesSketch; - import org.apache.druid.initialization.DruidModule; import org.apache.druid.segment.serde.ComplexMetrics; +import java.util.Collections; +import java.util.List; + /** * This module is to support numeric Tuple sketches, which extend the functionality of the count-distinct * Theta sketches by adding arrays of double values associated with unique keys. diff --git a/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchMultiPostAggregator.java b/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchMultiPostAggregator.java index c528cde5cd4..fc7e974a923 100644 --- a/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchMultiPostAggregator.java +++ b/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchMultiPostAggregator.java @@ -19,16 +19,15 @@ package org.apache.druid.query.aggregation.datasketches.tuple; -import java.util.List; -import java.util.Objects; -import java.util.Set; - import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.google.common.collect.Sets; - import org.apache.druid.query.aggregation.PostAggregator; +import java.util.List; +import java.util.Objects; +import java.util.Set; + /** * Base class for post aggs taking multiple sketches as input */ diff --git a/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchNoOpAggregator.java b/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchNoOpAggregator.java index 6e533dad7cd..7866ac96770 100644 --- a/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchNoOpAggregator.java +++ b/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchNoOpAggregator.java @@ -21,7 +21,6 @@ package org.apache.druid.query.aggregation.datasketches.tuple; import com.yahoo.sketches.tuple.ArrayOfDoublesSketch; import com.yahoo.sketches.tuple.ArrayOfDoublesUpdatableSketchBuilder; - import org.apache.druid.query.aggregation.Aggregator; public class ArrayOfDoublesSketchNoOpAggregator implements Aggregator diff --git a/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchNoOpBufferAggregator.java b/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchNoOpBufferAggregator.java index 57eaf937f0d..03112276fcc 100644 --- a/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchNoOpBufferAggregator.java +++ b/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchNoOpBufferAggregator.java @@ -19,14 +19,13 @@ package org.apache.druid.query.aggregation.datasketches.tuple; -import java.nio.ByteBuffer; - import com.yahoo.sketches.tuple.ArrayOfDoublesSketch; import com.yahoo.sketches.tuple.ArrayOfDoublesUpdatableSketchBuilder; - import org.apache.druid.query.aggregation.BufferAggregator; import org.apache.druid.query.monomorphicprocessing.RuntimeShapeInspector; +import java.nio.ByteBuffer; + public class ArrayOfDoublesSketchNoOpBufferAggregator implements BufferAggregator { diff --git a/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchObjectStrategy.java b/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchObjectStrategy.java index bc606c8f977..e2157da3411 100644 --- a/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchObjectStrategy.java +++ b/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchObjectStrategy.java @@ -19,15 +19,13 @@ package org.apache.druid.query.aggregation.datasketches.tuple; -import org.apache.druid.segment.data.ObjectStrategy; - -import java.nio.ByteBuffer; - -import javax.annotation.Nullable; - import com.yahoo.memory.Memory; import com.yahoo.sketches.tuple.ArrayOfDoublesSketch; import com.yahoo.sketches.tuple.ArrayOfDoublesSketches; +import org.apache.druid.segment.data.ObjectStrategy; + +import javax.annotation.Nullable; +import java.nio.ByteBuffer; public class ArrayOfDoublesSketchObjectStrategy implements ObjectStrategy { @@ -41,7 +39,7 @@ public class ArrayOfDoublesSketchObjectStrategy implements ObjectStrategy getClazz() + public Class getClazz() { return ArrayOfDoublesSketch.class; } diff --git a/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchOperations.java b/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchOperations.java index 7db75f39446..21afbfd52a2 100644 --- a/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchOperations.java +++ b/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchOperations.java @@ -20,22 +20,18 @@ package org.apache.druid.query.aggregation.datasketches.tuple; import com.yahoo.memory.Memory; - -import java.nio.charset.StandardCharsets; - -import org.apache.commons.codec.binary.Base64; - import com.yahoo.sketches.tuple.ArrayOfDoublesAnotB; import com.yahoo.sketches.tuple.ArrayOfDoublesCombiner; import com.yahoo.sketches.tuple.ArrayOfDoublesIntersection; +import com.yahoo.sketches.tuple.ArrayOfDoublesSetOperationBuilder; import com.yahoo.sketches.tuple.ArrayOfDoublesSketch; import com.yahoo.sketches.tuple.ArrayOfDoublesSketches; import com.yahoo.sketches.tuple.ArrayOfDoublesUnion; - +import org.apache.commons.codec.binary.Base64; import org.apache.druid.java.util.common.IAE; import org.apache.druid.java.util.common.ISE; -import com.yahoo.sketches.tuple.ArrayOfDoublesSetOperationBuilder; +import java.nio.charset.StandardCharsets; public class ArrayOfDoublesSketchOperations { diff --git a/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchPostAggregator.java b/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchPostAggregator.java index b4fc4e602d1..c28431c4fda 100644 --- a/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchPostAggregator.java +++ b/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchPostAggregator.java @@ -19,16 +19,15 @@ package org.apache.druid.query.aggregation.datasketches.tuple; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.google.common.base.Preconditions; +import org.apache.druid.query.aggregation.AggregatorFactory; +import org.apache.druid.query.aggregation.PostAggregator; + import java.util.Collections; import java.util.Map; import java.util.Set; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.google.common.base.Preconditions; - -import org.apache.druid.query.aggregation.AggregatorFactory; -import org.apache.druid.query.aggregation.PostAggregator; - /** * Base class for all post aggs */ diff --git a/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchSetOpPostAggregator.java b/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchSetOpPostAggregator.java index 77a7840376e..fba8467bf7c 100644 --- a/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchSetOpPostAggregator.java +++ b/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchSetOpPostAggregator.java @@ -19,23 +19,21 @@ package org.apache.druid.query.aggregation.datasketches.tuple; -import java.util.Comparator; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -import javax.annotation.Nullable; - import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.yahoo.sketches.Util; import com.yahoo.sketches.tuple.ArrayOfDoublesSketch; - import org.apache.druid.java.util.common.IAE; import org.apache.druid.query.aggregation.AggregatorUtil; import org.apache.druid.query.aggregation.PostAggregator; import org.apache.druid.query.cache.CacheKeyBuilder; +import javax.annotation.Nullable; +import java.util.Comparator; +import java.util.List; +import java.util.Map; +import java.util.Objects; + /** * Returns a result of a specified set operation on the given array of sketches. Supported operations are: * union, intersection and set difference (UNION, INTERSECT, NOT). diff --git a/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchTTestPostAggregator.java b/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchTTestPostAggregator.java index 2f30b23710f..edb8fa1483a 100644 --- a/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchTTestPostAggregator.java +++ b/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchTTestPostAggregator.java @@ -19,24 +19,22 @@ package org.apache.druid.query.aggregation.datasketches.tuple; -import java.util.Arrays; -import java.util.Comparator; -import java.util.List; -import java.util.Map; - -import org.apache.commons.math3.stat.descriptive.SummaryStatistics; -import org.apache.commons.math3.stat.inference.TTest; - import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.yahoo.sketches.tuple.ArrayOfDoublesSketch; import com.yahoo.sketches.tuple.ArrayOfDoublesSketchIterator; - +import org.apache.commons.math3.stat.descriptive.SummaryStatistics; +import org.apache.commons.math3.stat.inference.TTest; import org.apache.druid.java.util.common.IAE; import org.apache.druid.query.aggregation.AggregatorUtil; import org.apache.druid.query.aggregation.PostAggregator; import org.apache.druid.query.cache.CacheKeyBuilder; +import java.util.Arrays; +import java.util.Comparator; +import java.util.List; +import java.util.Map; + /** * Performs Student's t-test and returns a list of p-values given two instances of {@link ArrayOfDoublesSketch}. * The result will be N double values, where N is the number of double values kept in the sketch per key. diff --git a/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchToEstimateAndBoundsPostAggregator.java b/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchToEstimateAndBoundsPostAggregator.java index 7fe4a3ad272..2f1cc79892f 100644 --- a/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchToEstimateAndBoundsPostAggregator.java +++ b/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchToEstimateAndBoundsPostAggregator.java @@ -19,21 +19,19 @@ package org.apache.druid.query.aggregation.datasketches.tuple; -import java.util.Comparator; -import java.util.Map; -import java.util.Objects; - -import javax.annotation.Nullable; - import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.yahoo.sketches.tuple.ArrayOfDoublesSketch; - import org.apache.druid.java.util.common.IAE; import org.apache.druid.query.aggregation.AggregatorUtil; import org.apache.druid.query.aggregation.PostAggregator; import org.apache.druid.query.cache.CacheKeyBuilder; +import javax.annotation.Nullable; +import java.util.Comparator; +import java.util.Map; +import java.util.Objects; + /** * Returns a distinct count estimate and error bounds from a given {@link ArrayOfDoublesSketch}." * The result will be three double values: estimate of the number of distinct keys, lower bound and upper bound. diff --git a/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchToEstimatePostAggregator.java b/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchToEstimatePostAggregator.java index 7be638fcd6b..861c95c5389 100644 --- a/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchToEstimatePostAggregator.java +++ b/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchToEstimatePostAggregator.java @@ -19,17 +19,16 @@ package org.apache.druid.query.aggregation.datasketches.tuple; -import java.util.Comparator; -import java.util.Map; - import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.yahoo.sketches.tuple.ArrayOfDoublesSketch; - import org.apache.druid.query.aggregation.AggregatorUtil; import org.apache.druid.query.aggregation.PostAggregator; import org.apache.druid.query.cache.CacheKeyBuilder; +import java.util.Comparator; +import java.util.Map; + /** * Returns a distinct count estimate from a given {@link ArrayOfDoublesSketch}. */ diff --git a/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchToMeansPostAggregator.java b/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchToMeansPostAggregator.java index 2ba9fe47e1b..3651211b8b0 100644 --- a/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchToMeansPostAggregator.java +++ b/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchToMeansPostAggregator.java @@ -19,22 +19,20 @@ package org.apache.druid.query.aggregation.datasketches.tuple; -import java.util.Arrays; -import java.util.Comparator; -import java.util.Map; - -import org.apache.commons.math3.stat.descriptive.SummaryStatistics; - import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.yahoo.sketches.tuple.ArrayOfDoublesSketch; import com.yahoo.sketches.tuple.ArrayOfDoublesSketchIterator; - +import org.apache.commons.math3.stat.descriptive.SummaryStatistics; import org.apache.druid.java.util.common.IAE; import org.apache.druid.query.aggregation.AggregatorUtil; import org.apache.druid.query.aggregation.PostAggregator; import org.apache.druid.query.cache.CacheKeyBuilder; +import java.util.Arrays; +import java.util.Comparator; +import java.util.Map; + /** * Returns a list of mean values from a given {@link ArrayOfDoublesSketch}. * The result will be N double values, where N is the number of double values kept in the sketch per key. diff --git a/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchToNumEntriesPostAggregator.java b/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchToNumEntriesPostAggregator.java index 8f6ea203b44..68ab5ce80d8 100644 --- a/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchToNumEntriesPostAggregator.java +++ b/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchToNumEntriesPostAggregator.java @@ -19,17 +19,16 @@ package org.apache.druid.query.aggregation.datasketches.tuple; -import java.util.Comparator; -import java.util.Map; - import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.yahoo.sketches.tuple.ArrayOfDoublesSketch; - import org.apache.druid.query.aggregation.AggregatorUtil; import org.apache.druid.query.aggregation.PostAggregator; import org.apache.druid.query.cache.CacheKeyBuilder; +import java.util.Comparator; +import java.util.Map; + /** * Returns the number of retained entries from a given {@link ArrayOfDoublesSketch}. */ diff --git a/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchToQuantilesSketchPostAggregator.java b/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchToQuantilesSketchPostAggregator.java index 2c01554e535..1f4575bc287 100644 --- a/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchToQuantilesSketchPostAggregator.java +++ b/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchToQuantilesSketchPostAggregator.java @@ -19,24 +19,21 @@ package org.apache.druid.query.aggregation.datasketches.tuple; -import java.util.Comparator; -import java.util.Map; -import java.util.Objects; - -import javax.annotation.Nullable; - import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; - +import com.yahoo.sketches.quantiles.DoublesSketch; +import com.yahoo.sketches.quantiles.UpdateDoublesSketch; +import com.yahoo.sketches.tuple.ArrayOfDoublesSketch; +import com.yahoo.sketches.tuple.ArrayOfDoublesSketchIterator; import org.apache.druid.query.aggregation.AggregatorUtil; import org.apache.druid.query.aggregation.PostAggregator; import org.apache.druid.query.aggregation.datasketches.quantiles.DoublesSketchAggregatorFactory; import org.apache.druid.query.cache.CacheKeyBuilder; -import com.yahoo.sketches.tuple.ArrayOfDoublesSketch; -import com.yahoo.sketches.tuple.ArrayOfDoublesSketchIterator; -import com.yahoo.sketches.quantiles.DoublesSketch; -import com.yahoo.sketches.quantiles.UpdateDoublesSketch; +import javax.annotation.Nullable; +import java.util.Comparator; +import java.util.Map; +import java.util.Objects; /** * Returns a quanitles {@link DoublesSketch} constructed from a given column of double values from a given diff --git a/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchToStringPostAggregator.java b/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchToStringPostAggregator.java index 51f762bc700..422e98874e6 100644 --- a/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchToStringPostAggregator.java +++ b/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchToStringPostAggregator.java @@ -19,18 +19,17 @@ package org.apache.druid.query.aggregation.datasketches.tuple; -import java.util.Comparator; -import java.util.Map; - import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.yahoo.sketches.tuple.ArrayOfDoublesSketch; - import org.apache.druid.java.util.common.IAE; import org.apache.druid.query.aggregation.AggregatorUtil; import org.apache.druid.query.aggregation.PostAggregator; import org.apache.druid.query.cache.CacheKeyBuilder; +import java.util.Comparator; +import java.util.Map; + /** * Returns a human-readable summary of a given {@link ArrayOfDoublesSketch}. * This is a string returned by toString() method of the sketch. diff --git a/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchToVariancesPostAggregator.java b/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchToVariancesPostAggregator.java index 4723f7302a0..821968ae9c2 100644 --- a/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchToVariancesPostAggregator.java +++ b/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchToVariancesPostAggregator.java @@ -19,22 +19,20 @@ package org.apache.druid.query.aggregation.datasketches.tuple; -import java.util.Arrays; -import java.util.Comparator; -import java.util.Map; - -import org.apache.commons.math3.stat.descriptive.SummaryStatistics; - import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.yahoo.sketches.tuple.ArrayOfDoublesSketch; import com.yahoo.sketches.tuple.ArrayOfDoublesSketchIterator; - +import org.apache.commons.math3.stat.descriptive.SummaryStatistics; import org.apache.druid.java.util.common.IAE; import org.apache.druid.query.aggregation.AggregatorUtil; import org.apache.druid.query.aggregation.PostAggregator; import org.apache.druid.query.cache.CacheKeyBuilder; +import java.util.Arrays; +import java.util.Comparator; +import java.util.Map; + /** * Returns a list of variance values from a given {@link ArrayOfDoublesSketch}. * The result will be N double values, where N is the number of double values kept in the sketch per key. diff --git a/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchUnaryPostAggregator.java b/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchUnaryPostAggregator.java index 927ede3c4f2..c4fbea3f05b 100644 --- a/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchUnaryPostAggregator.java +++ b/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchUnaryPostAggregator.java @@ -19,16 +19,15 @@ package org.apache.druid.query.aggregation.datasketches.tuple; -import java.util.Objects; -import java.util.Set; - import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.google.common.base.Preconditions; import com.google.common.collect.Sets; - import org.apache.druid.query.aggregation.PostAggregator; +import java.util.Objects; +import java.util.Set; + /** * Base class for post aggs taking one sketch as input */ diff --git a/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/package-info.java b/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/package-info.java new file mode 100644 index 00000000000..bd6fcc53d1c --- /dev/null +++ b/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/package-info.java @@ -0,0 +1,23 @@ +/* + * 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. + */ + +@EverythingIsNonnullByDefault +package org.apache.druid.query.aggregation.datasketches.tuple; + +import org.apache.druid.annotations.EverythingIsNonnullByDefault; diff --git a/extensions-core/datasketches/src/test/java/org/apache/druid/query/aggregation/datasketches/theta/SketchEstimateWithErrorBoundsTest.java b/extensions-core/datasketches/src/test/java/org/apache/druid/query/aggregation/datasketches/theta/SketchEstimateWithErrorBoundsTest.java index 7d86d9db5bb..ad34fbf7c6f 100644 --- a/extensions-core/datasketches/src/test/java/org/apache/druid/query/aggregation/datasketches/theta/SketchEstimateWithErrorBoundsTest.java +++ b/extensions-core/datasketches/src/test/java/org/apache/druid/query/aggregation/datasketches/theta/SketchEstimateWithErrorBoundsTest.java @@ -18,14 +18,13 @@ */ package org.apache.druid.query.aggregation.datasketches.theta; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.druid.jackson.DefaultObjectMapper; import org.junit.Assert; import org.junit.Test; import java.io.IOException; -import com.fasterxml.jackson.databind.ObjectMapper; -import org.apache.druid.jackson.DefaultObjectMapper; - public class SketchEstimateWithErrorBoundsTest { diff --git a/extensions-core/datasketches/src/test/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchAggregatorFactoryTest.java b/extensions-core/datasketches/src/test/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchAggregatorFactoryTest.java index 78a6e24dbd7..59571438be0 100644 --- a/extensions-core/datasketches/src/test/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchAggregatorFactoryTest.java +++ b/extensions-core/datasketches/src/test/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchAggregatorFactoryTest.java @@ -19,16 +19,14 @@ package org.apache.druid.query.aggregation.datasketches.tuple; -import org.junit.Assert; -import org.junit.Test; - import com.yahoo.sketches.tuple.ArrayOfDoublesSketch; import com.yahoo.sketches.tuple.ArrayOfDoublesUpdatableSketch; import com.yahoo.sketches.tuple.ArrayOfDoublesUpdatableSketchBuilder; - import org.apache.druid.query.aggregation.AggregateCombiner; import org.apache.druid.query.aggregation.AggregatorFactory; import org.apache.druid.query.aggregation.TestObjectColumnSelector; +import org.junit.Assert; +import org.junit.Test; public class ArrayOfDoublesSketchAggregatorFactoryTest { diff --git a/extensions-core/datasketches/src/test/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchSetOpPostAggregatorTest.java b/extensions-core/datasketches/src/test/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchSetOpPostAggregatorTest.java index 8ced0aa9bec..4b416eb389d 100644 --- a/extensions-core/datasketches/src/test/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchSetOpPostAggregatorTest.java +++ b/extensions-core/datasketches/src/test/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchSetOpPostAggregatorTest.java @@ -19,13 +19,12 @@ package org.apache.druid.query.aggregation.datasketches.tuple; -import java.util.Arrays; - +import org.apache.druid.query.aggregation.PostAggregator; +import org.apache.druid.query.aggregation.post.ConstantPostAggregator; import org.junit.Assert; import org.junit.Test; -import org.apache.druid.query.aggregation.PostAggregator; -import org.apache.druid.query.aggregation.post.ConstantPostAggregator; +import java.util.Arrays; public class ArrayOfDoublesSketchSetOpPostAggregatorTest { diff --git a/extensions-core/datasketches/src/test/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchTTestPostAggregatorTest.java b/extensions-core/datasketches/src/test/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchTTestPostAggregatorTest.java index 7b58d22f1d3..6ca780ed9f0 100644 --- a/extensions-core/datasketches/src/test/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchTTestPostAggregatorTest.java +++ b/extensions-core/datasketches/src/test/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchTTestPostAggregatorTest.java @@ -19,13 +19,12 @@ package org.apache.druid.query.aggregation.datasketches.tuple; -import java.util.Arrays; - +import org.apache.druid.query.aggregation.PostAggregator; +import org.apache.druid.query.aggregation.post.ConstantPostAggregator; import org.junit.Assert; import org.junit.Test; -import org.apache.druid.query.aggregation.PostAggregator; -import org.apache.druid.query.aggregation.post.ConstantPostAggregator; +import java.util.Arrays; public class ArrayOfDoublesSketchTTestPostAggregatorTest { diff --git a/extensions-core/datasketches/src/test/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchToEstimateAndBoundsPostAggregatorTest.java b/extensions-core/datasketches/src/test/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchToEstimateAndBoundsPostAggregatorTest.java index 508a10c5993..5b9220dee6c 100644 --- a/extensions-core/datasketches/src/test/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchToEstimateAndBoundsPostAggregatorTest.java +++ b/extensions-core/datasketches/src/test/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchToEstimateAndBoundsPostAggregatorTest.java @@ -19,11 +19,10 @@ package org.apache.druid.query.aggregation.datasketches.tuple; -import org.junit.Assert; -import org.junit.Test; - import org.apache.druid.query.aggregation.PostAggregator; import org.apache.druid.query.aggregation.post.ConstantPostAggregator; +import org.junit.Assert; +import org.junit.Test; public class ArrayOfDoublesSketchToEstimateAndBoundsPostAggregatorTest { diff --git a/extensions-core/datasketches/src/test/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchToEstimatePostAggregatorTest.java b/extensions-core/datasketches/src/test/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchToEstimatePostAggregatorTest.java index 446cd4a3ac6..b87fda4b13a 100644 --- a/extensions-core/datasketches/src/test/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchToEstimatePostAggregatorTest.java +++ b/extensions-core/datasketches/src/test/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchToEstimatePostAggregatorTest.java @@ -19,11 +19,10 @@ package org.apache.druid.query.aggregation.datasketches.tuple; -import org.junit.Assert; -import org.junit.Test; - import org.apache.druid.query.aggregation.PostAggregator; import org.apache.druid.query.aggregation.post.ConstantPostAggregator; +import org.junit.Assert; +import org.junit.Test; public class ArrayOfDoublesSketchToEstimatePostAggregatorTest { diff --git a/extensions-core/datasketches/src/test/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchToMeansPostAggregatorTest.java b/extensions-core/datasketches/src/test/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchToMeansPostAggregatorTest.java index d2c761f3fe9..0ee27c075fe 100644 --- a/extensions-core/datasketches/src/test/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchToMeansPostAggregatorTest.java +++ b/extensions-core/datasketches/src/test/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchToMeansPostAggregatorTest.java @@ -19,11 +19,10 @@ package org.apache.druid.query.aggregation.datasketches.tuple; -import org.junit.Assert; -import org.junit.Test; - import org.apache.druid.query.aggregation.PostAggregator; import org.apache.druid.query.aggregation.post.ConstantPostAggregator; +import org.junit.Assert; +import org.junit.Test; public class ArrayOfDoublesSketchToMeansPostAggregatorTest { diff --git a/extensions-core/datasketches/src/test/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchToNumEntriesPostAggregatorTest.java b/extensions-core/datasketches/src/test/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchToNumEntriesPostAggregatorTest.java index 579b6658d60..e22b4655db2 100644 --- a/extensions-core/datasketches/src/test/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchToNumEntriesPostAggregatorTest.java +++ b/extensions-core/datasketches/src/test/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchToNumEntriesPostAggregatorTest.java @@ -19,11 +19,10 @@ package org.apache.druid.query.aggregation.datasketches.tuple; -import org.junit.Assert; -import org.junit.Test; - import org.apache.druid.query.aggregation.PostAggregator; import org.apache.druid.query.aggregation.post.ConstantPostAggregator; +import org.junit.Assert; +import org.junit.Test; public class ArrayOfDoublesSketchToNumEntriesPostAggregatorTest { diff --git a/extensions-core/datasketches/src/test/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchToQuantilesSketchPostAggregatorTest.java b/extensions-core/datasketches/src/test/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchToQuantilesSketchPostAggregatorTest.java index e4acc8d4135..16a4a2206e5 100644 --- a/extensions-core/datasketches/src/test/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchToQuantilesSketchPostAggregatorTest.java +++ b/extensions-core/datasketches/src/test/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchToQuantilesSketchPostAggregatorTest.java @@ -19,11 +19,10 @@ package org.apache.druid.query.aggregation.datasketches.tuple; -import org.junit.Assert; -import org.junit.Test; - import org.apache.druid.query.aggregation.PostAggregator; import org.apache.druid.query.aggregation.post.ConstantPostAggregator; +import org.junit.Assert; +import org.junit.Test; public class ArrayOfDoublesSketchToQuantilesSketchPostAggregatorTest { diff --git a/extensions-core/datasketches/src/test/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchToStringPostAggregatorTest.java b/extensions-core/datasketches/src/test/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchToStringPostAggregatorTest.java index 3f0c65eb755..77c35bdb11c 100644 --- a/extensions-core/datasketches/src/test/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchToStringPostAggregatorTest.java +++ b/extensions-core/datasketches/src/test/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchToStringPostAggregatorTest.java @@ -19,11 +19,10 @@ package org.apache.druid.query.aggregation.datasketches.tuple; -import org.junit.Assert; -import org.junit.Test; - import org.apache.druid.query.aggregation.PostAggregator; import org.apache.druid.query.aggregation.post.ConstantPostAggregator; +import org.junit.Assert; +import org.junit.Test; public class ArrayOfDoublesSketchToStringPostAggregatorTest { diff --git a/extensions-core/datasketches/src/test/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchToVariancesPostAggregatorTest.java b/extensions-core/datasketches/src/test/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchToVariancesPostAggregatorTest.java index fcd8e637310..f1b06618c82 100644 --- a/extensions-core/datasketches/src/test/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchToVariancesPostAggregatorTest.java +++ b/extensions-core/datasketches/src/test/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchToVariancesPostAggregatorTest.java @@ -19,11 +19,10 @@ package org.apache.druid.query.aggregation.datasketches.tuple; -import org.junit.Assert; -import org.junit.Test; - import org.apache.druid.query.aggregation.PostAggregator; import org.apache.druid.query.aggregation.post.ConstantPostAggregator; +import org.junit.Assert; +import org.junit.Test; public class ArrayOfDoublesSketchToVariancesPostAggregatorTest { diff --git a/extensions-core/druid-basic-security/src/main/java/org/apache/druid/security/basic/CommonCacheNotifier.java b/extensions-core/druid-basic-security/src/main/java/org/apache/druid/security/basic/CommonCacheNotifier.java index 33dd021a64d..73a940f05ea 100644 --- a/extensions-core/druid-basic-security/src/main/java/org/apache/druid/security/basic/CommonCacheNotifier.java +++ b/extensions-core/druid-basic-security/src/main/java/org/apache/druid/security/basic/CommonCacheNotifier.java @@ -21,12 +21,6 @@ package org.apache.druid.security.basic; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; -import org.apache.druid.java.util.emitter.EmittingLogger; -import org.apache.druid.java.util.http.client.HttpClient; -import org.apache.druid.java.util.http.client.Request; -import org.apache.druid.java.util.http.client.response.ClientResponse; -import org.apache.druid.java.util.http.client.response.HttpResponseHandler; -import org.apache.druid.java.util.http.client.response.StatusResponseHolder; import org.apache.druid.discovery.DiscoveryDruidNode; import org.apache.druid.discovery.DruidNodeDiscovery; import org.apache.druid.discovery.DruidNodeDiscoveryProvider; @@ -34,6 +28,12 @@ import org.apache.druid.java.util.common.Pair; import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.java.util.common.concurrent.Execs; import org.apache.druid.java.util.common.logger.Logger; +import org.apache.druid.java.util.emitter.EmittingLogger; +import org.apache.druid.java.util.http.client.HttpClient; +import org.apache.druid.java.util.http.client.Request; +import org.apache.druid.java.util.http.client.response.ClientResponse; +import org.apache.druid.java.util.http.client.response.HttpResponseHandler; +import org.apache.druid.java.util.http.client.response.StatusResponseHolder; import org.apache.druid.server.DruidNode; import org.jboss.netty.handler.codec.http.HttpChunk; import org.jboss.netty.handler.codec.http.HttpMethod; diff --git a/extensions-core/druid-kerberos/src/main/java/org/apache/druid/security/kerberos/DruidKerberosAuthenticationHandler.java b/extensions-core/druid-kerberos/src/main/java/org/apache/druid/security/kerberos/DruidKerberosAuthenticationHandler.java index 403fa1514ef..cbc52e33fa5 100644 --- a/extensions-core/druid-kerberos/src/main/java/org/apache/druid/security/kerberos/DruidKerberosAuthenticationHandler.java +++ b/extensions-core/druid-kerberos/src/main/java/org/apache/druid/security/kerberos/DruidKerberosAuthenticationHandler.java @@ -19,8 +19,8 @@ package org.apache.druid.security.kerberos; -import org.apache.druid.java.util.common.logger.Logger; import org.apache.commons.codec.binary.Base64; +import org.apache.druid.java.util.common.logger.Logger; import org.apache.hadoop.security.authentication.client.AuthenticationException; import org.apache.hadoop.security.authentication.server.AuthenticationToken; import org.apache.hadoop.security.authentication.server.KerberosAuthenticationHandler; diff --git a/extensions-core/druid-kerberos/src/main/java/org/apache/druid/security/kerberos/DruidKerberosUtil.java b/extensions-core/druid-kerberos/src/main/java/org/apache/druid/security/kerberos/DruidKerberosUtil.java index 6ffff0f9778..1caa76adc77 100644 --- a/extensions-core/druid-kerberos/src/main/java/org/apache/druid/security/kerberos/DruidKerberosUtil.java +++ b/extensions-core/druid-kerberos/src/main/java/org/apache/druid/security/kerberos/DruidKerberosUtil.java @@ -20,9 +20,9 @@ package org.apache.druid.security.kerberos; import com.google.common.base.Strings; +import org.apache.commons.codec.binary.Base64; import org.apache.druid.java.util.common.ISE; import org.apache.druid.java.util.common.logger.Logger; -import org.apache.commons.codec.binary.Base64; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.CommonConfigurationKeysPublic; import org.apache.hadoop.security.UserGroupInformation; diff --git a/extensions-core/druid-kerberos/src/main/java/org/apache/druid/security/kerberos/KerberosAuthenticator.java b/extensions-core/druid-kerberos/src/main/java/org/apache/druid/security/kerberos/KerberosAuthenticator.java index fd5a8a2e53f..e8966f1d7df 100644 --- a/extensions-core/druid-kerberos/src/main/java/org/apache/druid/security/kerberos/KerberosAuthenticator.java +++ b/extensions-core/druid-kerberos/src/main/java/org/apache/druid/security/kerberos/KerberosAuthenticator.java @@ -26,6 +26,7 @@ import com.fasterxml.jackson.annotation.JsonTypeName; import com.google.common.base.Joiner; import com.google.common.base.Preconditions; import com.google.common.base.Throwables; +import org.apache.commons.codec.binary.Base64; import org.apache.druid.guice.annotations.Self; import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.java.util.common.logger.Logger; @@ -33,7 +34,6 @@ import org.apache.druid.server.DruidNode; import org.apache.druid.server.security.AuthConfig; import org.apache.druid.server.security.AuthenticationResult; import org.apache.druid.server.security.Authenticator; -import org.apache.commons.codec.binary.Base64; import org.apache.hadoop.security.SecurityUtil; import org.apache.hadoop.security.authentication.client.AuthenticatedURL; import org.apache.hadoop.security.authentication.client.AuthenticationException; diff --git a/extensions-core/druid-kerberos/src/main/java/org/apache/druid/security/kerberos/KerberosHttpClient.java b/extensions-core/druid-kerberos/src/main/java/org/apache/druid/security/kerberos/KerberosHttpClient.java index 75e46906ceb..7cb79d745a7 100644 --- a/extensions-core/druid-kerberos/src/main/java/org/apache/druid/security/kerberos/KerberosHttpClient.java +++ b/extensions-core/druid-kerberos/src/main/java/org/apache/druid/security/kerberos/KerberosHttpClient.java @@ -24,12 +24,12 @@ import com.google.common.util.concurrent.FutureCallback; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.SettableFuture; +import org.apache.druid.java.util.common.concurrent.Execs; +import org.apache.druid.java.util.common.logger.Logger; import org.apache.druid.java.util.http.client.AbstractHttpClient; import org.apache.druid.java.util.http.client.HttpClient; import org.apache.druid.java.util.http.client.Request; import org.apache.druid.java.util.http.client.response.HttpResponseHandler; -import org.apache.druid.java.util.common.concurrent.Execs; -import org.apache.druid.java.util.common.logger.Logger; import org.apache.hadoop.security.UserGroupInformation; import org.jboss.netty.handler.codec.http.HttpHeaders; import org.joda.time.Duration; diff --git a/extensions-core/hdfs-storage/src/main/java/org/apache/druid/storage/hdfs/HdfsDataSegmentKiller.java b/extensions-core/hdfs-storage/src/main/java/org/apache/druid/storage/hdfs/HdfsDataSegmentKiller.java index b660ea10bfd..631fc51794a 100644 --- a/extensions-core/hdfs-storage/src/main/java/org/apache/druid/storage/hdfs/HdfsDataSegmentKiller.java +++ b/extensions-core/hdfs-storage/src/main/java/org/apache/druid/storage/hdfs/HdfsDataSegmentKiller.java @@ -21,11 +21,11 @@ package org.apache.druid.storage.hdfs; import com.google.common.base.Preconditions; import com.google.inject.Inject; +import org.apache.commons.lang.StringUtils; import org.apache.druid.java.util.emitter.EmittingLogger; import org.apache.druid.segment.loading.DataSegmentKiller; import org.apache.druid.segment.loading.SegmentLoadingException; import org.apache.druid.timeline.DataSegment; -import org.apache.commons.lang.StringUtils; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; diff --git a/extensions-core/hdfs-storage/src/main/java/org/apache/druid/storage/hdfs/HdfsStorageAuthentication.java b/extensions-core/hdfs-storage/src/main/java/org/apache/druid/storage/hdfs/HdfsStorageAuthentication.java index b9155265a8d..93fbf48efa2 100644 --- a/extensions-core/hdfs-storage/src/main/java/org/apache/druid/storage/hdfs/HdfsStorageAuthentication.java +++ b/extensions-core/hdfs-storage/src/main/java/org/apache/druid/storage/hdfs/HdfsStorageAuthentication.java @@ -22,13 +22,11 @@ package org.apache.druid.storage.hdfs; import com.google.common.base.Strings; import com.google.inject.Inject; - import org.apache.druid.guice.ManageLifecycle; import org.apache.druid.java.util.common.ISE; import org.apache.druid.java.util.common.lifecycle.LifecycleStart; import org.apache.druid.java.util.common.lifecycle.LifecycleStop; import org.apache.druid.java.util.common.logger.Logger; - import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.security.UserGroupInformation; diff --git a/extensions-core/hdfs-storage/src/test/java/org/apache/druid/segment/loading/HdfsDataSegmentFinderTest.java b/extensions-core/hdfs-storage/src/test/java/org/apache/druid/segment/loading/HdfsDataSegmentFinderTest.java index a0b7c1894c3..ec8b0ea5c5b 100644 --- a/extensions-core/hdfs-storage/src/test/java/org/apache/druid/segment/loading/HdfsDataSegmentFinderTest.java +++ b/extensions-core/hdfs-storage/src/test/java/org/apache/druid/segment/loading/HdfsDataSegmentFinderTest.java @@ -23,6 +23,8 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.jsontype.NamedType; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; +import org.apache.commons.io.FileUtils; +import org.apache.commons.io.IOUtils; import org.apache.druid.java.util.common.IOE; import org.apache.druid.java.util.common.Intervals; import org.apache.druid.java.util.common.StringUtils; @@ -30,8 +32,6 @@ import org.apache.druid.segment.TestHelper; import org.apache.druid.storage.hdfs.HdfsDataSegmentFinder; import org.apache.druid.timeline.DataSegment; import org.apache.druid.timeline.partition.NumberedShardSpec; -import org.apache.commons.io.FileUtils; -import org.apache.commons.io.IOUtils; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FSDataInputStream; import org.apache.hadoop.fs.FSDataOutputStream; diff --git a/extensions-core/hdfs-storage/src/test/java/org/apache/druid/segment/loading/HdfsFileTimestampVersionFinderTest.java b/extensions-core/hdfs-storage/src/test/java/org/apache/druid/segment/loading/HdfsFileTimestampVersionFinderTest.java index 22203250b32..f9052a566f1 100644 --- a/extensions-core/hdfs-storage/src/test/java/org/apache/druid/segment/loading/HdfsFileTimestampVersionFinderTest.java +++ b/extensions-core/hdfs-storage/src/test/java/org/apache/druid/segment/loading/HdfsFileTimestampVersionFinderTest.java @@ -20,10 +20,10 @@ package org.apache.druid.segment.loading; import com.google.common.io.ByteStreams; +import org.apache.commons.io.FileUtils; import org.apache.druid.java.util.common.IOE; import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.storage.hdfs.HdfsFileTimestampVersionFinder; -import org.apache.commons.io.FileUtils; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.Path; import org.apache.hadoop.hdfs.MiniDFSCluster; diff --git a/extensions-core/hdfs-storage/src/test/java/org/apache/druid/storage/hdfs/HdfsDataSegmentPullerTest.java b/extensions-core/hdfs-storage/src/test/java/org/apache/druid/storage/hdfs/HdfsDataSegmentPullerTest.java index 7dc691fc77c..2924a6d51eb 100644 --- a/extensions-core/hdfs-storage/src/test/java/org/apache/druid/storage/hdfs/HdfsDataSegmentPullerTest.java +++ b/extensions-core/hdfs-storage/src/test/java/org/apache/druid/storage/hdfs/HdfsDataSegmentPullerTest.java @@ -20,11 +20,11 @@ package org.apache.druid.storage.hdfs; import com.google.common.io.ByteStreams; +import org.apache.commons.io.FileUtils; import org.apache.druid.java.util.common.CompressionUtils; import org.apache.druid.java.util.common.IOE; import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.segment.loading.SegmentLoadingException; -import org.apache.commons.io.FileUtils; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.Path; import org.apache.hadoop.hdfs.MiniDFSCluster; diff --git a/extensions-core/histogram/src/main/java/org/apache/druid/query/aggregation/histogram/ApproximateHistogramAggregator.java b/extensions-core/histogram/src/main/java/org/apache/druid/query/aggregation/histogram/ApproximateHistogramAggregator.java index 1e862deac5d..07846ddf6ea 100644 --- a/extensions-core/histogram/src/main/java/org/apache/druid/query/aggregation/histogram/ApproximateHistogramAggregator.java +++ b/extensions-core/histogram/src/main/java/org/apache/druid/query/aggregation/histogram/ApproximateHistogramAggregator.java @@ -19,7 +19,6 @@ package org.apache.druid.query.aggregation.histogram; -import com.google.common.primitives.Longs; import org.apache.druid.common.config.NullHandling; import org.apache.druid.query.aggregation.Aggregator; import org.apache.druid.segment.BaseFloatColumnValueSelector; @@ -28,14 +27,8 @@ import java.util.Comparator; public class ApproximateHistogramAggregator implements Aggregator { - public static final Comparator COMPARATOR = new Comparator() - { - @Override - public int compare(Object o, Object o1) - { - return Longs.compare(((ApproximateHistogram) o).count(), ((ApproximateHistogram) o1).count()); - } - }; + public static final Comparator COMPARATOR = + Comparator.nullsFirst(Comparator.comparingLong(ApproximateHistogram::count)); static ApproximateHistogram combineHistograms(Object lhs, Object rhs) { diff --git a/extensions-core/histogram/src/main/java/org/apache/druid/query/aggregation/histogram/ApproximateHistogramAggregatorFactory.java b/extensions-core/histogram/src/main/java/org/apache/druid/query/aggregation/histogram/ApproximateHistogramAggregatorFactory.java index 919b9b77a01..65c2a862fad 100644 --- a/extensions-core/histogram/src/main/java/org/apache/druid/query/aggregation/histogram/ApproximateHistogramAggregatorFactory.java +++ b/extensions-core/histogram/src/main/java/org/apache/druid/query/aggregation/histogram/ApproximateHistogramAggregatorFactory.java @@ -24,6 +24,7 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonTypeName; import com.google.common.base.Preconditions; +import org.apache.commons.codec.binary.Base64; import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.query.aggregation.AggregateCombiner; import org.apache.druid.query.aggregation.Aggregator; @@ -34,7 +35,6 @@ import org.apache.druid.query.aggregation.BufferAggregator; import org.apache.druid.query.aggregation.ObjectAggregateCombiner; import org.apache.druid.segment.ColumnSelectorFactory; import org.apache.druid.segment.ColumnValueSelector; -import org.apache.commons.codec.binary.Base64; import javax.annotation.Nullable; import java.nio.ByteBuffer; diff --git a/extensions-core/histogram/src/main/java/org/apache/druid/query/aggregation/histogram/ApproximateHistogramFoldingSerde.java b/extensions-core/histogram/src/main/java/org/apache/druid/query/aggregation/histogram/ApproximateHistogramFoldingSerde.java index 198bed8da28..122c7f37ed4 100644 --- a/extensions-core/histogram/src/main/java/org/apache/druid/query/aggregation/histogram/ApproximateHistogramFoldingSerde.java +++ b/extensions-core/histogram/src/main/java/org/apache/druid/query/aggregation/histogram/ApproximateHistogramFoldingSerde.java @@ -19,7 +19,7 @@ package org.apache.druid.query.aggregation.histogram; -import com.google.common.collect.Ordering; +import it.unimi.dsi.fastutil.bytes.ByteArrays; import org.apache.druid.data.input.InputRow; import org.apache.druid.data.input.Rows; import org.apache.druid.segment.GenericColumnSerializer; @@ -37,16 +37,6 @@ import java.util.Collection; public class ApproximateHistogramFoldingSerde extends ComplexMetricSerde { - private static Ordering comparator = new Ordering() - { - @Override - public int compare( - ApproximateHistogram arg1, ApproximateHistogram arg2 - ) - { - return ApproximateHistogramAggregator.COMPARATOR.compare(arg1, arg2); - } - }.nullsFirst(); @Override public String getTypeName() @@ -94,12 +84,11 @@ public class ApproximateHistogramFoldingSerde extends ComplexMetricSerde } @Override - public void deserializeColumn( - ByteBuffer byteBuffer, ColumnBuilder columnBuilder - ) + public void deserializeColumn(ByteBuffer byteBuffer, ColumnBuilder columnBuilder) { - final GenericIndexed column = GenericIndexed.read(byteBuffer, getObjectStrategy(), columnBuilder.getFileMapper()); - columnBuilder.setComplexColumn(new ComplexColumnPartSupplier(getTypeName(), column)); + final GenericIndexed column = + GenericIndexed.read(byteBuffer, getObjectStrategy(), columnBuilder.getFileMapper()); + columnBuilder.setComplexColumnSupplier(new ComplexColumnPartSupplier(getTypeName(), column)); } @Override @@ -109,12 +98,12 @@ public class ApproximateHistogramFoldingSerde extends ComplexMetricSerde } @Override - public ObjectStrategy getObjectStrategy() + public ObjectStrategy getObjectStrategy() { return new ObjectStrategy() { @Override - public Class getClazz() + public Class getClazz() { return ApproximateHistogram.class; } @@ -130,7 +119,7 @@ public class ApproximateHistogramFoldingSerde extends ComplexMetricSerde public byte[] toBytes(ApproximateHistogram h) { if (h == null) { - return new byte[]{}; + return ByteArrays.EMPTY_ARRAY; } return h.toBytes(); } @@ -138,7 +127,7 @@ public class ApproximateHistogramFoldingSerde extends ComplexMetricSerde @Override public int compare(ApproximateHistogram o1, ApproximateHistogram o2) { - return comparator.compare(o1, o2); + return ApproximateHistogramAggregator.COMPARATOR.compare(o1, o2); } }; } diff --git a/extensions-core/histogram/src/main/java/org/apache/druid/query/aggregation/histogram/package-info.java b/extensions-core/histogram/src/main/java/org/apache/druid/query/aggregation/histogram/package-info.java new file mode 100644 index 00000000000..c7670f92e66 --- /dev/null +++ b/extensions-core/histogram/src/main/java/org/apache/druid/query/aggregation/histogram/package-info.java @@ -0,0 +1,23 @@ +/* + * 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. + */ + +@EverythingIsNonnullByDefault +package org.apache.druid.query.aggregation.histogram; + +import org.apache.druid.annotations.EverythingIsNonnullByDefault; diff --git a/extensions-core/histogram/src/main/java/org/apache/druid/query/aggregation/histogram/sql/QuantileSqlAggregator.java b/extensions-core/histogram/src/main/java/org/apache/druid/query/aggregation/histogram/sql/QuantileSqlAggregator.java index 6d4fd2eb470..26ec44d4b26 100644 --- a/extensions-core/histogram/src/main/java/org/apache/druid/query/aggregation/histogram/sql/QuantileSqlAggregator.java +++ b/extensions-core/histogram/src/main/java/org/apache/druid/query/aggregation/histogram/sql/QuantileSqlAggregator.java @@ -20,6 +20,18 @@ package org.apache.druid.query.aggregation.histogram.sql; import com.google.common.collect.ImmutableList; +import org.apache.calcite.rel.core.AggregateCall; +import org.apache.calcite.rel.core.Project; +import org.apache.calcite.rex.RexBuilder; +import org.apache.calcite.rex.RexLiteral; +import org.apache.calcite.rex.RexNode; +import org.apache.calcite.sql.SqlAggFunction; +import org.apache.calcite.sql.SqlFunctionCategory; +import org.apache.calcite.sql.SqlKind; +import org.apache.calcite.sql.type.OperandTypes; +import org.apache.calcite.sql.type.ReturnTypes; +import org.apache.calcite.sql.type.SqlTypeFamily; +import org.apache.calcite.sql.type.SqlTypeName; import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.query.aggregation.AggregatorFactory; import org.apache.druid.query.aggregation.histogram.ApproximateHistogram; @@ -35,18 +47,6 @@ import org.apache.druid.sql.calcite.expression.DruidExpression; import org.apache.druid.sql.calcite.expression.Expressions; import org.apache.druid.sql.calcite.planner.PlannerContext; import org.apache.druid.sql.calcite.table.RowSignature; -import org.apache.calcite.rel.core.AggregateCall; -import org.apache.calcite.rel.core.Project; -import org.apache.calcite.rex.RexBuilder; -import org.apache.calcite.rex.RexLiteral; -import org.apache.calcite.rex.RexNode; -import org.apache.calcite.sql.SqlAggFunction; -import org.apache.calcite.sql.SqlFunctionCategory; -import org.apache.calcite.sql.SqlKind; -import org.apache.calcite.sql.type.OperandTypes; -import org.apache.calcite.sql.type.ReturnTypes; -import org.apache.calcite.sql.type.SqlTypeFamily; -import org.apache.calcite.sql.type.SqlTypeName; import javax.annotation.Nullable; import java.util.ArrayList; diff --git a/extensions-core/kafka-eight/src/main/java/org/apache/druid/firehose/kafka/KafkaEightFirehoseFactory.java b/extensions-core/kafka-eight/src/main/java/org/apache/druid/firehose/kafka/KafkaEightFirehoseFactory.java index 7f5e0e5f5b1..0d0ed5863dd 100644 --- a/extensions-core/kafka-eight/src/main/java/org/apache/druid/firehose/kafka/KafkaEightFirehoseFactory.java +++ b/extensions-core/kafka-eight/src/main/java/org/apache/druid/firehose/kafka/KafkaEightFirehoseFactory.java @@ -24,17 +24,17 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Sets; -import org.apache.druid.data.input.Firehose; -import org.apache.druid.data.input.FirehoseFactory; -import org.apache.druid.data.input.InputRow; -import org.apache.druid.data.input.impl.InputRowParser; -import org.apache.druid.java.util.common.logger.Logger; import kafka.consumer.Consumer; import kafka.consumer.ConsumerConfig; import kafka.consumer.ConsumerIterator; import kafka.consumer.KafkaStream; import kafka.javaapi.consumer.ConsumerConnector; import kafka.message.InvalidMessageException; +import org.apache.druid.data.input.Firehose; +import org.apache.druid.data.input.FirehoseFactory; +import org.apache.druid.data.input.InputRow; +import org.apache.druid.data.input.impl.InputRowParser; +import org.apache.druid.java.util.common.logger.Logger; import javax.annotation.Nullable; import java.io.File; diff --git a/extensions-core/kafka-extraction-namespace/src/main/java/org/apache/druid/query/lookup/KafkaLookupExtractorFactory.java b/extensions-core/kafka-extraction-namespace/src/main/java/org/apache/druid/query/lookup/KafkaLookupExtractorFactory.java index 63b3860e8f6..530e6e7d2f8 100644 --- a/extensions-core/kafka-extraction-namespace/src/main/java/org/apache/druid/query/lookup/KafkaLookupExtractorFactory.java +++ b/extensions-core/kafka-extraction-namespace/src/main/java/org/apache/druid/query/lookup/KafkaLookupExtractorFactory.java @@ -30,6 +30,13 @@ import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListeningExecutorService; import com.google.common.util.concurrent.MoreExecutors; +import kafka.consumer.ConsumerConfig; +import kafka.consumer.KafkaStream; +import kafka.consumer.Whitelist; +import kafka.javaapi.consumer.ConsumerConnector; +import kafka.javaapi.consumer.ZookeeperConsumerConnector; +import kafka.message.MessageAndMetadata; +import kafka.serializer.Decoder; import org.apache.druid.java.util.common.IAE; import org.apache.druid.java.util.common.ISE; import org.apache.druid.java.util.common.StringUtils; @@ -38,13 +45,6 @@ import org.apache.druid.java.util.common.logger.Logger; import org.apache.druid.query.extraction.MapLookupExtractor; import org.apache.druid.server.lookup.namespace.cache.CacheHandler; import org.apache.druid.server.lookup.namespace.cache.NamespaceExtractionCacheManager; -import kafka.consumer.ConsumerConfig; -import kafka.consumer.KafkaStream; -import kafka.consumer.Whitelist; -import kafka.javaapi.consumer.ConsumerConnector; -import kafka.javaapi.consumer.ZookeeperConsumerConnector; -import kafka.message.MessageAndMetadata; -import kafka.serializer.Decoder; import javax.annotation.Nullable; import javax.validation.constraints.Min; diff --git a/extensions-core/kafka-extraction-namespace/src/test/java/org/apache/druid/query/lookup/KafkaLookupExtractorFactoryTest.java b/extensions-core/kafka-extraction-namespace/src/test/java/org/apache/druid/query/lookup/KafkaLookupExtractorFactoryTest.java index a5d1dd20511..23077290944 100644 --- a/extensions-core/kafka-extraction-namespace/src/test/java/org/apache/druid/query/lookup/KafkaLookupExtractorFactoryTest.java +++ b/extensions-core/kafka-extraction-namespace/src/test/java/org/apache/druid/query/lookup/KafkaLookupExtractorFactoryTest.java @@ -27,14 +27,14 @@ import com.google.common.base.Throwables; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.primitives.Bytes; -import org.apache.druid.jackson.DefaultObjectMapper; -import org.apache.druid.java.util.common.StringUtils; -import org.apache.druid.server.lookup.namespace.cache.CacheHandler; -import org.apache.druid.server.lookup.namespace.cache.NamespaceExtractionCacheManager; import kafka.consumer.ConsumerIterator; import kafka.consumer.KafkaStream; import kafka.consumer.TopicFilter; import kafka.javaapi.consumer.ConsumerConnector; +import org.apache.druid.jackson.DefaultObjectMapper; +import org.apache.druid.java.util.common.StringUtils; +import org.apache.druid.server.lookup.namespace.cache.CacheHandler; +import org.apache.druid.server.lookup.namespace.cache.NamespaceExtractionCacheManager; import org.easymock.EasyMock; import org.easymock.IAnswer; import org.junit.Assert; diff --git a/extensions-core/kafka-extraction-namespace/src/test/java/org/apache/druid/query/lookup/TestKafkaExtractionCluster.java b/extensions-core/kafka-extraction-namespace/src/test/java/org/apache/druid/query/lookup/TestKafkaExtractionCluster.java index 4569c5c9a44..8e27958f8c9 100644 --- a/extensions-core/kafka-extraction-namespace/src/test/java/org/apache/druid/query/lookup/TestKafkaExtractionCluster.java +++ b/extensions-core/kafka-extraction-namespace/src/test/java/org/apache/druid/query/lookup/TestKafkaExtractionCluster.java @@ -26,14 +26,6 @@ import com.google.inject.Binder; import com.google.inject.Injector; import com.google.inject.Module; import com.google.inject.name.Names; -import org.apache.druid.guice.GuiceInjectors; -import org.apache.druid.initialization.Initialization; -import org.apache.druid.java.util.common.DateTimes; -import org.apache.druid.java.util.common.ISE; -import org.apache.druid.java.util.common.StringUtils; -import org.apache.druid.java.util.common.io.Closer; -import org.apache.druid.java.util.common.logger.Logger; -import org.apache.druid.server.lookup.namespace.NamespaceExtractionModule; import kafka.admin.AdminUtils; import kafka.javaapi.producer.Producer; import kafka.producer.KeyedMessage; @@ -45,6 +37,14 @@ import kafka.utils.ZKStringSerializer$; import org.I0Itec.zkclient.ZkClient; import org.I0Itec.zkclient.exception.ZkException; import org.apache.curator.test.TestingServer; +import org.apache.druid.guice.GuiceInjectors; +import org.apache.druid.initialization.Initialization; +import org.apache.druid.java.util.common.DateTimes; +import org.apache.druid.java.util.common.ISE; +import org.apache.druid.java.util.common.StringUtils; +import org.apache.druid.java.util.common.io.Closer; +import org.apache.druid.java.util.common.logger.Logger; +import org.apache.druid.server.lookup.namespace.NamespaceExtractionModule; import org.apache.zookeeper.CreateMode; import org.junit.After; import org.junit.Assert; diff --git a/extensions-core/kafka-indexing-service/src/main/java/org/apache/druid/indexing/kafka/KafkaDataSourceMetadata.java b/extensions-core/kafka-indexing-service/src/main/java/org/apache/druid/indexing/kafka/KafkaDataSourceMetadata.java index 5bd2d5bc36e..3e5bec6d953 100644 --- a/extensions-core/kafka-indexing-service/src/main/java/org/apache/druid/indexing/kafka/KafkaDataSourceMetadata.java +++ b/extensions-core/kafka-indexing-service/src/main/java/org/apache/druid/indexing/kafka/KafkaDataSourceMetadata.java @@ -22,7 +22,6 @@ package org.apache.druid.indexing.kafka; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.google.common.collect.Maps; - import org.apache.druid.indexing.overlord.DataSourceMetadata; import org.apache.druid.java.util.common.IAE; diff --git a/extensions-core/kafka-indexing-service/src/main/java/org/apache/druid/indexing/kafka/supervisor/KafkaSupervisorTuningConfig.java b/extensions-core/kafka-indexing-service/src/main/java/org/apache/druid/indexing/kafka/supervisor/KafkaSupervisorTuningConfig.java index 3416941df78..4715f336f75 100644 --- a/extensions-core/kafka-indexing-service/src/main/java/org/apache/druid/indexing/kafka/supervisor/KafkaSupervisorTuningConfig.java +++ b/extensions-core/kafka-indexing-service/src/main/java/org/apache/druid/indexing/kafka/supervisor/KafkaSupervisorTuningConfig.java @@ -21,9 +21,9 @@ package org.apache.druid.indexing.kafka.supervisor; import com.fasterxml.jackson.annotation.JsonProperty; import org.apache.druid.indexing.kafka.KafkaTuningConfig; +import org.apache.druid.segment.IndexSpec; import org.apache.druid.segment.indexing.TuningConfigs; import org.apache.druid.segment.writeout.SegmentWriteOutMediumFactory; -import org.apache.druid.segment.IndexSpec; import org.joda.time.Duration; import org.joda.time.Period; diff --git a/extensions-core/kafka-indexing-service/src/test/java/org/apache/druid/indexing/kafka/KafkaIndexTaskTest.java b/extensions-core/kafka-indexing-service/src/test/java/org/apache/druid/indexing/kafka/KafkaIndexTaskTest.java index fa7605925fa..cd44d68b700 100644 --- a/extensions-core/kafka-indexing-service/src/test/java/org/apache/druid/indexing/kafka/KafkaIndexTaskTest.java +++ b/extensions-core/kafka-indexing-service/src/test/java/org/apache/druid/indexing/kafka/KafkaIndexTaskTest.java @@ -36,6 +36,7 @@ import com.google.common.io.Files; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListeningExecutorService; import com.google.common.util.concurrent.MoreExecutors; +import org.apache.curator.test.TestingCluster; import org.apache.druid.client.cache.CacheConfig; import org.apache.druid.client.cache.CachePopulatorStats; import org.apache.druid.client.cache.MapCache; @@ -139,7 +140,6 @@ import org.apache.druid.server.DruidNode; import org.apache.druid.server.coordination.DataSegmentServerAnnouncer; import org.apache.druid.server.coordination.ServerType; import org.apache.druid.timeline.DataSegment; -import org.apache.curator.test.TestingCluster; import org.apache.kafka.clients.producer.KafkaProducer; import org.apache.kafka.clients.producer.ProducerRecord; import org.easymock.EasyMock; @@ -2332,7 +2332,7 @@ public class KafkaIndexTaskTest ); IndexIO indexIO = new TestUtils().getTestIndexIO(); QueryableIndex index = indexIO.loadIndex(outputLocation); - DictionaryEncodedColumn theColumn = index.getColumn(column).getDictionaryEncoding(); + DictionaryEncodedColumn theColumn = (DictionaryEncodedColumn) index.getColumnHolder(column).getColumn(); List values = Lists.newArrayList(); for (int i = 0; i < theColumn.length(); i++) { int id = theColumn.getSingleValueRow(i); diff --git a/extensions-core/kafka-indexing-service/src/test/java/org/apache/druid/indexing/kafka/supervisor/KafkaSupervisorTest.java b/extensions-core/kafka-indexing-service/src/test/java/org/apache/druid/indexing/kafka/supervisor/KafkaSupervisorTest.java index 978de2f6886..937d4f9872b 100644 --- a/extensions-core/kafka-indexing-service/src/test/java/org/apache/druid/indexing/kafka/supervisor/KafkaSupervisorTest.java +++ b/extensions-core/kafka-indexing-service/src/test/java/org/apache/druid/indexing/kafka/supervisor/KafkaSupervisorTest.java @@ -26,6 +26,7 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; +import org.apache.curator.test.TestingCluster; import org.apache.druid.data.input.impl.DimensionSchema; import org.apache.druid.data.input.impl.DimensionsSpec; import org.apache.druid.data.input.impl.JSONParseSpec; @@ -72,7 +73,6 @@ import org.apache.druid.segment.realtime.FireDepartment; import org.apache.druid.server.metrics.DruidMonitorSchedulerConfig; import org.apache.druid.server.metrics.ExceptionCapturingServiceEmitter; import org.apache.druid.server.metrics.NoopServiceEmitter; -import org.apache.curator.test.TestingCluster; import org.apache.kafka.clients.producer.KafkaProducer; import org.apache.kafka.clients.producer.ProducerRecord; import org.easymock.Capture; @@ -2080,9 +2080,9 @@ public class KafkaSupervisorTest extends EasyMockSupport expect(taskStorage.getTask("id1")).andReturn(Optional.of(id1)).anyTimes(); expect(taskStorage.getTask("id2")).andReturn(Optional.of(id2)).anyTimes(); expect(taskStorage.getTask("id3")).andReturn(Optional.of(id3)).anyTimes(); - expect( - indexerMetadataStorageCoordinator.getDataSourceMetadata(DATASOURCE)).andReturn(new KafkaDataSourceMetadata(null) - ).anyTimes(); + expect(indexerMetadataStorageCoordinator.getDataSourceMetadata(DATASOURCE)) + .andReturn(new KafkaDataSourceMetadata(null)) + .anyTimes(); expect(taskClient.getStatusAsync("id1")).andReturn(Futures.immediateFuture(KafkaIndexTask.Status.READING)); expect(taskClient.getStatusAsync("id2")).andReturn(Futures.immediateFuture(KafkaIndexTask.Status.READING)); expect(taskClient.getStatusAsync("id3")).andReturn(Futures.immediateFuture(KafkaIndexTask.Status.READING)); diff --git a/extensions-core/kafka-indexing-service/src/test/java/org/apache/druid/indexing/kafka/test/TestBroker.java b/extensions-core/kafka-indexing-service/src/test/java/org/apache/druid/indexing/kafka/test/TestBroker.java index 701d69c3ddc..561276e6ed3 100644 --- a/extensions-core/kafka-indexing-service/src/test/java/org/apache/druid/indexing/kafka/test/TestBroker.java +++ b/extensions-core/kafka-indexing-service/src/test/java/org/apache/druid/indexing/kafka/test/TestBroker.java @@ -22,10 +22,10 @@ package org.apache.druid.indexing.kafka.test; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Maps; import com.google.common.io.Files; -import org.apache.druid.java.util.common.StringUtils; import kafka.server.KafkaConfig; import kafka.server.KafkaServer; import org.apache.commons.io.FileUtils; +import org.apache.druid.java.util.common.StringUtils; import org.apache.kafka.clients.consumer.KafkaConsumer; import org.apache.kafka.clients.producer.KafkaProducer; import org.apache.kafka.common.serialization.ByteArrayDeserializer; diff --git a/extensions-core/lookups-cached-global/src/main/java/org/apache/druid/query/lookup/NamespaceLookupExtractorFactory.java b/extensions-core/lookups-cached-global/src/main/java/org/apache/druid/query/lookup/NamespaceLookupExtractorFactory.java index a9fa5b16631..5efe002e1e7 100644 --- a/extensions-core/lookups-cached-global/src/main/java/org/apache/druid/query/lookup/NamespaceLookupExtractorFactory.java +++ b/extensions-core/lookups-cached-global/src/main/java/org/apache/druid/query/lookup/NamespaceLookupExtractorFactory.java @@ -26,7 +26,6 @@ import com.fasterxml.jackson.annotation.JsonTypeName; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Preconditions; import com.google.common.base.Throwables; - import org.apache.druid.java.util.common.ISE; import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.java.util.common.logger.Logger; diff --git a/extensions-core/lookups-cached-global/src/main/java/org/apache/druid/query/lookup/NamespaceLookupIntrospectHandler.java b/extensions-core/lookups-cached-global/src/main/java/org/apache/druid/query/lookup/NamespaceLookupIntrospectHandler.java index 63732bfc991..7508f16b674 100644 --- a/extensions-core/lookups-cached-global/src/main/java/org/apache/druid/query/lookup/NamespaceLookupIntrospectHandler.java +++ b/extensions-core/lookups-cached-global/src/main/java/org/apache/druid/query/lookup/NamespaceLookupIntrospectHandler.java @@ -20,7 +20,6 @@ package org.apache.druid.query.lookup; import com.google.common.collect.ImmutableMap; - import org.apache.druid.common.utils.ServletResourceUtils; import org.apache.druid.java.util.common.ISE; import org.apache.druid.query.extraction.MapLookupExtractor; diff --git a/extensions-core/lookups-cached-global/src/main/java/org/apache/druid/query/lookup/namespace/UriExtractionNamespace.java b/extensions-core/lookups-cached-global/src/main/java/org/apache/druid/query/lookup/namespace/UriExtractionNamespace.java index ab577ee4aec..2ed771959d5 100644 --- a/extensions-core/lookups-cached-global/src/main/java/org/apache/druid/query/lookup/namespace/UriExtractionNamespace.java +++ b/extensions-core/lookups-cached-global/src/main/java/org/apache/druid/query/lookup/namespace/UriExtractionNamespace.java @@ -416,13 +416,13 @@ public class UriExtractionNamespace implements ExtractionNamespace columns.contains(this.keyColumn), "Column [%s] not found int columns: %s", this.keyColumn, - Arrays.toString(columns.toArray()) + columns ); Preconditions.checkArgument( columns.contains(this.valueColumn), "Column [%s] not found int columns: %s", this.valueColumn, - Arrays.toString(columns.toArray()) + columns ); this.parser = new DelegateParser(delegate, this.keyColumn, this.valueColumn); diff --git a/extensions-core/lookups-cached-global/src/main/java/org/apache/druid/server/lookup/namespace/cache/CacheScheduler.java b/extensions-core/lookups-cached-global/src/main/java/org/apache/druid/server/lookup/namespace/cache/CacheScheduler.java index c0accb65391..658cd2ce105 100644 --- a/extensions-core/lookups-cached-global/src/main/java/org/apache/druid/server/lookup/namespace/cache/CacheScheduler.java +++ b/extensions-core/lookups-cached-global/src/main/java/org/apache/druid/server/lookup/namespace/cache/CacheScheduler.java @@ -23,12 +23,12 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Throwables; import com.google.inject.Inject; import org.apache.druid.concurrent.ConcurrentAwaitableCounter; -import org.apache.druid.java.util.emitter.service.ServiceEmitter; -import org.apache.druid.java.util.emitter.service.ServiceMetricEvent; import org.apache.druid.guice.LazySingleton; import org.apache.druid.java.util.common.ISE; import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.java.util.common.logger.Logger; +import org.apache.druid.java.util.emitter.service.ServiceEmitter; +import org.apache.druid.java.util.emitter.service.ServiceMetricEvent; import org.apache.druid.query.lookup.namespace.CacheGenerator; import org.apache.druid.query.lookup.namespace.ExtractionNamespace; import sun.misc.Cleaner; diff --git a/extensions-core/lookups-cached-global/src/main/java/org/apache/druid/server/lookup/namespace/cache/NamespaceExtractionCacheManager.java b/extensions-core/lookups-cached-global/src/main/java/org/apache/druid/server/lookup/namespace/cache/NamespaceExtractionCacheManager.java index 69ea89c05cd..7f3f7751a55 100644 --- a/extensions-core/lookups-cached-global/src/main/java/org/apache/druid/server/lookup/namespace/cache/NamespaceExtractionCacheManager.java +++ b/extensions-core/lookups-cached-global/src/main/java/org/apache/druid/server/lookup/namespace/cache/NamespaceExtractionCacheManager.java @@ -22,10 +22,10 @@ package org.apache.druid.server.lookup.namespace.cache; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Throwables; import com.google.common.util.concurrent.ThreadFactoryBuilder; -import org.apache.druid.java.util.emitter.service.ServiceEmitter; import org.apache.druid.java.util.common.concurrent.ExecutorServices; import org.apache.druid.java.util.common.lifecycle.Lifecycle; import org.apache.druid.java.util.common.logger.Logger; +import org.apache.druid.java.util.emitter.service.ServiceEmitter; import org.apache.druid.server.lookup.namespace.NamespaceExtractionConfig; import java.util.concurrent.ScheduledThreadPoolExecutor; diff --git a/extensions-core/lookups-cached-single/src/main/java/org/apache/druid/server/lookup/LoadingLookupFactory.java b/extensions-core/lookups-cached-single/src/main/java/org/apache/druid/server/lookup/LoadingLookupFactory.java index 5f85cec42ee..2e31faaff93 100644 --- a/extensions-core/lookups-cached-single/src/main/java/org/apache/druid/server/lookup/LoadingLookupFactory.java +++ b/extensions-core/lookups-cached-single/src/main/java/org/apache/druid/server/lookup/LoadingLookupFactory.java @@ -22,7 +22,6 @@ package org.apache.druid.server.lookup; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonTypeName; import com.google.common.base.Preconditions; - import org.apache.druid.java.util.common.logger.Logger; import org.apache.druid.query.lookup.LookupExtractorFactory; import org.apache.druid.query.lookup.LookupIntrospectHandler; diff --git a/extensions-core/lookups-cached-single/src/main/java/org/apache/druid/server/lookup/LookupExtractionModule.java b/extensions-core/lookups-cached-single/src/main/java/org/apache/druid/server/lookup/LookupExtractionModule.java index 2aa5b1fed5f..1dc4f85f9f1 100644 --- a/extensions-core/lookups-cached-single/src/main/java/org/apache/druid/server/lookup/LookupExtractionModule.java +++ b/extensions-core/lookups-cached-single/src/main/java/org/apache/druid/server/lookup/LookupExtractionModule.java @@ -23,7 +23,6 @@ import com.fasterxml.jackson.databind.Module; import com.fasterxml.jackson.databind.module.SimpleModule; import com.google.common.collect.ImmutableList; import com.google.inject.Binder; - import org.apache.druid.initialization.DruidModule; import org.apache.druid.java.util.common.StringUtils; diff --git a/extensions-core/lookups-cached-single/src/main/java/org/apache/druid/server/lookup/PollingLookup.java b/extensions-core/lookups-cached-single/src/main/java/org/apache/druid/server/lookup/PollingLookup.java index 35e9c3cb3cb..d768c7486ca 100644 --- a/extensions-core/lookups-cached-single/src/main/java/org/apache/druid/server/lookup/PollingLookup.java +++ b/extensions-core/lookups-cached-single/src/main/java/org/apache/druid/server/lookup/PollingLookup.java @@ -23,10 +23,9 @@ import com.google.common.base.Preconditions; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListeningScheduledExecutorService; import com.google.common.util.concurrent.MoreExecutors; - import org.apache.druid.common.config.NullHandling; -import org.apache.druid.java.util.common.concurrent.Execs; import org.apache.druid.java.util.common.ISE; +import org.apache.druid.java.util.common.concurrent.Execs; import org.apache.druid.java.util.common.logger.Logger; import org.apache.druid.query.lookup.LookupExtractor; import org.apache.druid.server.lookup.cache.polling.OnHeapPollingCache; diff --git a/extensions-core/lookups-cached-single/src/main/java/org/apache/druid/server/lookup/cache/loading/OnHeapLoadingCache.java b/extensions-core/lookups-cached-single/src/main/java/org/apache/druid/server/lookup/cache/loading/OnHeapLoadingCache.java index 016e57d3ad4..6298fc78052 100644 --- a/extensions-core/lookups-cached-single/src/main/java/org/apache/druid/server/lookup/cache/loading/OnHeapLoadingCache.java +++ b/extensions-core/lookups-cached-single/src/main/java/org/apache/druid/server/lookup/cache/loading/OnHeapLoadingCache.java @@ -24,7 +24,6 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; - import org.apache.druid.java.util.common.logger.Logger; import java.util.Map; diff --git a/extensions-core/lookups-cached-single/src/main/java/org/apache/druid/server/lookup/jdbc/JdbcDataFetcher.java b/extensions-core/lookups-cached-single/src/main/java/org/apache/druid/server/lookup/jdbc/JdbcDataFetcher.java index 58955067c96..e74076b8b94 100644 --- a/extensions-core/lookups-cached-single/src/main/java/org/apache/druid/server/lookup/jdbc/JdbcDataFetcher.java +++ b/extensions-core/lookups-cached-single/src/main/java/org/apache/druid/server/lookup/jdbc/JdbcDataFetcher.java @@ -22,7 +22,6 @@ package org.apache.druid.server.lookup.jdbc; import com.fasterxml.jackson.annotation.JsonProperty; import com.google.common.base.Preconditions; import com.google.common.collect.Lists; - import org.apache.druid.common.config.NullHandling; import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.java.util.common.logger.Logger; diff --git a/extensions-core/lookups-cached-single/src/test/java/org/apache/druid/server/lookup/PollingLookupTest.java b/extensions-core/lookups-cached-single/src/test/java/org/apache/druid/server/lookup/PollingLookupTest.java index 18bb8b75924..c9ab212745f 100644 --- a/extensions-core/lookups-cached-single/src/test/java/org/apache/druid/server/lookup/PollingLookupTest.java +++ b/extensions-core/lookups-cached-single/src/test/java/org/apache/druid/server/lookup/PollingLookupTest.java @@ -24,7 +24,6 @@ import com.google.common.base.Function; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Maps; import com.google.common.collect.Sets; - import org.apache.druid.common.config.NullHandling; import org.apache.druid.java.util.common.ISE; import org.apache.druid.query.lookup.LookupExtractor; diff --git a/extensions-core/mysql-metadata-storage/src/main/java/org/apache/druid/firehose/sql/MySQLFirehoseDatabaseConnector.java b/extensions-core/mysql-metadata-storage/src/main/java/org/apache/druid/firehose/sql/MySQLFirehoseDatabaseConnector.java index 2096d1030b5..581f7ffdf76 100644 --- a/extensions-core/mysql-metadata-storage/src/main/java/org/apache/druid/firehose/sql/MySQLFirehoseDatabaseConnector.java +++ b/extensions-core/mysql-metadata-storage/src/main/java/org/apache/druid/firehose/sql/MySQLFirehoseDatabaseConnector.java @@ -20,9 +20,9 @@ package org.apache.druid.firehose.sql; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonTypeName; +import org.apache.commons.dbcp2.BasicDataSource; import org.apache.druid.metadata.MetadataStorageConnectorConfig; import org.apache.druid.metadata.SQLFirehoseDatabaseConnector; -import org.apache.commons.dbcp2.BasicDataSource; import org.skife.jdbi.v2.DBI; diff --git a/extensions-core/mysql-metadata-storage/src/main/java/org/apache/druid/metadata/storage/mysql/MySQLConnector.java b/extensions-core/mysql-metadata-storage/src/main/java/org/apache/druid/metadata/storage/mysql/MySQLConnector.java index 8c709032caf..8778eb3d37f 100644 --- a/extensions-core/mysql-metadata-storage/src/main/java/org/apache/druid/metadata/storage/mysql/MySQLConnector.java +++ b/extensions-core/mysql-metadata-storage/src/main/java/org/apache/druid/metadata/storage/mysql/MySQLConnector.java @@ -24,13 +24,13 @@ import com.google.common.base.Supplier; import com.google.common.collect.ImmutableList; import com.google.inject.Inject; import com.mysql.jdbc.exceptions.MySQLTransientException; +import org.apache.commons.dbcp2.BasicDataSource; import org.apache.druid.java.util.common.ISE; import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.java.util.common.logger.Logger; import org.apache.druid.metadata.MetadataStorageConnectorConfig; import org.apache.druid.metadata.MetadataStorageTablesConfig; import org.apache.druid.metadata.SQLMetadataConnector; -import org.apache.commons.dbcp2.BasicDataSource; import org.skife.jdbi.v2.DBI; import org.skife.jdbi.v2.Handle; import org.skife.jdbi.v2.tweak.HandleCallback; diff --git a/extensions-core/postgresql-metadata-storage/src/main/java/org/apache/druid/metadata/storage/postgresql/PostgreSQLConnector.java b/extensions-core/postgresql-metadata-storage/src/main/java/org/apache/druid/metadata/storage/postgresql/PostgreSQLConnector.java index 21fcbf59656..52e11ad36c1 100644 --- a/extensions-core/postgresql-metadata-storage/src/main/java/org/apache/druid/metadata/storage/postgresql/PostgreSQLConnector.java +++ b/extensions-core/postgresql-metadata-storage/src/main/java/org/apache/druid/metadata/storage/postgresql/PostgreSQLConnector.java @@ -21,12 +21,12 @@ package org.apache.druid.metadata.storage.postgresql; import com.google.common.base.Supplier; import com.google.inject.Inject; +import org.apache.commons.dbcp2.BasicDataSource; import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.java.util.common.logger.Logger; import org.apache.druid.metadata.MetadataStorageConnectorConfig; import org.apache.druid.metadata.MetadataStorageTablesConfig; import org.apache.druid.metadata.SQLMetadataConnector; -import org.apache.commons.dbcp2.BasicDataSource; import org.postgresql.PGProperty; import org.skife.jdbi.v2.DBI; import org.skife.jdbi.v2.Handle; diff --git a/extensions-core/s3-extensions/src/main/java/org/apache/druid/firehose/s3/StaticS3FirehoseFactory.java b/extensions-core/s3-extensions/src/main/java/org/apache/druid/firehose/s3/StaticS3FirehoseFactory.java index e167abd454a..f3783b37e21 100644 --- a/extensions-core/s3-extensions/src/main/java/org/apache/druid/firehose/s3/StaticS3FirehoseFactory.java +++ b/extensions-core/s3-extensions/src/main/java/org/apache/druid/firehose/s3/StaticS3FirehoseFactory.java @@ -40,8 +40,8 @@ import org.apache.druid.java.util.common.IOE; import org.apache.druid.java.util.common.ISE; import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.java.util.common.logger.Logger; -import org.apache.druid.storage.s3.ServerSideEncryptingAmazonS3; import org.apache.druid.storage.s3.S3Utils; +import org.apache.druid.storage.s3.ServerSideEncryptingAmazonS3; import java.io.IOException; import java.io.InputStream; diff --git a/extensions-core/s3-extensions/src/main/java/org/apache/druid/storage/s3/S3StorageDruidModule.java b/extensions-core/s3-extensions/src/main/java/org/apache/druid/storage/s3/S3StorageDruidModule.java index 543e58b476d..445e906efcd 100644 --- a/extensions-core/s3-extensions/src/main/java/org/apache/druid/storage/s3/S3StorageDruidModule.java +++ b/extensions-core/s3-extensions/src/main/java/org/apache/druid/storage/s3/S3StorageDruidModule.java @@ -31,6 +31,7 @@ import com.google.common.collect.ImmutableList; import com.google.inject.Binder; import com.google.inject.Provides; import com.google.inject.multibindings.MapBinder; +import org.apache.commons.lang.StringUtils; import org.apache.druid.common.aws.AWSClientConfig; import org.apache.druid.common.aws.AWSCredentialsConfig; import org.apache.druid.common.aws.AWSEndpointConfig; @@ -40,7 +41,6 @@ import org.apache.druid.guice.Binders; import org.apache.druid.guice.JsonConfigProvider; import org.apache.druid.guice.LazySingleton; import org.apache.druid.initialization.DruidModule; -import org.apache.commons.lang.StringUtils; import java.util.List; diff --git a/extensions-core/s3-extensions/src/test/java/org/apache/druid/firehose/s3/StaticS3FirehoseFactoryTest.java b/extensions-core/s3-extensions/src/test/java/org/apache/druid/firehose/s3/StaticS3FirehoseFactoryTest.java index cb2b02c84a9..49acd61dcfc 100644 --- a/extensions-core/s3-extensions/src/test/java/org/apache/druid/firehose/s3/StaticS3FirehoseFactoryTest.java +++ b/extensions-core/s3-extensions/src/test/java/org/apache/druid/firehose/s3/StaticS3FirehoseFactoryTest.java @@ -39,10 +39,10 @@ import com.google.inject.Provides; import org.apache.druid.data.input.FiniteFirehoseFactory; import org.apache.druid.data.input.impl.StringInputRowParser; import org.apache.druid.initialization.DruidModule; -import org.apache.druid.storage.s3.S3Utils; -import org.easymock.EasyMock; -import org.apache.druid.storage.s3.ServerSideEncryptingAmazonS3; import org.apache.druid.storage.s3.NoopServerSideEncryption; +import org.apache.druid.storage.s3.S3Utils; +import org.apache.druid.storage.s3.ServerSideEncryptingAmazonS3; +import org.easymock.EasyMock; import org.junit.Assert; import org.junit.Test; diff --git a/extensions-core/s3-extensions/src/test/java/org/apache/druid/storage/s3/S3DataSegmentFinderTest.java b/extensions-core/s3-extensions/src/test/java/org/apache/druid/storage/s3/S3DataSegmentFinderTest.java index 0902a878485..75cb14b361d 100644 --- a/extensions-core/s3-extensions/src/test/java/org/apache/druid/storage/s3/S3DataSegmentFinderTest.java +++ b/extensions-core/s3-extensions/src/test/java/org/apache/druid/storage/s3/S3DataSegmentFinderTest.java @@ -38,6 +38,8 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; import com.google.common.collect.Maps; import com.google.common.collect.Ordering; +import org.apache.commons.io.FileUtils; +import org.apache.commons.io.IOUtils; import org.apache.druid.java.util.common.DateTimes; import org.apache.druid.java.util.common.Intervals; import org.apache.druid.java.util.common.StringUtils; @@ -45,8 +47,6 @@ import org.apache.druid.segment.TestHelper; import org.apache.druid.segment.loading.SegmentLoadingException; import org.apache.druid.timeline.DataSegment; import org.apache.druid.timeline.partition.NumberedShardSpec; -import org.apache.commons.io.FileUtils; -import org.apache.commons.io.IOUtils; import org.junit.Assert; import org.junit.Before; import org.junit.BeforeClass; diff --git a/extensions-core/s3-extensions/src/test/java/org/apache/druid/storage/s3/S3DataSegmentPusherTest.java b/extensions-core/s3-extensions/src/test/java/org/apache/druid/storage/s3/S3DataSegmentPusherTest.java index a4dd9dd94c7..8c38a907822 100644 --- a/extensions-core/s3-extensions/src/test/java/org/apache/druid/storage/s3/S3DataSegmentPusherTest.java +++ b/extensions-core/s3-extensions/src/test/java/org/apache/druid/storage/s3/S3DataSegmentPusherTest.java @@ -30,11 +30,11 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.io.Files; +import org.apache.commons.io.IOUtils; import org.apache.druid.jackson.DefaultObjectMapper; import org.apache.druid.java.util.common.Intervals; import org.apache.druid.timeline.DataSegment; import org.apache.druid.timeline.partition.NoneShardSpec; -import org.apache.commons.io.IOUtils; import org.easymock.Capture; import org.easymock.EasyMock; import org.easymock.IAnswer; diff --git a/extensions-core/stats/src/main/java/org/apache/druid/query/aggregation/teststats/PvaluefromZscorePostAggregator.java b/extensions-core/stats/src/main/java/org/apache/druid/query/aggregation/teststats/PvaluefromZscorePostAggregator.java index 3d65d2327cb..a6b0daf3cd5 100644 --- a/extensions-core/stats/src/main/java/org/apache/druid/query/aggregation/teststats/PvaluefromZscorePostAggregator.java +++ b/extensions-core/stats/src/main/java/org/apache/druid/query/aggregation/teststats/PvaluefromZscorePostAggregator.java @@ -25,13 +25,13 @@ import com.fasterxml.jackson.annotation.JsonTypeName; import com.google.common.base.Preconditions; import com.google.common.collect.Iterables; import com.google.common.collect.Sets; +import org.apache.commons.math3.distribution.NormalDistribution; import org.apache.druid.query.Queries; import org.apache.druid.query.aggregation.AggregatorFactory; import org.apache.druid.query.aggregation.PostAggregator; import org.apache.druid.query.aggregation.post.ArithmeticPostAggregator; import org.apache.druid.query.aggregation.post.PostAggregatorIds; import org.apache.druid.query.cache.CacheKeyBuilder; -import org.apache.commons.math3.distribution.NormalDistribution; import java.util.Collections; import java.util.Comparator; diff --git a/extensions-core/stats/src/main/java/org/apache/druid/query/aggregation/variance/VarianceAggregatorFactory.java b/extensions-core/stats/src/main/java/org/apache/druid/query/aggregation/variance/VarianceAggregatorFactory.java index 167b090d050..d94385b8704 100644 --- a/extensions-core/stats/src/main/java/org/apache/druid/query/aggregation/variance/VarianceAggregatorFactory.java +++ b/extensions-core/stats/src/main/java/org/apache/druid/query/aggregation/variance/VarianceAggregatorFactory.java @@ -23,6 +23,7 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonTypeName; import com.google.common.base.Preconditions; +import org.apache.commons.codec.binary.Base64; import org.apache.druid.java.util.common.IAE; import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.query.aggregation.AggregateCombiner; @@ -38,7 +39,6 @@ import org.apache.druid.query.cache.CacheKeyBuilder; import org.apache.druid.segment.ColumnSelectorFactory; import org.apache.druid.segment.ColumnValueSelector; import org.apache.druid.segment.NilColumnValueSelector; -import org.apache.commons.codec.binary.Base64; import java.nio.ByteBuffer; import java.util.Collections; diff --git a/extensions-core/stats/src/main/java/org/apache/druid/query/aggregation/variance/VarianceSerde.java b/extensions-core/stats/src/main/java/org/apache/druid/query/aggregation/variance/VarianceSerde.java index b24fe5a5773..d14670cc0e4 100644 --- a/extensions-core/stats/src/main/java/org/apache/druid/query/aggregation/variance/VarianceSerde.java +++ b/extensions-core/stats/src/main/java/org/apache/druid/query/aggregation/variance/VarianceSerde.java @@ -21,7 +21,6 @@ package org.apache.druid.query.aggregation.variance; import com.google.common.collect.Ordering; import org.apache.druid.data.input.InputRow; -import org.apache.druid.segment.writeout.SegmentWriteOutMedium; import org.apache.druid.segment.GenericColumnSerializer; import org.apache.druid.segment.column.ColumnBuilder; import org.apache.druid.segment.data.GenericIndexed; @@ -30,6 +29,7 @@ import org.apache.druid.segment.serde.ComplexColumnPartSupplier; import org.apache.druid.segment.serde.ComplexMetricExtractor; import org.apache.druid.segment.serde.ComplexMetricSerde; import org.apache.druid.segment.serde.LargeColumnSupportedComplexColumnSerializer; +import org.apache.druid.segment.writeout.SegmentWriteOutMedium; import java.nio.ByteBuffer; import java.util.List; @@ -81,12 +81,10 @@ public class VarianceSerde extends ComplexMetricSerde } @Override - public void deserializeColumn( - ByteBuffer byteBuffer, ColumnBuilder columnBuilder - ) + public void deserializeColumn(ByteBuffer byteBuffer, ColumnBuilder columnBuilder) { final GenericIndexed column = GenericIndexed.read(byteBuffer, getObjectStrategy(), columnBuilder.getFileMapper()); - columnBuilder.setComplexColumn(new ComplexColumnPartSupplier(getTypeName(), column)); + columnBuilder.setComplexColumnSupplier(new ComplexColumnPartSupplier(getTypeName(), column)); } @Override @@ -95,7 +93,7 @@ public class VarianceSerde extends ComplexMetricSerde return new ObjectStrategy() { @Override - public Class getClazz() + public Class getClazz() { return VarianceAggregatorCollector.class; } diff --git a/extensions-core/stats/src/main/java/org/apache/druid/query/aggregation/variance/package-info.java b/extensions-core/stats/src/main/java/org/apache/druid/query/aggregation/variance/package-info.java new file mode 100644 index 00000000000..d60a1c1c4d2 --- /dev/null +++ b/extensions-core/stats/src/main/java/org/apache/druid/query/aggregation/variance/package-info.java @@ -0,0 +1,23 @@ +/* + * 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. + */ + +@EverythingIsNonnullByDefault +package org.apache.druid.query.aggregation.variance; + +import org.apache.druid.annotations.EverythingIsNonnullByDefault; diff --git a/hll/src/main/java/org/apache/druid/hll/HyperLogLogCollector.java b/hll/src/main/java/org/apache/druid/hll/HyperLogLogCollector.java index 51a7649408d..bc8dbbbebe6 100644 --- a/hll/src/main/java/org/apache/druid/hll/HyperLogLogCollector.java +++ b/hll/src/main/java/org/apache/druid/hll/HyperLogLogCollector.java @@ -93,7 +93,7 @@ public abstract class HyperLogLogCollector implements Comparable dimList = row.getDimensions(); WritableUtils.writeVInt(out, dimList.size()); - if (dimList != null) { - for (String dim : dimList) { - IndexSerdeTypeHelper typeHelper = typeHelperMap.get(dim); - if (typeHelper == null) { - typeHelper = STRING_HELPER; - } - writeString(dim, out); + for (String dim : dimList) { + IndexSerdeTypeHelper typeHelper = typeHelperMap.get(dim); + if (typeHelper == null) { + typeHelper = STRING_HELPER; + } + writeString(dim, out); - try { - typeHelper.serialize(out, row.getRaw(dim)); - } - catch (ParseException pe) { - parseExceptionMessages.add(pe.getMessage()); - } + try { + typeHelper.serialize(out, row.getRaw(dim)); + } + catch (ParseException pe) { + parseExceptionMessages.add(pe.getMessage()); } } @@ -315,12 +312,7 @@ public class InputRowSerde writeString(k, out); try (Aggregator agg = aggFactory.factorize( - IncrementalIndex.makeColumnSelectorFactory( - VirtualColumns.EMPTY, - aggFactory, - supplier, - true - ) + IncrementalIndex.makeColumnSelectorFactory(VirtualColumns.EMPTY, aggFactory, supplier, true) )) { try { agg.aggregate(); diff --git a/indexing-hadoop/src/main/java/org/apache/druid/indexer/Utils.java b/indexing-hadoop/src/main/java/org/apache/druid/indexer/Utils.java index 1a2ce04ca19..2baa371c840 100644 --- a/indexing-hadoop/src/main/java/org/apache/druid/indexer/Utils.java +++ b/indexing-hadoop/src/main/java/org/apache/druid/indexer/Utils.java @@ -22,9 +22,8 @@ package org.apache.druid.indexer; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.collect.Maps; import org.apache.druid.jackson.DefaultObjectMapper; -import org.apache.druid.java.util.common.jackson.JacksonUtils; import org.apache.druid.java.util.common.ISE; - +import org.apache.druid.java.util.common.jackson.JacksonUtils; import org.apache.druid.java.util.common.logger.Logger; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; diff --git a/indexing-hadoop/src/main/java/org/apache/druid/indexer/hadoop/DatasourceRecordReader.java b/indexing-hadoop/src/main/java/org/apache/druid/indexer/hadoop/DatasourceRecordReader.java index 3ec6a71d216..7c001683698 100644 --- a/indexing-hadoop/src/main/java/org/apache/druid/indexer/hadoop/DatasourceRecordReader.java +++ b/indexing-hadoop/src/main/java/org/apache/druid/indexer/hadoop/DatasourceRecordReader.java @@ -25,6 +25,7 @@ import com.google.common.collect.Iterators; import com.google.common.collect.Lists; import com.google.common.io.Closeables; import com.google.common.io.Files; +import org.apache.commons.io.FileUtils; import org.apache.druid.data.input.InputRow; import org.apache.druid.data.input.Row; import org.apache.druid.indexer.HadoopDruidIndexerConfig; @@ -34,7 +35,6 @@ import org.apache.druid.segment.QueryableIndex; import org.apache.druid.segment.QueryableIndexStorageAdapter; import org.apache.druid.segment.realtime.firehose.IngestSegmentFirehose; import org.apache.druid.segment.realtime.firehose.WindowedStorageAdapter; -import org.apache.commons.io.FileUtils; import org.apache.hadoop.fs.Path; import org.apache.hadoop.io.NullWritable; import org.apache.hadoop.mapreduce.InputSplit; diff --git a/indexing-hadoop/src/main/java/org/apache/druid/indexer/path/GranularityPathSpec.java b/indexing-hadoop/src/main/java/org/apache/druid/indexer/path/GranularityPathSpec.java index beb7c7c57ca..3494aba6b07 100644 --- a/indexing-hadoop/src/main/java/org/apache/druid/indexer/path/GranularityPathSpec.java +++ b/indexing-hadoop/src/main/java/org/apache/druid/indexer/path/GranularityPathSpec.java @@ -21,13 +21,11 @@ package org.apache.druid.indexer.path; import com.fasterxml.jackson.annotation.JsonProperty; import com.google.common.collect.Sets; - -import org.apache.druid.java.util.common.granularity.Granularity; import org.apache.druid.indexer.HadoopDruidIndexerConfig; import org.apache.druid.indexer.hadoop.FSSpideringIterator; +import org.apache.druid.java.util.common.granularity.Granularity; import org.apache.druid.java.util.common.guava.Comparators; import org.apache.druid.java.util.common.logger.Logger; - import org.apache.hadoop.fs.FileStatus; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; diff --git a/indexing-hadoop/src/main/java/org/apache/druid/indexer/updater/HadoopConverterJob.java b/indexing-hadoop/src/main/java/org/apache/druid/indexer/updater/HadoopConverterJob.java index c61e4ca0b40..ea6f216b28f 100644 --- a/indexing-hadoop/src/main/java/org/apache/druid/indexer/updater/HadoopConverterJob.java +++ b/indexing-hadoop/src/main/java/org/apache/druid/indexer/updater/HadoopConverterJob.java @@ -28,6 +28,7 @@ import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Sets; import com.google.common.io.Files; +import org.apache.commons.io.FileUtils; import org.apache.druid.indexer.JobHelper; import org.apache.druid.indexer.hadoop.DatasourceInputSplit; import org.apache.druid.indexer.hadoop.WindowedDataSegment; @@ -36,7 +37,6 @@ import org.apache.druid.java.util.common.ISE; import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.java.util.common.logger.Logger; import org.apache.druid.timeline.DataSegment; -import org.apache.commons.io.FileUtils; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.LocatedFileStatus; diff --git a/indexing-hadoop/src/test/java/org/apache/druid/indexer/BatchDeltaIngestionTest.java b/indexing-hadoop/src/test/java/org/apache/druid/indexer/BatchDeltaIngestionTest.java index 70b2abf5df0..bee94fce422 100644 --- a/indexing-hadoop/src/test/java/org/apache/druid/indexer/BatchDeltaIngestionTest.java +++ b/indexing-hadoop/src/test/java/org/apache/druid/indexer/BatchDeltaIngestionTest.java @@ -27,6 +27,7 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; +import org.apache.commons.io.FileUtils; import org.apache.druid.data.input.Firehose; import org.apache.druid.data.input.InputRow; import org.apache.druid.data.input.impl.CSVParseSpec; @@ -55,7 +56,6 @@ import org.apache.druid.segment.realtime.firehose.WindowedStorageAdapter; import org.apache.druid.segment.transform.TransformSpec; import org.apache.druid.timeline.DataSegment; import org.apache.druid.timeline.partition.HashBasedNumberedShardSpec; -import org.apache.commons.io.FileUtils; import org.joda.time.Interval; import org.junit.Assert; import org.junit.Rule; diff --git a/indexing-hadoop/src/test/java/org/apache/druid/indexer/BucketTest.java b/indexing-hadoop/src/test/java/org/apache/druid/indexer/BucketTest.java index 9eedd80f8ad..f20d1392413 100644 --- a/indexing-hadoop/src/test/java/org/apache/druid/indexer/BucketTest.java +++ b/indexing-hadoop/src/test/java/org/apache/druid/indexer/BucketTest.java @@ -20,10 +20,8 @@ package org.apache.druid.indexer; import com.google.common.primitives.Bytes; - import org.apache.druid.java.util.common.DateTimes; import org.apache.druid.java.util.common.Pair; - import org.hamcrest.number.OrderingComparison; import org.joda.time.DateTime; import org.joda.time.chrono.ISOChronology; diff --git a/indexing-hadoop/src/test/java/org/apache/druid/indexer/DeterminePartitionsJobTest.java b/indexing-hadoop/src/test/java/org/apache/druid/indexer/DeterminePartitionsJobTest.java index 320467b5882..72ca8db50c0 100644 --- a/indexing-hadoop/src/test/java/org/apache/druid/indexer/DeterminePartitionsJobTest.java +++ b/indexing-hadoop/src/test/java/org/apache/druid/indexer/DeterminePartitionsJobTest.java @@ -22,6 +22,7 @@ package org.apache.druid.indexer; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.io.Files; +import org.apache.commons.io.FileUtils; import org.apache.druid.data.input.impl.CSVParseSpec; import org.apache.druid.data.input.impl.DimensionsSpec; import org.apache.druid.data.input.impl.StringInputRowParser; @@ -34,7 +35,6 @@ import org.apache.druid.query.aggregation.LongSumAggregatorFactory; import org.apache.druid.segment.indexing.DataSchema; import org.apache.druid.segment.indexing.granularity.UniformGranularitySpec; import org.apache.druid.timeline.partition.SingleDimensionShardSpec; -import org.apache.commons.io.FileUtils; import org.junit.After; import org.junit.Assert; import org.junit.Test; diff --git a/indexing-hadoop/src/test/java/org/apache/druid/indexer/HdfsClasspathSetupTest.java b/indexing-hadoop/src/test/java/org/apache/druid/indexer/HdfsClasspathSetupTest.java index a25b6c95bdd..d304f342c25 100644 --- a/indexing-hadoop/src/test/java/org/apache/druid/indexer/HdfsClasspathSetupTest.java +++ b/indexing-hadoop/src/test/java/org/apache/druid/indexer/HdfsClasspathSetupTest.java @@ -23,12 +23,12 @@ import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListeningExecutorService; import com.google.common.util.concurrent.MoreExecutors; -import org.apache.druid.common.utils.UUIDUtils; -import org.apache.druid.java.util.common.IOE; -import org.apache.druid.java.util.common.StringUtils; import junit.framework.Assert; import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; +import org.apache.druid.common.utils.UUIDUtils; +import org.apache.druid.java.util.common.IOE; +import org.apache.druid.java.util.common.StringUtils; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.Path; import org.apache.hadoop.hdfs.DistributedFileSystem; diff --git a/indexing-hadoop/src/test/java/org/apache/druid/indexer/IndexGeneratorJobTest.java b/indexing-hadoop/src/test/java/org/apache/druid/indexer/IndexGeneratorJobTest.java index 125ce2fde8c..8b079c1bf67 100644 --- a/indexing-hadoop/src/test/java/org/apache/druid/indexer/IndexGeneratorJobTest.java +++ b/indexing-hadoop/src/test/java/org/apache/druid/indexer/IndexGeneratorJobTest.java @@ -25,6 +25,7 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; import com.google.common.collect.Maps; +import org.apache.commons.io.FileUtils; import org.apache.druid.data.input.impl.CSVParseSpec; import org.apache.druid.data.input.impl.DimensionsSpec; import org.apache.druid.data.input.impl.InputRowParser; @@ -46,7 +47,6 @@ import org.apache.druid.timeline.partition.HashBasedNumberedShardSpec; import org.apache.druid.timeline.partition.NumberedShardSpec; import org.apache.druid.timeline.partition.ShardSpec; import org.apache.druid.timeline.partition.SingleDimensionShardSpec; -import org.apache.commons.io.FileUtils; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.LocalFileSystem; diff --git a/indexing-hadoop/src/test/java/org/apache/druid/indexer/UtilsTest.java b/indexing-hadoop/src/test/java/org/apache/druid/indexer/UtilsTest.java index 987b65d7621..6ba39dc1a64 100644 --- a/indexing-hadoop/src/test/java/org/apache/druid/indexer/UtilsTest.java +++ b/indexing-hadoop/src/test/java/org/apache/druid/indexer/UtilsTest.java @@ -22,9 +22,9 @@ package org.apache.druid.indexer; import com.google.common.base.Function; import com.google.common.collect.Maps; import com.google.common.io.ByteStreams; +import org.apache.commons.io.FileUtils; import org.apache.druid.java.util.common.ISE; import org.apache.druid.java.util.common.StringUtils; -import org.apache.commons.io.FileUtils; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; diff --git a/indexing-service/pom.xml b/indexing-service/pom.xml index b77a09a9109..9b0a31b4a5f 100644 --- a/indexing-service/pom.xml +++ b/indexing-service/pom.xml @@ -69,6 +69,13 @@ hadoop-client test + + org.apache.druid + druid-common + ${project.parent.version} + test-jar + test + org.apache.druid druid-processing diff --git a/indexing-service/src/main/java/org/apache/druid/indexing/appenderator/ActionBasedUsedSegmentChecker.java b/indexing-service/src/main/java/org/apache/druid/indexing/appenderator/ActionBasedUsedSegmentChecker.java index 2d725f6d7d1..7af0aab4195 100644 --- a/indexing-service/src/main/java/org/apache/druid/indexing/appenderator/ActionBasedUsedSegmentChecker.java +++ b/indexing-service/src/main/java/org/apache/druid/indexing/appenderator/ActionBasedUsedSegmentChecker.java @@ -23,9 +23,9 @@ import com.google.common.base.Function; import com.google.common.collect.Iterables; import com.google.common.collect.Maps; import com.google.common.collect.Sets; -import org.apache.druid.java.util.common.JodaUtils; import org.apache.druid.indexing.common.actions.SegmentListUsedAction; import org.apache.druid.indexing.common.actions.TaskActionClient; +import org.apache.druid.java.util.common.JodaUtils; import org.apache.druid.segment.realtime.appenderator.SegmentIdentifier; import org.apache.druid.segment.realtime.appenderator.UsedSegmentChecker; import org.apache.druid.timeline.DataSegment; diff --git a/indexing-service/src/main/java/org/apache/druid/indexing/common/TaskReportFileWriter.java b/indexing-service/src/main/java/org/apache/druid/indexing/common/TaskReportFileWriter.java index ce126f49cc2..d9c9e81576e 100644 --- a/indexing-service/src/main/java/org/apache/druid/indexing/common/TaskReportFileWriter.java +++ b/indexing-service/src/main/java/org/apache/druid/indexing/common/TaskReportFileWriter.java @@ -20,8 +20,8 @@ package org.apache.druid.indexing.common; import com.fasterxml.jackson.databind.ObjectMapper; -import org.apache.druid.java.util.common.logger.Logger; import org.apache.commons.io.FileUtils; +import org.apache.druid.java.util.common.logger.Logger; import java.io.File; import java.util.Map; diff --git a/indexing-service/src/main/java/org/apache/druid/indexing/common/TaskToolbox.java b/indexing-service/src/main/java/org/apache/druid/indexing/common/TaskToolbox.java index 0bb96a88525..d4f788aab76 100644 --- a/indexing-service/src/main/java/org/apache/druid/indexing/common/TaskToolbox.java +++ b/indexing-service/src/main/java/org/apache/druid/indexing/common/TaskToolbox.java @@ -27,17 +27,17 @@ import com.google.common.collect.Maps; import com.google.common.collect.Multimap; import com.google.common.collect.Multimaps; import com.google.inject.Provider; -import org.apache.druid.client.cache.CachePopulatorStats; -import org.apache.druid.java.util.emitter.service.ServiceEmitter; -import org.apache.druid.java.util.metrics.MonitorScheduler; import org.apache.druid.client.cache.Cache; import org.apache.druid.client.cache.CacheConfig; +import org.apache.druid.client.cache.CachePopulatorStats; import org.apache.druid.discovery.DataNodeService; import org.apache.druid.discovery.DruidNodeAnnouncer; import org.apache.druid.discovery.LookupNodeService; import org.apache.druid.indexing.common.actions.SegmentInsertAction; import org.apache.druid.indexing.common.actions.TaskActionClient; import org.apache.druid.indexing.common.config.TaskConfig; +import org.apache.druid.java.util.emitter.service.ServiceEmitter; +import org.apache.druid.java.util.metrics.MonitorScheduler; import org.apache.druid.query.QueryRunnerFactoryConglomerate; import org.apache.druid.segment.IndexIO; import org.apache.druid.segment.IndexMergerV9; diff --git a/indexing-service/src/main/java/org/apache/druid/indexing/common/index/YeOldePlumberSchool.java b/indexing-service/src/main/java/org/apache/druid/indexing/common/index/YeOldePlumberSchool.java index 8841cf3833c..ec2029ee2ba 100644 --- a/indexing-service/src/main/java/org/apache/druid/indexing/common/index/YeOldePlumberSchool.java +++ b/indexing-service/src/main/java/org/apache/druid/indexing/common/index/YeOldePlumberSchool.java @@ -30,6 +30,7 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Sets; +import org.apache.commons.io.FileUtils; import org.apache.druid.data.input.Committer; import org.apache.druid.data.input.InputRow; import org.apache.druid.java.util.common.StringUtils; @@ -52,7 +53,6 @@ import org.apache.druid.segment.realtime.plumber.Plumber; import org.apache.druid.segment.realtime.plumber.PlumberSchool; import org.apache.druid.segment.realtime.plumber.Sink; import org.apache.druid.timeline.DataSegment; -import org.apache.commons.io.FileUtils; import org.joda.time.Interval; import java.io.File; diff --git a/indexing-service/src/main/java/org/apache/druid/indexing/common/task/AppenderatorDriverRealtimeIndexTask.java b/indexing-service/src/main/java/org/apache/druid/indexing/common/task/AppenderatorDriverRealtimeIndexTask.java index d06cdb581ab..bc6af54f00a 100644 --- a/indexing-service/src/main/java/org/apache/druid/indexing/common/task/AppenderatorDriverRealtimeIndexTask.java +++ b/indexing-service/src/main/java/org/apache/druid/indexing/common/task/AppenderatorDriverRealtimeIndexTask.java @@ -31,6 +31,7 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.Maps; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; +import org.apache.commons.io.FileUtils; import org.apache.druid.data.input.Committer; import org.apache.druid.data.input.Firehose; import org.apache.druid.data.input.FirehoseFactory; @@ -84,7 +85,6 @@ import org.apache.druid.segment.realtime.plumber.Committers; import org.apache.druid.server.security.Action; import org.apache.druid.server.security.AuthorizerMapper; import org.apache.druid.utils.CircularBuffer; -import org.apache.commons.io.FileUtils; import javax.servlet.http.HttpServletRequest; import javax.ws.rs.GET; diff --git a/indexing-service/src/main/java/org/apache/druid/indexing/common/task/ArchiveTask.java b/indexing-service/src/main/java/org/apache/druid/indexing/common/task/ArchiveTask.java index 1196c7fa484..2d13a5e89cc 100644 --- a/indexing-service/src/main/java/org/apache/druid/indexing/common/task/ArchiveTask.java +++ b/indexing-service/src/main/java/org/apache/druid/indexing/common/task/ArchiveTask.java @@ -22,8 +22,8 @@ package org.apache.druid.indexing.common.task; import com.fasterxml.jackson.annotation.JsonProperty; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; -import org.apache.druid.indexing.common.TaskLock; import org.apache.druid.indexer.TaskStatus; +import org.apache.druid.indexing.common.TaskLock; import org.apache.druid.indexing.common.TaskToolbox; import org.apache.druid.indexing.common.actions.SegmentListUnusedAction; import org.apache.druid.indexing.common.actions.SegmentMetadataUpdateAction; diff --git a/indexing-service/src/main/java/org/apache/druid/indexing/common/task/CompactionTask.java b/indexing-service/src/main/java/org/apache/druid/indexing/common/task/CompactionTask.java index cce1a743757..e577161904b 100644 --- a/indexing-service/src/main/java/org/apache/druid/indexing/common/task/CompactionTask.java +++ b/indexing-service/src/main/java/org/apache/druid/indexing/common/task/CompactionTask.java @@ -61,7 +61,7 @@ import org.apache.druid.query.aggregation.AggregatorFactory; import org.apache.druid.segment.DimensionHandler; import org.apache.druid.segment.IndexIO; import org.apache.druid.segment.QueryableIndex; -import org.apache.druid.segment.column.Column; +import org.apache.druid.segment.column.ColumnHolder; import org.apache.druid.segment.column.ValueType; import org.apache.druid.segment.indexing.DataSchema; import org.apache.druid.segment.indexing.granularity.ArbitraryGranularitySpec; @@ -493,8 +493,8 @@ public class CompactionTask extends AbstractTask final Map dimensionHandlerMap = queryableIndex.getDimensionHandlers(); for (String dimension : queryableIndex.getAvailableDimensions()) { - final Column column = Preconditions.checkNotNull( - queryableIndex.getColumn(dimension), + final ColumnHolder columnHolder = Preconditions.checkNotNull( + queryableIndex.getColumnHolder(dimension), "Cannot find column for dimension[%s]", dimension ); @@ -510,10 +510,10 @@ public class CompactionTask extends AbstractTask dimensionSchemaMap.put( dimension, createDimensionSchema( - column.getCapabilities().getType(), + columnHolder.getCapabilities().getType(), dimension, dimensionHandler.getMultivalueHandling(), - column.getCapabilities().hasBitmapIndexes() + columnHolder.getCapabilities().hasBitmapIndexes() ) ); } diff --git a/indexing-service/src/main/java/org/apache/druid/indexing/common/task/KillTask.java b/indexing-service/src/main/java/org/apache/druid/indexing/common/task/KillTask.java index cb723800d22..a6a781f3e12 100644 --- a/indexing-service/src/main/java/org/apache/druid/indexing/common/task/KillTask.java +++ b/indexing-service/src/main/java/org/apache/druid/indexing/common/task/KillTask.java @@ -23,9 +23,8 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; - -import org.apache.druid.indexing.common.TaskLock; import org.apache.druid.indexer.TaskStatus; +import org.apache.druid.indexing.common.TaskLock; import org.apache.druid.indexing.common.TaskToolbox; import org.apache.druid.indexing.common.actions.SegmentListUnusedAction; import org.apache.druid.indexing.common.actions.SegmentNukeAction; diff --git a/indexing-service/src/main/java/org/apache/druid/indexing/common/task/MergeTask.java b/indexing-service/src/main/java/org/apache/druid/indexing/common/task/MergeTask.java index c57f16f27ee..b8fa9385753 100644 --- a/indexing-service/src/main/java/org/apache/druid/indexing/common/task/MergeTask.java +++ b/indexing-service/src/main/java/org/apache/druid/indexing/common/task/MergeTask.java @@ -28,11 +28,11 @@ import com.google.common.base.Throwables; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; import org.apache.druid.indexing.common.TaskToolbox; -import org.apache.druid.segment.writeout.SegmentWriteOutMediumFactory; import org.apache.druid.query.aggregation.AggregatorFactory; import org.apache.druid.segment.IndexMerger; import org.apache.druid.segment.IndexSpec; import org.apache.druid.segment.QueryableIndex; +import org.apache.druid.segment.writeout.SegmentWriteOutMediumFactory; import org.apache.druid.timeline.DataSegment; import javax.annotation.Nullable; diff --git a/indexing-service/src/main/java/org/apache/druid/indexing/common/task/MoveTask.java b/indexing-service/src/main/java/org/apache/druid/indexing/common/task/MoveTask.java index ccb1dc07253..050ec8b5185 100644 --- a/indexing-service/src/main/java/org/apache/druid/indexing/common/task/MoveTask.java +++ b/indexing-service/src/main/java/org/apache/druid/indexing/common/task/MoveTask.java @@ -23,9 +23,8 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; - -import org.apache.druid.indexing.common.TaskLock; import org.apache.druid.indexer.TaskStatus; +import org.apache.druid.indexing.common.TaskLock; import org.apache.druid.indexing.common.TaskToolbox; import org.apache.druid.indexing.common.actions.SegmentListUnusedAction; import org.apache.druid.indexing.common.actions.SegmentMetadataUpdateAction; diff --git a/indexing-service/src/main/java/org/apache/druid/indexing/common/task/RealtimeIndexTask.java b/indexing-service/src/main/java/org/apache/druid/indexing/common/task/RealtimeIndexTask.java index 1b331f02032..8fb63428b0e 100644 --- a/indexing-service/src/main/java/org/apache/druid/indexing/common/task/RealtimeIndexTask.java +++ b/indexing-service/src/main/java/org/apache/druid/indexing/common/task/RealtimeIndexTask.java @@ -27,6 +27,7 @@ import com.google.common.base.Supplier; import com.google.common.base.Throwables; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; +import org.apache.commons.io.FileUtils; import org.apache.druid.data.input.Committer; import org.apache.druid.data.input.Firehose; import org.apache.druid.data.input.FirehoseFactory; @@ -69,7 +70,6 @@ import org.apache.druid.segment.realtime.plumber.RealtimePlumberSchool; import org.apache.druid.segment.realtime.plumber.VersioningPolicy; import org.apache.druid.server.coordination.DataSegmentAnnouncer; import org.apache.druid.timeline.DataSegment; -import org.apache.commons.io.FileUtils; import org.joda.time.DateTime; import org.joda.time.Interval; diff --git a/indexing-service/src/main/java/org/apache/druid/indexing/common/task/RestoreTask.java b/indexing-service/src/main/java/org/apache/druid/indexing/common/task/RestoreTask.java index 292a309e8a6..bac0152ac1f 100644 --- a/indexing-service/src/main/java/org/apache/druid/indexing/common/task/RestoreTask.java +++ b/indexing-service/src/main/java/org/apache/druid/indexing/common/task/RestoreTask.java @@ -22,8 +22,8 @@ package org.apache.druid.indexing.common.task; import com.fasterxml.jackson.annotation.JsonProperty; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; -import org.apache.druid.indexing.common.TaskLock; import org.apache.druid.indexer.TaskStatus; +import org.apache.druid.indexing.common.TaskLock; import org.apache.druid.indexing.common.TaskToolbox; import org.apache.druid.indexing.common.actions.SegmentListUnusedAction; import org.apache.druid.indexing.common.actions.SegmentMetadataUpdateAction; diff --git a/indexing-service/src/main/java/org/apache/druid/indexing/common/task/SameIntervalMergeTask.java b/indexing-service/src/main/java/org/apache/druid/indexing/common/task/SameIntervalMergeTask.java index f065f3b8be8..e1c0f2bee18 100644 --- a/indexing-service/src/main/java/org/apache/druid/indexing/common/task/SameIntervalMergeTask.java +++ b/indexing-service/src/main/java/org/apache/druid/indexing/common/task/SameIntervalMergeTask.java @@ -26,9 +26,9 @@ import org.apache.druid.indexer.TaskStatus; import org.apache.druid.indexing.common.TaskToolbox; import org.apache.druid.indexing.common.actions.SegmentListUsedAction; import org.apache.druid.java.util.common.DateTimes; -import org.apache.druid.segment.writeout.SegmentWriteOutMediumFactory; import org.apache.druid.query.aggregation.AggregatorFactory; import org.apache.druid.segment.IndexSpec; +import org.apache.druid.segment.writeout.SegmentWriteOutMediumFactory; import org.apache.druid.timeline.DataSegment; import org.joda.time.Interval; diff --git a/indexing-service/src/main/java/org/apache/druid/indexing/common/task/batch/parallel/ParallelIndexSubTask.java b/indexing-service/src/main/java/org/apache/druid/indexing/common/task/batch/parallel/ParallelIndexSubTask.java index 20871afc6d1..dc4d9eb7153 100644 --- a/indexing-service/src/main/java/org/apache/druid/indexing/common/task/batch/parallel/ParallelIndexSubTask.java +++ b/indexing-service/src/main/java/org/apache/druid/indexing/common/task/batch/parallel/ParallelIndexSubTask.java @@ -24,6 +24,7 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.google.common.base.Optional; import com.google.common.base.Preconditions; +import org.apache.commons.io.FileUtils; import org.apache.druid.client.indexing.IndexingServiceClient; import org.apache.druid.data.input.Firehose; import org.apache.druid.data.input.FirehoseFactory; @@ -64,7 +65,6 @@ import org.apache.druid.segment.realtime.appenderator.BatchAppenderatorDriver; import org.apache.druid.segment.realtime.appenderator.SegmentAllocator; import org.apache.druid.segment.realtime.appenderator.SegmentsAndMetadata; import org.apache.druid.timeline.DataSegment; -import org.apache.commons.io.FileUtils; import org.joda.time.Interval; import javax.annotation.Nullable; diff --git a/indexing-service/src/main/java/org/apache/druid/indexing/common/tasklogs/FileTaskLogs.java b/indexing-service/src/main/java/org/apache/druid/indexing/common/tasklogs/FileTaskLogs.java index c690c9a0eba..4365e65fb15 100644 --- a/indexing-service/src/main/java/org/apache/druid/indexing/common/tasklogs/FileTaskLogs.java +++ b/indexing-service/src/main/java/org/apache/druid/indexing/common/tasklogs/FileTaskLogs.java @@ -23,12 +23,12 @@ import com.google.common.base.Optional; import com.google.common.io.ByteSource; import com.google.common.io.Files; import com.google.inject.Inject; +import org.apache.commons.io.FileUtils; import org.apache.druid.indexing.common.config.FileTaskLogsConfig; import org.apache.druid.java.util.common.IOE; import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.java.util.common.logger.Logger; import org.apache.druid.tasklogs.TaskLogs; -import org.apache.commons.io.FileUtils; import java.io.File; import java.io.FileFilter; diff --git a/indexing-service/src/main/java/org/apache/druid/indexing/overlord/ForkingTaskRunner.java b/indexing-service/src/main/java/org/apache/druid/indexing/overlord/ForkingTaskRunner.java index c393c41c673..15fadda42a7 100644 --- a/indexing-service/src/main/java/org/apache/druid/indexing/overlord/ForkingTaskRunner.java +++ b/indexing-service/src/main/java/org/apache/druid/indexing/overlord/ForkingTaskRunner.java @@ -41,6 +41,7 @@ import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListeningExecutorService; import com.google.common.util.concurrent.MoreExecutors; import com.google.inject.Inject; +import org.apache.commons.io.FileUtils; import org.apache.druid.guice.annotations.Self; import org.apache.druid.indexer.RunnerTaskState; import org.apache.druid.indexer.TaskLocation; @@ -65,7 +66,6 @@ import org.apache.druid.server.DruidNode; import org.apache.druid.server.metrics.MonitorsConfig; import org.apache.druid.tasklogs.TaskLogPusher; import org.apache.druid.tasklogs.TaskLogStreamer; -import org.apache.commons.io.FileUtils; import org.joda.time.DateTime; import org.joda.time.Interval; diff --git a/indexing-service/src/main/java/org/apache/druid/indexing/overlord/RemoteTaskRunnerFactory.java b/indexing-service/src/main/java/org/apache/druid/indexing/overlord/RemoteTaskRunnerFactory.java index c0ed65898b2..2efd8a1cfe6 100644 --- a/indexing-service/src/main/java/org/apache/druid/indexing/overlord/RemoteTaskRunnerFactory.java +++ b/indexing-service/src/main/java/org/apache/druid/indexing/overlord/RemoteTaskRunnerFactory.java @@ -22,7 +22,7 @@ package org.apache.druid.indexing.overlord; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.base.Supplier; import com.google.inject.Inject; -import org.apache.druid.java.util.http.client.HttpClient; +import org.apache.curator.framework.CuratorFramework; import org.apache.druid.curator.cache.PathChildrenCacheFactory; import org.apache.druid.guice.annotations.EscalatedGlobal; import org.apache.druid.indexing.overlord.autoscaling.NoopProvisioningStrategy; @@ -30,8 +30,8 @@ import org.apache.druid.indexing.overlord.autoscaling.ProvisioningSchedulerConfi import org.apache.druid.indexing.overlord.autoscaling.ProvisioningStrategy; import org.apache.druid.indexing.overlord.config.RemoteTaskRunnerConfig; import org.apache.druid.indexing.overlord.setup.WorkerBehaviorConfig; +import org.apache.druid.java.util.http.client.HttpClient; import org.apache.druid.server.initialization.IndexerZkConfig; -import org.apache.curator.framework.CuratorFramework; /** */ diff --git a/indexing-service/src/main/java/org/apache/druid/indexing/overlord/TaskStorage.java b/indexing-service/src/main/java/org/apache/druid/indexing/overlord/TaskStorage.java index f716b52a0e3..b2f55f0c9d4 100644 --- a/indexing-service/src/main/java/org/apache/druid/indexing/overlord/TaskStorage.java +++ b/indexing-service/src/main/java/org/apache/druid/indexing/overlord/TaskStorage.java @@ -130,8 +130,6 @@ public interface TaskStorage * Returns a list of currently running or pending tasks as stored in the storage facility as {@link TaskInfo}. No * particular order is guaranteed, but implementations are encouraged to return tasks in ascending order of creation. * - * @param dataSource datasource - * * @return list of {@link TaskInfo} */ List> getActiveTaskInfo(@Nullable String dataSource); diff --git a/indexing-service/src/main/java/org/apache/druid/indexing/overlord/ZkWorker.java b/indexing-service/src/main/java/org/apache/druid/indexing/overlord/ZkWorker.java index 967f0e50e71..2d55e592508 100644 --- a/indexing-service/src/main/java/org/apache/druid/indexing/overlord/ZkWorker.java +++ b/indexing-service/src/main/java/org/apache/druid/indexing/overlord/ZkWorker.java @@ -27,13 +27,13 @@ import com.google.common.base.Throwables; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.Sets; +import org.apache.curator.framework.recipes.cache.ChildData; +import org.apache.curator.framework.recipes.cache.PathChildrenCache; +import org.apache.curator.framework.recipes.cache.PathChildrenCacheListener; import org.apache.druid.annotations.UsedInGeneratedCode; import org.apache.druid.indexing.worker.TaskAnnouncement; import org.apache.druid.indexing.worker.Worker; import org.apache.druid.java.util.common.DateTimes; -import org.apache.curator.framework.recipes.cache.ChildData; -import org.apache.curator.framework.recipes.cache.PathChildrenCache; -import org.apache.curator.framework.recipes.cache.PathChildrenCacheListener; import org.joda.time.DateTime; import java.io.Closeable; diff --git a/indexing-service/src/main/java/org/apache/druid/indexing/overlord/autoscaling/AbstractWorkerProvisioningStrategy.java b/indexing-service/src/main/java/org/apache/druid/indexing/overlord/autoscaling/AbstractWorkerProvisioningStrategy.java index e3197e33069..878fb957119 100644 --- a/indexing-service/src/main/java/org/apache/druid/indexing/overlord/autoscaling/AbstractWorkerProvisioningStrategy.java +++ b/indexing-service/src/main/java/org/apache/druid/indexing/overlord/autoscaling/AbstractWorkerProvisioningStrategy.java @@ -20,10 +20,10 @@ package org.apache.druid.indexing.overlord.autoscaling; import com.google.common.base.Supplier; -import org.apache.druid.java.util.emitter.EmittingLogger; import org.apache.druid.indexing.overlord.WorkerTaskRunner; import org.apache.druid.java.util.common.DateTimes; import org.apache.druid.java.util.common.granularity.PeriodGranularity; +import org.apache.druid.java.util.emitter.EmittingLogger; import org.joda.time.Duration; import org.joda.time.Period; diff --git a/indexing-service/src/main/java/org/apache/druid/indexing/overlord/autoscaling/NoopAutoScaler.java b/indexing-service/src/main/java/org/apache/druid/indexing/overlord/autoscaling/NoopAutoScaler.java index 8b992098f29..457f08bce2c 100644 --- a/indexing-service/src/main/java/org/apache/druid/indexing/overlord/autoscaling/NoopAutoScaler.java +++ b/indexing-service/src/main/java/org/apache/druid/indexing/overlord/autoscaling/NoopAutoScaler.java @@ -19,9 +19,8 @@ package org.apache.druid.indexing.overlord.autoscaling; -import org.apache.druid.java.util.emitter.EmittingLogger; - import org.apache.druid.java.util.common.UOE; +import org.apache.druid.java.util.emitter.EmittingLogger; import java.util.List; diff --git a/indexing-service/src/main/java/org/apache/druid/indexing/overlord/autoscaling/PendingTaskBasedWorkerProvisioningStrategy.java b/indexing-service/src/main/java/org/apache/druid/indexing/overlord/autoscaling/PendingTaskBasedWorkerProvisioningStrategy.java index a0f7e91cfd4..79bf9e99d74 100644 --- a/indexing-service/src/main/java/org/apache/druid/indexing/overlord/autoscaling/PendingTaskBasedWorkerProvisioningStrategy.java +++ b/indexing-service/src/main/java/org/apache/druid/indexing/overlord/autoscaling/PendingTaskBasedWorkerProvisioningStrategy.java @@ -30,8 +30,6 @@ import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.Sets; import com.google.inject.Inject; -import org.apache.druid.java.util.common.concurrent.ScheduledExecutors; -import org.apache.druid.java.util.emitter.EmittingLogger; import org.apache.druid.indexing.common.task.Task; import org.apache.druid.indexing.overlord.ImmutableWorkerInfo; import org.apache.druid.indexing.overlord.WorkerTaskRunner; @@ -41,6 +39,8 @@ import org.apache.druid.indexing.overlord.setup.WorkerBehaviorConfig; import org.apache.druid.indexing.overlord.setup.WorkerSelectStrategy; import org.apache.druid.indexing.worker.Worker; import org.apache.druid.java.util.common.DateTimes; +import org.apache.druid.java.util.common.concurrent.ScheduledExecutors; +import org.apache.druid.java.util.emitter.EmittingLogger; import org.joda.time.DateTime; import org.joda.time.Duration; diff --git a/indexing-service/src/main/java/org/apache/druid/indexing/overlord/autoscaling/ProvisioningUtil.java b/indexing-service/src/main/java/org/apache/druid/indexing/overlord/autoscaling/ProvisioningUtil.java index 399abf46bbe..6eb7e05305c 100644 --- a/indexing-service/src/main/java/org/apache/druid/indexing/overlord/autoscaling/ProvisioningUtil.java +++ b/indexing-service/src/main/java/org/apache/druid/indexing/overlord/autoscaling/ProvisioningUtil.java @@ -20,7 +20,6 @@ package org.apache.druid.indexing.overlord.autoscaling; import com.google.common.base.Predicate; - import org.apache.druid.indexing.overlord.ImmutableWorkerInfo; import org.apache.druid.java.util.common.ISE; diff --git a/indexing-service/src/main/java/org/apache/druid/indexing/overlord/autoscaling/SimpleWorkerProvisioningStrategy.java b/indexing-service/src/main/java/org/apache/druid/indexing/overlord/autoscaling/SimpleWorkerProvisioningStrategy.java index 69079540480..46fc55b5110 100644 --- a/indexing-service/src/main/java/org/apache/druid/indexing/overlord/autoscaling/SimpleWorkerProvisioningStrategy.java +++ b/indexing-service/src/main/java/org/apache/druid/indexing/overlord/autoscaling/SimpleWorkerProvisioningStrategy.java @@ -29,15 +29,15 @@ import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Sets; import com.google.inject.Inject; -import org.apache.druid.java.util.common.concurrent.ScheduledExecutors; -import org.apache.druid.java.util.emitter.EmittingLogger; import org.apache.druid.indexing.overlord.ImmutableWorkerInfo; import org.apache.druid.indexing.overlord.TaskRunnerWorkItem; import org.apache.druid.indexing.overlord.WorkerTaskRunner; -import org.apache.druid.indexing.overlord.setup.WorkerBehaviorConfig; import org.apache.druid.indexing.overlord.setup.DefaultWorkerBehaviorConfig; +import org.apache.druid.indexing.overlord.setup.WorkerBehaviorConfig; import org.apache.druid.indexing.worker.Worker; import org.apache.druid.java.util.common.DateTimes; +import org.apache.druid.java.util.common.concurrent.ScheduledExecutors; +import org.apache.druid.java.util.emitter.EmittingLogger; import org.joda.time.DateTime; import org.joda.time.Duration; diff --git a/indexing-service/src/main/java/org/apache/druid/indexing/overlord/autoscaling/ec2/EC2AutoScaler.java b/indexing-service/src/main/java/org/apache/druid/indexing/overlord/autoscaling/ec2/EC2AutoScaler.java index e69399ac964..175c8705dc3 100644 --- a/indexing-service/src/main/java/org/apache/druid/indexing/overlord/autoscaling/ec2/EC2AutoScaler.java +++ b/indexing-service/src/main/java/org/apache/druid/indexing/overlord/autoscaling/ec2/EC2AutoScaler.java @@ -36,10 +36,10 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.google.common.base.Function; import com.google.common.collect.FluentIterable; import com.google.common.collect.Lists; -import org.apache.druid.java.util.emitter.EmittingLogger; import org.apache.druid.indexing.overlord.autoscaling.AutoScaler; import org.apache.druid.indexing.overlord.autoscaling.AutoScalingData; import org.apache.druid.indexing.overlord.autoscaling.SimpleWorkerProvisioningConfig; +import org.apache.druid.java.util.emitter.EmittingLogger; import java.util.List; diff --git a/indexing-service/src/main/java/org/apache/druid/indexing/overlord/autoscaling/ec2/GalaxyEC2UserData.java b/indexing-service/src/main/java/org/apache/druid/indexing/overlord/autoscaling/ec2/GalaxyEC2UserData.java index a57971b9160..bbb36b23caa 100644 --- a/indexing-service/src/main/java/org/apache/druid/indexing/overlord/autoscaling/ec2/GalaxyEC2UserData.java +++ b/indexing-service/src/main/java/org/apache/druid/indexing/overlord/autoscaling/ec2/GalaxyEC2UserData.java @@ -24,8 +24,8 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.base.Throwables; -import org.apache.druid.guice.annotations.Json; import org.apache.commons.codec.binary.Base64; +import org.apache.druid.guice.annotations.Json; /** */ diff --git a/indexing-service/src/main/java/org/apache/druid/indexing/overlord/autoscaling/ec2/StringEC2UserData.java b/indexing-service/src/main/java/org/apache/druid/indexing/overlord/autoscaling/ec2/StringEC2UserData.java index e1863751375..7896ec81821 100644 --- a/indexing-service/src/main/java/org/apache/druid/indexing/overlord/autoscaling/ec2/StringEC2UserData.java +++ b/indexing-service/src/main/java/org/apache/druid/indexing/overlord/autoscaling/ec2/StringEC2UserData.java @@ -21,9 +21,8 @@ package org.apache.druid.indexing.overlord.autoscaling.ec2; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; - -import org.apache.druid.java.util.common.StringUtils; import org.apache.commons.codec.binary.Base64; +import org.apache.druid.java.util.common.StringUtils; public class StringEC2UserData implements EC2UserData { diff --git a/indexing-service/src/main/java/org/apache/druid/indexing/overlord/hrtr/HttpRemoteTaskRunnerFactory.java b/indexing-service/src/main/java/org/apache/druid/indexing/overlord/hrtr/HttpRemoteTaskRunnerFactory.java index 70c1e108007..99f6f6607dc 100644 --- a/indexing-service/src/main/java/org/apache/druid/indexing/overlord/hrtr/HttpRemoteTaskRunnerFactory.java +++ b/indexing-service/src/main/java/org/apache/druid/indexing/overlord/hrtr/HttpRemoteTaskRunnerFactory.java @@ -22,7 +22,7 @@ package org.apache.druid.indexing.overlord.hrtr; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.base.Supplier; import com.google.inject.Inject; -import org.apache.druid.java.util.http.client.HttpClient; +import org.apache.curator.framework.CuratorFramework; import org.apache.druid.discovery.DruidNodeDiscoveryProvider; import org.apache.druid.guice.annotations.EscalatedGlobal; import org.apache.druid.guice.annotations.Smile; @@ -33,8 +33,8 @@ import org.apache.druid.indexing.overlord.autoscaling.ProvisioningSchedulerConfi import org.apache.druid.indexing.overlord.autoscaling.ProvisioningStrategy; import org.apache.druid.indexing.overlord.config.HttpRemoteTaskRunnerConfig; import org.apache.druid.indexing.overlord.setup.WorkerBehaviorConfig; +import org.apache.druid.java.util.http.client.HttpClient; import org.apache.druid.server.initialization.IndexerZkConfig; -import org.apache.curator.framework.CuratorFramework; /** */ diff --git a/indexing-service/src/main/java/org/apache/druid/indexing/overlord/http/security/SupervisorResourceFilter.java b/indexing-service/src/main/java/org/apache/druid/indexing/overlord/http/security/SupervisorResourceFilter.java index 1c2fb9386a9..5179a89cd1c 100644 --- a/indexing-service/src/main/java/org/apache/druid/indexing/overlord/http/security/SupervisorResourceFilter.java +++ b/indexing-service/src/main/java/org/apache/druid/indexing/overlord/http/security/SupervisorResourceFilter.java @@ -33,8 +33,8 @@ import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.server.http.security.AbstractResourceFilter; import org.apache.druid.server.security.Access; import org.apache.druid.server.security.Action; -import org.apache.druid.server.security.AuthorizerMapper; import org.apache.druid.server.security.AuthorizationUtils; +import org.apache.druid.server.security.AuthorizerMapper; import org.apache.druid.server.security.ForbiddenException; import org.apache.druid.server.security.ResourceAction; diff --git a/indexing-service/src/main/java/org/apache/druid/indexing/overlord/http/security/TaskResourceFilter.java b/indexing-service/src/main/java/org/apache/druid/indexing/overlord/http/security/TaskResourceFilter.java index 12ef0b7b6bd..26c927f02fc 100644 --- a/indexing-service/src/main/java/org/apache/druid/indexing/overlord/http/security/TaskResourceFilter.java +++ b/indexing-service/src/main/java/org/apache/druid/indexing/overlord/http/security/TaskResourceFilter.java @@ -31,8 +31,8 @@ import org.apache.druid.indexing.overlord.TaskStorageQueryAdapter; import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.server.http.security.AbstractResourceFilter; import org.apache.druid.server.security.Access; -import org.apache.druid.server.security.AuthorizerMapper; import org.apache.druid.server.security.AuthorizationUtils; +import org.apache.druid.server.security.AuthorizerMapper; import org.apache.druid.server.security.ForbiddenException; import org.apache.druid.server.security.Resource; import org.apache.druid.server.security.ResourceAction; diff --git a/indexing-service/src/main/java/org/apache/druid/indexing/worker/WorkerCuratorCoordinator.java b/indexing-service/src/main/java/org/apache/druid/indexing/worker/WorkerCuratorCoordinator.java index b7c724db026..ff5d4d4f3cc 100644 --- a/indexing-service/src/main/java/org/apache/druid/indexing/worker/WorkerCuratorCoordinator.java +++ b/indexing-service/src/main/java/org/apache/druid/indexing/worker/WorkerCuratorCoordinator.java @@ -25,6 +25,7 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; import com.google.common.util.concurrent.MoreExecutors; import com.google.inject.Inject; +import org.apache.curator.framework.CuratorFramework; import org.apache.druid.curator.CuratorUtils; import org.apache.druid.curator.announcement.Announcer; import org.apache.druid.indexing.overlord.config.RemoteTaskRunnerConfig; @@ -34,7 +35,6 @@ import org.apache.druid.java.util.common.lifecycle.LifecycleStart; import org.apache.druid.java.util.common.lifecycle.LifecycleStop; import org.apache.druid.java.util.common.logger.Logger; import org.apache.druid.server.initialization.IndexerZkConfig; -import org.apache.curator.framework.CuratorFramework; import org.apache.zookeeper.CreateMode; import org.apache.zookeeper.KeeperException; diff --git a/indexing-service/src/main/java/org/apache/druid/indexing/worker/WorkerTaskMonitor.java b/indexing-service/src/main/java/org/apache/druid/indexing/worker/WorkerTaskMonitor.java index 1760d1ff866..878e170a7fd 100644 --- a/indexing-service/src/main/java/org/apache/druid/indexing/worker/WorkerTaskMonitor.java +++ b/indexing-service/src/main/java/org/apache/druid/indexing/worker/WorkerTaskMonitor.java @@ -22,6 +22,10 @@ package org.apache.druid.indexing.worker; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.base.Preconditions; import com.google.inject.Inject; +import org.apache.curator.framework.CuratorFramework; +import org.apache.curator.framework.recipes.cache.PathChildrenCache; +import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent; +import org.apache.curator.framework.recipes.cache.PathChildrenCacheListener; import org.apache.druid.client.indexing.IndexingService; import org.apache.druid.discovery.DruidLeaderClient; import org.apache.druid.indexer.TaskLocation; @@ -33,10 +37,6 @@ import org.apache.druid.java.util.common.concurrent.Execs; import org.apache.druid.java.util.common.lifecycle.LifecycleStart; import org.apache.druid.java.util.common.lifecycle.LifecycleStop; import org.apache.druid.java.util.emitter.EmittingLogger; -import org.apache.curator.framework.CuratorFramework; -import org.apache.curator.framework.recipes.cache.PathChildrenCache; -import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent; -import org.apache.curator.framework.recipes.cache.PathChildrenCacheListener; /** * This class is deprecated and required only to support {@link org.apache.druid.indexing.overlord.RemoteTaskRunner}. diff --git a/indexing-service/src/main/java/org/apache/druid/indexing/worker/executor/ExecutorLifecycle.java b/indexing-service/src/main/java/org/apache/druid/indexing/worker/executor/ExecutorLifecycle.java index a0d4e394f1f..d3b531a3a46 100644 --- a/indexing-service/src/main/java/org/apache/druid/indexing/worker/executor/ExecutorLifecycle.java +++ b/indexing-service/src/main/java/org/apache/druid/indexing/worker/executor/ExecutorLifecycle.java @@ -26,8 +26,7 @@ import com.google.common.base.Throwables; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import com.google.inject.Inject; -import org.apache.druid.java.util.emitter.EmittingLogger; -import org.apache.druid.java.util.common.concurrent.Execs; +import org.apache.commons.io.FileUtils; import org.apache.druid.indexer.TaskStatus; import org.apache.druid.indexing.common.actions.TaskActionClientFactory; import org.apache.druid.indexing.common.config.TaskConfig; @@ -35,9 +34,10 @@ import org.apache.druid.indexing.common.task.Task; import org.apache.druid.indexing.overlord.TaskRunner; import org.apache.druid.java.util.common.DateTimes; import org.apache.druid.java.util.common.ISE; +import org.apache.druid.java.util.common.concurrent.Execs; import org.apache.druid.java.util.common.lifecycle.LifecycleStart; import org.apache.druid.java.util.common.lifecycle.LifecycleStop; -import org.apache.commons.io.FileUtils; +import org.apache.druid.java.util.emitter.EmittingLogger; import java.io.File; import java.io.IOException; diff --git a/indexing-service/src/test/java/org/apache/druid/indexing/common/actions/RemoteTaskActionClientTest.java b/indexing-service/src/test/java/org/apache/druid/indexing/common/actions/RemoteTaskActionClientTest.java index a9f53d7cda4..39baa14eb07 100644 --- a/indexing-service/src/test/java/org/apache/druid/indexing/common/actions/RemoteTaskActionClientTest.java +++ b/indexing-service/src/test/java/org/apache/druid/indexing/common/actions/RemoteTaskActionClientTest.java @@ -20,8 +20,6 @@ package org.apache.druid.indexing.common.actions; import com.fasterxml.jackson.databind.ObjectMapper; -import org.apache.druid.java.util.http.client.Request; -import org.apache.druid.java.util.http.client.response.FullResponseHolder; import org.apache.druid.discovery.DruidLeaderClient; import org.apache.druid.indexing.common.RetryPolicyConfig; import org.apache.druid.indexing.common.RetryPolicyFactory; @@ -31,6 +29,8 @@ import org.apache.druid.indexing.common.task.NoopTask; import org.apache.druid.indexing.common.task.Task; import org.apache.druid.jackson.DefaultObjectMapper; import org.apache.druid.java.util.common.Intervals; +import org.apache.druid.java.util.http.client.Request; +import org.apache.druid.java.util.http.client.response.FullResponseHolder; import org.easymock.EasyMock; import org.jboss.netty.handler.codec.http.HttpMethod; import org.jboss.netty.handler.codec.http.HttpResponse; diff --git a/indexing-service/src/test/java/org/apache/druid/indexing/common/task/CompactionTaskTest.java b/indexing-service/src/test/java/org/apache/druid/indexing/common/task/CompactionTaskTest.java index 9d9f46c84ba..36eb56ac48c 100644 --- a/indexing-service/src/test/java/org/apache/druid/indexing/common/task/CompactionTaskTest.java +++ b/indexing-service/src/test/java/org/apache/druid/indexing/common/task/CompactionTaskTest.java @@ -71,13 +71,11 @@ import org.apache.druid.segment.IndexSpec; import org.apache.druid.segment.Metadata; import org.apache.druid.segment.QueryableIndex; import org.apache.druid.segment.SimpleQueryableIndex; +import org.apache.druid.segment.column.BaseColumn; import org.apache.druid.segment.column.BitmapIndex; -import org.apache.druid.segment.column.Column; import org.apache.druid.segment.column.ColumnCapabilities; import org.apache.druid.segment.column.ColumnCapabilitiesImpl; -import org.apache.druid.segment.column.ComplexColumn; -import org.apache.druid.segment.column.DictionaryEncodedColumn; -import org.apache.druid.segment.column.GenericColumn; +import org.apache.druid.segment.column.ColumnHolder; import org.apache.druid.segment.column.SpatialIndex; import org.apache.druid.segment.column.ValueType; import org.apache.druid.segment.data.CompressionFactory.LongEncodingStrategy; @@ -171,7 +169,7 @@ public class CompactionTaskTest DIMENSIONS = new HashMap<>(); AGGREGATORS = new HashMap<>(); - DIMENSIONS.put(Column.TIME_COLUMN_NAME, new LongDimensionSchema(Column.TIME_COLUMN_NAME)); + DIMENSIONS.put(ColumnHolder.TIME_COLUMN_NAME, new LongDimensionSchema(ColumnHolder.TIME_COLUMN_NAME)); DIMENSIONS.put(TIMESTAMP_COLUMN, new LongDimensionSchema(TIMESTAMP_COLUMN)); for (int i = 0; i < 5; i++) { final StringDimensionSchema schema = new StringDimensionSchema( @@ -1030,10 +1028,10 @@ public class CompactionTaskTest for (Entry entry : segmentFileMap.entrySet()) { final DataSegment segment = entry.getKey(); final List columnNames = new ArrayList<>(segment.getDimensions().size() + segment.getMetrics().size()); - columnNames.add(Column.TIME_COLUMN_NAME); + columnNames.add(ColumnHolder.TIME_COLUMN_NAME); columnNames.addAll(segment.getDimensions()); columnNames.addAll(segment.getMetrics()); - final Map columnMap = new HashMap<>(columnNames.size()); + final Map columnMap = new HashMap<>(columnNames.size()); final List aggregatorFactories = new ArrayList<>(segment.getMetrics().size()); for (String columnName : columnNames) { @@ -1059,7 +1057,7 @@ public class CompactionTaskTest entry.getValue(), new SimpleQueryableIndex( segment.getInterval(), - new ListIndexed<>(segment.getDimensions(), String.class), + new ListIndexed<>(segment.getDimensions()), null, columnMap, null, @@ -1101,17 +1099,17 @@ public class CompactionTaskTest } } - private static Column createColumn(DimensionSchema dimensionSchema) + private static ColumnHolder createColumn(DimensionSchema dimensionSchema) { return new TestColumn(IncrementalIndex.TYPE_MAP.get(dimensionSchema.getValueType())); } - private static Column createColumn(AggregatorFactory aggregatorFactory) + private static ColumnHolder createColumn(AggregatorFactory aggregatorFactory) { return new TestColumn(ValueType.fromString(aggregatorFactory.getTypeName())); } - private static class TestColumn implements Column + private static class TestColumn implements ColumnHolder { private final ColumnCapabilities columnCapabilities; @@ -1138,19 +1136,13 @@ public class CompactionTaskTest } @Override - public DictionaryEncodedColumn getDictionaryEncoding() + public BaseColumn getColumn() { return null; } @Override - public GenericColumn getGenericColumn() - { - return null; - } - - @Override - public ComplexColumn getComplexColumn() + public SettableColumnValueSelector makeNewSettableColumnValueSelector() { return null; } @@ -1166,11 +1158,5 @@ public class CompactionTaskTest { return null; } - - @Override - public SettableColumnValueSelector makeSettableColumnValueSelector() - { - return null; - } } } diff --git a/indexing-service/src/test/java/org/apache/druid/indexing/common/task/HadoopTaskTest.java b/indexing-service/src/test/java/org/apache/druid/indexing/common/task/HadoopTaskTest.java index d692f5fe5e4..7e2b2ef8184 100644 --- a/indexing-service/src/test/java/org/apache/druid/indexing/common/task/HadoopTaskTest.java +++ b/indexing-service/src/test/java/org/apache/druid/indexing/common/task/HadoopTaskTest.java @@ -21,8 +21,8 @@ package org.apache.druid.indexing.common.task; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; -import org.apache.druid.indexer.updater.HadoopDruidConverterConfig; import org.apache.druid.indexer.TaskStatus; +import org.apache.druid.indexer.updater.HadoopDruidConverterConfig; import org.apache.druid.indexing.common.TaskToolbox; import org.apache.druid.indexing.common.actions.TaskActionClient; import org.apache.druid.indexing.common.config.TaskConfig; diff --git a/indexing-service/src/test/java/org/apache/druid/indexing/common/task/TaskReportSerdeTest.java b/indexing-service/src/test/java/org/apache/druid/indexing/common/task/TaskReportSerdeTest.java index 4e97374f7c5..d133b3ac8da 100644 --- a/indexing-service/src/test/java/org/apache/druid/indexing/common/task/TaskReportSerdeTest.java +++ b/indexing-service/src/test/java/org/apache/druid/indexing/common/task/TaskReportSerdeTest.java @@ -27,7 +27,6 @@ import org.apache.druid.indexing.common.IngestionStatsAndErrorsTaskReport; import org.apache.druid.indexing.common.IngestionStatsAndErrorsTaskReportData; import org.apache.druid.indexing.common.TaskReport; import org.apache.druid.indexing.common.TestUtils; - import org.junit.Assert; import org.junit.Test; diff --git a/indexing-service/src/test/java/org/apache/druid/indexing/common/tasklogs/FileTaskLogsTest.java b/indexing-service/src/test/java/org/apache/druid/indexing/common/tasklogs/FileTaskLogsTest.java index 112c5cfd572..b5b44c009ed 100644 --- a/indexing-service/src/test/java/org/apache/druid/indexing/common/tasklogs/FileTaskLogsTest.java +++ b/indexing-service/src/test/java/org/apache/druid/indexing/common/tasklogs/FileTaskLogsTest.java @@ -22,10 +22,10 @@ package org.apache.druid.indexing.common.tasklogs; import com.google.common.collect.ImmutableMap; import com.google.common.io.ByteStreams; import com.google.common.io.Files; +import org.apache.commons.io.FileUtils; import org.apache.druid.indexing.common.config.FileTaskLogsConfig; import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.tasklogs.TaskLogs; -import org.apache.commons.io.FileUtils; import org.junit.Assert; import org.junit.Rule; import org.junit.Test; diff --git a/indexing-service/src/test/java/org/apache/druid/indexing/firehose/IngestSegmentFirehoseFactoryTest.java b/indexing-service/src/test/java/org/apache/druid/indexing/firehose/IngestSegmentFirehoseFactoryTest.java index 27ae2509d03..03660fead8f 100644 --- a/indexing-service/src/test/java/org/apache/druid/indexing/firehose/IngestSegmentFirehoseFactoryTest.java +++ b/indexing-service/src/test/java/org/apache/druid/indexing/firehose/IngestSegmentFirehoseFactoryTest.java @@ -72,7 +72,7 @@ import org.apache.druid.segment.IndexIO; import org.apache.druid.segment.IndexMergerV9; import org.apache.druid.segment.IndexSpec; import org.apache.druid.segment.TestHelper; -import org.apache.druid.segment.column.Column; +import org.apache.druid.segment.column.ColumnHolder; import org.apache.druid.segment.incremental.IncrementalIndex; import org.apache.druid.segment.incremental.IncrementalIndexSchema; import org.apache.druid.segment.loading.DataSegmentArchiver; @@ -559,7 +559,7 @@ public class IngestSegmentFirehoseFactoryTest Assert.assertEquals(MAX_SHARD_NUMBER.longValue(), segmentSet.size()); Integer rowcount = 0; final TransformSpec transformSpec = new TransformSpec( - new SelectorDimFilter(Column.TIME_COLUMN_NAME, "1", null), + new SelectorDimFilter(ColumnHolder.TIME_COLUMN_NAME, "1", null), ImmutableList.of( new ExpressionTransform(METRIC_FLOAT_NAME, METRIC_FLOAT_NAME + " * 10", ExprMacroTable.nil()) ) diff --git a/indexing-service/src/test/java/org/apache/druid/indexing/firehose/IngestSegmentFirehoseFactoryTimelineTest.java b/indexing-service/src/test/java/org/apache/druid/indexing/firehose/IngestSegmentFirehoseFactoryTimelineTest.java index bc42c876db7..10731211978 100644 --- a/indexing-service/src/test/java/org/apache/druid/indexing/firehose/IngestSegmentFirehoseFactoryTimelineTest.java +++ b/indexing-service/src/test/java/org/apache/druid/indexing/firehose/IngestSegmentFirehoseFactoryTimelineTest.java @@ -27,6 +27,7 @@ import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Sets; import com.google.common.io.Files; +import org.apache.commons.io.FileUtils; import org.apache.druid.data.input.Firehose; import org.apache.druid.data.input.InputRow; import org.apache.druid.data.input.MapBasedInputRow; @@ -68,7 +69,6 @@ import org.apache.druid.segment.transform.TransformSpec; import org.apache.druid.server.metrics.NoopServiceEmitter; import org.apache.druid.timeline.DataSegment; import org.apache.druid.timeline.partition.LinearShardSpec; -import org.apache.commons.io.FileUtils; import org.easymock.EasyMock; import org.joda.time.Interval; import org.junit.After; diff --git a/indexing-service/src/test/java/org/apache/druid/indexing/overlord/RealtimeishTask.java b/indexing-service/src/test/java/org/apache/druid/indexing/overlord/RealtimeishTask.java index e60de63b463..24291e8257a 100644 --- a/indexing-service/src/test/java/org/apache/druid/indexing/overlord/RealtimeishTask.java +++ b/indexing-service/src/test/java/org/apache/druid/indexing/overlord/RealtimeishTask.java @@ -21,9 +21,9 @@ package org.apache.druid.indexing.overlord; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; +import org.apache.druid.indexer.TaskStatus; import org.apache.druid.indexing.common.TaskLock; import org.apache.druid.indexing.common.TaskLockType; -import org.apache.druid.indexer.TaskStatus; import org.apache.druid.indexing.common.TaskToolbox; import org.apache.druid.indexing.common.actions.LockAcquireAction; import org.apache.druid.indexing.common.actions.LockListAction; diff --git a/indexing-service/src/test/java/org/apache/druid/indexing/overlord/RemoteTaskRunnerRunPendingTasksConcurrencyTest.java b/indexing-service/src/test/java/org/apache/druid/indexing/overlord/RemoteTaskRunnerRunPendingTasksConcurrencyTest.java index d3146bb0a81..3aed5a59c74 100644 --- a/indexing-service/src/test/java/org/apache/druid/indexing/overlord/RemoteTaskRunnerRunPendingTasksConcurrencyTest.java +++ b/indexing-service/src/test/java/org/apache/druid/indexing/overlord/RemoteTaskRunnerRunPendingTasksConcurrencyTest.java @@ -20,13 +20,11 @@ package org.apache.druid.indexing.overlord; import com.google.common.util.concurrent.ListenableFuture; - import org.apache.druid.indexer.TaskState; import org.apache.druid.indexer.TaskStatus; import org.apache.druid.indexing.common.TestTasks; import org.apache.druid.indexing.common.task.Task; import org.apache.druid.java.util.common.ISE; - import org.apache.zookeeper.ZooKeeper; import org.joda.time.Period; import org.junit.After; diff --git a/indexing-service/src/test/java/org/apache/druid/indexing/overlord/RemoteTaskRunnerTest.java b/indexing-service/src/test/java/org/apache/druid/indexing/overlord/RemoteTaskRunnerTest.java index 1616bb44093..cbb381dbd48 100644 --- a/indexing-service/src/test/java/org/apache/druid/indexing/overlord/RemoteTaskRunnerTest.java +++ b/indexing-service/src/test/java/org/apache/druid/indexing/overlord/RemoteTaskRunnerTest.java @@ -28,9 +28,10 @@ import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Sets; import com.google.common.util.concurrent.ListenableFuture; +import org.apache.curator.framework.CuratorFramework; import org.apache.druid.indexer.TaskState; -import org.apache.druid.indexing.common.IndexingServiceCondition; import org.apache.druid.indexer.TaskStatus; +import org.apache.druid.indexing.common.IndexingServiceCondition; import org.apache.druid.indexing.common.TestRealtimeTask; import org.apache.druid.indexing.common.TestTasks; import org.apache.druid.indexing.common.TestUtils; @@ -42,13 +43,15 @@ import org.apache.druid.java.util.common.DateTimes; import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.java.util.emitter.EmittingLogger; import org.apache.druid.java.util.emitter.service.ServiceEmitter; -import org.apache.curator.framework.CuratorFramework; +import org.apache.druid.testing.DeadlockDetectingTimeout; import org.easymock.EasyMock; import org.joda.time.Period; import org.junit.After; import org.junit.Assert; import org.junit.Before; +import org.junit.Rule; import org.junit.Test; +import org.junit.rules.TestRule; import java.util.ArrayList; import java.util.Collection; @@ -62,7 +65,6 @@ public class RemoteTaskRunnerTest private static final String workerHost = "worker"; private static final String announcementsPath = joiner.join(RemoteTaskRunnerTestUtils.announcementsPath, workerHost); private static final String statusPath = joiner.join(RemoteTaskRunnerTestUtils.statusPath, workerHost); - private static final int TIMEOUT_SECONDS = 20; private RemoteTaskRunner remoteTaskRunner; private RemoteTaskRunnerTestUtils rtrTestUtils = new RemoteTaskRunnerTestUtils(); @@ -72,6 +74,9 @@ public class RemoteTaskRunnerTest private Task task; private Worker worker; + @Rule + public final TestRule timeout = new DeadlockDetectingTimeout(60, TimeUnit.SECONDS); + @Before public void setUp() throws Exception { @@ -312,7 +317,7 @@ public class RemoteTaskRunnerTest cf.delete().forPath(joiner.join(statusPath, task.getId())); - TaskStatus status = future.get(TIMEOUT_SECONDS, TimeUnit.SECONDS); + TaskStatus status = future.get(); Assert.assertEquals(status.getStatusCode(), TaskState.FAILED); } @@ -403,7 +408,7 @@ public class RemoteTaskRunnerTest cf.delete().forPath(announcementsPath); - TaskStatus status = future.get(TIMEOUT_SECONDS, TimeUnit.SECONDS); + TaskStatus status = future.get(); Assert.assertEquals(TaskState.FAILED, status.getStatusCode()); RemoteTaskRunnerConfig config = remoteTaskRunner.getRemoteTaskRunnerConfig(); @@ -659,7 +664,7 @@ public class RemoteTaskRunnerTest ); mockWorkerCompleteSuccessfulTask(task); - TaskStatus status = future.get(TIMEOUT_SECONDS, TimeUnit.SECONDS); + TaskStatus status = future.get(); Assert.assertEquals(status.getStatusCode(), TaskState.SUCCESS); Assert.assertEquals(TaskState.SUCCESS, status.getStatusCode()); } @@ -702,7 +707,7 @@ public class RemoteTaskRunnerTest Assert.assertTrue(taskAnnounced(task1.getId())); mockWorkerRunningTask(task1); mockWorkerCompleteFailedTask(task1); - Assert.assertTrue(taskFuture1.get(TIMEOUT_SECONDS, TimeUnit.SECONDS).isFailure()); + Assert.assertTrue(taskFuture1.get().isFailure()); Assert.assertEquals(0, remoteTaskRunner.getBlackListedWorkers().size()); Assert.assertEquals( 1, @@ -720,7 +725,7 @@ public class RemoteTaskRunnerTest Assert.assertTrue(taskAnnounced(task2.getId())); mockWorkerRunningTask(task2); mockWorkerCompleteFailedTask(task2); - Assert.assertTrue(taskFuture2.get(TIMEOUT_SECONDS, TimeUnit.SECONDS).isFailure()); + Assert.assertTrue(taskFuture2.get().isFailure()); Assert.assertEquals(1, remoteTaskRunner.getBlackListedWorkers().size()); Assert.assertEquals( 2, @@ -755,7 +760,7 @@ public class RemoteTaskRunnerTest Assert.assertTrue(taskAnnounced(task3.getId())); mockWorkerRunningTask(task3); mockWorkerCompleteSuccessfulTask(task3); - Assert.assertTrue(taskFuture3.get(TIMEOUT_SECONDS, TimeUnit.SECONDS).isSuccess()); + Assert.assertTrue(taskFuture3.get().isSuccess()); Assert.assertEquals(0, remoteTaskRunner.getBlackListedWorkers().size()); Assert.assertEquals( 0, @@ -807,7 +812,7 @@ public class RemoteTaskRunnerTest rtrTestUtils.mockWorkerRunningTask(expectedWorker, task); rtrTestUtils.mockWorkerCompleteFailedTask(expectedWorker, task); - Assert.assertTrue(taskFuture.get(TIMEOUT_SECONDS, TimeUnit.SECONDS).isFailure()); + Assert.assertTrue(taskFuture.get().isFailure()); Assert.assertEquals(0, remoteTaskRunner.getBlackListedWorkers().size()); Assert.assertEquals( ((i + 1) / 2), @@ -860,7 +865,7 @@ public class RemoteTaskRunnerTest rtrTestUtils.mockWorkerRunningTask(expectedWorker, task); rtrTestUtils.mockWorkerCompleteFailedTask(expectedWorker, task); - Assert.assertTrue(taskFuture.get(TIMEOUT_SECONDS, TimeUnit.SECONDS).isFailure()); + Assert.assertTrue(taskFuture.get().isFailure()); Assert.assertEquals(i > 2 ? 1 : 0, remoteTaskRunner.getBlackListedWorkers().size()); Assert.assertEquals( i > 4 ? i - 2 : ((i + 1) / 2), @@ -894,7 +899,7 @@ public class RemoteTaskRunnerTest Assert.assertTrue(taskAnnounced(task1.getId())); mockWorkerRunningTask(task1); mockWorkerCompleteFailedTask(task1); - Assert.assertTrue(taskFuture1.get(TIMEOUT_SECONDS, TimeUnit.SECONDS).isFailure()); + Assert.assertTrue(taskFuture1.get().isFailure()); Assert.assertEquals(0, remoteTaskRunner.getBlackListedWorkers().size()); Future taskFuture2 = remoteTaskRunner.run(task2); @@ -905,11 +910,11 @@ public class RemoteTaskRunnerTest Assert.assertTrue(taskAnnounced(task3.getId())); mockWorkerRunningTask(task3); mockWorkerCompleteFailedTask(task3); - Assert.assertTrue(taskFuture3.get(TIMEOUT_SECONDS, TimeUnit.SECONDS).isFailure()); + Assert.assertTrue(taskFuture3.get().isFailure()); Assert.assertEquals(1, remoteTaskRunner.getBlackListedWorkers().size()); mockWorkerCompleteSuccessfulTask(task2); - Assert.assertTrue(taskFuture2.get(TIMEOUT_SECONDS, TimeUnit.SECONDS).isSuccess()); + Assert.assertTrue(taskFuture2.get().isSuccess()); Assert.assertEquals(0, remoteTaskRunner.getBlackListedWorkers().size()); } } diff --git a/indexing-service/src/test/java/org/apache/druid/indexing/overlord/RemoteTaskRunnerTestUtils.java b/indexing-service/src/test/java/org/apache/druid/indexing/overlord/RemoteTaskRunnerTestUtils.java index 8995c9fd6e0..ffd5d685a43 100644 --- a/indexing-service/src/test/java/org/apache/druid/indexing/overlord/RemoteTaskRunnerTestUtils.java +++ b/indexing-service/src/test/java/org/apache/druid/indexing/overlord/RemoteTaskRunnerTestUtils.java @@ -24,12 +24,16 @@ import com.google.common.base.Joiner; import com.google.common.base.Preconditions; import com.google.common.base.Supplier; import com.google.common.base.Throwables; +import org.apache.curator.framework.CuratorFramework; +import org.apache.curator.framework.CuratorFrameworkFactory; +import org.apache.curator.retry.ExponentialBackoffRetry; +import org.apache.curator.test.TestingCluster; import org.apache.druid.common.guava.DSuppliers; import org.apache.druid.curator.PotentiallyGzippedCompressionProvider; import org.apache.druid.curator.cache.PathChildrenCacheFactory; import org.apache.druid.indexer.TaskLocation; -import org.apache.druid.indexing.common.IndexingServiceCondition; import org.apache.druid.indexer.TaskStatus; +import org.apache.druid.indexing.common.IndexingServiceCondition; import org.apache.druid.indexing.common.TestUtils; import org.apache.druid.indexing.common.task.Task; import org.apache.druid.indexing.overlord.autoscaling.NoopProvisioningStrategy; @@ -43,10 +47,6 @@ import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.java.util.http.client.HttpClient; import org.apache.druid.server.initialization.IndexerZkConfig; import org.apache.druid.server.initialization.ZkPathsConfig; -import org.apache.curator.framework.CuratorFramework; -import org.apache.curator.framework.CuratorFrameworkFactory; -import org.apache.curator.retry.ExponentialBackoffRetry; -import org.apache.curator.test.TestingCluster; import org.apache.zookeeper.CreateMode; import java.util.concurrent.atomic.AtomicReference; diff --git a/indexing-service/src/test/java/org/apache/druid/indexing/overlord/SingleTaskBackgroundRunnerTest.java b/indexing-service/src/test/java/org/apache/druid/indexing/overlord/SingleTaskBackgroundRunnerTest.java index 74dd1d2eaae..753972bfdcd 100644 --- a/indexing-service/src/test/java/org/apache/druid/indexing/overlord/SingleTaskBackgroundRunnerTest.java +++ b/indexing-service/src/test/java/org/apache/druid/indexing/overlord/SingleTaskBackgroundRunnerTest.java @@ -21,9 +21,9 @@ package org.apache.druid.indexing.overlord; import com.google.common.util.concurrent.ListenableFuture; import org.apache.druid.indexer.TaskState; +import org.apache.druid.indexer.TaskStatus; import org.apache.druid.indexing.common.SegmentLoaderFactory; import org.apache.druid.indexing.common.TaskReportFileWriter; -import org.apache.druid.indexer.TaskStatus; import org.apache.druid.indexing.common.TaskToolbox; import org.apache.druid.indexing.common.TaskToolboxFactory; import org.apache.druid.indexing.common.TestUtils; diff --git a/indexing-service/src/test/java/org/apache/druid/indexing/overlord/TaskLifecycleTest.java b/indexing-service/src/test/java/org/apache/druid/indexing/overlord/TaskLifecycleTest.java index 68ec75c08e9..eb0393332e5 100644 --- a/indexing-service/src/test/java/org/apache/druid/indexing/overlord/TaskLifecycleTest.java +++ b/indexing-service/src/test/java/org/apache/druid/indexing/overlord/TaskLifecycleTest.java @@ -45,10 +45,10 @@ import org.apache.druid.discovery.DataNodeService; import org.apache.druid.discovery.DruidNodeAnnouncer; import org.apache.druid.discovery.LookupNodeService; import org.apache.druid.indexer.TaskState; +import org.apache.druid.indexer.TaskStatus; import org.apache.druid.indexing.common.Counters; import org.apache.druid.indexing.common.SegmentLoaderFactory; import org.apache.druid.indexing.common.TaskLock; -import org.apache.druid.indexer.TaskStatus; import org.apache.druid.indexing.common.TaskToolbox; import org.apache.druid.indexing.common.TaskToolboxFactory; import org.apache.druid.indexing.common.TestUtils; diff --git a/indexing-service/src/test/java/org/apache/druid/indexing/overlord/TaskLockBoxConcurrencyTest.java b/indexing-service/src/test/java/org/apache/druid/indexing/overlord/TaskLockBoxConcurrencyTest.java index 770a2792221..10b46c88fba 100644 --- a/indexing-service/src/test/java/org/apache/druid/indexing/overlord/TaskLockBoxConcurrencyTest.java +++ b/indexing-service/src/test/java/org/apache/druid/indexing/overlord/TaskLockBoxConcurrencyTest.java @@ -22,8 +22,8 @@ package org.apache.druid.indexing.overlord; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.collect.ImmutableList; import org.apache.druid.common.guava.SettableSupplier; -import org.apache.druid.indexing.common.TaskLockType; import org.apache.druid.indexer.TaskStatus; +import org.apache.druid.indexing.common.TaskLockType; import org.apache.druid.indexing.common.config.TaskStorageConfig; import org.apache.druid.indexing.common.task.NoopTask; import org.apache.druid.indexing.common.task.Task; diff --git a/indexing-service/src/test/java/org/apache/druid/indexing/overlord/hrtr/HttpRemoteTaskRunnerTest.java b/indexing-service/src/test/java/org/apache/druid/indexing/overlord/hrtr/HttpRemoteTaskRunnerTest.java index 7309452adaa..3f7b5c3c6f2 100644 --- a/indexing-service/src/test/java/org/apache/druid/indexing/overlord/hrtr/HttpRemoteTaskRunnerTest.java +++ b/indexing-service/src/test/java/org/apache/druid/indexing/overlord/hrtr/HttpRemoteTaskRunnerTest.java @@ -28,6 +28,7 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; import com.google.common.util.concurrent.MoreExecutors; +import org.apache.curator.framework.CuratorFramework; import org.apache.druid.common.guava.DSuppliers; import org.apache.druid.discovery.DiscoveryDruidNode; import org.apache.druid.discovery.DruidNodeDiscovery; @@ -52,7 +53,6 @@ import org.apache.druid.segment.TestHelper; import org.apache.druid.server.DruidNode; import org.apache.druid.server.initialization.IndexerZkConfig; import org.apache.druid.server.initialization.ZkPathsConfig; -import org.apache.curator.framework.CuratorFramework; import org.easymock.EasyMock; import org.eclipse.jetty.util.ConcurrentHashSet; import org.joda.time.Period; diff --git a/indexing-service/src/test/java/org/apache/druid/indexing/overlord/hrtr/WorkerHolderTest.java b/indexing-service/src/test/java/org/apache/druid/indexing/overlord/hrtr/WorkerHolderTest.java index f82ed7a5d0c..cc26b66859b 100644 --- a/indexing-service/src/test/java/org/apache/druid/indexing/overlord/hrtr/WorkerHolderTest.java +++ b/indexing-service/src/test/java/org/apache/druid/indexing/overlord/hrtr/WorkerHolderTest.java @@ -20,7 +20,6 @@ package org.apache.druid.indexing.overlord.hrtr; import com.google.common.collect.ImmutableList; -import org.apache.druid.java.util.http.client.HttpClient; import org.apache.druid.indexer.TaskLocation; import org.apache.druid.indexer.TaskStatus; import org.apache.druid.indexing.common.task.NoopTask; @@ -29,6 +28,7 @@ import org.apache.druid.indexing.overlord.config.HttpRemoteTaskRunnerConfig; import org.apache.druid.indexing.worker.TaskAnnouncement; import org.apache.druid.indexing.worker.Worker; import org.apache.druid.indexing.worker.WorkerHistoryItem; +import org.apache.druid.java.util.http.client.HttpClient; import org.apache.druid.segment.TestHelper; import org.apache.druid.server.coordination.ChangeRequestHttpSyncer; import org.easymock.EasyMock; diff --git a/indexing-service/src/test/java/org/apache/druid/indexing/overlord/http/OverlordTest.java b/indexing-service/src/test/java/org/apache/druid/indexing/overlord/http/OverlordTest.java index 8c1f33a1fe7..f34dcd10bf8 100644 --- a/indexing-service/src/test/java/org/apache/druid/indexing/overlord/http/OverlordTest.java +++ b/indexing-service/src/test/java/org/apache/druid/indexing/overlord/http/OverlordTest.java @@ -26,6 +26,11 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.MoreExecutors; +import org.apache.curator.framework.CuratorFramework; +import org.apache.curator.framework.CuratorFrameworkFactory; +import org.apache.curator.retry.RetryOneTime; +import org.apache.curator.test.TestingServer; +import org.apache.curator.test.Timing; import org.apache.druid.curator.PotentiallyGzippedCompressionProvider; import org.apache.druid.curator.discovery.NoopServiceAnnouncer; import org.apache.druid.discovery.DruidLeaderSelector; @@ -62,11 +67,6 @@ import org.apache.druid.server.metrics.NoopServiceEmitter; import org.apache.druid.server.security.AuthConfig; import org.apache.druid.server.security.AuthTestUtils; import org.apache.druid.server.security.AuthenticationResult; -import org.apache.curator.framework.CuratorFramework; -import org.apache.curator.framework.CuratorFrameworkFactory; -import org.apache.curator.retry.RetryOneTime; -import org.apache.curator.test.TestingServer; -import org.apache.curator.test.Timing; import org.easymock.EasyMock; import org.joda.time.Period; import org.junit.After; diff --git a/indexing-service/src/test/java/org/apache/druid/indexing/worker/WorkerTaskManagerTest.java b/indexing-service/src/test/java/org/apache/druid/indexing/worker/WorkerTaskManagerTest.java index 5caa70b1cab..749d44af805 100644 --- a/indexing-service/src/test/java/org/apache/druid/indexing/worker/WorkerTaskManagerTest.java +++ b/indexing-service/src/test/java/org/apache/druid/indexing/worker/WorkerTaskManagerTest.java @@ -25,8 +25,8 @@ import com.google.common.collect.ImmutableSet; import com.google.common.io.Files; import org.apache.druid.discovery.DruidLeaderClient; import org.apache.druid.indexer.TaskLocation; -import org.apache.druid.indexing.common.SegmentLoaderFactory; import org.apache.druid.indexer.TaskStatus; +import org.apache.druid.indexing.common.SegmentLoaderFactory; import org.apache.druid.indexing.common.TaskToolboxFactory; import org.apache.druid.indexing.common.TestTasks; import org.apache.druid.indexing.common.TestUtils; diff --git a/indexing-service/src/test/java/org/apache/druid/indexing/worker/WorkerTaskMonitorTest.java b/indexing-service/src/test/java/org/apache/druid/indexing/worker/WorkerTaskMonitorTest.java index eac46c57292..3e69c836298 100644 --- a/indexing-service/src/test/java/org/apache/druid/indexing/worker/WorkerTaskMonitorTest.java +++ b/indexing-service/src/test/java/org/apache/druid/indexing/worker/WorkerTaskMonitorTest.java @@ -24,9 +24,13 @@ import com.fasterxml.jackson.databind.jsontype.NamedType; import com.google.common.base.Joiner; import com.google.common.collect.Lists; import com.google.common.io.Files; +import org.apache.curator.framework.CuratorFramework; +import org.apache.curator.framework.CuratorFrameworkFactory; +import org.apache.curator.retry.ExponentialBackoffRetry; +import org.apache.curator.test.TestingCluster; import org.apache.druid.curator.PotentiallyGzippedCompressionProvider; -import org.apache.druid.indexer.TaskState; import org.apache.druid.discovery.DruidLeaderClient; +import org.apache.druid.indexer.TaskState; import org.apache.druid.indexing.common.IndexingServiceCondition; import org.apache.druid.indexing.common.SegmentLoaderFactory; import org.apache.druid.indexing.common.TaskToolboxFactory; @@ -38,8 +42,8 @@ import org.apache.druid.indexing.common.actions.TaskActionClientFactory; import org.apache.druid.indexing.common.config.TaskConfig; import org.apache.druid.indexing.common.task.NoopTestTaskFileWriter; import org.apache.druid.indexing.common.task.Task; -import org.apache.druid.indexing.overlord.TestRemoteTaskRunnerConfig; import org.apache.druid.indexing.overlord.SingleTaskBackgroundRunner; +import org.apache.druid.indexing.overlord.TestRemoteTaskRunnerConfig; import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.segment.IndexIO; import org.apache.druid.segment.IndexMergerV9; @@ -52,10 +56,6 @@ import org.apache.druid.server.initialization.IndexerZkConfig; import org.apache.druid.server.initialization.ServerConfig; import org.apache.druid.server.initialization.ZkPathsConfig; import org.apache.druid.server.metrics.NoopServiceEmitter; -import org.apache.curator.framework.CuratorFramework; -import org.apache.curator.framework.CuratorFrameworkFactory; -import org.apache.curator.retry.ExponentialBackoffRetry; -import org.apache.curator.test.TestingCluster; import org.easymock.EasyMock; import org.joda.time.Period; import org.junit.After; diff --git a/indexing-service/src/test/java/org/apache/druid/indexing/worker/http/WorkerResourceTest.java b/indexing-service/src/test/java/org/apache/druid/indexing/worker/http/WorkerResourceTest.java index bed3ce68575..78aead2bce5 100644 --- a/indexing-service/src/test/java/org/apache/druid/indexing/worker/http/WorkerResourceTest.java +++ b/indexing-service/src/test/java/org/apache/druid/indexing/worker/http/WorkerResourceTest.java @@ -20,6 +20,10 @@ package org.apache.druid.indexing.worker.http; import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.curator.framework.CuratorFramework; +import org.apache.curator.framework.CuratorFrameworkFactory; +import org.apache.curator.retry.ExponentialBackoffRetry; +import org.apache.curator.test.TestingCluster; import org.apache.druid.curator.PotentiallyGzippedCompressionProvider; import org.apache.druid.indexing.overlord.config.RemoteTaskRunnerConfig; import org.apache.druid.indexing.worker.Worker; @@ -29,10 +33,6 @@ import org.apache.druid.jackson.DefaultObjectMapper; import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.server.initialization.IndexerZkConfig; import org.apache.druid.server.initialization.ZkPathsConfig; -import org.apache.curator.framework.CuratorFramework; -import org.apache.curator.framework.CuratorFrameworkFactory; -import org.apache.curator.retry.ExponentialBackoffRetry; -import org.apache.curator.test.TestingCluster; import org.easymock.EasyMock; import org.junit.After; import org.junit.Assert; diff --git a/integration-tests/src/main/java/org/apache/druid/testing/clients/QueryResourceTestClient.java b/integration-tests/src/main/java/org/apache/druid/testing/clients/QueryResourceTestClient.java index 1db718e7d1d..9fc9e389378 100644 --- a/integration-tests/src/main/java/org/apache/druid/testing/clients/QueryResourceTestClient.java +++ b/integration-tests/src/main/java/org/apache/druid/testing/clients/QueryResourceTestClient.java @@ -24,12 +24,12 @@ import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.base.Throwables; import com.google.inject.Inject; +import org.apache.druid.java.util.common.ISE; +import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.java.util.http.client.HttpClient; import org.apache.druid.java.util.http.client.Request; import org.apache.druid.java.util.http.client.response.StatusResponseHandler; import org.apache.druid.java.util.http.client.response.StatusResponseHolder; -import org.apache.druid.java.util.common.ISE; -import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.query.Query; import org.apache.druid.testing.IntegrationTestingConfig; import org.apache.druid.testing.guice.TestClient; diff --git a/integration-tests/src/main/java/org/apache/druid/testing/utils/LoggerListener.java b/integration-tests/src/main/java/org/apache/druid/testing/utils/LoggerListener.java index ca79a285e6e..7282396b933 100644 --- a/integration-tests/src/main/java/org/apache/druid/testing/utils/LoggerListener.java +++ b/integration-tests/src/main/java/org/apache/druid/testing/utils/LoggerListener.java @@ -19,11 +19,10 @@ package org.apache.druid.testing.utils; +import org.apache.druid.java.util.common.logger.Logger; import org.testng.ITestResult; import org.testng.TestListenerAdapter; -import org.apache.druid.java.util.common.logger.Logger; - public class LoggerListener extends TestListenerAdapter { private static final Logger LOG = new Logger(LoggerListener.class); diff --git a/integration-tests/src/main/java/org/apache/druid/testing/utils/RetryUtil.java b/integration-tests/src/main/java/org/apache/druid/testing/utils/RetryUtil.java index 53888dbcfd1..c2ef4c98f1c 100644 --- a/integration-tests/src/main/java/org/apache/druid/testing/utils/RetryUtil.java +++ b/integration-tests/src/main/java/org/apache/druid/testing/utils/RetryUtil.java @@ -20,7 +20,6 @@ package org.apache.druid.testing.utils; import com.google.common.base.Throwables; - import org.apache.druid.java.util.common.ISE; import org.apache.druid.java.util.common.logger.Logger; diff --git a/integration-tests/src/test/java/org/apache/druid/tests/indexer/AbstractITRealtimeIndexTaskTest.java b/integration-tests/src/test/java/org/apache/druid/tests/indexer/AbstractITRealtimeIndexTaskTest.java index fb9681fdee4..4eaa40c26bd 100644 --- a/integration-tests/src/test/java/org/apache/druid/tests/indexer/AbstractITRealtimeIndexTaskTest.java +++ b/integration-tests/src/test/java/org/apache/druid/tests/indexer/AbstractITRealtimeIndexTaskTest.java @@ -20,6 +20,7 @@ package org.apache.druid.tests.indexer; import com.google.common.base.Throwables; import com.google.inject.Inject; +import org.apache.commons.io.IOUtils; import org.apache.druid.curator.discovery.ServerDiscoveryFactory; import org.apache.druid.java.util.common.DateTimes; import org.apache.druid.java.util.common.ISE; @@ -29,7 +30,6 @@ import org.apache.druid.java.util.http.client.HttpClient; import org.apache.druid.testing.IntegrationTestingConfig; import org.apache.druid.testing.guice.TestClient; import org.apache.druid.testing.utils.RetryUtil; -import org.apache.commons.io.IOUtils; import org.joda.time.DateTime; import org.joda.time.format.DateTimeFormat; import org.joda.time.format.DateTimeFormatter; diff --git a/integration-tests/src/test/java/org/apache/druid/tests/indexer/AbstractIndexerTest.java b/integration-tests/src/test/java/org/apache/druid/tests/indexer/AbstractIndexerTest.java index d59c383bbcd..7f7819265d5 100644 --- a/integration-tests/src/test/java/org/apache/druid/tests/indexer/AbstractIndexerTest.java +++ b/integration-tests/src/test/java/org/apache/druid/tests/indexer/AbstractIndexerTest.java @@ -21,6 +21,7 @@ package org.apache.druid.tests.indexer; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.inject.Inject; +import org.apache.commons.io.IOUtils; import org.apache.druid.guice.annotations.Json; import org.apache.druid.guice.annotations.Smile; import org.apache.druid.java.util.common.Intervals; @@ -28,7 +29,6 @@ import org.apache.druid.testing.clients.CoordinatorResourceTestClient; import org.apache.druid.testing.clients.OverlordResourceTestClient; import org.apache.druid.testing.utils.RetryUtil; import org.apache.druid.testing.utils.TestQueryHelper; -import org.apache.commons.io.IOUtils; import org.joda.time.Interval; import java.io.Closeable; diff --git a/integration-tests/src/test/java/org/apache/druid/tests/indexer/ITKafkaIndexingServiceTest.java b/integration-tests/src/test/java/org/apache/druid/tests/indexer/ITKafkaIndexingServiceTest.java index 7b59721277a..2c42de8f776 100644 --- a/integration-tests/src/test/java/org/apache/druid/tests/indexer/ITKafkaIndexingServiceTest.java +++ b/integration-tests/src/test/java/org/apache/druid/tests/indexer/ITKafkaIndexingServiceTest.java @@ -21,6 +21,13 @@ package org.apache.druid.tests.indexer; import com.google.common.base.Throwables; import com.google.inject.Inject; +import kafka.admin.AdminUtils; +import kafka.admin.RackAwareMode; +import kafka.utils.ZKStringSerializer$; +import kafka.utils.ZkUtils; +import org.I0Itec.zkclient.ZkClient; +import org.I0Itec.zkclient.ZkConnection; +import org.apache.commons.io.IOUtils; import org.apache.druid.java.util.common.DateTimes; import org.apache.druid.java.util.common.ISE; import org.apache.druid.java.util.common.StringUtils; @@ -29,13 +36,6 @@ import org.apache.druid.testing.IntegrationTestingConfig; import org.apache.druid.testing.guice.DruidTestModuleFactory; import org.apache.druid.testing.utils.RetryUtil; import org.apache.druid.testing.utils.TestQueryHelper; -import kafka.admin.AdminUtils; -import kafka.admin.RackAwareMode; -import kafka.utils.ZKStringSerializer$; -import kafka.utils.ZkUtils; -import org.I0Itec.zkclient.ZkClient; -import org.I0Itec.zkclient.ZkConnection; -import org.apache.commons.io.IOUtils; import org.apache.kafka.clients.producer.KafkaProducer; import org.apache.kafka.clients.producer.ProducerRecord; import org.apache.kafka.common.serialization.StringSerializer; diff --git a/integration-tests/src/test/java/org/apache/druid/tests/indexer/ITKafkaTest.java b/integration-tests/src/test/java/org/apache/druid/tests/indexer/ITKafkaTest.java index b9ddcfc394d..90f21c235d0 100644 --- a/integration-tests/src/test/java/org/apache/druid/tests/indexer/ITKafkaTest.java +++ b/integration-tests/src/test/java/org/apache/druid/tests/indexer/ITKafkaTest.java @@ -21,6 +21,13 @@ package org.apache.druid.tests.indexer; import com.google.common.base.Throwables; import com.google.inject.Inject; +import kafka.admin.AdminUtils; +import kafka.admin.RackAwareMode; +import kafka.utils.ZKStringSerializer$; +import kafka.utils.ZkUtils; +import org.I0Itec.zkclient.ZkClient; +import org.I0Itec.zkclient.ZkConnection; +import org.apache.commons.io.IOUtils; import org.apache.druid.java.util.common.DateTimes; import org.apache.druid.java.util.common.ISE; import org.apache.druid.java.util.common.StringUtils; @@ -29,13 +36,6 @@ import org.apache.druid.testing.IntegrationTestingConfig; import org.apache.druid.testing.guice.DruidTestModuleFactory; import org.apache.druid.testing.utils.RetryUtil; import org.apache.druid.testing.utils.TestQueryHelper; -import kafka.admin.AdminUtils; -import kafka.admin.RackAwareMode; -import kafka.utils.ZKStringSerializer$; -import kafka.utils.ZkUtils; -import org.I0Itec.zkclient.ZkClient; -import org.I0Itec.zkclient.ZkConnection; -import org.apache.commons.io.IOUtils; import org.apache.kafka.clients.producer.KafkaProducer; import org.apache.kafka.clients.producer.ProducerRecord; import org.apache.kafka.common.serialization.StringSerializer; diff --git a/integration-tests/src/test/java/org/apache/druid/tests/security/ITBasicAuthConfigurationTest.java b/integration-tests/src/test/java/org/apache/druid/tests/security/ITBasicAuthConfigurationTest.java index 4e2d092d216..bc8c25032ef 100644 --- a/integration-tests/src/test/java/org/apache/druid/tests/security/ITBasicAuthConfigurationTest.java +++ b/integration-tests/src/test/java/org/apache/druid/tests/security/ITBasicAuthConfigurationTest.java @@ -23,6 +23,7 @@ import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.base.Throwables; import com.google.inject.Inject; +import org.apache.calcite.avatica.AvaticaSqlException; import org.apache.druid.guice.annotations.Client; import org.apache.druid.java.util.common.ISE; import org.apache.druid.java.util.common.StringUtils; @@ -41,7 +42,6 @@ import org.apache.druid.server.security.ResourceType; import org.apache.druid.sql.avatica.DruidAvaticaHandler; import org.apache.druid.testing.IntegrationTestingConfig; import org.apache.druid.testing.guice.DruidTestModuleFactory; -import org.apache.calcite.avatica.AvaticaSqlException; import org.jboss.netty.handler.codec.http.HttpMethod; import org.jboss.netty.handler.codec.http.HttpResponseStatus; import org.testng.Assert; diff --git a/java-util/src/main/java/org/apache/druid/java/util/common/CompressionUtils.java b/java-util/src/main/java/org/apache/druid/java/util/common/CompressionUtils.java index d5cd535d308..79e010aa40c 100644 --- a/java-util/src/main/java/org/apache/druid/java/util/common/CompressionUtils.java +++ b/java-util/src/main/java/org/apache/druid/java/util/common/CompressionUtils.java @@ -26,12 +26,12 @@ import com.google.common.io.ByteSink; import com.google.common.io.ByteSource; import com.google.common.io.ByteStreams; import com.google.common.io.Files; -import org.apache.druid.java.util.common.io.NativeIO; -import org.apache.druid.java.util.common.logger.Logger; import org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream; import org.apache.commons.compress.compressors.snappy.FramedSnappyCompressorInputStream; import org.apache.commons.compress.compressors.xz.XZCompressorInputStream; import org.apache.commons.compress.compressors.zstandard.ZstdCompressorInputStream; +import org.apache.druid.java.util.common.io.NativeIO; +import org.apache.druid.java.util.common.logger.Logger; import java.io.BufferedInputStream; import java.io.ByteArrayInputStream; diff --git a/java-util/src/main/java/org/apache/druid/java/util/common/io/NativeIO.java b/java-util/src/main/java/org/apache/druid/java/util/common/io/NativeIO.java index a9816df542e..9eb5d7d68f2 100644 --- a/java-util/src/main/java/org/apache/druid/java/util/common/io/NativeIO.java +++ b/java-util/src/main/java/org/apache/druid/java/util/common/io/NativeIO.java @@ -19,6 +19,12 @@ package org.apache.druid.java.util.common.io; +import com.google.common.annotations.VisibleForTesting; +import com.sun.jna.LastErrorException; +import com.sun.jna.Native; +import com.sun.jna.Platform; +import org.apache.druid.java.util.common.logger.Logger; + import java.io.File; import java.io.FileDescriptor; import java.io.IOException; @@ -26,12 +32,6 @@ import java.io.InputStream; import java.io.RandomAccessFile; import java.lang.reflect.Field; -import com.google.common.annotations.VisibleForTesting; -import com.sun.jna.LastErrorException; -import com.sun.jna.Native; -import com.sun.jna.Platform; -import org.apache.druid.java.util.common.logger.Logger; - /** * Native I/O operations in order to minimize cache impact. */ diff --git a/java-util/src/main/java/org/apache/druid/java/util/common/parsers/JSONFlattenerMaker.java b/java-util/src/main/java/org/apache/druid/java/util/common/parsers/JSONFlattenerMaker.java index 805dc540b1d..d16280a8831 100644 --- a/java-util/src/main/java/org/apache/druid/java/util/common/parsers/JSONFlattenerMaker.java +++ b/java-util/src/main/java/org/apache/druid/java/util/common/parsers/JSONFlattenerMaker.java @@ -26,9 +26,9 @@ import com.jayway.jsonpath.JsonPath; import com.jayway.jsonpath.Option; import com.jayway.jsonpath.spi.json.JacksonJsonNodeJsonProvider; import com.jayway.jsonpath.spi.mapper.JacksonMappingProvider; -import org.apache.druid.java.util.common.StringUtils; import net.thisptr.jackson.jq.JsonQuery; import net.thisptr.jackson.jq.exception.JsonQueryException; +import org.apache.druid.java.util.common.StringUtils; import javax.annotation.Nullable; import java.nio.charset.CharsetEncoder; diff --git a/java-util/src/main/java/org/apache/druid/java/util/emitter/core/HttpPostEmitter.java b/java-util/src/main/java/org/apache/druid/java/util/emitter/core/HttpPostEmitter.java index 57f9cf2bfd1..8f4951efe19 100644 --- a/java-util/src/main/java/org/apache/druid/java/util/emitter/core/HttpPostEmitter.java +++ b/java-util/src/main/java/org/apache/druid/java/util/emitter/core/HttpPostEmitter.java @@ -25,6 +25,7 @@ import com.google.common.base.Preconditions; import com.google.common.base.Predicate; import com.google.common.base.Throwables; import com.google.common.primitives.Ints; +import io.netty.handler.codec.http.HttpHeaders; import org.apache.druid.concurrent.ConcurrentAwaitableCounter; import org.apache.druid.java.util.common.ISE; import org.apache.druid.java.util.common.RetryUtils; @@ -32,7 +33,6 @@ import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.java.util.common.lifecycle.LifecycleStart; import org.apache.druid.java.util.common.lifecycle.LifecycleStop; import org.apache.druid.java.util.common.logger.Logger; -import io.netty.handler.codec.http.HttpHeaders; import org.asynchttpclient.AsyncHttpClient; import org.asynchttpclient.ListenableFuture; import org.asynchttpclient.RequestBuilder; diff --git a/java-util/src/test/java/org/apache/druid/java/util/common/io/smoosh/SmooshedFileMapperTest.java b/java-util/src/test/java/org/apache/druid/java/util/common/io/smoosh/SmooshedFileMapperTest.java index 38510f87eac..46851bbe1ff 100644 --- a/java-util/src/test/java/org/apache/druid/java/util/common/io/smoosh/SmooshedFileMapperTest.java +++ b/java-util/src/test/java/org/apache/druid/java/util/common/io/smoosh/SmooshedFileMapperTest.java @@ -21,10 +21,10 @@ package org.apache.druid.java.util.common.io.smoosh; import com.google.common.io.Files; import com.google.common.primitives.Ints; +import junit.framework.Assert; import org.apache.druid.java.util.common.BufferUtils; import org.apache.druid.java.util.common.ISE; import org.apache.druid.java.util.common.StringUtils; -import junit.framework.Assert; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; diff --git a/java-util/src/test/java/org/apache/druid/java/util/emitter/core/EmitterTest.java b/java-util/src/test/java/org/apache/druid/java/util/emitter/core/EmitterTest.java index fe961bbf54a..c80736313e6 100644 --- a/java-util/src/test/java/org/apache/druid/java/util/emitter/core/EmitterTest.java +++ b/java-util/src/test/java/org/apache/druid/java/util/emitter/core/EmitterTest.java @@ -22,15 +22,15 @@ package org.apache.druid.java.util.emitter.core; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.io.BaseEncoding; -import org.apache.druid.java.util.common.CompressionUtils; -import org.apache.druid.java.util.common.StringUtils; -import org.apache.druid.java.util.common.lifecycle.Lifecycle; -import org.apache.druid.java.util.emitter.service.UnitEvent; import io.netty.buffer.Unpooled; import io.netty.handler.codec.http.DefaultHttpResponse; import io.netty.handler.codec.http.HttpHeaders; import io.netty.handler.codec.http.HttpResponseStatus; import io.netty.handler.codec.http.HttpVersion; +import org.apache.druid.java.util.common.CompressionUtils; +import org.apache.druid.java.util.common.StringUtils; +import org.apache.druid.java.util.common.lifecycle.Lifecycle; +import org.apache.druid.java.util.emitter.service.UnitEvent; import org.asynchttpclient.DefaultAsyncHttpClientConfig; import org.asynchttpclient.ListenableFuture; import org.asynchttpclient.Request; diff --git a/java-util/src/test/java/org/apache/druid/java/util/emitter/core/HttpPostEmitterStressTest.java b/java-util/src/test/java/org/apache/druid/java/util/emitter/core/HttpPostEmitterStressTest.java index 0030ef96e98..08e5d9d9043 100644 --- a/java-util/src/test/java/org/apache/druid/java/util/emitter/core/HttpPostEmitterStressTest.java +++ b/java-util/src/test/java/org/apache/druid/java/util/emitter/core/HttpPostEmitterStressTest.java @@ -21,9 +21,9 @@ package org.apache.druid.java.util.emitter.core; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.primitives.Ints; -import org.apache.druid.java.util.emitter.service.ServiceMetricEvent; import it.unimi.dsi.fastutil.ints.IntArrayList; import it.unimi.dsi.fastutil.ints.IntList; +import org.apache.druid.java.util.emitter.service.ServiceMetricEvent; import org.asynchttpclient.ListenableFuture; import org.asynchttpclient.Request; import org.asynchttpclient.Response; diff --git a/pom.xml b/pom.xml index f81c21cb7b6..9d127d7664e 100644 --- a/pom.xml +++ b/pom.xml @@ -749,7 +749,7 @@ junit junit - 4.11 + 4.12 test @@ -1035,6 +1035,7 @@ -Ddruid.indexing.doubleStorage=double + false true diff --git a/processing/src/main/java/org/apache/druid/collections/bitmap/ConciseBitmapFactory.java b/processing/src/main/java/org/apache/druid/collections/bitmap/ConciseBitmapFactory.java index be83bb3e964..a6cbb568cde 100644 --- a/processing/src/main/java/org/apache/druid/collections/bitmap/ConciseBitmapFactory.java +++ b/processing/src/main/java/org/apache/druid/collections/bitmap/ConciseBitmapFactory.java @@ -105,7 +105,7 @@ public class ConciseBitmapFactory implements BitmapFactory @Override public ImmutableBitmap mapImmutableBitmap(ByteBuffer b) { - return new WrappedImmutableConciseBitmap(b); + return new WrappedImmutableConciseBitmap(b.asIntBuffer()); } @Override diff --git a/processing/src/main/java/org/apache/druid/collections/bitmap/WrappedImmutableConciseBitmap.java b/processing/src/main/java/org/apache/druid/collections/bitmap/WrappedImmutableConciseBitmap.java index 6710b1097ab..19d3ac39ac9 100644 --- a/processing/src/main/java/org/apache/druid/collections/bitmap/WrappedImmutableConciseBitmap.java +++ b/processing/src/main/java/org/apache/druid/collections/bitmap/WrappedImmutableConciseBitmap.java @@ -23,7 +23,7 @@ package org.apache.druid.collections.bitmap; import org.apache.druid.extendedset.intset.ImmutableConciseSet; import org.roaringbitmap.IntIterator; -import java.nio.ByteBuffer; +import java.nio.IntBuffer; public class WrappedImmutableConciseBitmap implements ImmutableBitmap { @@ -32,9 +32,9 @@ public class WrappedImmutableConciseBitmap implements ImmutableBitmap */ private final ImmutableConciseSet bitmap; - public WrappedImmutableConciseBitmap(ByteBuffer byteBuffer) + public WrappedImmutableConciseBitmap(IntBuffer buffer) { - this.bitmap = new ImmutableConciseSet(byteBuffer); + this.bitmap = new ImmutableConciseSet(buffer); } /** diff --git a/processing/src/main/java/org/apache/druid/collections/spatial/ImmutableRTree.java b/processing/src/main/java/org/apache/druid/collections/spatial/ImmutableRTree.java index b9e62d2d0f0..31955cfd9d0 100644 --- a/processing/src/main/java/org/apache/druid/collections/spatial/ImmutableRTree.java +++ b/processing/src/main/java/org/apache/druid/collections/spatial/ImmutableRTree.java @@ -21,6 +21,7 @@ package org.apache.druid.collections.spatial; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; +import it.unimi.dsi.fastutil.bytes.ByteArrays; import org.apache.druid.collections.bitmap.BitmapFactory; import org.apache.druid.collections.bitmap.ImmutableBitmap; import org.apache.druid.collections.spatial.search.Bound; @@ -28,7 +29,6 @@ import org.apache.druid.collections.spatial.search.GutmanSearchStrategy; import org.apache.druid.collections.spatial.search.SearchStrategy; import org.apache.druid.io.Channels; import org.apache.druid.segment.writeout.WriteOutBytes; -import it.unimi.dsi.fastutil.bytes.ByteArrays; import java.io.IOException; import java.nio.ByteBuffer; @@ -36,7 +36,7 @@ import java.nio.ByteBuffer; /** * An immutable representation of an {@link RTree} for spatial indexing. */ -public final class ImmutableRTree +public final class ImmutableRTree implements Comparable { private static final byte VERSION = 0x0; @@ -61,7 +61,6 @@ public final class ImmutableRTree public ImmutableRTree(ByteBuffer data, BitmapFactory bitmapFactory) { - data = data.asReadOnlyBuffer(); final int initPosition = data.position(); Preconditions.checkArgument(data.get(initPosition) == VERSION, "Mismatching versions"); this.numDims = data.getInt(1 + initPosition) & 0x7FFF; @@ -75,7 +74,7 @@ public final class ImmutableRTree return empty(); } - ByteBuffer buffer = ByteBuffer.wrap(new byte[calcNumBytes(rTree)]); + ByteBuffer buffer = ByteBuffer.allocate(calcNumBytes(rTree)); buffer.put(VERSION); buffer.putInt(rTree.getNumDims()); @@ -149,8 +148,21 @@ public final class ImmutableRTree } } + @Override public int compareTo(ImmutableRTree other) { return this.data.compareTo(other.data); } + + @Override + public boolean equals(Object obj) + { + return obj instanceof ImmutableRTree && data.equals(((ImmutableRTree) obj).data); + } + + @Override + public int hashCode() + { + return data.hashCode(); + } } diff --git a/processing/src/main/java/org/apache/druid/query/ColumnSelectorPlus.java b/processing/src/main/java/org/apache/druid/query/ColumnSelectorPlus.java index d2dba151135..89f20e5887d 100644 --- a/processing/src/main/java/org/apache/druid/query/ColumnSelectorPlus.java +++ b/processing/src/main/java/org/apache/druid/query/ColumnSelectorPlus.java @@ -46,7 +46,7 @@ public class ColumnSelectorPlus extends ColumnValueSelector * * @see AggregatorFactory#combine */ - @SuppressWarnings("unused") // Going to be used when https://github.com/apache/incubator-druid/projects/2 is complete void fold(ColumnValueSelector selector); @Override diff --git a/processing/src/main/java/org/apache/druid/query/aggregation/AggregatorUtil.java b/processing/src/main/java/org/apache/druid/query/aggregation/AggregatorUtil.java index 0e1be64c1b0..33a8296ad12 100644 --- a/processing/src/main/java/org/apache/druid/query/aggregation/AggregatorUtil.java +++ b/processing/src/main/java/org/apache/druid/query/aggregation/AggregatorUtil.java @@ -37,6 +37,7 @@ import org.apache.druid.segment.FloatColumnSelector; import org.apache.druid.segment.LongColumnSelector; import org.apache.druid.segment.virtual.ExpressionSelectors; +import javax.annotation.Nullable; import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; @@ -112,8 +113,8 @@ public class AggregatorUtil /** * returns the list of dependent postAggregators that should be calculated in order to calculate given postAgg * - * @param postAggregatorList List of postAggregator, there is a restriction that the list should be in an order - * such that all the dependencies of any given aggregator should occur before that aggregator. + * @param postAggregatorList List of postAggregator, there is a restriction that the list should be in an order such + * that all the dependencies of any given aggregator should occur before that aggregator. * See AggregatorUtilTest.testOutOfOrderPruneDependentPostAgg for example. * @param postAggName name of the postAgg on which dependency is to be calculated * @@ -162,18 +163,23 @@ public class AggregatorUtil return new Pair<>(condensedAggs, condensedPostAggs); } - public static BaseFloatColumnValueSelector makeColumnValueSelectorWithFloatDefault( + /** + * Only one of fieldName and fieldExpression should be non-null + */ + static BaseFloatColumnValueSelector makeColumnValueSelectorWithFloatDefault( final ColumnSelectorFactory metricFactory, final ExprMacroTable macroTable, - final String fieldName, - final String fieldExpression, + @Nullable final String fieldName, + @Nullable final String fieldExpression, final float nullValue ) { - if (fieldName != null && fieldExpression == null) { - return metricFactory.makeColumnValueSelector(fieldName); + if ((fieldName == null) == (fieldExpression == null)) { + throw new IllegalArgumentException("Only one of fieldName and fieldExpression should be non-null"); } - if (fieldName == null && fieldExpression != null) { + if (fieldName != null) { + return metricFactory.makeColumnValueSelector(fieldName); + } else { final Expr expr = Parser.parse(fieldExpression, macroTable); final ColumnValueSelector baseSelector = ExpressionSelectors.makeExprEvalSelector(metricFactory, expr); class ExpressionFloatColumnSelector implements FloatColumnSelector @@ -202,21 +208,25 @@ public class AggregatorUtil } return new ExpressionFloatColumnSelector(); } - throw new IllegalArgumentException("Must have a valid, non-null fieldName or expression"); } - public static BaseLongColumnValueSelector makeColumnValueSelectorWithLongDefault( + /** + * Only one of fieldName and fieldExpression should be non-null + */ + static BaseLongColumnValueSelector makeColumnValueSelectorWithLongDefault( final ColumnSelectorFactory metricFactory, final ExprMacroTable macroTable, - final String fieldName, - final String fieldExpression, + @Nullable final String fieldName, + @Nullable final String fieldExpression, final long nullValue ) { - if (fieldName != null && fieldExpression == null) { - return metricFactory.makeColumnValueSelector(fieldName); + if ((fieldName == null) == (fieldExpression == null)) { + throw new IllegalArgumentException("Only one of fieldName and fieldExpression should be non-null"); } - if (fieldName == null && fieldExpression != null) { + if (fieldName != null) { + return metricFactory.makeColumnValueSelector(fieldName); + } else { final Expr expr = Parser.parse(fieldExpression, macroTable); final ColumnValueSelector baseSelector = ExpressionSelectors.makeExprEvalSelector(metricFactory, expr); class ExpressionLongColumnSelector implements LongColumnSelector @@ -243,21 +253,25 @@ public class AggregatorUtil } return new ExpressionLongColumnSelector(); } - throw new IllegalArgumentException("Must have a valid, non-null fieldName or expression"); } - public static BaseDoubleColumnValueSelector makeColumnValueSelectorWithDoubleDefault( + /** + * Only one of fieldName and fieldExpression should be non-null + */ + static BaseDoubleColumnValueSelector makeColumnValueSelectorWithDoubleDefault( final ColumnSelectorFactory metricFactory, final ExprMacroTable macroTable, - final String fieldName, - final String fieldExpression, + @Nullable final String fieldName, + @Nullable final String fieldExpression, final double nullValue ) { - if (fieldName != null && fieldExpression == null) { - return metricFactory.makeColumnValueSelector(fieldName); + if ((fieldName == null) == (fieldExpression == null)) { + throw new IllegalArgumentException("Only one of fieldName and fieldExpression should be non-null"); } - if (fieldName == null && fieldExpression != null) { + if (fieldName != null) { + return metricFactory.makeColumnValueSelector(fieldName); + } else { final Expr expr = Parser.parse(fieldExpression, macroTable); final ColumnValueSelector baseSelector = ExpressionSelectors.makeExprEvalSelector(metricFactory, expr); class ExpressionDoubleColumnSelector implements DoubleColumnSelector @@ -284,6 +298,5 @@ public class AggregatorUtil } return new ExpressionDoubleColumnSelector(); } - throw new IllegalArgumentException("Must have a valid, non-null fieldName or expression"); } } diff --git a/processing/src/main/java/org/apache/druid/query/aggregation/FilteredAggregatorFactory.java b/processing/src/main/java/org/apache/druid/query/aggregation/FilteredAggregatorFactory.java index e9c8573d0d9..313bec1dfce 100644 --- a/processing/src/main/java/org/apache/druid/query/aggregation/FilteredAggregatorFactory.java +++ b/processing/src/main/java/org/apache/druid/query/aggregation/FilteredAggregatorFactory.java @@ -26,7 +26,7 @@ import org.apache.druid.query.filter.DimFilter; import org.apache.druid.query.filter.IntervalDimFilter; import org.apache.druid.query.filter.ValueMatcher; import org.apache.druid.segment.ColumnSelectorFactory; -import org.apache.druid.segment.column.Column; +import org.apache.druid.segment.column.ColumnHolder; import org.apache.druid.segment.filter.Filters; import org.joda.time.Interval; @@ -155,7 +155,7 @@ public class FilteredAggregatorFactory extends AggregatorFactory return this; } - if (!intervalDimFilter.getDimension().equals(Column.TIME_COLUMN_NAME)) { + if (!intervalDimFilter.getDimension().equals(ColumnHolder.TIME_COLUMN_NAME)) { // segment time boundary optimization only applies when we filter on __time return this; } diff --git a/processing/src/main/java/org/apache/druid/query/aggregation/HistogramAggregatorFactory.java b/processing/src/main/java/org/apache/druid/query/aggregation/HistogramAggregatorFactory.java index 7e2d0743714..8838442b231 100644 --- a/processing/src/main/java/org/apache/druid/query/aggregation/HistogramAggregatorFactory.java +++ b/processing/src/main/java/org/apache/druid/query/aggregation/HistogramAggregatorFactory.java @@ -23,10 +23,10 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.google.common.base.Preconditions; import com.google.common.collect.Lists; +import org.apache.commons.codec.binary.Base64; import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.segment.ColumnSelectorFactory; import org.apache.druid.segment.ColumnValueSelector; -import org.apache.commons.codec.binary.Base64; import javax.annotation.Nullable; import java.nio.ByteBuffer; diff --git a/processing/src/main/java/org/apache/druid/query/aggregation/JavaScriptAggregatorFactory.java b/processing/src/main/java/org/apache/druid/query/aggregation/JavaScriptAggregatorFactory.java index 91ebafaa109..e747ad68d73 100644 --- a/processing/src/main/java/org/apache/druid/query/aggregation/JavaScriptAggregatorFactory.java +++ b/processing/src/main/java/org/apache/druid/query/aggregation/JavaScriptAggregatorFactory.java @@ -27,6 +27,7 @@ import com.google.common.base.Joiner; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; +import it.unimi.dsi.fastutil.objects.ObjectArrays; import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.js.JavaScriptConfig; import org.apache.druid.segment.BaseObjectColumnValueSelector; @@ -339,11 +340,11 @@ public class JavaScriptAggregatorFactory extends AggregatorFactory if (arg != null && arg.getClass().isArray()) { // Context.javaToJS on an array sort of works, although it returns false for Array.isArray(...) and // may have other issues too. Let's just copy the array and wrap that. - final Object[] arrayAsObjectArray = new Object[Array.getLength(arg)]; - for (int j = 0; j < Array.getLength(arg); j++) { - arrayAsObjectArray[j] = Array.get(arg, j); - } - args[i + 1] = cx.newArray(scope, arrayAsObjectArray); + args[i + 1] = cx.newArray(scope, arrayToObjectArray(arg)); + } else if (arg instanceof List) { + // Using toArray(Object[]), instead of just toArray(), because Arrays.asList()'s impl and similar List + // impls could clone the underlying array in toArray(), that could be not Object[], but e. g. String[]. + args[i + 1] = cx.newArray(scope, ((List) arg).toArray(ObjectArrays.EMPTY_ARRAY)); } else { args[i + 1] = Context.javaToJS(arg, scope); } @@ -354,6 +355,16 @@ public class JavaScriptAggregatorFactory extends AggregatorFactory return Context.toNumber(res); } + private Object[] arrayToObjectArray(Object array) + { + int len = Array.getLength(array); + final Object[] objectArray = new Object[len]; + for (int j = 0; j < len; j++) { + objectArray[j] = Array.get(array, j); + } + return objectArray; + } + @Override public double combine(final double a, final double b) { diff --git a/processing/src/main/java/org/apache/druid/query/aggregation/SerializablePairLongStringSerde.java b/processing/src/main/java/org/apache/druid/query/aggregation/SerializablePairLongStringSerde.java index 26b0b816054..ab40ec7a189 100644 --- a/processing/src/main/java/org/apache/druid/query/aggregation/SerializablePairLongStringSerde.java +++ b/processing/src/main/java/org/apache/druid/query/aggregation/SerializablePairLongStringSerde.java @@ -76,7 +76,7 @@ public class SerializablePairLongStringSerde extends ComplexMetricSerde public void deserializeColumn(ByteBuffer buffer, ColumnBuilder columnBuilder) { final GenericIndexed column = GenericIndexed.read(buffer, getObjectStrategy(), columnBuilder.getFileMapper()); - columnBuilder.setComplexColumn(new ComplexColumnPartSupplier(getTypeName(), column)); + columnBuilder.setComplexColumnSupplier(new ComplexColumnPartSupplier(getTypeName(), column)); } @Override diff --git a/processing/src/main/java/org/apache/druid/query/aggregation/SimpleDoubleAggregatorFactory.java b/processing/src/main/java/org/apache/druid/query/aggregation/SimpleDoubleAggregatorFactory.java index 32c598cc57a..9dc8a2d99c4 100644 --- a/processing/src/main/java/org/apache/druid/query/aggregation/SimpleDoubleAggregatorFactory.java +++ b/processing/src/main/java/org/apache/druid/query/aggregation/SimpleDoubleAggregatorFactory.java @@ -26,7 +26,7 @@ import org.apache.druid.math.expr.ExprMacroTable; import org.apache.druid.math.expr.Parser; import org.apache.druid.segment.BaseDoubleColumnValueSelector; import org.apache.druid.segment.ColumnSelectorFactory; -import org.apache.druid.segment.column.Column; +import org.apache.druid.segment.column.ColumnHolder; import javax.annotation.Nullable; import java.util.Collections; @@ -37,7 +37,9 @@ import java.util.Objects; public abstract class SimpleDoubleAggregatorFactory extends NullableAggregatorFactory { protected final String name; + @Nullable protected final String fieldName; + @Nullable protected final String expression; protected final ExprMacroTable macroTable; protected final boolean storeDoubleAsFloat; @@ -45,15 +47,15 @@ public abstract class SimpleDoubleAggregatorFactory extends NullableAggregatorFa public SimpleDoubleAggregatorFactory( ExprMacroTable macroTable, String name, - final String fieldName, - String expression + @Nullable final String fieldName, + @Nullable String expression ) { this.macroTable = macroTable; this.name = name; this.fieldName = fieldName; this.expression = expression; - this.storeDoubleAsFloat = Column.storeDoubleAsFloat(); + this.storeDoubleAsFloat = ColumnHolder.storeDoubleAsFloat(); Preconditions.checkNotNull(name, "Must have a valid, non-null aggregator name"); Preconditions.checkArgument( fieldName == null ^ expression == null, @@ -165,12 +167,14 @@ public abstract class SimpleDoubleAggregatorFactory extends NullableAggregatorFa return name; } + @Nullable @JsonProperty public String getFieldName() { return fieldName; } + @Nullable @JsonProperty public String getExpression() { diff --git a/processing/src/main/java/org/apache/druid/query/aggregation/SimpleFloatAggregatorFactory.java b/processing/src/main/java/org/apache/druid/query/aggregation/SimpleFloatAggregatorFactory.java index 3f05c44bb0b..c535088c098 100644 --- a/processing/src/main/java/org/apache/druid/query/aggregation/SimpleFloatAggregatorFactory.java +++ b/processing/src/main/java/org/apache/druid/query/aggregation/SimpleFloatAggregatorFactory.java @@ -36,15 +36,17 @@ import java.util.Objects; public abstract class SimpleFloatAggregatorFactory extends NullableAggregatorFactory { protected final String name; + @Nullable protected final String fieldName; + @Nullable protected final String expression; protected final ExprMacroTable macroTable; public SimpleFloatAggregatorFactory( ExprMacroTable macroTable, String name, - final String fieldName, - String expression + @Nullable final String fieldName, + @Nullable String expression ) { this.macroTable = macroTable; @@ -159,12 +161,14 @@ public abstract class SimpleFloatAggregatorFactory extends NullableAggregatorFac return name; } + @Nullable @JsonProperty public String getFieldName() { return fieldName; } + @Nullable @JsonProperty public String getExpression() { diff --git a/processing/src/main/java/org/apache/druid/query/aggregation/SimpleLongAggregatorFactory.java b/processing/src/main/java/org/apache/druid/query/aggregation/SimpleLongAggregatorFactory.java index d023d609124..ec7e2221c81 100644 --- a/processing/src/main/java/org/apache/druid/query/aggregation/SimpleLongAggregatorFactory.java +++ b/processing/src/main/java/org/apache/druid/query/aggregation/SimpleLongAggregatorFactory.java @@ -36,15 +36,17 @@ import java.util.Objects; public abstract class SimpleLongAggregatorFactory extends NullableAggregatorFactory { protected final String name; + @Nullable protected final String fieldName; + @Nullable protected final String expression; protected final ExprMacroTable macroTable; public SimpleLongAggregatorFactory( ExprMacroTable macroTable, String name, - final String fieldName, - String expression + @Nullable final String fieldName, + @Nullable String expression ) { this.macroTable = macroTable; @@ -155,12 +157,14 @@ public abstract class SimpleLongAggregatorFactory extends NullableAggregatorFact return name; } + @Nullable @JsonProperty public String getFieldName() { return fieldName; } + @Nullable @JsonProperty public String getExpression() { diff --git a/processing/src/main/java/org/apache/druid/query/aggregation/cardinality/CardinalityAggregatorFactory.java b/processing/src/main/java/org/apache/druid/query/aggregation/cardinality/CardinalityAggregatorFactory.java index 6bf3e5785b8..a96b7cde0db 100644 --- a/processing/src/main/java/org/apache/druid/query/aggregation/cardinality/CardinalityAggregatorFactory.java +++ b/processing/src/main/java/org/apache/druid/query/aggregation/cardinality/CardinalityAggregatorFactory.java @@ -25,6 +25,7 @@ import com.google.common.base.Function; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; +import org.apache.commons.codec.binary.Base64; import org.apache.druid.hll.HyperLogLogCollector; import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.query.ColumnSelectorPlus; @@ -43,7 +44,6 @@ import org.apache.druid.query.dimension.DefaultDimensionSpec; import org.apache.druid.query.dimension.DimensionSpec; import org.apache.druid.segment.ColumnSelectorFactory; import org.apache.druid.segment.DimensionHandlerUtils; -import org.apache.commons.codec.binary.Base64; import java.nio.ByteBuffer; import java.util.Collections; diff --git a/processing/src/main/java/org/apache/druid/query/aggregation/first/DoubleFirstAggregatorFactory.java b/processing/src/main/java/org/apache/druid/query/aggregation/first/DoubleFirstAggregatorFactory.java index f4cd9d42851..8782e1235cd 100644 --- a/processing/src/main/java/org/apache/druid/query/aggregation/first/DoubleFirstAggregatorFactory.java +++ b/processing/src/main/java/org/apache/druid/query/aggregation/first/DoubleFirstAggregatorFactory.java @@ -22,8 +22,6 @@ package org.apache.druid.query.aggregation.first; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.google.common.base.Preconditions; -import com.google.common.primitives.Doubles; -import com.google.common.primitives.Longs; import org.apache.druid.collections.SerializablePair; import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.java.util.common.UOE; @@ -36,7 +34,7 @@ import org.apache.druid.query.aggregation.NullableAggregatorFactory; import org.apache.druid.query.monomorphicprocessing.RuntimeShapeInspector; import org.apache.druid.segment.ColumnSelectorFactory; import org.apache.druid.segment.ColumnValueSelector; -import org.apache.druid.segment.column.Column; +import org.apache.druid.segment.column.ColumnHolder; import javax.annotation.Nullable; import java.nio.ByteBuffer; @@ -49,15 +47,8 @@ import java.util.Objects; public class DoubleFirstAggregatorFactory extends NullableAggregatorFactory { - public static final Comparator VALUE_COMPARATOR = (o1, o2) -> Doubles.compare( - ((SerializablePair) o1).rhs, - ((SerializablePair) o2).rhs - ); - - public static final Comparator TIME_COMPARATOR = (o1, o2) -> Longs.compare( - ((SerializablePair) o1).lhs, - ((SerializablePair) o2).lhs - ); + public static final Comparator> VALUE_COMPARATOR = + Comparator.comparingDouble(o -> o.rhs); private final String fieldName; private final String name; @@ -74,7 +65,7 @@ public class DoubleFirstAggregatorFactory extends NullableAggregatorFactory) lhs).lhs; + Long rightTime = ((SerializablePair) rhs).lhs; + if (leftTime <= rightTime) { + return lhs; + } else { + return rhs; + } } @Override @@ -210,7 +204,7 @@ public class DoubleFirstAggregatorFactory extends NullableAggregatorFactory requiredFields() { - return Arrays.asList(Column.TIME_COLUMN_NAME, fieldName); + return Arrays.asList(ColumnHolder.TIME_COLUMN_NAME, fieldName); } @Override diff --git a/processing/src/main/java/org/apache/druid/query/aggregation/first/FloatFirstAggregatorFactory.java b/processing/src/main/java/org/apache/druid/query/aggregation/first/FloatFirstAggregatorFactory.java index 2c9a6f580e7..d7ddb4b3bf5 100644 --- a/processing/src/main/java/org/apache/druid/query/aggregation/first/FloatFirstAggregatorFactory.java +++ b/processing/src/main/java/org/apache/druid/query/aggregation/first/FloatFirstAggregatorFactory.java @@ -22,8 +22,6 @@ package org.apache.druid.query.aggregation.first; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.google.common.base.Preconditions; -import com.google.common.primitives.Doubles; -import com.google.common.primitives.Longs; import org.apache.druid.collections.SerializablePair; import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.java.util.common.UOE; @@ -36,7 +34,7 @@ import org.apache.druid.query.aggregation.NullableAggregatorFactory; import org.apache.druid.query.monomorphicprocessing.RuntimeShapeInspector; import org.apache.druid.segment.ColumnSelectorFactory; import org.apache.druid.segment.ColumnValueSelector; -import org.apache.druid.segment.column.Column; +import org.apache.druid.segment.column.ColumnHolder; import javax.annotation.Nullable; import java.nio.ByteBuffer; @@ -49,15 +47,8 @@ import java.util.Objects; public class FloatFirstAggregatorFactory extends NullableAggregatorFactory { - public static final Comparator VALUE_COMPARATOR = (o1, o2) -> Doubles.compare( - ((SerializablePair) o1).rhs, - ((SerializablePair) o2).rhs - ); - - public static final Comparator TIME_COMPARATOR = (o1, o2) -> Longs.compare( - ((SerializablePair) o1).lhs, - ((SerializablePair) o2).lhs - ); + public static final Comparator> VALUE_COMPARATOR = + Comparator.comparingDouble(o -> o.rhs); private final String fieldName; private final String name; @@ -84,17 +75,14 @@ public class FloatFirstAggregatorFactory extends NullableAggregatorFactory) lhs).lhs; + Long rightTime = ((SerializablePair) rhs).lhs; + if (leftTime <= rightTime) { + return lhs; + } else { + return rhs; + } } @Override @@ -208,7 +202,7 @@ public class FloatFirstAggregatorFactory extends NullableAggregatorFactory requiredFields() { - return Arrays.asList(Column.TIME_COLUMN_NAME, fieldName); + return Arrays.asList(ColumnHolder.TIME_COLUMN_NAME, fieldName); } @Override diff --git a/processing/src/main/java/org/apache/druid/query/aggregation/first/LongFirstAggregatorFactory.java b/processing/src/main/java/org/apache/druid/query/aggregation/first/LongFirstAggregatorFactory.java index 1313dedeaf2..6289b8c8fbc 100644 --- a/processing/src/main/java/org/apache/druid/query/aggregation/first/LongFirstAggregatorFactory.java +++ b/processing/src/main/java/org/apache/druid/query/aggregation/first/LongFirstAggregatorFactory.java @@ -22,7 +22,6 @@ package org.apache.druid.query.aggregation.first; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.google.common.base.Preconditions; -import com.google.common.primitives.Longs; import org.apache.druid.collections.SerializablePair; import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.java.util.common.UOE; @@ -35,7 +34,7 @@ import org.apache.druid.query.aggregation.NullableAggregatorFactory; import org.apache.druid.query.monomorphicprocessing.RuntimeShapeInspector; import org.apache.druid.segment.ColumnSelectorFactory; import org.apache.druid.segment.ColumnValueSelector; -import org.apache.druid.segment.column.Column; +import org.apache.druid.segment.column.ColumnHolder; import javax.annotation.Nullable; import java.nio.ByteBuffer; @@ -47,10 +46,8 @@ import java.util.Map; public class LongFirstAggregatorFactory extends NullableAggregatorFactory { - public static final Comparator VALUE_COMPARATOR = (o1, o2) -> Longs.compare( - ((SerializablePair) o1).rhs, - ((SerializablePair) o2).rhs - ); + public static final Comparator> VALUE_COMPARATOR = + Comparator.comparingLong(o -> o.rhs); private final String fieldName; private final String name; @@ -77,17 +74,14 @@ public class LongFirstAggregatorFactory extends NullableAggregatorFactory) lhs).lhs; + Long rightTime = ((SerializablePair) rhs).lhs; + if (leftTime <= rightTime) { + return lhs; + } else { + return rhs; + } } @Override @@ -201,7 +201,7 @@ public class LongFirstAggregatorFactory extends NullableAggregatorFactory requiredFields() { - return Arrays.asList(Column.TIME_COLUMN_NAME, fieldName); + return Arrays.asList(ColumnHolder.TIME_COLUMN_NAME, fieldName); } @Override diff --git a/processing/src/main/java/org/apache/druid/query/aggregation/first/StringFirstAggregatorFactory.java b/processing/src/main/java/org/apache/druid/query/aggregation/first/StringFirstAggregatorFactory.java index 350f271b3b6..0a898bfc8e3 100644 --- a/processing/src/main/java/org/apache/druid/query/aggregation/first/StringFirstAggregatorFactory.java +++ b/processing/src/main/java/org/apache/druid/query/aggregation/first/StringFirstAggregatorFactory.java @@ -34,7 +34,7 @@ import org.apache.druid.query.aggregation.SerializablePairLongString; import org.apache.druid.query.cache.CacheKeyBuilder; import org.apache.druid.segment.BaseObjectColumnValueSelector; import org.apache.druid.segment.ColumnSelectorFactory; -import org.apache.druid.segment.column.Column; +import org.apache.druid.segment.column.ColumnHolder; import java.util.Arrays; import java.util.Collections; @@ -118,7 +118,7 @@ public class StringFirstAggregatorFactory extends NullableAggregatorFactory requiredFields() { - return Arrays.asList(Column.TIME_COLUMN_NAME, fieldName); + return Arrays.asList(ColumnHolder.TIME_COLUMN_NAME, fieldName); } @Override diff --git a/processing/src/main/java/org/apache/druid/query/aggregation/hyperloglog/HyperUniquesAggregatorFactory.java b/processing/src/main/java/org/apache/druid/query/aggregation/hyperloglog/HyperUniquesAggregatorFactory.java index 628019edf93..05a08180952 100644 --- a/processing/src/main/java/org/apache/druid/query/aggregation/hyperloglog/HyperUniquesAggregatorFactory.java +++ b/processing/src/main/java/org/apache/druid/query/aggregation/hyperloglog/HyperUniquesAggregatorFactory.java @@ -21,6 +21,7 @@ package org.apache.druid.query.aggregation.hyperloglog; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; +import org.apache.commons.codec.binary.Base64; import org.apache.druid.hll.HyperLogLogCollector; import org.apache.druid.java.util.common.IAE; import org.apache.druid.java.util.common.StringUtils; @@ -38,7 +39,6 @@ import org.apache.druid.query.cache.CacheKeyBuilder; import org.apache.druid.segment.BaseObjectColumnValueSelector; import org.apache.druid.segment.ColumnSelectorFactory; import org.apache.druid.segment.NilColumnValueSelector; -import org.apache.commons.codec.binary.Base64; import java.nio.ByteBuffer; import java.util.Collections; diff --git a/processing/src/main/java/org/apache/druid/query/aggregation/hyperloglog/HyperUniquesSerde.java b/processing/src/main/java/org/apache/druid/query/aggregation/hyperloglog/HyperUniquesSerde.java index a85a8e1fc60..56979500c41 100644 --- a/processing/src/main/java/org/apache/druid/query/aggregation/hyperloglog/HyperUniquesSerde.java +++ b/processing/src/main/java/org/apache/druid/query/aggregation/hyperloglog/HyperUniquesSerde.java @@ -19,11 +19,9 @@ package org.apache.druid.query.aggregation.hyperloglog; -import com.google.common.collect.Ordering; import org.apache.druid.data.input.InputRow; import org.apache.druid.hll.HyperLogLogCollector; import org.apache.druid.hll.HyperLogLogHash; -import org.apache.druid.segment.writeout.SegmentWriteOutMedium; import org.apache.druid.segment.GenericColumnSerializer; import org.apache.druid.segment.column.ColumnBuilder; import org.apache.druid.segment.data.GenericIndexed; @@ -32,22 +30,16 @@ import org.apache.druid.segment.serde.ComplexColumnPartSupplier; import org.apache.druid.segment.serde.ComplexMetricExtractor; import org.apache.druid.segment.serde.ComplexMetricSerde; import org.apache.druid.segment.serde.LargeColumnSupportedComplexColumnSerializer; +import org.apache.druid.segment.writeout.SegmentWriteOutMedium; import java.nio.ByteBuffer; +import java.util.Comparator; import java.util.List; public class HyperUniquesSerde extends ComplexMetricSerde { - private static Ordering comparator = new Ordering() - { - @Override - public int compare( - HyperLogLogCollector arg1, HyperLogLogCollector arg2 - ) - { - return arg1.toByteBuffer().compareTo(arg2.toByteBuffer()); - } - }.nullsFirst(); + private static Comparator comparator = + Comparator.nullsFirst(Comparator.comparing(HyperLogLogCollector::toByteBuffer)); private final HyperLogLogHash hyperLogLogHash; @@ -63,9 +55,9 @@ public class HyperUniquesSerde extends ComplexMetricSerde } @Override - public ComplexMetricExtractor getExtractor() + public ComplexMetricExtractor getExtractor() { - return new ComplexMetricExtractor() + return new ComplexMetricExtractor() { @Override public Class extractedClass() @@ -103,7 +95,7 @@ public class HyperUniquesSerde extends ComplexMetricSerde ) { final GenericIndexed column = GenericIndexed.read(byteBuffer, getObjectStrategy(), columnBuilder.getFileMapper()); - columnBuilder.setComplexColumn(new ComplexColumnPartSupplier(getTypeName(), column)); + columnBuilder.setComplexColumnSupplier(new ComplexColumnPartSupplier(getTypeName(), column)); } @Override @@ -112,7 +104,7 @@ public class HyperUniquesSerde extends ComplexMetricSerde return new ObjectStrategy() { @Override - public Class getClazz() + public Class getClazz() { return HyperLogLogCollector.class; } diff --git a/processing/src/main/java/org/apache/druid/query/aggregation/hyperloglog/PreComputedHyperUniquesSerde.java b/processing/src/main/java/org/apache/druid/query/aggregation/hyperloglog/PreComputedHyperUniquesSerde.java index 7be5e41deba..3eb0710275c 100644 --- a/processing/src/main/java/org/apache/druid/query/aggregation/hyperloglog/PreComputedHyperUniquesSerde.java +++ b/processing/src/main/java/org/apache/druid/query/aggregation/hyperloglog/PreComputedHyperUniquesSerde.java @@ -19,12 +19,12 @@ package org.apache.druid.query.aggregation.hyperloglog; +import org.apache.commons.codec.binary.Base64; import org.apache.druid.data.input.InputRow; import org.apache.druid.hll.HyperLogLogCollector; import org.apache.druid.hll.HyperLogLogHash; import org.apache.druid.java.util.common.ISE; import org.apache.druid.segment.serde.ComplexMetricExtractor; -import org.apache.commons.codec.binary.Base64; import java.nio.ByteBuffer; diff --git a/processing/src/main/java/org/apache/druid/query/aggregation/hyperloglog/package-info.java b/processing/src/main/java/org/apache/druid/query/aggregation/hyperloglog/package-info.java new file mode 100644 index 00000000000..d48386a4643 --- /dev/null +++ b/processing/src/main/java/org/apache/druid/query/aggregation/hyperloglog/package-info.java @@ -0,0 +1,23 @@ +/* + * 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. + */ + +@EverythingIsNonnullByDefault +package org.apache.druid.query.aggregation.hyperloglog; + +import org.apache.druid.annotations.EverythingIsNonnullByDefault; diff --git a/processing/src/main/java/org/apache/druid/query/aggregation/last/DoubleLastAggregatorFactory.java b/processing/src/main/java/org/apache/druid/query/aggregation/last/DoubleLastAggregatorFactory.java index 8842baafd63..2b343beeb39 100644 --- a/processing/src/main/java/org/apache/druid/query/aggregation/last/DoubleLastAggregatorFactory.java +++ b/processing/src/main/java/org/apache/druid/query/aggregation/last/DoubleLastAggregatorFactory.java @@ -36,7 +36,7 @@ import org.apache.druid.query.aggregation.first.LongFirstAggregatorFactory; import org.apache.druid.query.monomorphicprocessing.RuntimeShapeInspector; import org.apache.druid.segment.ColumnSelectorFactory; import org.apache.druid.segment.ColumnValueSelector; -import org.apache.druid.segment.column.Column; +import org.apache.druid.segment.column.ColumnHolder; import javax.annotation.Nullable; import java.nio.ByteBuffer; @@ -64,7 +64,7 @@ public class DoubleLastAggregatorFactory extends NullableAggregatorFactory 0 ? lhs : rhs; + Long leftTime = ((SerializablePair) lhs).lhs; + Long rightTime = ((SerializablePair) rhs).lhs; + if (leftTime >= rightTime) { + return lhs; + } else { + return rhs; + } } @Override @@ -200,7 +203,7 @@ public class DoubleLastAggregatorFactory extends NullableAggregatorFactory requiredFields() { - return Arrays.asList(Column.TIME_COLUMN_NAME, fieldName); + return Arrays.asList(ColumnHolder.TIME_COLUMN_NAME, fieldName); } @Override diff --git a/processing/src/main/java/org/apache/druid/query/aggregation/last/FloatLastAggregatorFactory.java b/processing/src/main/java/org/apache/druid/query/aggregation/last/FloatLastAggregatorFactory.java index f9a8fba7de4..16e521629e7 100644 --- a/processing/src/main/java/org/apache/druid/query/aggregation/last/FloatLastAggregatorFactory.java +++ b/processing/src/main/java/org/apache/druid/query/aggregation/last/FloatLastAggregatorFactory.java @@ -36,7 +36,7 @@ import org.apache.druid.query.aggregation.first.LongFirstAggregatorFactory; import org.apache.druid.query.monomorphicprocessing.RuntimeShapeInspector; import org.apache.druid.segment.ColumnSelectorFactory; import org.apache.druid.segment.ColumnValueSelector; -import org.apache.druid.segment.column.Column; +import org.apache.druid.segment.column.ColumnHolder; import javax.annotation.Nullable; import java.nio.ByteBuffer; @@ -74,17 +74,14 @@ public class FloatLastAggregatorFactory extends NullableAggregatorFactory 0 ? lhs : rhs; + Long leftTime = ((SerializablePair) lhs).lhs; + Long rightTime = ((SerializablePair) rhs).lhs; + if (leftTime >= rightTime) { + return lhs; + } else { + return rhs; + } } @Override @@ -198,7 +201,7 @@ public class FloatLastAggregatorFactory extends NullableAggregatorFactory requiredFields() { - return Arrays.asList(Column.TIME_COLUMN_NAME, fieldName); + return Arrays.asList(ColumnHolder.TIME_COLUMN_NAME, fieldName); } @Override diff --git a/processing/src/main/java/org/apache/druid/query/aggregation/last/LongLastAggregatorFactory.java b/processing/src/main/java/org/apache/druid/query/aggregation/last/LongLastAggregatorFactory.java index f992119daba..1b42fe1aaf4 100644 --- a/processing/src/main/java/org/apache/druid/query/aggregation/last/LongLastAggregatorFactory.java +++ b/processing/src/main/java/org/apache/druid/query/aggregation/last/LongLastAggregatorFactory.java @@ -31,12 +31,11 @@ import org.apache.druid.query.aggregation.AggregatorFactory; import org.apache.druid.query.aggregation.AggregatorUtil; import org.apache.druid.query.aggregation.BufferAggregator; import org.apache.druid.query.aggregation.NullableAggregatorFactory; -import org.apache.druid.query.aggregation.first.DoubleFirstAggregatorFactory; import org.apache.druid.query.aggregation.first.LongFirstAggregatorFactory; import org.apache.druid.query.monomorphicprocessing.RuntimeShapeInspector; import org.apache.druid.segment.ColumnSelectorFactory; import org.apache.druid.segment.ColumnValueSelector; -import org.apache.druid.segment.column.Column; +import org.apache.druid.segment.column.ColumnHolder; import javax.annotation.Nullable; import java.nio.ByteBuffer; @@ -73,19 +72,13 @@ public class LongLastAggregatorFactory extends NullableAggregatorFactory 0 ? lhs : rhs; + Long leftTime = ((SerializablePair) lhs).lhs; + Long rightTime = ((SerializablePair) rhs).lhs; + if (leftTime >= rightTime) { + return lhs; + } else { + return rhs; + } } @Override @@ -197,7 +196,7 @@ public class LongLastAggregatorFactory extends NullableAggregatorFactory requiredFields() { - return Arrays.asList(Column.TIME_COLUMN_NAME, fieldName); + return Arrays.asList(ColumnHolder.TIME_COLUMN_NAME, fieldName); } @Override diff --git a/processing/src/main/java/org/apache/druid/query/aggregation/last/StringLastAggregatorFactory.java b/processing/src/main/java/org/apache/druid/query/aggregation/last/StringLastAggregatorFactory.java index d9ef34a4d60..4973186c376 100644 --- a/processing/src/main/java/org/apache/druid/query/aggregation/last/StringLastAggregatorFactory.java +++ b/processing/src/main/java/org/apache/druid/query/aggregation/last/StringLastAggregatorFactory.java @@ -34,7 +34,7 @@ import org.apache.druid.query.aggregation.first.StringFirstAggregatorFactory; import org.apache.druid.query.cache.CacheKeyBuilder; import org.apache.druid.segment.BaseObjectColumnValueSelector; import org.apache.druid.segment.ColumnSelectorFactory; -import org.apache.druid.segment.column.Column; +import org.apache.druid.segment.column.ColumnHolder; import java.util.Arrays; import java.util.Collections; @@ -43,7 +43,6 @@ import java.util.List; import java.util.Map; import java.util.Objects; - @JsonTypeName("stringLast") public class StringLastAggregatorFactory extends NullableAggregatorFactory { @@ -77,7 +76,7 @@ public class StringLastAggregatorFactory extends NullableAggregatorFactory requiredFields() { - return Arrays.asList(Column.TIME_COLUMN_NAME, fieldName); + return Arrays.asList(ColumnHolder.TIME_COLUMN_NAME, fieldName); } @Override diff --git a/processing/src/main/java/org/apache/druid/query/aggregation/package-info.java b/processing/src/main/java/org/apache/druid/query/aggregation/package-info.java new file mode 100644 index 00000000000..73a0a65871c --- /dev/null +++ b/processing/src/main/java/org/apache/druid/query/aggregation/package-info.java @@ -0,0 +1,23 @@ +/* + * 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. + */ + +@EverythingIsNonnullByDefault +package org.apache.druid.query.aggregation; + +import org.apache.druid.annotations.EverythingIsNonnullByDefault; diff --git a/processing/src/main/java/org/apache/druid/query/aggregation/post/package-info.java b/processing/src/main/java/org/apache/druid/query/aggregation/post/package-info.java new file mode 100644 index 00000000000..36880c8b049 --- /dev/null +++ b/processing/src/main/java/org/apache/druid/query/aggregation/post/package-info.java @@ -0,0 +1,23 @@ +/* + * 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. + */ + +@EverythingIsNonnullByDefault +package org.apache.druid.query.aggregation.post; + +import org.apache.druid.annotations.EverythingIsNonnullByDefault; diff --git a/processing/src/main/java/org/apache/druid/query/dimension/DefaultDimensionSpec.java b/processing/src/main/java/org/apache/druid/query/dimension/DefaultDimensionSpec.java index b948f6e0066..921402c8da9 100644 --- a/processing/src/main/java/org/apache/druid/query/dimension/DefaultDimensionSpec.java +++ b/processing/src/main/java/org/apache/druid/query/dimension/DefaultDimensionSpec.java @@ -21,16 +21,16 @@ package org.apache.druid.query.dimension; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; -import com.google.common.base.Function; -import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; import org.apache.druid.query.cache.CacheKeyBuilder; import org.apache.druid.query.extraction.ExtractionFn; import org.apache.druid.segment.DimensionSelector; import org.apache.druid.segment.column.ValueType; +import javax.annotation.Nullable; import java.util.Arrays; import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.StreamSupport; /** */ @@ -48,18 +48,9 @@ public class DefaultDimensionSpec implements DimensionSpec public static List toSpec(Iterable dimensionNames) { - return Lists.newArrayList( - Iterables.transform( - dimensionNames, new Function() - { - @Override - public DimensionSpec apply(String input) - { - return new DefaultDimensionSpec(input, input); - } - } - ) - ); + return StreamSupport.stream(dimensionNames.spliterator(), false) + .map(input -> new DefaultDimensionSpec(input, input)) + .collect(Collectors.toList()); } private static final byte CACHE_TYPE_ID = 0x0; @@ -70,8 +61,8 @@ public class DefaultDimensionSpec implements DimensionSpec @JsonCreator public DefaultDimensionSpec( @JsonProperty("dimension") String dimension, - @JsonProperty("outputName") String outputName, - @JsonProperty("outputType") ValueType outputType + @JsonProperty("outputName") @Nullable String outputName, + @JsonProperty("outputType") @Nullable ValueType outputType ) { this.dimension = dimension; @@ -81,10 +72,7 @@ public class DefaultDimensionSpec implements DimensionSpec this.outputName = outputName == null ? dimension : outputName; } - public DefaultDimensionSpec( - String dimension, - String outputName - ) + public DefaultDimensionSpec(String dimension, String outputName) { this(dimension, outputName, ValueType.STRING); } diff --git a/processing/src/main/java/org/apache/druid/query/dimension/DimensionSpec.java b/processing/src/main/java/org/apache/druid/query/dimension/DimensionSpec.java index fa12358f38f..3adf5d507af 100644 --- a/processing/src/main/java/org/apache/druid/query/dimension/DimensionSpec.java +++ b/processing/src/main/java/org/apache/druid/query/dimension/DimensionSpec.java @@ -26,6 +26,8 @@ import org.apache.druid.query.extraction.ExtractionFn; import org.apache.druid.segment.DimensionSelector; import org.apache.druid.segment.column.ValueType; +import javax.annotation.Nullable; + /** * Provides information about a dimension for a grouping query, like topN or groupBy. Note that this is not annotated * with {@code PublicApi}, since it is not meant to be stable for usage by non-built-in queries. @@ -47,6 +49,7 @@ public interface DimensionSpec extends Cacheable //ExtractionFn can be implemented with decorate(..) fn @Deprecated + @Nullable ExtractionFn getExtractionFn(); DimensionSelector decorate(DimensionSelector selector); diff --git a/processing/src/main/java/org/apache/druid/query/dimension/ForwardingFilteredDimensionSelector.java b/processing/src/main/java/org/apache/druid/query/dimension/ForwardingFilteredDimensionSelector.java index 38e000e7eac..3213f57c159 100644 --- a/processing/src/main/java/org/apache/druid/query/dimension/ForwardingFilteredDimensionSelector.java +++ b/processing/src/main/java/org/apache/druid/query/dimension/ForwardingFilteredDimensionSelector.java @@ -22,21 +22,22 @@ package org.apache.druid.query.dimension; import com.google.common.base.Preconditions; import com.google.common.base.Predicate; import com.google.common.base.Predicates; +import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap; import org.apache.druid.java.util.common.IAE; import org.apache.druid.query.filter.ValueMatcher; import org.apache.druid.query.monomorphicprocessing.RuntimeShapeInspector; +import org.apache.druid.segment.AbstractDimensionSelector; import org.apache.druid.segment.DimensionSelector; import org.apache.druid.segment.DimensionSelectorUtils; import org.apache.druid.segment.IdLookup; import org.apache.druid.segment.data.ArrayBasedIndexedInts; import org.apache.druid.segment.data.IndexedInts; import org.apache.druid.segment.filter.BooleanValueMatcher; -import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap; import javax.annotation.Nullable; import java.util.BitSet; -final class ForwardingFilteredDimensionSelector implements DimensionSelector, IdLookup +final class ForwardingFilteredDimensionSelector extends AbstractDimensionSelector implements IdLookup { private final DimensionSelector selector; private final IdLookup baseIdLookup; @@ -194,13 +195,6 @@ final class ForwardingFilteredDimensionSelector implements DimensionSelector, Id return forwardMapping.get(baseIdLookup.lookupId(name)); } - @Nullable - @Override - public Object getObject() - { - return defaultGetObject(); - } - @Override public Class classOfObject() { diff --git a/processing/src/main/java/org/apache/druid/query/dimension/ListFilteredDimensionSpec.java b/processing/src/main/java/org/apache/druid/query/dimension/ListFilteredDimensionSpec.java index cf8f6bae433..ef7cdc91132 100644 --- a/processing/src/main/java/org/apache/druid/query/dimension/ListFilteredDimensionSpec.java +++ b/processing/src/main/java/org/apache/druid/query/dimension/ListFilteredDimensionSpec.java @@ -23,12 +23,12 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.google.common.base.Preconditions; import com.google.common.base.Predicate; import com.google.common.base.Predicates; +import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap; import org.apache.druid.common.config.NullHandling; import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.query.filter.DimFilterUtils; import org.apache.druid.segment.DimensionSelector; import org.apache.druid.segment.IdLookup; -import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap; import javax.annotation.Nullable; import java.nio.ByteBuffer; diff --git a/processing/src/main/java/org/apache/druid/query/dimension/PredicateFilteredDimensionSelector.java b/processing/src/main/java/org/apache/druid/query/dimension/PredicateFilteredDimensionSelector.java index 51390eefe91..b607c9e2523 100644 --- a/processing/src/main/java/org/apache/druid/query/dimension/PredicateFilteredDimensionSelector.java +++ b/processing/src/main/java/org/apache/druid/query/dimension/PredicateFilteredDimensionSelector.java @@ -22,6 +22,7 @@ package org.apache.druid.query.dimension; import com.google.common.base.Predicate; import org.apache.druid.query.filter.ValueMatcher; import org.apache.druid.query.monomorphicprocessing.RuntimeShapeInspector; +import org.apache.druid.segment.AbstractDimensionSelector; import org.apache.druid.segment.DimensionSelector; import org.apache.druid.segment.IdLookup; import org.apache.druid.segment.data.ArrayBasedIndexedInts; @@ -30,7 +31,7 @@ import org.apache.druid.segment.data.IndexedInts; import javax.annotation.Nullable; import java.util.Objects; -final class PredicateFilteredDimensionSelector implements DimensionSelector +final class PredicateFilteredDimensionSelector extends AbstractDimensionSelector { private final DimensionSelector selector; private final Predicate predicate; @@ -152,13 +153,6 @@ final class PredicateFilteredDimensionSelector implements DimensionSelector return selector.idLookup(); } - @Nullable - @Override - public Object getObject() - { - return defaultGetObject(); - } - @Override public Class classOfObject() { diff --git a/processing/src/main/java/org/apache/druid/query/dimension/RegexFilteredDimensionSpec.java b/processing/src/main/java/org/apache/druid/query/dimension/RegexFilteredDimensionSpec.java index 12746c7b6e7..0ad457d5744 100644 --- a/processing/src/main/java/org/apache/druid/query/dimension/RegexFilteredDimensionSpec.java +++ b/processing/src/main/java/org/apache/druid/query/dimension/RegexFilteredDimensionSpec.java @@ -22,12 +22,12 @@ package org.apache.druid.query.dimension; import com.fasterxml.jackson.annotation.JsonProperty; import com.google.common.base.Preconditions; import com.google.common.base.Predicate; +import it.unimi.dsi.fastutil.ints.Int2IntMap; +import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap; import org.apache.druid.common.config.NullHandling; import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.query.filter.DimFilterUtils; import org.apache.druid.segment.DimensionSelector; -import it.unimi.dsi.fastutil.ints.Int2IntMap; -import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap; import javax.annotation.Nullable; import java.nio.ByteBuffer; diff --git a/processing/src/main/java/org/apache/druid/query/filter/BitmapIndexSelector.java b/processing/src/main/java/org/apache/druid/query/filter/BitmapIndexSelector.java index a89a24f575d..b19327f9d17 100644 --- a/processing/src/main/java/org/apache/druid/query/filter/BitmapIndexSelector.java +++ b/processing/src/main/java/org/apache/druid/query/filter/BitmapIndexSelector.java @@ -19,21 +19,27 @@ package org.apache.druid.query.filter; +import com.google.errorprone.annotations.MustBeClosed; import org.apache.druid.collections.bitmap.BitmapFactory; import org.apache.druid.collections.bitmap.ImmutableBitmap; import org.apache.druid.collections.spatial.ImmutableRTree; import org.apache.druid.segment.column.BitmapIndex; -import org.apache.druid.segment.data.Indexed; +import org.apache.druid.segment.data.CloseableIndexed; + +import javax.annotation.Nullable; /** */ public interface BitmapIndexSelector { - Indexed getDimensionValues(String dimension); + @MustBeClosed + @Nullable + CloseableIndexed getDimensionValues(String dimension); boolean hasMultipleValues(String dimension); int getNumRows(); BitmapFactory getBitmapFactory(); BitmapIndex getBitmapIndex(String dimension); + @Nullable ImmutableBitmap getBitmapIndex(String dimension, String value); ImmutableRTree getSpatialIndex(String dimension); } diff --git a/processing/src/main/java/org/apache/druid/query/filter/InDimFilter.java b/processing/src/main/java/org/apache/druid/query/filter/InDimFilter.java index 7f63acf9986..64430d3b1cf 100644 --- a/processing/src/main/java/org/apache/druid/query/filter/InDimFilter.java +++ b/processing/src/main/java/org/apache/druid/query/filter/InDimFilter.java @@ -31,6 +31,10 @@ import com.google.common.collect.Sets; import com.google.common.collect.TreeRangeSet; import com.google.common.primitives.Doubles; import com.google.common.primitives.Floats; +import it.unimi.dsi.fastutil.ints.IntArrayList; +import it.unimi.dsi.fastutil.ints.IntOpenHashSet; +import it.unimi.dsi.fastutil.longs.LongArrayList; +import it.unimi.dsi.fastutil.longs.LongOpenHashSet; import org.apache.druid.common.config.NullHandling; import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.java.util.common.guava.Comparators; @@ -40,10 +44,6 @@ import org.apache.druid.query.lookup.LookupExtractionFn; import org.apache.druid.query.lookup.LookupExtractor; import org.apache.druid.segment.DimensionHandlerUtils; import org.apache.druid.segment.filter.InFilter; -import it.unimi.dsi.fastutil.ints.IntArrayList; -import it.unimi.dsi.fastutil.ints.IntOpenHashSet; -import it.unimi.dsi.fastutil.longs.LongArrayList; -import it.unimi.dsi.fastutil.longs.LongOpenHashSet; import java.util.ArrayList; import java.util.Arrays; diff --git a/processing/src/main/java/org/apache/druid/query/groupby/GroupByQuery.java b/processing/src/main/java/org/apache/druid/query/groupby/GroupByQuery.java index bedd6f2ef64..abd5c9a5d6f 100644 --- a/processing/src/main/java/org/apache/druid/query/groupby/GroupByQuery.java +++ b/processing/src/main/java/org/apache/druid/query/groupby/GroupByQuery.java @@ -62,7 +62,7 @@ import org.apache.druid.query.spec.QuerySegmentSpec; import org.apache.druid.segment.DimensionHandlerUtils; import org.apache.druid.segment.VirtualColumn; import org.apache.druid.segment.VirtualColumns; -import org.apache.druid.segment.column.Column; +import org.apache.druid.segment.column.ColumnHolder; import org.apache.druid.segment.column.ValueType; import org.joda.time.Interval; @@ -566,6 +566,7 @@ public class GroupByQuery extends BaseQuery } } + @Nullable private Comparator getTimeComparator(boolean granular) { if (Granularities.ALL.equals(getGranularity())) { @@ -719,10 +720,10 @@ public class GroupByQuery extends BaseQuery } } - if (outputNames.contains(Column.TIME_COLUMN_NAME)) { + if (outputNames.contains(ColumnHolder.TIME_COLUMN_NAME)) { throw new IAE( "'%s' cannot be used as an output name for dimensions, aggregators, or post-aggregators.", - Column.TIME_COLUMN_NAME + ColumnHolder.TIME_COLUMN_NAME ); } } diff --git a/processing/src/main/java/org/apache/druid/query/groupby/GroupByQueryEngine.java b/processing/src/main/java/org/apache/druid/query/groupby/GroupByQueryEngine.java index 4d9e34fffb8..74effcbdf3a 100644 --- a/processing/src/main/java/org/apache/druid/query/groupby/GroupByQueryEngine.java +++ b/processing/src/main/java/org/apache/druid/query/groupby/GroupByQueryEngine.java @@ -329,14 +329,12 @@ public class GroupByQueryEngine } final DimensionSelector selector = cursor.getColumnSelectorFactory().makeDimensionSelector(dimSpec); - if (selector != null) { - if (selector.getValueCardinality() == DimensionSelector.CARDINALITY_UNKNOWN) { - throw new UnsupportedOperationException( - "GroupBy v1 does not support dimension selectors with unknown cardinality."); - } - dimensions.add(selector); - dimNames.add(dimSpec.getOutputName()); + if (selector.getValueCardinality() == DimensionSelector.CARDINALITY_UNKNOWN) { + throw new UnsupportedOperationException( + "GroupBy v1 does not support dimension selectors with unknown cardinality."); } + dimensions.add(selector); + dimNames.add(dimSpec.getOutputName()); } aggregatorSpecs = query.getAggregatorSpecs(); diff --git a/processing/src/main/java/org/apache/druid/query/groupby/GroupByQueryQueryToolChest.java b/processing/src/main/java/org/apache/druid/query/groupby/GroupByQueryQueryToolChest.java index 44977454286..27e77feae14 100644 --- a/processing/src/main/java/org/apache/druid/query/groupby/GroupByQueryQueryToolChest.java +++ b/processing/src/main/java/org/apache/druid/query/groupby/GroupByQueryQueryToolChest.java @@ -123,11 +123,7 @@ public class GroupByQueryQueryToolChest extends QueryToolChest mergeGroupByResults( diff --git a/processing/src/main/java/org/apache/druid/query/groupby/RowBasedColumnSelectorFactory.java b/processing/src/main/java/org/apache/druid/query/groupby/RowBasedColumnSelectorFactory.java index 925df54bda2..081b48191de 100644 --- a/processing/src/main/java/org/apache/druid/query/groupby/RowBasedColumnSelectorFactory.java +++ b/processing/src/main/java/org/apache/druid/query/groupby/RowBasedColumnSelectorFactory.java @@ -28,19 +28,19 @@ import org.apache.druid.query.dimension.DimensionSpec; import org.apache.druid.query.extraction.ExtractionFn; import org.apache.druid.query.filter.ValueMatcher; import org.apache.druid.query.monomorphicprocessing.RuntimeShapeInspector; +import org.apache.druid.segment.BaseSingleValueDimensionSelector; import org.apache.druid.segment.ColumnSelectorFactory; import org.apache.druid.segment.ColumnValueSelector; import org.apache.druid.segment.DimensionHandlerUtils; import org.apache.druid.segment.DimensionSelector; import org.apache.druid.segment.IdLookup; import org.apache.druid.segment.LongColumnSelector; -import org.apache.druid.segment.column.Column; import org.apache.druid.segment.column.ColumnCapabilities; import org.apache.druid.segment.column.ColumnCapabilitiesImpl; +import org.apache.druid.segment.column.ColumnHolder; import org.apache.druid.segment.column.ValueType; import org.apache.druid.segment.data.IndexedInts; import org.apache.druid.segment.data.RangeIndexedInts; -import org.apache.druid.segment.data.ZeroIndexedInts; import javax.annotation.Nullable; import java.util.List; @@ -74,17 +74,7 @@ public class RowBasedColumnSelectorFactory implements ColumnSelectorFactory @Nullable final Map rowSignature ) { - return new RowBasedColumnSelectorFactory( - new Supplier() - { - @Override - public Row get() - { - return row.get(); - } - }, - rowSignature - ); + return new RowBasedColumnSelectorFactory(row::get, rowSignature); } @Override @@ -100,100 +90,19 @@ public class RowBasedColumnSelectorFactory implements ColumnSelectorFactory final String dimension = dimensionSpec.getDimension(); final ExtractionFn extractionFn = dimensionSpec.getExtractionFn(); - if (Column.TIME_COLUMN_NAME.equals(dimensionSpec.getDimension())) { + if (ColumnHolder.TIME_COLUMN_NAME.equals(dimensionSpec.getDimension())) { if (extractionFn == null) { throw new UnsupportedOperationException("time dimension must provide an extraction function"); } - return new DimensionSelector() + return new BaseSingleValueDimensionSelector() { @Override - public IndexedInts getRow() - { - return ZeroIndexedInts.instance(); - } - - @Override - public ValueMatcher makeValueMatcher(final String value) - { - return new ValueMatcher() - { - @Override - public boolean matches() - { - String rowValue = extractionFn.apply(row.get().getTimestampFromEpoch()); - return Objects.equals(rowValue, value); - } - - @Override - public void inspectRuntimeShape(RuntimeShapeInspector inspector) - { - inspector.visit("row", row); - inspector.visit("extractionFn", extractionFn); - } - }; - } - - @Override - public ValueMatcher makeValueMatcher(final Predicate predicate) - { - return new ValueMatcher() - { - @Override - public boolean matches() - { - String rowValue = extractionFn.apply(row.get().getTimestampFromEpoch()); - return predicate.apply(rowValue); - } - - @Override - public void inspectRuntimeShape(RuntimeShapeInspector inspector) - { - inspector.visit("row", row); - inspector.visit("extractionFn", extractionFn); - inspector.visit("predicate", predicate); - } - }; - } - - @Override - public int getValueCardinality() - { - return DimensionSelector.CARDINALITY_UNKNOWN; - } - - @Override - public String lookupName(int id) + protected String getValue() { return extractionFn.apply(row.get().getTimestampFromEpoch()); } - @Override - public boolean nameLookupPossibleInAdvance() - { - return false; - } - - @Nullable - @Override - public IdLookup idLookup() - { - return null; - } - - @Nullable - @Override - public Object getObject() - { - return lookupName(0); - } - - @Override - public Class classOfObject() - { - return String.class; - } - @Override public void inspectRuntimeShape(RuntimeShapeInspector inspector) { @@ -215,7 +124,7 @@ public class RowBasedColumnSelectorFactory implements ColumnSelectorFactory } @Override - public ValueMatcher makeValueMatcher(final String value) + public ValueMatcher makeValueMatcher(final @Nullable String value) { if (extractionFn == null) { return new ValueMatcher() @@ -367,7 +276,7 @@ public class RowBasedColumnSelectorFactory implements ColumnSelectorFactory if (dimensionValues.size() == 1) { return dimensionValues.get(0); } - return dimensionValues.toArray(new String[0]); + return dimensionValues; } @Override @@ -389,7 +298,7 @@ public class RowBasedColumnSelectorFactory implements ColumnSelectorFactory @Override public ColumnValueSelector makeColumnValueSelector(String columnName) { - if (columnName.equals(Column.TIME_COLUMN_NAME)) { + if (columnName.equals(ColumnHolder.TIME_COLUMN_NAME)) { class TimeLongColumnSelector implements LongColumnSelector { @Override @@ -471,7 +380,7 @@ public class RowBasedColumnSelectorFactory implements ColumnSelectorFactory @Override public ColumnCapabilities getColumnCapabilities(String columnName) { - if (Column.TIME_COLUMN_NAME.equals(columnName)) { + if (ColumnHolder.TIME_COLUMN_NAME.equals(columnName)) { // TIME_COLUMN_NAME is handled specially; override the provided rowSignature. return new ColumnCapabilitiesImpl().setType(ValueType.LONG); } else { diff --git a/processing/src/main/java/org/apache/druid/query/groupby/epinephelinae/LimitedTemporaryStorage.java b/processing/src/main/java/org/apache/druid/query/groupby/epinephelinae/LimitedTemporaryStorage.java index 96b40ede4c2..07f3785545d 100644 --- a/processing/src/main/java/org/apache/druid/query/groupby/epinephelinae/LimitedTemporaryStorage.java +++ b/processing/src/main/java/org/apache/druid/query/groupby/epinephelinae/LimitedTemporaryStorage.java @@ -21,10 +21,10 @@ package org.apache.druid.query.groupby.epinephelinae; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; +import org.apache.commons.io.FileUtils; import org.apache.druid.java.util.common.ISE; import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.java.util.common.logger.Logger; -import org.apache.commons.io.FileUtils; import java.io.Closeable; import java.io.File; diff --git a/processing/src/main/java/org/apache/druid/query/groupby/epinephelinae/ParallelCombiner.java b/processing/src/main/java/org/apache/druid/query/groupby/epinephelinae/ParallelCombiner.java index fe88b43656f..0ef98c6913d 100644 --- a/processing/src/main/java/org/apache/druid/query/groupby/epinephelinae/ParallelCombiner.java +++ b/processing/src/main/java/org/apache/druid/query/groupby/epinephelinae/ParallelCombiner.java @@ -26,6 +26,8 @@ import com.google.common.base.Throwables; import com.google.common.collect.Iterables; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListeningExecutorService; +import it.unimi.dsi.fastutil.objects.Object2IntArrayMap; +import it.unimi.dsi.fastutil.objects.Object2IntMap; import org.apache.druid.collections.ReferenceCountingResourceHolder; import org.apache.druid.collections.Releaser; import org.apache.druid.java.util.common.CloseableIterators; @@ -45,8 +47,6 @@ import org.apache.druid.segment.ColumnValueSelector; import org.apache.druid.segment.DimensionSelector; import org.apache.druid.segment.ObjectColumnSelector; import org.apache.druid.segment.column.ColumnCapabilities; -import it.unimi.dsi.fastutil.objects.Object2IntArrayMap; -import it.unimi.dsi.fastutil.objects.Object2IntMap; import java.io.IOException; import java.nio.ByteBuffer; diff --git a/processing/src/main/java/org/apache/druid/query/groupby/epinephelinae/RowBasedGrouperHelper.java b/processing/src/main/java/org/apache/druid/query/groupby/epinephelinae/RowBasedGrouperHelper.java index f5ddd12936a..74e50fe343f 100644 --- a/processing/src/main/java/org/apache/druid/query/groupby/epinephelinae/RowBasedGrouperHelper.java +++ b/processing/src/main/java/org/apache/druid/query/groupby/epinephelinae/RowBasedGrouperHelper.java @@ -29,6 +29,9 @@ import com.google.common.collect.Maps; import com.google.common.primitives.Ints; import com.google.common.primitives.Longs; import com.google.common.util.concurrent.ListeningExecutorService; +import it.unimi.dsi.fastutil.ints.IntArrays; +import it.unimi.dsi.fastutil.objects.Object2IntMap; +import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; import org.apache.druid.collections.ReferenceCountingResourceHolder; import org.apache.druid.common.config.NullHandling; import org.apache.druid.common.utils.IntArrayUtils; @@ -65,9 +68,6 @@ import org.apache.druid.segment.DimensionSelector; import org.apache.druid.segment.column.ColumnCapabilities; import org.apache.druid.segment.column.ValueType; import org.apache.druid.segment.data.IndexedInts; -import it.unimi.dsi.fastutil.ints.IntArrays; -import it.unimi.dsi.fastutil.objects.Object2IntMap; -import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; import org.joda.time.DateTime; import javax.annotation.Nullable; diff --git a/processing/src/main/java/org/apache/druid/query/groupby/epinephelinae/SpillingGrouper.java b/processing/src/main/java/org/apache/druid/query/groupby/epinephelinae/SpillingGrouper.java index 3207dadc8e2..61b7c09f8af 100644 --- a/processing/src/main/java/org/apache/druid/query/groupby/epinephelinae/SpillingGrouper.java +++ b/processing/src/main/java/org/apache/druid/query/groupby/epinephelinae/SpillingGrouper.java @@ -27,6 +27,8 @@ import com.google.common.base.Supplier; import com.google.common.base.Throwables; import com.google.common.collect.Iterators; import com.google.common.collect.Lists; +import net.jpountz.lz4.LZ4BlockInputStream; +import net.jpountz.lz4.LZ4BlockOutputStream; import org.apache.druid.java.util.common.CloseableIterators; import org.apache.druid.java.util.common.io.Closer; import org.apache.druid.java.util.common.logger.Logger; @@ -35,8 +37,6 @@ import org.apache.druid.query.BaseQuery; import org.apache.druid.query.aggregation.AggregatorFactory; import org.apache.druid.query.groupby.orderby.DefaultLimitSpec; import org.apache.druid.segment.ColumnSelectorFactory; -import net.jpountz.lz4.LZ4BlockInputStream; -import net.jpountz.lz4.LZ4BlockOutputStream; import java.io.File; import java.io.FileInputStream; diff --git a/processing/src/main/java/org/apache/druid/query/groupby/epinephelinae/column/DictionaryBuildingStringGroupByColumnSelectorStrategy.java b/processing/src/main/java/org/apache/druid/query/groupby/epinephelinae/column/DictionaryBuildingStringGroupByColumnSelectorStrategy.java index 9b34616fb89..f2f6914c019 100644 --- a/processing/src/main/java/org/apache/druid/query/groupby/epinephelinae/column/DictionaryBuildingStringGroupByColumnSelectorStrategy.java +++ b/processing/src/main/java/org/apache/druid/query/groupby/epinephelinae/column/DictionaryBuildingStringGroupByColumnSelectorStrategy.java @@ -21,12 +21,12 @@ package org.apache.druid.query.groupby.epinephelinae.column; import com.google.common.base.Preconditions; import com.google.common.collect.Lists; +import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; import org.apache.druid.common.config.NullHandling; import org.apache.druid.segment.ColumnValueSelector; import org.apache.druid.segment.DimensionSelector; import org.apache.druid.segment.data.ArrayBasedIndexedInts; import org.apache.druid.segment.data.IndexedInts; -import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; import java.nio.ByteBuffer; import java.util.List; diff --git a/processing/src/main/java/org/apache/druid/query/groupby/epinephelinae/package-info.java b/processing/src/main/java/org/apache/druid/query/groupby/epinephelinae/package-info.java new file mode 100644 index 00000000000..e3b8aab642d --- /dev/null +++ b/processing/src/main/java/org/apache/druid/query/groupby/epinephelinae/package-info.java @@ -0,0 +1,23 @@ +/* + * 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. + */ + +@EverythingIsNonnullByDefault +package org.apache.druid.query.groupby.epinephelinae; + +import org.apache.druid.annotations.EverythingIsNonnullByDefault; diff --git a/processing/src/main/java/org/apache/druid/query/groupby/package-info.java b/processing/src/main/java/org/apache/druid/query/groupby/package-info.java new file mode 100644 index 00000000000..7a7fe25e39f --- /dev/null +++ b/processing/src/main/java/org/apache/druid/query/groupby/package-info.java @@ -0,0 +1,23 @@ +/* + * 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. + */ + +@EverythingIsNonnullByDefault +package org.apache.druid.query.groupby; + +import org.apache.druid.annotations.EverythingIsNonnullByDefault; diff --git a/processing/src/main/java/org/apache/druid/query/metadata/SegmentAnalyzer.java b/processing/src/main/java/org/apache/druid/query/metadata/SegmentAnalyzer.java index e201f78c3c4..1fe4a49dca5 100644 --- a/processing/src/main/java/org/apache/druid/query/metadata/SegmentAnalyzer.java +++ b/processing/src/main/java/org/apache/druid/query/metadata/SegmentAnalyzer.java @@ -40,9 +40,9 @@ import org.apache.druid.segment.Segment; import org.apache.druid.segment.StorageAdapter; import org.apache.druid.segment.VirtualColumns; import org.apache.druid.segment.column.BitmapIndex; -import org.apache.druid.segment.column.Column; import org.apache.druid.segment.column.ColumnCapabilities; import org.apache.druid.segment.column.ColumnCapabilitiesImpl; +import org.apache.druid.segment.column.ColumnHolder; import org.apache.druid.segment.column.ComplexColumn; import org.apache.druid.segment.column.ValueType; import org.apache.druid.segment.data.IndexedInts; @@ -99,9 +99,9 @@ public class SegmentAnalyzer Map columns = Maps.newTreeMap(); for (String columnName : columnNames) { - final Column column = index == null ? null : index.getColumn(columnName); - final ColumnCapabilities capabilities = column != null - ? column.getCapabilities() + final ColumnHolder columnHolder = index == null ? null : index.getColumnHolder(columnName); + final ColumnCapabilities capabilities = columnHolder != null + ? columnHolder.getCapabilities() : storageAdapter.getColumnCapabilities(columnName); final ColumnAnalysis analysis; @@ -118,13 +118,13 @@ public class SegmentAnalyzer break; case STRING: if (index != null) { - analysis = analyzeStringColumn(capabilities, column); + analysis = analyzeStringColumn(capabilities, columnHolder); } else { analysis = analyzeStringColumn(capabilities, storageAdapter, columnName); } break; case COMPLEX: - analysis = analyzeComplexColumn(capabilities, column, storageAdapter.getColumnTypeName(columnName)); + analysis = analyzeComplexColumn(capabilities, columnHolder, storageAdapter.getColumnTypeName(columnName)); break; default: log.warn("Unknown column type[%s].", type); @@ -135,12 +135,12 @@ public class SegmentAnalyzer } // Add time column too - ColumnCapabilities timeCapabilities = storageAdapter.getColumnCapabilities(Column.TIME_COLUMN_NAME); + ColumnCapabilities timeCapabilities = storageAdapter.getColumnCapabilities(ColumnHolder.TIME_COLUMN_NAME); if (timeCapabilities == null) { timeCapabilities = new ColumnCapabilitiesImpl().setType(ValueType.LONG).setHasMultipleValues(false); } columns.put( - Column.TIME_COLUMN_NAME, + ColumnHolder.TIME_COLUMN_NAME, analyzeNumericColumn(timeCapabilities, length, NUM_BYTES_IN_TIMESTAMP) ); @@ -191,7 +191,7 @@ public class SegmentAnalyzer private ColumnAnalysis analyzeStringColumn( final ColumnCapabilities capabilities, - final Column column + final ColumnHolder columnHolder ) { long size = 0; @@ -203,7 +203,7 @@ public class SegmentAnalyzer return ColumnAnalysis.error("string_no_bitmap"); } - final BitmapIndex bitmapIndex = column.getBitmapIndex(); + final BitmapIndex bitmapIndex = columnHolder.getBitmapIndex(); final int cardinality = bitmapIndex.getCardinality(); if (analyzingSize()) { @@ -310,11 +310,11 @@ public class SegmentAnalyzer private ColumnAnalysis analyzeComplexColumn( @Nullable final ColumnCapabilities capabilities, - @Nullable final Column column, + @Nullable final ColumnHolder columnHolder, final String typeName ) { - try (final ComplexColumn complexColumn = column != null ? column.getComplexColumn() : null) { + try (final ComplexColumn complexColumn = columnHolder != null ? (ComplexColumn) columnHolder.getColumn() : null) { final boolean hasMultipleValues = capabilities != null && capabilities.hasMultipleValues(); long size = 0; diff --git a/processing/src/main/java/org/apache/druid/query/metadata/SegmentMetadataQueryQueryToolChest.java b/processing/src/main/java/org/apache/druid/query/metadata/SegmentMetadataQueryQueryToolChest.java index 615d88afa8f..554835ae5c9 100644 --- a/processing/src/main/java/org/apache/druid/query/metadata/SegmentMetadataQueryQueryToolChest.java +++ b/processing/src/main/java/org/apache/druid/query/metadata/SegmentMetadataQueryQueryToolChest.java @@ -32,8 +32,8 @@ import com.google.common.collect.Ordering; import com.google.common.collect.Sets; import com.google.inject.Inject; import org.apache.druid.common.guava.CombiningSequence; -import org.apache.druid.java.util.common.JodaUtils; import org.apache.druid.data.input.impl.TimestampSpec; +import org.apache.druid.java.util.common.JodaUtils; import org.apache.druid.java.util.common.granularity.Granularity; import org.apache.druid.java.util.common.guava.Comparators; import org.apache.druid.java.util.common.guava.MappedSequence; diff --git a/processing/src/main/java/org/apache/druid/query/scan/ScanQueryEngine.java b/processing/src/main/java/org/apache/druid/query/scan/ScanQueryEngine.java index 06c48063a7c..1502a502530 100644 --- a/processing/src/main/java/org/apache/druid/query/scan/ScanQueryEngine.java +++ b/processing/src/main/java/org/apache/druid/query/scan/ScanQueryEngine.java @@ -18,7 +18,6 @@ */ package org.apache.druid.query.scan; -import com.google.common.base.Function; import com.google.common.base.Preconditions; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; @@ -34,11 +33,10 @@ import org.apache.druid.query.QueryContexts; import org.apache.druid.query.QueryInterruptedException; import org.apache.druid.query.filter.Filter; import org.apache.druid.segment.BaseObjectColumnValueSelector; -import org.apache.druid.segment.Cursor; import org.apache.druid.segment.Segment; import org.apache.druid.segment.StorageAdapter; import org.apache.druid.segment.VirtualColumn; -import org.apache.druid.segment.column.Column; +import org.apache.druid.segment.column.ColumnHolder; import org.apache.druid.segment.filter.Filters; import org.joda.time.Interval; @@ -49,6 +47,7 @@ import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import java.util.NoSuchElementException; import java.util.Set; import java.util.concurrent.TimeoutException; @@ -95,7 +94,7 @@ public class ScanQueryEngine } else { final Set availableColumns = Sets.newLinkedHashSet( Iterables.concat( - Collections.singleton(legacy ? LEGACY_TIMESTAMP_KEY : Column.TIME_COLUMN_NAME), + Collections.singleton(legacy ? LEGACY_TIMESTAMP_KEY : ColumnHolder.TIME_COLUMN_NAME), Iterables.transform( Arrays.asList(query.getVirtualColumns().getVirtualColumns()), VirtualColumn::getOutputName @@ -108,7 +107,7 @@ public class ScanQueryEngine allColumns.addAll(availableColumns); if (legacy) { - allColumns.remove(Column.TIME_COLUMN_NAME); + allColumns.remove(ColumnHolder.TIME_COLUMN_NAME); } } @@ -124,21 +123,16 @@ public class ScanQueryEngine } final long limit = query.getLimit() - (long) responseContext.get(ScanQueryRunnerFactory.CTX_COUNT); return Sequences.concat( - Sequences.map( - adapter.makeCursors( - filter, - intervals.get(0), - query.getVirtualColumns(), - Granularities.ALL, - query.isDescending(), - null - ), - new Function>() - { - @Override - public Sequence apply(final Cursor cursor) - { - return new BaseSequence<>( + adapter + .makeCursors( + filter, + intervals.get(0), + query.getVirtualColumns(), + Granularities.ALL, + query.isDescending(), + null + ) + .map(cursor -> new BaseSequence<>( new BaseSequence.IteratorMaker>() { @Override @@ -151,7 +145,7 @@ public class ScanQueryEngine if (legacy && LEGACY_TIMESTAMP_KEY.equals(column)) { selector = cursor.getColumnSelectorFactory() - .makeColumnValueSelector(Column.TIME_COLUMN_NAME); + .makeColumnValueSelector(ColumnHolder.TIME_COLUMN_NAME); } else { selector = cursor.getColumnSelectorFactory().makeColumnValueSelector(column); } @@ -173,6 +167,9 @@ public class ScanQueryEngine @Override public ScanResultValue next() { + if (!hasNext()) { + throw new NoSuchElementException(); + } if (hasTimeout && System.currentTimeMillis() >= timeoutAt) { throw new QueryInterruptedException(new TimeoutException()); } @@ -208,9 +205,8 @@ public class ScanQueryEngine private List rowsToCompactedList() { final List events = new ArrayList<>(batchSize); - for (int i = 0; !cursor.isDone() - && i < batchSize - && offset < limit; cursor.advance(), i++, offset++) { + final long iterLimit = Math.min(limit, offset + batchSize); + for (; !cursor.isDone() && offset < iterLimit; cursor.advance(), offset++) { final List theEvent = new ArrayList<>(allColumns.size()); for (int j = 0; j < allColumns.size(); j++) { theEvent.add(getColumnValue(j)); @@ -223,9 +219,8 @@ public class ScanQueryEngine private List> rowsToList() { List> events = Lists.newArrayListWithCapacity(batchSize); - for (int i = 0; !cursor.isDone() - && i < batchSize - && offset < limit; cursor.advance(), i++, offset++) { + final long iterLimit = Math.min(limit, offset + batchSize); + for (; !cursor.isDone() && offset < iterLimit; cursor.advance(), offset++) { final Map theEvent = new LinkedHashMap<>(); for (int j = 0; j < allColumns.size(); j++) { theEvent.put(allColumns.get(j), getColumnValue(j)); @@ -256,10 +251,7 @@ public class ScanQueryEngine { } } - ); - } - } - ) + )) ); } } diff --git a/processing/src/main/java/org/apache/druid/query/scan/ScanQueryRunnerFactory.java b/processing/src/main/java/org/apache/druid/query/scan/ScanQueryRunnerFactory.java index 72d1b0ce247..6a124c8c879 100644 --- a/processing/src/main/java/org/apache/druid/query/scan/ScanQueryRunnerFactory.java +++ b/processing/src/main/java/org/apache/druid/query/scan/ScanQueryRunnerFactory.java @@ -20,8 +20,8 @@ package org.apache.druid.query.scan; import com.google.common.base.Function; import com.google.inject.Inject; -import org.apache.druid.java.util.common.JodaUtils; import org.apache.druid.java.util.common.ISE; +import org.apache.druid.java.util.common.JodaUtils; import org.apache.druid.java.util.common.guava.Sequence; import org.apache.druid.java.util.common.guava.Sequences; import org.apache.druid.query.Query; diff --git a/processing/src/main/java/org/apache/druid/query/search/AutoStrategy.java b/processing/src/main/java/org/apache/druid/query/search/AutoStrategy.java index 919492f6b23..3ce2f7d9449 100644 --- a/processing/src/main/java/org/apache/druid/query/search/AutoStrategy.java +++ b/processing/src/main/java/org/apache/druid/query/search/AutoStrategy.java @@ -27,7 +27,7 @@ import org.apache.druid.segment.QueryableIndex; import org.apache.druid.segment.Segment; import org.apache.druid.segment.VirtualColumns; import org.apache.druid.segment.column.BitmapIndex; -import org.apache.druid.segment.column.Column; +import org.apache.druid.segment.column.ColumnHolder; import java.util.List; @@ -114,9 +114,9 @@ public class AutoStrategy extends SearchStrategy { long totalCard = 0; for (DimensionSpec dimension : dimensionSpecs) { - final Column column = index.getColumn(dimension.getDimension()); - if (column != null) { - final BitmapIndex bitmapIndex = column.getBitmapIndex(); + final ColumnHolder columnHolder = index.getColumnHolder(dimension.getDimension()); + if (columnHolder != null) { + final BitmapIndex bitmapIndex = columnHolder.getBitmapIndex(); if (bitmapIndex != null) { totalCard += bitmapIndex.getCardinality(); } diff --git a/processing/src/main/java/org/apache/druid/query/search/CursorOnlyStrategy.java b/processing/src/main/java/org/apache/druid/query/search/CursorOnlyStrategy.java index 64f43561f4b..ec646e62d11 100644 --- a/processing/src/main/java/org/apache/druid/query/search/CursorOnlyStrategy.java +++ b/processing/src/main/java/org/apache/druid/query/search/CursorOnlyStrategy.java @@ -20,6 +20,7 @@ package org.apache.druid.query.search; import com.google.common.collect.ImmutableList; +import it.unimi.dsi.fastutil.objects.Object2IntRBTreeMap; import org.apache.druid.java.util.common.guava.Sequence; import org.apache.druid.query.ColumnSelectorPlus; import org.apache.druid.query.dimension.DimensionSpec; @@ -30,7 +31,6 @@ import org.apache.druid.segment.DimensionHandlerUtils; import org.apache.druid.segment.Segment; import org.apache.druid.segment.StorageAdapter; import org.apache.druid.segment.VirtualColumns; -import it.unimi.dsi.fastutil.objects.Object2IntRBTreeMap; import org.joda.time.Interval; import java.util.Arrays; diff --git a/processing/src/main/java/org/apache/druid/query/search/DefaultSearchQueryMetrics.java b/processing/src/main/java/org/apache/druid/query/search/DefaultSearchQueryMetrics.java index a44b004a91f..3f7811335e1 100644 --- a/processing/src/main/java/org/apache/druid/query/search/DefaultSearchQueryMetrics.java +++ b/processing/src/main/java/org/apache/druid/query/search/DefaultSearchQueryMetrics.java @@ -19,9 +19,9 @@ package org.apache.druid.query.search; -import org.apache.druid.java.util.emitter.service.ServiceEmitter; import org.apache.druid.collections.bitmap.BitmapFactory; import org.apache.druid.java.util.common.ISE; +import org.apache.druid.java.util.emitter.service.ServiceEmitter; import org.apache.druid.query.BitmapResultFactory; import org.apache.druid.query.Query; import org.apache.druid.query.QueryMetrics; diff --git a/processing/src/main/java/org/apache/druid/query/search/SearchQueryExecutor.java b/processing/src/main/java/org/apache/druid/query/search/SearchQueryExecutor.java index da4b9b52806..e31416c2fa1 100644 --- a/processing/src/main/java/org/apache/druid/query/search/SearchQueryExecutor.java +++ b/processing/src/main/java/org/apache/druid/query/search/SearchQueryExecutor.java @@ -19,9 +19,9 @@ package org.apache.druid.query.search; +import it.unimi.dsi.fastutil.objects.Object2IntRBTreeMap; import org.apache.druid.query.dimension.DimensionSpec; import org.apache.druid.segment.Segment; -import it.unimi.dsi.fastutil.objects.Object2IntRBTreeMap; import java.util.List; diff --git a/processing/src/main/java/org/apache/druid/query/search/SearchQueryRunner.java b/processing/src/main/java/org/apache/druid/query/search/SearchQueryRunner.java index 6808cdf4774..3eae4b15332 100644 --- a/processing/src/main/java/org/apache/druid/query/search/SearchQueryRunner.java +++ b/processing/src/main/java/org/apache/druid/query/search/SearchQueryRunner.java @@ -23,6 +23,8 @@ import com.google.common.base.Function; import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; +import it.unimi.dsi.fastutil.objects.Object2IntMap; +import it.unimi.dsi.fastutil.objects.Object2IntRBTreeMap; import org.apache.druid.java.util.common.IAE; import org.apache.druid.java.util.common.ISE; import org.apache.druid.java.util.common.guava.FunctionalIterable; @@ -44,8 +46,6 @@ import org.apache.druid.segment.Segment; import org.apache.druid.segment.column.ColumnCapabilities; import org.apache.druid.segment.column.ValueType; import org.apache.druid.segment.data.IndexedInts; -import it.unimi.dsi.fastutil.objects.Object2IntMap; -import it.unimi.dsi.fastutil.objects.Object2IntRBTreeMap; import java.util.List; import java.util.Map; @@ -126,7 +126,7 @@ public class SearchQueryRunner implements QueryRunner> final Object2IntRBTreeMap set ) { - if (selector != null && !DimensionSelectorUtils.isNilSelector(selector)) { + if (!DimensionSelectorUtils.isNilSelector(selector)) { final IndexedInts row = selector.getRow(); for (int i = 0, rowSize = row.size(); i < rowSize; ++i) { final String dimVal = selector.lookupName(row.get(i)); diff --git a/processing/src/main/java/org/apache/druid/query/search/SearchStrategySelector.java b/processing/src/main/java/org/apache/druid/query/search/SearchStrategySelector.java index 6b8be88de24..9f96ab15f9e 100644 --- a/processing/src/main/java/org/apache/druid/query/search/SearchStrategySelector.java +++ b/processing/src/main/java/org/apache/druid/query/search/SearchStrategySelector.java @@ -21,8 +21,8 @@ package org.apache.druid.query.search; import com.google.common.base.Supplier; import com.google.inject.Inject; -import org.apache.druid.java.util.emitter.EmittingLogger; import org.apache.druid.java.util.common.ISE; +import org.apache.druid.java.util.emitter.EmittingLogger; public class SearchStrategySelector { diff --git a/processing/src/main/java/org/apache/druid/query/search/UseIndexesStrategy.java b/processing/src/main/java/org/apache/druid/query/search/UseIndexesStrategy.java index e01c2af070c..33ff8f04889 100644 --- a/processing/src/main/java/org/apache/druid/query/search/UseIndexesStrategy.java +++ b/processing/src/main/java/org/apache/druid/query/search/UseIndexesStrategy.java @@ -22,6 +22,7 @@ package org.apache.druid.query.search; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; +import it.unimi.dsi.fastutil.objects.Object2IntRBTreeMap; import org.apache.druid.collections.bitmap.BitmapFactory; import org.apache.druid.collections.bitmap.ImmutableBitmap; import org.apache.druid.collections.bitmap.MutableBitmap; @@ -38,10 +39,9 @@ import org.apache.druid.segment.Segment; import org.apache.druid.segment.StorageAdapter; import org.apache.druid.segment.VirtualColumns; import org.apache.druid.segment.column.BitmapIndex; -import org.apache.druid.segment.column.Column; import org.apache.druid.segment.column.ColumnCapabilities; -import org.apache.druid.segment.column.GenericColumn; -import it.unimi.dsi.fastutil.objects.Object2IntRBTreeMap; +import org.apache.druid.segment.column.ColumnHolder; +import org.apache.druid.segment.column.NumericColumn; import org.joda.time.Interval; import java.util.Arrays; @@ -164,8 +164,8 @@ public class UseIndexesStrategy extends SearchStrategy final ImmutableBitmap timeFilteredBitmap; if (!interval.contains(segment.getDataInterval())) { final MutableBitmap timeBitmap = bitmapFactory.makeEmptyMutableBitmap(); - final Column timeColumn = index.getColumn(Column.TIME_COLUMN_NAME); - try (final GenericColumn timeValues = timeColumn.getGenericColumn()) { + final ColumnHolder timeColumnHolder = index.getColumnHolder(ColumnHolder.TIME_COLUMN_NAME); + try (final NumericColumn timeValues = (NumericColumn) timeColumnHolder.getColumn()) { int startIndex = Math.max(0, getStartIndexOfTime(timeValues, interval.getStartMillis(), true)); int endIndex = Math.min( @@ -188,7 +188,7 @@ public class UseIndexesStrategy extends SearchStrategy return timeFilteredBitmap; } - private static int getStartIndexOfTime(GenericColumn timeValues, long time, boolean inclusive) + private static int getStartIndexOfTime(NumericColumn timeValues, long time, boolean inclusive) { int low = 0; int high = timeValues.length() - 1; @@ -245,12 +245,12 @@ public class UseIndexesStrategy extends SearchStrategy final BitmapFactory bitmapFactory = index.getBitmapFactoryForDimensions(); for (DimensionSpec dimension : dimsToSearch) { - final Column column = index.getColumn(dimension.getDimension()); - if (column == null) { + final ColumnHolder columnHolder = index.getColumnHolder(dimension.getDimension()); + if (columnHolder == null) { continue; } - final BitmapIndex bitmapIndex = column.getBitmapIndex(); + final BitmapIndex bitmapIndex = columnHolder.getBitmapIndex(); Preconditions.checkArgument(bitmapIndex != null, "Dimension [%s] should support bitmap index", dimension.getDimension() ); diff --git a/processing/src/main/java/org/apache/druid/query/select/DefaultSelectQueryMetrics.java b/processing/src/main/java/org/apache/druid/query/select/DefaultSelectQueryMetrics.java index d2b6b604498..83cad77fecf 100644 --- a/processing/src/main/java/org/apache/druid/query/select/DefaultSelectQueryMetrics.java +++ b/processing/src/main/java/org/apache/druid/query/select/DefaultSelectQueryMetrics.java @@ -19,9 +19,9 @@ package org.apache.druid.query.select; -import org.apache.druid.java.util.emitter.service.ServiceEmitter; import org.apache.druid.collections.bitmap.BitmapFactory; import org.apache.druid.java.util.common.ISE; +import org.apache.druid.java.util.emitter.service.ServiceEmitter; import org.apache.druid.query.BitmapResultFactory; import org.apache.druid.query.Query; import org.apache.druid.query.QueryMetrics; diff --git a/processing/src/main/java/org/apache/druid/query/select/SelectQueryEngine.java b/processing/src/main/java/org/apache/druid/query/select/SelectQueryEngine.java index a6106758324..921903810e8 100644 --- a/processing/src/main/java/org/apache/druid/query/select/SelectQueryEngine.java +++ b/processing/src/main/java/org/apache/druid/query/select/SelectQueryEngine.java @@ -46,8 +46,8 @@ import org.apache.druid.segment.DimensionHandlerUtils; import org.apache.druid.segment.DimensionSelector; import org.apache.druid.segment.Segment; import org.apache.druid.segment.StorageAdapter; -import org.apache.druid.segment.column.Column; import org.apache.druid.segment.column.ColumnCapabilities; +import org.apache.druid.segment.column.ColumnHolder; import org.apache.druid.segment.column.ValueType; import org.apache.druid.segment.data.IndexedInts; import org.apache.druid.segment.filter.Filters; @@ -235,7 +235,7 @@ public class SelectQueryEngine ); final BaseLongColumnValueSelector timestampColumnSelector = - cursor.getColumnSelectorFactory().makeColumnValueSelector(Column.TIME_COLUMN_NAME); + cursor.getColumnSelectorFactory().makeColumnValueSelector(ColumnHolder.TIME_COLUMN_NAME); final List> selectorPlusList = Arrays.asList( DimensionHandlerUtils.createColumnSelectorPluses( diff --git a/processing/src/main/java/org/apache/druid/query/timeboundary/TimeBoundaryQuery.java b/processing/src/main/java/org/apache/druid/query/timeboundary/TimeBoundaryQuery.java index e1db7578515..57de16af7b1 100644 --- a/processing/src/main/java/org/apache/druid/query/timeboundary/TimeBoundaryQuery.java +++ b/processing/src/main/java/org/apache/druid/query/timeboundary/TimeBoundaryQuery.java @@ -23,6 +23,7 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.google.common.collect.Lists; import com.google.common.collect.Maps; +import it.unimi.dsi.fastutil.bytes.ByteArrays; import org.apache.druid.java.util.common.DateTimes; import org.apache.druid.java.util.common.Intervals; import org.apache.druid.java.util.common.StringUtils; @@ -114,7 +115,7 @@ public class TimeBoundaryQuery extends BaseQuery public byte[] getCacheKey() { - final byte[] filterBytes = dimFilter == null ? new byte[] {} : dimFilter.getCacheKey(); + final byte[] filterBytes = dimFilter == null ? ByteArrays.EMPTY_ARRAY : dimFilter.getCacheKey(); final byte[] boundBytes = StringUtils.toUtf8(bound); final byte delimiter = (byte) 0xff; return ByteBuffer.allocate(2 + boundBytes.length + filterBytes.length) diff --git a/processing/src/main/java/org/apache/druid/query/timeboundary/TimeBoundaryQueryRunnerFactory.java b/processing/src/main/java/org/apache/druid/query/timeboundary/TimeBoundaryQueryRunnerFactory.java index ae025766d3e..dcf5dcd2570 100644 --- a/processing/src/main/java/org/apache/druid/query/timeboundary/TimeBoundaryQueryRunnerFactory.java +++ b/processing/src/main/java/org/apache/druid/query/timeboundary/TimeBoundaryQueryRunnerFactory.java @@ -40,7 +40,7 @@ import org.apache.druid.segment.Cursor; import org.apache.druid.segment.Segment; import org.apache.druid.segment.StorageAdapter; import org.apache.druid.segment.VirtualColumns; -import org.apache.druid.segment.column.Column; +import org.apache.druid.segment.column.ColumnHolder; import org.apache.druid.segment.filter.Filters; import org.joda.time.DateTime; @@ -49,7 +49,6 @@ import java.util.List; import java.util.Map; import java.util.concurrent.ExecutorService; - /** */ public class TimeBoundaryQueryRunnerFactory @@ -102,7 +101,7 @@ public class TimeBoundaryQueryRunnerFactory return null; } final BaseLongColumnValueSelector timestampColumnSelector = - cursor.getColumnSelectorFactory().makeColumnValueSelector(Column.TIME_COLUMN_NAME); + cursor.getColumnSelectorFactory().makeColumnValueSelector(ColumnHolder.TIME_COLUMN_NAME); final DateTime timestamp = DateTimes.utc(timestampColumnSelector.getLong()); return new Result<>(adapter.getInterval().getStart(), timestamp); } diff --git a/processing/src/main/java/org/apache/druid/query/topn/Historical1SimpleDoubleAggPooledTopNScannerPrototype.java b/processing/src/main/java/org/apache/druid/query/topn/Historical1SimpleDoubleAggPooledTopNScannerPrototype.java index 36374900da2..aee95f13471 100644 --- a/processing/src/main/java/org/apache/druid/query/topn/Historical1SimpleDoubleAggPooledTopNScannerPrototype.java +++ b/processing/src/main/java/org/apache/druid/query/topn/Historical1SimpleDoubleAggPooledTopNScannerPrototype.java @@ -22,9 +22,9 @@ package org.apache.druid.query.topn; import org.apache.druid.query.aggregation.SimpleDoubleBufferAggregator; import org.apache.druid.segment.data.IndexedInts; import org.apache.druid.segment.data.Offset; +import org.apache.druid.segment.historical.HistoricalColumnSelector; import org.apache.druid.segment.historical.HistoricalCursor; import org.apache.druid.segment.historical.HistoricalDimensionSelector; -import org.apache.druid.segment.historical.HistoricalColumnSelector; import java.nio.ByteBuffer; diff --git a/processing/src/main/java/org/apache/druid/query/topn/HistoricalSingleValueDimSelector1SimpleDoubleAggPooledTopNScannerPrototype.java b/processing/src/main/java/org/apache/druid/query/topn/HistoricalSingleValueDimSelector1SimpleDoubleAggPooledTopNScannerPrototype.java index b1389c36f01..850a885a854 100644 --- a/processing/src/main/java/org/apache/druid/query/topn/HistoricalSingleValueDimSelector1SimpleDoubleAggPooledTopNScannerPrototype.java +++ b/processing/src/main/java/org/apache/druid/query/topn/HistoricalSingleValueDimSelector1SimpleDoubleAggPooledTopNScannerPrototype.java @@ -21,8 +21,8 @@ package org.apache.druid.query.topn; import org.apache.druid.query.aggregation.SimpleDoubleBufferAggregator; import org.apache.druid.segment.data.Offset; -import org.apache.druid.segment.historical.HistoricalCursor; import org.apache.druid.segment.historical.HistoricalColumnSelector; +import org.apache.druid.segment.historical.HistoricalCursor; import org.apache.druid.segment.historical.SingleValueHistoricalDimensionSelector; import java.nio.ByteBuffer; diff --git a/processing/src/main/java/org/apache/druid/query/topn/PooledTopNAlgorithm.java b/processing/src/main/java/org/apache/druid/query/topn/PooledTopNAlgorithm.java index dd0e88c6c43..326bdf59bc0 100644 --- a/processing/src/main/java/org/apache/druid/query/topn/PooledTopNAlgorithm.java +++ b/processing/src/main/java/org/apache/druid/query/topn/PooledTopNAlgorithm.java @@ -744,11 +744,7 @@ public class PooledTopNAlgorithm } // Output type must be STRING in order for PooledTopNAlgorithm to make sense; so no need to convert value. - resultBuilder.addEntry( - dimSelector.lookupName(i), - i, - vals - ); + resultBuilder.addEntry(dimSelector.lookupName(i), i, vals); } } } diff --git a/processing/src/main/java/org/apache/druid/query/topn/TopNQueryEngine.java b/processing/src/main/java/org/apache/druid/query/topn/TopNQueryEngine.java index 81413f1ea4a..0b2fb487354 100644 --- a/processing/src/main/java/org/apache/druid/query/topn/TopNQueryEngine.java +++ b/processing/src/main/java/org/apache/druid/query/topn/TopNQueryEngine.java @@ -33,8 +33,8 @@ import org.apache.druid.query.filter.Filter; import org.apache.druid.segment.Cursor; import org.apache.druid.segment.SegmentMissingException; import org.apache.druid.segment.StorageAdapter; -import org.apache.druid.segment.column.Column; import org.apache.druid.segment.column.ColumnCapabilities; +import org.apache.druid.segment.column.ColumnHolder; import org.apache.druid.segment.column.ValueType; import org.apache.druid.segment.filter.Filters; import org.joda.time.Interval; @@ -131,7 +131,7 @@ public class TopNQueryEngine // TimeExtractionTopNAlgorithm can work on any single-value dimension of type long. // Once we have arbitrary dimension types following check should be replaced by checking // that the column is of type long and single-value. - dimension.equals(Column.TIME_COLUMN_NAME) + dimension.equals(ColumnHolder.TIME_COLUMN_NAME) ) { // A special TimeExtractionTopNAlgorithm is required, since DimExtractionTopNAlgorithm // currently relies on the dimension cardinality to support lexicographic sorting diff --git a/processing/src/main/java/org/apache/druid/query/topn/types/NumericTopNColumnSelectorStrategy.java b/processing/src/main/java/org/apache/druid/query/topn/types/NumericTopNColumnSelectorStrategy.java index f396825d547..fea86a1a569 100644 --- a/processing/src/main/java/org/apache/druid/query/topn/types/NumericTopNColumnSelectorStrategy.java +++ b/processing/src/main/java/org/apache/druid/query/topn/types/NumericTopNColumnSelectorStrategy.java @@ -19,6 +19,10 @@ package org.apache.druid.query.topn.types; +import it.unimi.dsi.fastutil.ints.Int2ObjectMap; +import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; +import it.unimi.dsi.fastutil.longs.Long2ObjectMap; +import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; import org.apache.druid.java.util.common.IAE; import org.apache.druid.query.aggregation.Aggregator; import org.apache.druid.query.topn.BaseTopNAlgorithm; @@ -32,10 +36,6 @@ import org.apache.druid.segment.Cursor; import org.apache.druid.segment.DimensionHandlerUtils; import org.apache.druid.segment.StorageAdapter; import org.apache.druid.segment.column.ValueType; -import it.unimi.dsi.fastutil.ints.Int2ObjectMap; -import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; -import it.unimi.dsi.fastutil.longs.Long2ObjectMap; -import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; import java.util.Map; import java.util.function.Function; diff --git a/processing/src/main/java/org/apache/druid/segment/AbstractDimensionSelector.java b/processing/src/main/java/org/apache/druid/segment/AbstractDimensionSelector.java new file mode 100644 index 00000000000..19c4fcb8326 --- /dev/null +++ b/processing/src/main/java/org/apache/druid/segment/AbstractDimensionSelector.java @@ -0,0 +1,38 @@ +/* + * 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; + +import javax.annotation.Nullable; + +/** + * An abstract class that provides an implementation of {@link #getObject()}. + * Don't extend this abstract class if you could provide a more efficient implementation for those methods, implement + * {@link DimensionSelector} directly then. + */ +public abstract class AbstractDimensionSelector implements DimensionSelector +{ + + @Nullable + @Override + public Object getObject() + { + return defaultGetObject(); + } +} diff --git a/processing/src/main/java/org/apache/druid/segment/AbstractIndex.java b/processing/src/main/java/org/apache/druid/segment/AbstractIndex.java index 670b36caaad..74258053412 100644 --- a/processing/src/main/java/org/apache/druid/segment/AbstractIndex.java +++ b/processing/src/main/java/org/apache/druid/segment/AbstractIndex.java @@ -21,10 +21,9 @@ package org.apache.druid.segment; import org.apache.druid.java.util.common.Intervals; import org.apache.druid.java.util.common.granularity.Granularities; -import org.apache.druid.segment.column.Column; +import org.apache.druid.segment.column.ColumnHolder; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; @@ -48,7 +47,7 @@ public abstract class AbstractIndex null ).toList(); List columnNames = new ArrayList<>(); - columnNames.add(Column.TIME_COLUMN_NAME); + columnNames.add(ColumnHolder.TIME_COLUMN_NAME); columnNames.addAll(getColumnNames()); for (Cursor cursor : cursors) { ColumnSelectorFactory columnSelectorFactory = cursor.getColumnSelectorFactory(); @@ -60,11 +59,7 @@ public abstract class AbstractIndex sb.append(columnNames.get(i)).append('='); ColumnValueSelector selector = selectors.get(i); Object columnValue = selector.getObject(); - if (columnValue instanceof Object[]) { - sb.append(Arrays.toString((Object[]) columnValue)); - } else { - sb.append(columnValue); - } + sb.append(columnValue); sb.append(", "); } sb.setLength(sb.length() - 2); diff --git a/processing/src/main/java/org/apache/druid/segment/BaseObjectColumnValueSelector.java b/processing/src/main/java/org/apache/druid/segment/BaseObjectColumnValueSelector.java index 71e1af2606b..45a399b4964 100644 --- a/processing/src/main/java/org/apache/druid/segment/BaseObjectColumnValueSelector.java +++ b/processing/src/main/java/org/apache/druid/segment/BaseObjectColumnValueSelector.java @@ -36,5 +36,5 @@ public interface BaseObjectColumnValueSelector extends BaseNullableColumnValu @Nullable T getObject(); - Class classOfObject(); + Class classOfObject(); } diff --git a/processing/src/main/java/org/apache/druid/segment/virtual/BaseSingleValueDimensionSelector.java b/processing/src/main/java/org/apache/druid/segment/BaseSingleValueDimensionSelector.java similarity index 89% rename from processing/src/main/java/org/apache/druid/segment/virtual/BaseSingleValueDimensionSelector.java rename to processing/src/main/java/org/apache/druid/segment/BaseSingleValueDimensionSelector.java index 3a01f720e1b..adb0ecd1e6e 100644 --- a/processing/src/main/java/org/apache/druid/segment/virtual/BaseSingleValueDimensionSelector.java +++ b/processing/src/main/java/org/apache/druid/segment/BaseSingleValueDimensionSelector.java @@ -17,14 +17,12 @@ * under the License. */ -package org.apache.druid.segment.virtual; +package org.apache.druid.segment; import com.google.common.base.Predicate; import org.apache.druid.query.filter.ValueMatcher; import org.apache.druid.query.monomorphicprocessing.CalledFromHotLoop; import org.apache.druid.query.monomorphicprocessing.RuntimeShapeInspector; -import org.apache.druid.segment.DimensionSelector; -import org.apache.druid.segment.IdLookup; import org.apache.druid.segment.data.IndexedInts; import org.apache.druid.segment.data.ZeroIndexedInts; @@ -34,6 +32,7 @@ import java.util.Objects; public abstract class BaseSingleValueDimensionSelector implements DimensionSelector { @CalledFromHotLoop + @Nullable protected abstract String getValue(); @Override @@ -45,17 +44,18 @@ public abstract class BaseSingleValueDimensionSelector implements DimensionSelec @Override public int getValueCardinality() { - return DimensionSelector.CARDINALITY_UNKNOWN; + return CARDINALITY_UNKNOWN; } @Override public String lookupName(int id) { + assert id == 0; return getValue(); } @Override - public ValueMatcher makeValueMatcher(final String value) + public ValueMatcher makeValueMatcher(final @Nullable String value) { return new ValueMatcher() { @@ -108,13 +108,13 @@ public abstract class BaseSingleValueDimensionSelector implements DimensionSelec @Nullable @Override - public Object getObject() + public String getObject() { return getValue(); } @Override - public Class classOfObject() + public Class classOfObject() { return String.class; } diff --git a/processing/src/main/java/org/apache/druid/segment/ColumnSelector.java b/processing/src/main/java/org/apache/druid/segment/ColumnSelector.java index c3ac63e8ab4..d73b2dacc48 100644 --- a/processing/src/main/java/org/apache/druid/segment/ColumnSelector.java +++ b/processing/src/main/java/org/apache/druid/segment/ColumnSelector.java @@ -19,7 +19,7 @@ package org.apache.druid.segment; -import org.apache.druid.segment.column.Column; +import org.apache.druid.segment.column.ColumnHolder; import javax.annotation.Nullable; import java.util.List; @@ -31,5 +31,5 @@ public interface ColumnSelector List getColumnNames(); @Nullable - Column getColumn(String columnName); + ColumnHolder getColumnHolder(String columnName); } diff --git a/processing/src/main/java/org/apache/druid/segment/ColumnSelectorBitmapIndexSelector.java b/processing/src/main/java/org/apache/druid/segment/ColumnSelectorBitmapIndexSelector.java index df0bddde886..596a9f37f88 100644 --- a/processing/src/main/java/org/apache/druid/segment/ColumnSelectorBitmapIndexSelector.java +++ b/processing/src/main/java/org/apache/druid/segment/ColumnSelectorBitmapIndexSelector.java @@ -25,13 +25,16 @@ import org.apache.druid.collections.spatial.ImmutableRTree; import org.apache.druid.common.config.NullHandling; import org.apache.druid.query.filter.BitmapIndexSelector; import org.apache.druid.query.monomorphicprocessing.RuntimeShapeInspector; +import org.apache.druid.segment.column.BaseColumn; import org.apache.druid.segment.column.BitmapIndex; -import org.apache.druid.segment.column.Column; +import org.apache.druid.segment.column.ColumnHolder; import org.apache.druid.segment.column.DictionaryEncodedColumn; -import org.apache.druid.segment.column.GenericColumn; -import org.apache.druid.segment.data.Indexed; +import org.apache.druid.segment.column.NumericColumn; +import org.apache.druid.segment.data.CloseableIndexed; import org.apache.druid.segment.data.IndexedIterable; +import javax.annotation.Nullable; +import java.io.IOException; import java.util.Iterator; /** @@ -53,26 +56,26 @@ public class ColumnSelectorBitmapIndexSelector implements BitmapIndexSelector this.index = index; } + @Nullable @Override - public Indexed getDimensionValues(String dimension) + public CloseableIndexed getDimensionValues(String dimension) { if (isVirtualColumn(dimension)) { // Virtual columns don't have dictionaries or indexes. return null; } - final Column columnDesc = index.getColumn(dimension); - if (columnDesc == null || !columnDesc.getCapabilities().isDictionaryEncoded()) { + final ColumnHolder columnHolder = index.getColumnHolder(dimension); + if (columnHolder == null) { return null; } - final DictionaryEncodedColumn column = columnDesc.getDictionaryEncoding(); - return new Indexed() + BaseColumn col = columnHolder.getColumn(); + if (!(col instanceof DictionaryEncodedColumn)) { + return null; + } + final DictionaryEncodedColumn column = (DictionaryEncodedColumn) col; + return new CloseableIndexed() { - @Override - public Class getClazz() - { - return String.class; - } @Override public int size() @@ -103,6 +106,12 @@ public class ColumnSelectorBitmapIndexSelector implements BitmapIndexSelector { inspector.visit("column", column); } + + @Override + public void close() throws IOException + { + column.close(); + } }; } @@ -113,14 +122,14 @@ public class ColumnSelectorBitmapIndexSelector implements BitmapIndexSelector return virtualColumns.getVirtualColumn(dimension).capabilities(dimension).hasMultipleValues(); } - final Column column = index.getColumn(dimension); - return column != null && column.getCapabilities().hasMultipleValues(); + final ColumnHolder columnHolder = index.getColumnHolder(dimension); + return columnHolder != null && columnHolder.getCapabilities().hasMultipleValues(); } @Override public int getNumRows() { - try (final GenericColumn column = index.getColumn(Column.TIME_COLUMN_NAME).getGenericColumn()) { + try (final NumericColumn column = (NumericColumn) index.getColumnHolder(ColumnHolder.TIME_COLUMN_NAME).getColumn()) { return column.length(); } } @@ -139,8 +148,8 @@ public class ColumnSelectorBitmapIndexSelector implements BitmapIndexSelector return null; } - final Column column = index.getColumn(dimension); - if (column == null || !column.getCapabilities().isFilterable()) { + final ColumnHolder columnHolder = index.getColumnHolder(dimension); + if (columnHolder == null || !columnHolder.getCapabilities().isFilterable()) { // for missing columns and columns with types that do not support filtering, // treat the column as if it were a String column full of nulls. // Create a BitmapIndex so that filters applied to null columns can use @@ -179,7 +188,7 @@ public class ColumnSelectorBitmapIndexSelector implements BitmapIndexSelector * i.e., return an 'insertion point' of 1 for non-null values (see {@link BitmapIndex} interface) */ @Override - public int getIndex(String value) + public int getIndex(@Nullable String value) { return NullHandling.isNullOrEquivalent(value) ? 0 : -2; } @@ -194,8 +203,8 @@ public class ColumnSelectorBitmapIndexSelector implements BitmapIndexSelector } } }; - } else if (column.getCapabilities().hasBitmapIndexes()) { - return column.getBitmapIndex(); + } else if (columnHolder.getCapabilities().hasBitmapIndexes()) { + return columnHolder.getBitmapIndex(); } else { return null; } @@ -209,8 +218,8 @@ public class ColumnSelectorBitmapIndexSelector implements BitmapIndexSelector return null; } - final Column column = index.getColumn(dimension); - if (column == null || !column.getCapabilities().isFilterable()) { + final ColumnHolder columnHolder = index.getColumnHolder(dimension); + if (columnHolder == null || !columnHolder.getCapabilities().isFilterable()) { if (NullHandling.isNullOrEquivalent(value)) { return bitmapFactory.complement(bitmapFactory.makeEmptyImmutableBitmap(), getNumRows()); } else { @@ -218,11 +227,11 @@ public class ColumnSelectorBitmapIndexSelector implements BitmapIndexSelector } } - if (!column.getCapabilities().hasBitmapIndexes()) { + if (!columnHolder.getCapabilities().hasBitmapIndexes()) { return null; } - final BitmapIndex bitmapIndex = column.getBitmapIndex(); + final BitmapIndex bitmapIndex = columnHolder.getBitmapIndex(); return bitmapIndex.getBitmap(bitmapIndex.getIndex(value)); } @@ -233,12 +242,12 @@ public class ColumnSelectorBitmapIndexSelector implements BitmapIndexSelector return ImmutableRTree.empty(); } - final Column column = index.getColumn(dimension); - if (column == null || !column.getCapabilities().hasSpatialIndexes()) { + final ColumnHolder columnHolder = index.getColumnHolder(dimension); + if (columnHolder == null || !columnHolder.getCapabilities().hasSpatialIndexes()) { return ImmutableRTree.empty(); } - return column.getSpatialIndex().getRTree(); + return columnHolder.getSpatialIndex().getRTree(); } private boolean isVirtualColumn(final String columnName) diff --git a/processing/src/main/java/org/apache/druid/segment/DimensionHandler.java b/processing/src/main/java/org/apache/druid/segment/DimensionHandler.java index 805d5b8a197..fe4466fe4f6 100644 --- a/processing/src/main/java/org/apache/druid/segment/DimensionHandler.java +++ b/processing/src/main/java/org/apache/druid/segment/DimensionHandler.java @@ -20,6 +20,7 @@ package org.apache.druid.segment; import org.apache.druid.data.input.impl.DimensionSchema.MultiValueHandling; +import org.apache.druid.java.util.common.io.Closer; import org.apache.druid.segment.column.ColumnCapabilities; import org.apache.druid.segment.selector.settable.SettableColumnValueSelector; import org.apache.druid.segment.writeout.SegmentWriteOutMedium; @@ -92,14 +93,14 @@ public interface DimensionHandler * @param segmentWriteOutMedium this SegmentWriteOutMedium object could be used internally in the created merger, if needed * @param capabilities The ColumnCapabilities of the dimension represented by this DimensionHandler * @param progress ProgressIndicator used by the merging process - * @return A new DimensionMergerV9 object. */ DimensionMergerV9 makeMerger( IndexSpec indexSpec, SegmentWriteOutMedium segmentWriteOutMedium, ColumnCapabilities capabilities, - ProgressIndicator progress + ProgressIndicator progress, + Closer closer ); /** diff --git a/processing/src/main/java/org/apache/druid/segment/DimensionHandlerUtils.java b/processing/src/main/java/org/apache/druid/segment/DimensionHandlerUtils.java index 13b278c0414..197b976afb3 100644 --- a/processing/src/main/java/org/apache/druid/segment/DimensionHandlerUtils.java +++ b/processing/src/main/java/org/apache/druid/segment/DimensionHandlerUtils.java @@ -151,6 +151,7 @@ public final class DimensionHandlerUtils ) { int dimCount = dimensionSpecs.size(); + @SuppressWarnings("unchecked") ColumnSelectorPlus[] dims = new ColumnSelectorPlus[dimCount]; for (int i = 0; i < dimCount; i++) { final DimensionSpec dimSpec = dimensionSpecs.get(i); @@ -176,7 +177,7 @@ public final class DimensionHandlerUtils return dims; } - public static ColumnValueSelector getColumnValueSelectorFromDimensionSpec( + private static ColumnValueSelector getColumnValueSelectorFromDimensionSpec( DimensionSpec dimSpec, ColumnSelectorFactory columnSelectorFactory ) @@ -187,21 +188,19 @@ public final class DimensionHandlerUtils switch (capabilities.getType()) { case STRING: return columnSelectorFactory.makeDimensionSelector(dimSpec); - case LONG: - case FLOAT: - case DOUBLE: - return columnSelectorFactory.makeColumnValueSelector(dimSpec.getDimension()); default: - return null; + return columnSelectorFactory.makeColumnValueSelector(dimSpec.getDimension()); } } - // When determining the capabilities of a column during query processing, this function - // adjusts the capabilities for columns that cannot be handled as-is to manageable defaults - // (e.g., treating missing columns as empty String columns) + /** + * When determining the capabilities of a column during query processing, this function + * adjusts the capabilities for columns that cannot be handled as-is to manageable defaults + * (e.g., treating missing columns as empty String columns) + */ private static ColumnCapabilities getEffectiveCapabilities( DimensionSpec dimSpec, - ColumnCapabilities capabilities + @Nullable ColumnCapabilities capabilities ) { if (capabilities == null) { @@ -233,7 +232,7 @@ public final class DimensionHandlerUtils private static ColumnSelectorStrategyClass makeStrategy( ColumnSelectorStrategyFactory strategyFactory, DimensionSpec dimSpec, - ColumnCapabilities capabilities, + @Nullable ColumnCapabilities capabilities, ColumnValueSelector selector ) { diff --git a/processing/src/main/java/org/apache/druid/segment/DimensionIndexer.java b/processing/src/main/java/org/apache/druid/segment/DimensionIndexer.java index 118df7700c0..0ddbba0856d 100644 --- a/processing/src/main/java/org/apache/druid/segment/DimensionIndexer.java +++ b/processing/src/main/java/org/apache/druid/segment/DimensionIndexer.java @@ -22,7 +22,7 @@ package org.apache.druid.segment; import org.apache.druid.collections.bitmap.BitmapFactory; import org.apache.druid.collections.bitmap.MutableBitmap; import org.apache.druid.query.dimension.DimensionSpec; -import org.apache.druid.segment.data.Indexed; +import org.apache.druid.segment.data.CloseableIndexed; import org.apache.druid.segment.incremental.IncrementalIndex; import org.apache.druid.segment.incremental.IncrementalIndexRowHolder; @@ -160,7 +160,7 @@ public interface DimensionIndexer * * @return Sorted index of actual values */ - Indexed getSortedIndexedValues(); + CloseableIndexed getSortedIndexedValues(); /** @@ -268,22 +268,16 @@ public interface DimensionIndexer */ int getUnsortedEncodedKeyComponentHashCode(@Nullable EncodedKeyComponentType key); - boolean LIST = true; - boolean ARRAY = false; - /** * Given a row value array from a Row key, as described in the documentation for - * compareUnsortedEncodedKeyComponents(), convert the unsorted encoded values to a list or array of actual values. + * {@link #compareUnsortedEncodedKeyComponents}, convert the unsorted encoded values to a list of actual values. * - * If the key has one element, this method should return a single Object instead of an array or list, ignoring - * the asList parameter. + * If the key has one element, this method should return a single Object instead of a list. * * @param key dimension value array from a Row key - * @param asList if true, return an array; if false, return a list - * @return single value, array, or list containing the actual values corresponding to the encoded values - * in the input array + * @return single value or list containing the actual values corresponding to the encoded values in the input array */ - Object convertUnsortedEncodedKeyComponentToActualArrayOrList(EncodedKeyComponentType key, boolean asList); + Object convertUnsortedEncodedKeyComponentToActualList(EncodedKeyComponentType key); /** * Converts dictionary-encoded row values from unspecified (random) encoding order, to sorted encoding. This step diff --git a/processing/src/main/java/org/apache/druid/segment/DimensionSelector.java b/processing/src/main/java/org/apache/druid/segment/DimensionSelector.java index 1097b2ac29b..d4ffe6c280c 100644 --- a/processing/src/main/java/org/apache/druid/segment/DimensionSelector.java +++ b/processing/src/main/java/org/apache/druid/segment/DimensionSelector.java @@ -27,11 +27,12 @@ import org.apache.druid.query.monomorphicprocessing.HotLoopCallee; import org.apache.druid.segment.data.IndexedInts; import javax.annotation.Nullable; +import java.util.Arrays; /** */ @PublicApi -public interface DimensionSelector extends ColumnValueSelector, HotLoopCallee +public interface DimensionSelector extends ColumnValueSelector, HotLoopCallee { int CARDINALITY_UNKNOWN = -1; @@ -125,6 +126,11 @@ public interface DimensionSelector extends ColumnValueSelector, HotLoopCallee @Nullable IdLookup idLookup(); + /** + * @deprecated This method is marked as deprecated in DimensionSelector to minimize the probability of accidental + * calling. "Polymorphism" of DimensionSelector should be used only when operating on {@link ColumnValueSelector} + * objects. + */ @Deprecated @Override default float getFloat() @@ -133,6 +139,11 @@ public interface DimensionSelector extends ColumnValueSelector, HotLoopCallee return 0.0f; } + /** + * @deprecated This method is marked as deprecated in DimensionSelector to minimize the probability of accidental + * calling. "Polymorphism" of DimensionSelector should be used only when operating on {@link ColumnValueSelector} + * objects. + */ @Deprecated @Override default double getDouble() @@ -141,6 +152,11 @@ public interface DimensionSelector extends ColumnValueSelector, HotLoopCallee return 0.0; } + /** + * @deprecated This method is marked as deprecated in DimensionSelector to minimize the probability of accidental + * calling. "Polymorphism" of DimensionSelector should be used only when operating on {@link ColumnValueSelector} + * objects. + */ @Deprecated @Override default long getLong() @@ -177,7 +193,7 @@ public interface DimensionSelector extends ColumnValueSelector, HotLoopCallee for (int i = 0; i < rowSize; i++) { strings[i] = lookupName(row.get(i)); } - return strings; + return Arrays.asList(strings); } } } diff --git a/processing/src/main/java/org/apache/druid/segment/DimensionSelectorUtils.java b/processing/src/main/java/org/apache/druid/segment/DimensionSelectorUtils.java index 7360fefb5fc..a8a6ed2712f 100644 --- a/processing/src/main/java/org/apache/druid/segment/DimensionSelectorUtils.java +++ b/processing/src/main/java/org/apache/druid/segment/DimensionSelectorUtils.java @@ -46,7 +46,7 @@ public final class DimensionSelectorUtils * {@code makeValueMatcher()} to this method, but encouraged to implement {@code makeValueMatcher()} themselves, * bypassing the {@link IndexedInts} abstraction. */ - public static ValueMatcher makeValueMatcherGeneric(DimensionSelector selector, String value) + public static ValueMatcher makeValueMatcherGeneric(DimensionSelector selector, @Nullable String value) { IdLookup idLookup = selector.idLookup(); if (idLookup != null) { @@ -118,7 +118,7 @@ public final class DimensionSelectorUtils private static ValueMatcher makeNonDictionaryEncodedValueMatcherGeneric( final DimensionSelector selector, - final String value + final @Nullable String value ) { return new ValueMatcher() @@ -293,5 +293,4 @@ public final class DimensionSelectorUtils && selector.getValueCardinality() == 1 && selector.lookupName(0) == null; } - } diff --git a/processing/src/main/java/org/apache/druid/segment/DoubleColumnSelector.java b/processing/src/main/java/org/apache/druid/segment/DoubleColumnSelector.java index e7f16295a54..46ff2081f89 100644 --- a/processing/src/main/java/org/apache/druid/segment/DoubleColumnSelector.java +++ b/processing/src/main/java/org/apache/druid/segment/DoubleColumnSelector.java @@ -31,7 +31,7 @@ import javax.annotation.Nullable; public interface DoubleColumnSelector extends ColumnValueSelector { /** - * @deprecated This method is marked as deprecated in DoubleColumnSelector to minimize the probability of accidential + * @deprecated This method is marked as deprecated in DoubleColumnSelector to minimize the probability of accidental * calling. "Polymorphism" of DoubleColumnSelector should be used only when operating on {@link ColumnValueSelector} * objects. */ @@ -43,7 +43,7 @@ public interface DoubleColumnSelector extends ColumnValueSelector } /** - * @deprecated This method is marked as deprecated in DoubleColumnSelector to minimize the probability of accidential + * @deprecated This method is marked as deprecated in DoubleColumnSelector to minimize the probability of accidental * calling. "Polymorphism" of DoubleColumnSelector should be used only when operating on {@link ColumnValueSelector} * objects. */ @@ -55,7 +55,7 @@ public interface DoubleColumnSelector extends ColumnValueSelector } /** - * @deprecated This method is marked as deprecated in DoubleColumnSelector to minimize the probability of accidential + * @deprecated This method is marked as deprecated in DoubleColumnSelector to minimize the probability of accidental * calling. "Polymorphism" of DoubleColumnSelector should be used only when operating on {@link ColumnValueSelector} * objects. */ @@ -71,7 +71,7 @@ public interface DoubleColumnSelector extends ColumnValueSelector } /** - * @deprecated This method is marked as deprecated in DoubleColumnSelector to minimize the probability of accidential + * @deprecated This method is marked as deprecated in DoubleColumnSelector to minimize the probability of accidental * calling. "Polymorphism" of DoubleColumnSelector should be used only when operating on {@link ColumnValueSelector} * objects. */ diff --git a/processing/src/main/java/org/apache/druid/segment/DoubleColumnSerializer.java b/processing/src/main/java/org/apache/druid/segment/DoubleColumnSerializer.java index 0082f2595dc..67b68eda5a1 100644 --- a/processing/src/main/java/org/apache/druid/segment/DoubleColumnSerializer.java +++ b/processing/src/main/java/org/apache/druid/segment/DoubleColumnSerializer.java @@ -21,16 +21,16 @@ package org.apache.druid.segment; import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.java.util.common.io.smoosh.FileSmoosher; -import org.apache.druid.segment.writeout.SegmentWriteOutMedium; +import org.apache.druid.segment.data.ColumnarDoublesSerializer; import org.apache.druid.segment.data.CompressionFactory; import org.apache.druid.segment.data.CompressionStrategy; -import org.apache.druid.segment.data.ColumnarDoublesSerializer; +import org.apache.druid.segment.writeout.SegmentWriteOutMedium; import java.io.IOException; import java.nio.ByteOrder; import java.nio.channels.WritableByteChannel; -public class DoubleColumnSerializer implements GenericColumnSerializer +public class DoubleColumnSerializer implements GenericColumnSerializer { public static DoubleColumnSerializer create( SegmentWriteOutMedium segmentWriteOutMedium, @@ -73,7 +73,7 @@ public class DoubleColumnSerializer implements GenericColumnSerializer } @Override - public void serialize(ColumnValueSelector selector) throws IOException + public void serialize(ColumnValueSelector selector) throws IOException { writer.add(selector.getDouble()); } diff --git a/processing/src/main/java/org/apache/druid/segment/DoubleColumnSerializerV2.java b/processing/src/main/java/org/apache/druid/segment/DoubleColumnSerializerV2.java index 9859cee8233..3078a6aaad0 100644 --- a/processing/src/main/java/org/apache/druid/segment/DoubleColumnSerializerV2.java +++ b/processing/src/main/java/org/apache/druid/segment/DoubleColumnSerializerV2.java @@ -40,9 +40,9 @@ import java.nio.channels.WritableByteChannel; * Column Serializer for double column. * The column is serialized in two parts, first a bitmap indicating the nullability of row values * and second the actual row values. - * This class is Unsafe for concurrent use from multiple threads. + * This class is unsafe for concurrent use from multiple threads. */ -public class DoubleColumnSerializerV2 implements GenericColumnSerializer +public class DoubleColumnSerializerV2 implements GenericColumnSerializer { public static DoubleColumnSerializerV2 create( SegmentWriteOutMedium segmentWriteOutMedium, @@ -105,7 +105,7 @@ public class DoubleColumnSerializerV2 implements GenericColumnSerializer } @Override - public void serialize(ColumnValueSelector selector) throws IOException + public void serialize(ColumnValueSelector selector) throws IOException { if (selector.isNull()) { nullRowsBitmap.add(rowCount); diff --git a/processing/src/main/java/org/apache/druid/segment/DoubleDimensionHandler.java b/processing/src/main/java/org/apache/druid/segment/DoubleDimensionHandler.java index 008c46ef3e7..5e43d0dd345 100644 --- a/processing/src/main/java/org/apache/druid/segment/DoubleDimensionHandler.java +++ b/processing/src/main/java/org/apache/druid/segment/DoubleDimensionHandler.java @@ -19,6 +19,7 @@ package org.apache.druid.segment; +import org.apache.druid.java.util.common.io.Closer; import org.apache.druid.segment.column.ColumnCapabilities; import org.apache.druid.segment.selector.settable.SettableColumnValueSelector; import org.apache.druid.segment.selector.settable.SettableDoubleColumnValueSelector; @@ -62,7 +63,8 @@ public class DoubleDimensionHandler implements DimensionHandler getSortedIndexedValues() + public CloseableIndexed getSortedIndexedValues() { throw new UnsupportedOperationException("Numeric columns do not support value dictionaries."); } @@ -164,7 +164,7 @@ public class DoubleDimensionIndexer implements DimensionIndexer { /** - * @deprecated This method is marked as deprecated in FloatColumnSelector to minimize the probability of accidential + * @deprecated This method is marked as deprecated in FloatColumnSelector to minimize the probability of accidental * calling. "Polymorphism" of FloatColumnSelector should be used only when operating on {@link ColumnValueSelector} * objects. */ @@ -43,7 +43,7 @@ public interface FloatColumnSelector extends ColumnValueSelector } /** - * @deprecated This method is marked as deprecated in FloatColumnSelector to minimize the probability of accidential + * @deprecated This method is marked as deprecated in FloatColumnSelector to minimize the probability of accidental * calling. "Polymorphism" of FloatColumnSelector should be used only when operating on {@link ColumnValueSelector} * objects. */ @@ -55,7 +55,7 @@ public interface FloatColumnSelector extends ColumnValueSelector } /** - * @deprecated This method is marked as deprecated in FloatColumnSelector to minimize the probability of accidential + * @deprecated This method is marked as deprecated in FloatColumnSelector to minimize the probability of accidental * calling. "Polymorphism" of FloatColumnSelector should be used only when operating on {@link ColumnValueSelector} * objects. */ @@ -71,7 +71,7 @@ public interface FloatColumnSelector extends ColumnValueSelector } /** - * @deprecated This method is marked as deprecated in FloatColumnSelector to minimize the probability of accidential + * @deprecated This method is marked as deprecated in FloatColumnSelector to minimize the probability of accidental * calling. "Polymorphism" of FloatColumnSelector should be used only when operating on {@link ColumnValueSelector} * objects. */ diff --git a/processing/src/main/java/org/apache/druid/segment/FloatColumnSerializer.java b/processing/src/main/java/org/apache/druid/segment/FloatColumnSerializer.java index f21325f8657..8d413d54c1f 100644 --- a/processing/src/main/java/org/apache/druid/segment/FloatColumnSerializer.java +++ b/processing/src/main/java/org/apache/druid/segment/FloatColumnSerializer.java @@ -21,16 +21,16 @@ package org.apache.druid.segment; import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.java.util.common.io.smoosh.FileSmoosher; -import org.apache.druid.segment.writeout.SegmentWriteOutMedium; +import org.apache.druid.segment.data.ColumnarFloatsSerializer; import org.apache.druid.segment.data.CompressionFactory; import org.apache.druid.segment.data.CompressionStrategy; -import org.apache.druid.segment.data.ColumnarFloatsSerializer; +import org.apache.druid.segment.writeout.SegmentWriteOutMedium; import java.io.IOException; import java.nio.ByteOrder; import java.nio.channels.WritableByteChannel; -public class FloatColumnSerializer implements GenericColumnSerializer +public class FloatColumnSerializer implements GenericColumnSerializer { public static FloatColumnSerializer create( SegmentWriteOutMedium segmentWriteOutMedium, @@ -73,7 +73,7 @@ public class FloatColumnSerializer implements GenericColumnSerializer } @Override - public void serialize(ColumnValueSelector selector) throws IOException + public void serialize(ColumnValueSelector selector) throws IOException { writer.add(selector.getFloat()); } diff --git a/processing/src/main/java/org/apache/druid/segment/FloatColumnSerializerV2.java b/processing/src/main/java/org/apache/druid/segment/FloatColumnSerializerV2.java index 1ef0b59bce9..41e7b685a90 100644 --- a/processing/src/main/java/org/apache/druid/segment/FloatColumnSerializerV2.java +++ b/processing/src/main/java/org/apache/druid/segment/FloatColumnSerializerV2.java @@ -40,9 +40,9 @@ import java.nio.channels.WritableByteChannel; * Column Serializer for float column. * The column is serialized in two parts, first a bitmap indicating the nullability of row values * and second the actual row values. - * This class is Unsafe for concurrent use from multiple threads. + * This class is unsafe for concurrent use from multiple threads. */ -public class FloatColumnSerializerV2 implements GenericColumnSerializer +public class FloatColumnSerializerV2 implements GenericColumnSerializer { public static FloatColumnSerializerV2 create( SegmentWriteOutMedium segmentWriteOutMedium, @@ -105,7 +105,7 @@ public class FloatColumnSerializerV2 implements GenericColumnSerializer } @Override - public void serialize(ColumnValueSelector selector) throws IOException + public void serialize(ColumnValueSelector selector) throws IOException { if (selector.isNull()) { nullRowsBitmap.add(rowCount); diff --git a/processing/src/main/java/org/apache/druid/segment/FloatDimensionHandler.java b/processing/src/main/java/org/apache/druid/segment/FloatDimensionHandler.java index 0c0f4cb768f..2a072a99de5 100644 --- a/processing/src/main/java/org/apache/druid/segment/FloatDimensionHandler.java +++ b/processing/src/main/java/org/apache/druid/segment/FloatDimensionHandler.java @@ -19,6 +19,7 @@ package org.apache.druid.segment; +import org.apache.druid.java.util.common.io.Closer; import org.apache.druid.segment.column.ColumnCapabilities; import org.apache.druid.segment.selector.settable.SettableColumnValueSelector; import org.apache.druid.segment.selector.settable.SettableFloatColumnValueSelector; @@ -62,7 +63,8 @@ public class FloatDimensionHandler implements DimensionHandler getSortedIndexedValues() + public CloseableIndexed getSortedIndexedValues() { throw new UnsupportedOperationException("Numeric columns do not support value dictionaries."); } @@ -167,7 +167,7 @@ public class FloatDimensionIndexer implements DimensionIndexer extends Serializer { void open() throws IOException; - void serialize(ColumnValueSelector selector) throws IOException; + void serialize(ColumnValueSelector selector) throws IOException; } diff --git a/processing/src/main/java/org/apache/druid/segment/IndexIO.java b/processing/src/main/java/org/apache/druid/segment/IndexIO.java index 6d74deb9bc0..3c5a06fe311 100644 --- a/processing/src/main/java/org/apache/druid/segment/IndexIO.java +++ b/processing/src/main/java/org/apache/druid/segment/IndexIO.java @@ -45,11 +45,11 @@ import org.apache.druid.java.util.common.io.smoosh.Smoosh; import org.apache.druid.java.util.common.io.smoosh.SmooshedFileMapper; import org.apache.druid.java.util.common.logger.Logger; import org.apache.druid.java.util.emitter.EmittingLogger; -import org.apache.druid.segment.column.Column; import org.apache.druid.segment.column.ColumnBuilder; import org.apache.druid.segment.column.ColumnCapabilities; import org.apache.druid.segment.column.ColumnConfig; import org.apache.druid.segment.column.ColumnDescriptor; +import org.apache.druid.segment.column.ColumnHolder; import org.apache.druid.segment.column.ValueType; import org.apache.druid.segment.data.BitmapSerde; import org.apache.druid.segment.data.BitmapSerdeFactory; @@ -61,8 +61,8 @@ import org.apache.druid.segment.data.VSizeColumnarMultiInts; import org.apache.druid.segment.serde.BitmapIndexColumnPartSupplier; import org.apache.druid.segment.serde.ComplexColumnPartSupplier; import org.apache.druid.segment.serde.DictionaryEncodedColumnSupplier; -import org.apache.druid.segment.serde.FloatGenericColumnSupplier; -import org.apache.druid.segment.serde.LongGenericColumnSupplier; +import org.apache.druid.segment.serde.FloatNumericColumnSupplier; +import org.apache.druid.segment.serde.LongNumericColumnSupplier; import org.apache.druid.segment.serde.SpatialIndexColumnPartSupplier; import org.joda.time.Interval; @@ -73,7 +73,6 @@ import java.io.IOException; import java.io.InputStream; import java.nio.ByteBuffer; import java.nio.ByteOrder; -import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.Objects; @@ -218,18 +217,15 @@ public class IndexIO rp2.getTimestamp() ); } - final Object[] dims1 = rp1.getDimensionValuesForDebug(); - final Object[] dims2 = rp2.getDimensionValuesForDebug(); - if (dims1.length != dims2.length) { - throw new SegmentValidationException( - "Dim lengths not equal %s vs %s", - Arrays.deepToString(dims1), - Arrays.deepToString(dims2) - ); + final List dims1 = rp1.getDimensionValuesForDebug(); + final List dims2 = rp2.getDimensionValuesForDebug(); + if (dims1.size() != dims2.size()) { + throw new SegmentValidationException("Dim lengths not equal %s vs %s", dims1, dims2); } final List dim1Names = adapter1.getDimensionNames(); final List dim2Names = adapter2.getDimensionNames(); - for (int i = 0; i < dims1.length; ++i) { + int dimCount = dims1.size(); + for (int i = 0; i < dimCount; ++i) { final String dim1Name = dim1Names.get(i); final String dim2Name = dim2Names.get(i); @@ -246,22 +242,22 @@ public class IndexIO ); } - Object vals1 = dims1[i]; - Object vals2 = dims2[i]; + Object vals1 = dims1.get(i); + Object vals2 = dims2.get(i); if (isNullRow(vals1) ^ isNullRow(vals2)) { throw notEqualValidationException(dim1Name, vals1, vals2); } - if (vals1 instanceof Object[] && vals2 instanceof Object[]) { - if (!Arrays.equals((Object[]) vals1, (Object[]) vals2)) { - throw notEqualValidationException(dim1Name, vals1, vals2); - } - } else if (vals1 instanceof Object[]) { - if (((Object[]) vals1).length != 1 || !Objects.equals(((Object[]) vals1)[0], vals2)) { - throw notEqualValidationException(dim1Name, vals1, vals2); - } - } else if (vals2 instanceof Object[]) { - if (((Object[]) vals2).length != 1 || !Objects.equals(((Object[]) vals2)[0], vals1)) { - throw notEqualValidationException(dim1Name, vals1, vals2); + boolean vals1IsList = vals1 instanceof List; + boolean vals2IsList = vals2 instanceof List; + if (vals1IsList ^ vals2IsList) { + if (vals1IsList) { + if (((List) vals1).size() != 1 || !Objects.equals(((List) vals1).get(0), vals2)) { + throw notEqualValidationException(dim1Name, vals1, vals2); + } + } else { + if (((List) vals2).size() != 1 || !Objects.equals(((List) vals2).get(0), vals1)) { + throw notEqualValidationException(dim1Name, vals1, vals2); + } } } else { if (!Objects.equals(vals1, vals2)) { @@ -276,10 +272,13 @@ public class IndexIO if (row == null) { return true; } - if (!(row instanceof Object[])) { + if (!(row instanceof List)) { return false; } - for (Object v : (Object[]) row) { + List rowAsList = (List) row; + //noinspection ForLoopReplaceableByForEach -- in order to not create a garbage iterator object + for (int i = 0, rowSize = rowAsList.size(); i < rowSize; i++) { + Object v = rowAsList.get(i); //noinspection VariableNotUsedInsideIf if (v != null) { return false; @@ -340,7 +339,7 @@ public class IndexIO Map metrics = Maps.newLinkedHashMap(); for (String metric : availableMetrics) { final String metricFilename = makeMetricFile(inDir, metric, BYTE_ORDER).getName(); - final MetricHolder holder = MetricHolder.fromByteBuffer(smooshedFiles.mapFile(metricFilename), smooshedFiles); + final MetricHolder holder = MetricHolder.fromByteBuffer(smooshedFiles.mapFile(metricFilename)); if (!metric.equals(holder.getName())) { throw new ISE("Metric[%s] loaded up metric[%s] from disk. File names do matter.", metric, holder.getName()); @@ -425,13 +424,13 @@ public class IndexIO { MMappedIndex index = legacyHandler.mapDir(inDir); - Map columns = Maps.newHashMap(); + Map columns = Maps.newHashMap(); for (String dimension : index.getAvailableDimensions()) { ColumnBuilder builder = new ColumnBuilder() .setType(ValueType.STRING) .setHasMultipleValues(true) - .setDictionaryEncodedColumn( + .setDictionaryEncodedColumnSupplier( new DictionaryEncodedColumnSupplier( index.getDimValueLookup(dimension), null, @@ -462,8 +461,8 @@ public class IndexIO metric, new ColumnBuilder() .setType(ValueType.FLOAT) - .setGenericColumn( - new FloatGenericColumnSupplier( + .setNumericColumnSupplier( + new FloatNumericColumnSupplier( metricHolder.floatType, LEGACY_FACTORY.getBitmapFactory().makeEmptyImmutableBitmap() ) @@ -475,11 +474,8 @@ public class IndexIO metric, new ColumnBuilder() .setType(ValueType.COMPLEX) - .setComplexColumn( - new ComplexColumnPartSupplier( - metricHolder.getTypeName(), - (GenericIndexed) metricHolder.complexType - ) + .setComplexColumnSupplier( + new ComplexColumnPartSupplier(metricHolder.getTypeName(), metricHolder.complexType) ) .build() ); @@ -495,11 +491,11 @@ public class IndexIO } columns.put( - Column.TIME_COLUMN_NAME, + ColumnHolder.TIME_COLUMN_NAME, new ColumnBuilder() .setType(ValueType.LONG) - .setGenericColumn( - new LongGenericColumnSupplier( + .setNumericColumnSupplier( + new LongNumericColumnSupplier( index.timestamps, LEGACY_FACTORY.getBitmapFactory().makeEmptyImmutableBitmap() ) @@ -587,7 +583,7 @@ public class IndexIO } } - Map columns = Maps.newHashMap(); + Map columns = Maps.newHashMap(); for (String columnName : cols) { if (Strings.isNullOrEmpty(columnName)) { @@ -597,7 +593,7 @@ public class IndexIO columns.put(columnName, deserializeColumn(mapper, smooshedFiles.mapFile(columnName), smooshedFiles)); } - columns.put(Column.TIME_COLUMN_NAME, deserializeColumn(mapper, smooshedFiles.mapFile("__time"), smooshedFiles)); + columns.put(ColumnHolder.TIME_COLUMN_NAME, deserializeColumn(mapper, smooshedFiles.mapFile("__time"), smooshedFiles)); final QueryableIndex index = new SimpleQueryableIndex( dataInterval, @@ -613,7 +609,7 @@ public class IndexIO return index; } - private Column deserializeColumn(ObjectMapper mapper, ByteBuffer byteBuffer, SmooshedFileMapper smooshedFiles) + private ColumnHolder deserializeColumn(ObjectMapper mapper, ByteBuffer byteBuffer, SmooshedFileMapper smooshedFiles) throws IOException { ColumnDescriptor serde = mapper.readValue( diff --git a/processing/src/main/java/org/apache/druid/segment/IndexMerger.java b/processing/src/main/java/org/apache/druid/segment/IndexMerger.java index be471f6a3f0..0f29cb150c1 100644 --- a/processing/src/main/java/org/apache/druid/segment/IndexMerger.java +++ b/processing/src/main/java/org/apache/druid/segment/IndexMerger.java @@ -307,7 +307,7 @@ public interface IndexMerger static TransformableRowIterator toMergedIndexRowIterator( TransformableRowIterator sourceRowIterator, int indexNumber, - final List mergers + final List mergers ) { RowPointer sourceRowPointer = sourceRowIterator.getPointer(); diff --git a/processing/src/main/java/org/apache/druid/segment/IndexMergerV9.java b/processing/src/main/java/org/apache/druid/segment/IndexMergerV9.java index a828cd604c8..d39994e42a8 100644 --- a/processing/src/main/java/org/apache/druid/segment/IndexMergerV9.java +++ b/processing/src/main/java/org/apache/druid/segment/IndexMergerV9.java @@ -29,6 +29,7 @@ import com.google.common.collect.Sets; import com.google.common.io.Files; import com.google.common.primitives.Ints; import com.google.inject.Inject; +import org.apache.commons.io.FileUtils; import org.apache.druid.common.config.NullHandling; import org.apache.druid.io.ZeroCopyByteArrayOutputStream; import org.apache.druid.java.util.common.DateTimes; @@ -41,10 +42,10 @@ import org.apache.druid.java.util.common.io.smoosh.FileSmoosher; import org.apache.druid.java.util.common.io.smoosh.SmooshedWriter; import org.apache.druid.java.util.common.logger.Logger; import org.apache.druid.query.aggregation.AggregatorFactory; -import org.apache.druid.segment.column.Column; import org.apache.druid.segment.column.ColumnCapabilities; import org.apache.druid.segment.column.ColumnCapabilitiesImpl; import org.apache.druid.segment.column.ColumnDescriptor; +import org.apache.druid.segment.column.ColumnHolder; import org.apache.druid.segment.column.ValueType; import org.apache.druid.segment.data.GenericIndexed; import org.apache.druid.segment.incremental.IncrementalIndex; @@ -54,15 +55,14 @@ import org.apache.druid.segment.serde.ColumnPartSerde; import org.apache.druid.segment.serde.ComplexColumnPartSerde; import org.apache.druid.segment.serde.ComplexMetricSerde; import org.apache.druid.segment.serde.ComplexMetrics; -import org.apache.druid.segment.serde.DoubleGenericColumnPartSerde; -import org.apache.druid.segment.serde.DoubleGenericColumnPartSerdeV2; -import org.apache.druid.segment.serde.FloatGenericColumnPartSerde; -import org.apache.druid.segment.serde.FloatGenericColumnPartSerdeV2; -import org.apache.druid.segment.serde.LongGenericColumnPartSerde; -import org.apache.druid.segment.serde.LongGenericColumnPartSerdeV2; +import org.apache.druid.segment.serde.DoubleNumericColumnPartSerde; +import org.apache.druid.segment.serde.DoubleNumericColumnPartSerdeV2; +import org.apache.druid.segment.serde.FloatNumericColumnPartSerde; +import org.apache.druid.segment.serde.FloatNumericColumnPartSerdeV2; +import org.apache.druid.segment.serde.LongNumericColumnPartSerde; +import org.apache.druid.segment.serde.LongNumericColumnPartSerdeV2; import org.apache.druid.segment.writeout.SegmentWriteOutMedium; import org.apache.druid.segment.writeout.SegmentWriteOutMediumFactory; -import org.apache.commons.io.FileUtils; import org.joda.time.DateTime; import org.joda.time.Interval; @@ -101,7 +101,7 @@ public class IndexMergerV9 implements IndexMerger private File makeIndexFiles( final List adapters, - final AggregatorFactory[] metricAggs, + final @Nullable AggregatorFactory[] metricAggs, final File outDir, final ProgressIndicator progress, final List mergedDimensions, @@ -162,10 +162,10 @@ public class IndexMergerV9 implements IndexMerger mergeCapabilities(adapters, mergedDimensions, metricsValueTypes, metricTypeNames, dimCapabilities); final Map handlers = makeDimensionHandlers(mergedDimensions, dimCapabilities); - final List mergers = new ArrayList<>(); + final List mergers = new ArrayList<>(); for (int i = 0; i < mergedDimensions.size(); i++) { DimensionHandler handler = handlers.get(mergedDimensions.get(i)); - mergers.add(handler.makeMerger(indexSpec, segmentWriteOutMedium, dimCapabilities.get(i), progress)); + mergers.add(handler.makeMerger(indexSpec, segmentWriteOutMedium, dimCapabilities.get(i), progress, closer)); } /************* Setup Dim Conversions **************/ @@ -213,7 +213,7 @@ public class IndexMergerV9 implements IndexMerger ); for (int i = 0; i < mergedDimensions.size(); i++) { - DimensionMergerV9 merger = (DimensionMergerV9) mergers.get(i); + DimensionMergerV9 merger = mergers.get(i); merger.writeIndexes(rowNumConversions); if (merger.canSkip()) { continue; @@ -263,7 +263,7 @@ public class IndexMergerV9 implements IndexMerger final List mergedMetrics, final ProgressIndicator progress, final IndexSpec indexSpec, - final List mergers + final List mergers ) throws IOException { final String section = "make index.drd"; @@ -372,14 +372,14 @@ public class IndexMergerV9 implements IndexMerger static ColumnPartSerde createLongColumnPartSerde(GenericColumnSerializer serializer, IndexSpec indexSpec) { - // If using default values for null use LongGenericColumnPartSerde to allow rollback to previous versions. + // If using default values for null use LongNumericColumnPartSerde to allow rollback to previous versions. if (NullHandling.replaceWithDefault()) { - return LongGenericColumnPartSerde.serializerBuilder() + return LongNumericColumnPartSerde.serializerBuilder() .withByteOrder(IndexIO.BYTE_ORDER) .withDelegate(serializer) .build(); } else { - return LongGenericColumnPartSerdeV2.serializerBuilder() + return LongNumericColumnPartSerdeV2.serializerBuilder() .withByteOrder(IndexIO.BYTE_ORDER) .withBitmapSerdeFactory(indexSpec.getBitmapSerdeFactory()) .withDelegate(serializer) @@ -389,14 +389,14 @@ public class IndexMergerV9 implements IndexMerger static ColumnPartSerde createDoubleColumnPartSerde(GenericColumnSerializer serializer, IndexSpec indexSpec) { - // If using default values for null use DoubleGenericColumnPartSerde to allow rollback to previous versions. + // If using default values for null use DoubleNumericColumnPartSerde to allow rollback to previous versions. if (NullHandling.replaceWithDefault()) { - return DoubleGenericColumnPartSerde.serializerBuilder() + return DoubleNumericColumnPartSerde.serializerBuilder() .withByteOrder(IndexIO.BYTE_ORDER) .withDelegate(serializer) .build(); } else { - return DoubleGenericColumnPartSerdeV2.serializerBuilder() + return DoubleNumericColumnPartSerdeV2.serializerBuilder() .withByteOrder(IndexIO.BYTE_ORDER) .withBitmapSerdeFactory(indexSpec.getBitmapSerdeFactory()) .withDelegate(serializer) @@ -406,14 +406,14 @@ public class IndexMergerV9 implements IndexMerger static ColumnPartSerde createFloatColumnPartSerde(GenericColumnSerializer serializer, IndexSpec indexSpec) { - // If using default values for null use FloatGenericColumnPartSerde to allow rollback to previous versions. + // If using default values for null use FloatNumericColumnPartSerde to allow rollback to previous versions. if (NullHandling.replaceWithDefault()) { - return FloatGenericColumnPartSerde.serializerBuilder() + return FloatNumericColumnPartSerde.serializerBuilder() .withByteOrder(IndexIO.BYTE_ORDER) .withDelegate(serializer) .build(); } else { - return FloatGenericColumnPartSerdeV2.serializerBuilder() + return FloatNumericColumnPartSerdeV2.serializerBuilder() .withByteOrder(IndexIO.BYTE_ORDER) .withBitmapSerdeFactory(indexSpec.getBitmapSerdeFactory()) .withDelegate(serializer) @@ -437,7 +437,7 @@ public class IndexMergerV9 implements IndexMerger .setValueType(ValueType.LONG) .addSerde(createLongColumnPartSerde(timeWriter, indexSpec)) .build(); - makeColumn(v9Smoosher, Column.TIME_COLUMN_NAME, serdeficator); + makeColumn(v9Smoosher, ColumnHolder.TIME_COLUMN_NAME, serdeficator); log.info("Completed time column in %,d millis.", System.currentTimeMillis() - startTime); progress.stopSection(section); } @@ -469,7 +469,7 @@ public class IndexMergerV9 implements IndexMerger final TimeAndDimsIterator timeAndDimsIterator, final GenericColumnSerializer timeWriter, final ArrayList metricWriters, - final List mergers, + final List mergers, final boolean fillRowNumConversions ) throws IOException { @@ -687,7 +687,7 @@ public class IndexMergerV9 implements IndexMerger final List indexes, final ProgressIndicator progress, final List mergedDimensions, - final List mergers + final List mergers ) throws IOException { final String section = "setup dimension conversions"; @@ -1010,7 +1010,7 @@ public class IndexMergerV9 implements IndexMerger final List mergedMetrics, final Function, TimeAndDimsIterator> rowMergerFn, final Map handlers, - final List mergers + final List mergers ) { List perIndexRowIterators = Lists.newArrayListWithCapacity(indexes.size()); diff --git a/processing/src/main/java/org/apache/druid/segment/IndexableAdapter.java b/processing/src/main/java/org/apache/druid/segment/IndexableAdapter.java index 9cb4ec3cdc5..5cccab281f4 100644 --- a/processing/src/main/java/org/apache/druid/segment/IndexableAdapter.java +++ b/processing/src/main/java/org/apache/druid/segment/IndexableAdapter.java @@ -19,9 +19,10 @@ package org.apache.druid.segment; +import com.google.errorprone.annotations.MustBeClosed; import org.apache.druid.segment.column.ColumnCapabilities; import org.apache.druid.segment.data.BitmapValues; -import org.apache.druid.segment.data.Indexed; +import org.apache.druid.segment.data.CloseableIndexed; import org.joda.time.Interval; import javax.annotation.Nullable; @@ -40,8 +41,9 @@ public interface IndexableAdapter List getMetricNames(); + @MustBeClosed @Nullable - > Indexed getDimValueLookup(String dimension); + > CloseableIndexed getDimValueLookup(String dimension); TransformableRowIterator getRows(); diff --git a/processing/src/main/java/org/apache/druid/segment/IntIteratorUtils.java b/processing/src/main/java/org/apache/druid/segment/IntIteratorUtils.java index 7ada05e93fc..7a59a1932bd 100644 --- a/processing/src/main/java/org/apache/druid/segment/IntIteratorUtils.java +++ b/processing/src/main/java/org/apache/druid/segment/IntIteratorUtils.java @@ -19,13 +19,13 @@ package org.apache.druid.segment; -import org.apache.druid.java.util.common.IAE; import it.unimi.dsi.fastutil.ints.IntArrayList; import it.unimi.dsi.fastutil.ints.IntIterator; import it.unimi.dsi.fastutil.ints.IntIterators; import it.unimi.dsi.fastutil.ints.IntList; import it.unimi.dsi.fastutil.ints.IntLists; import it.unimi.dsi.fastutil.longs.LongHeaps; +import org.apache.druid.java.util.common.IAE; import java.util.List; import java.util.NoSuchElementException; diff --git a/processing/src/main/java/org/apache/druid/segment/LongColumnSelector.java b/processing/src/main/java/org/apache/druid/segment/LongColumnSelector.java index 103cd964dc6..e328d9da618 100644 --- a/processing/src/main/java/org/apache/druid/segment/LongColumnSelector.java +++ b/processing/src/main/java/org/apache/druid/segment/LongColumnSelector.java @@ -31,7 +31,7 @@ import javax.annotation.Nullable; public interface LongColumnSelector extends ColumnValueSelector { /** - * @deprecated This method is marked as deprecated in LongColumnSelector to minimize the probability of accidential + * @deprecated This method is marked as deprecated in LongColumnSelector to minimize the probability of accidental * calling. "Polymorphism" of LongColumnSelector should be used only when operating on {@link ColumnValueSelector} * objects. */ @@ -43,7 +43,7 @@ public interface LongColumnSelector extends ColumnValueSelector } /** - * @deprecated This method is marked as deprecated in LongColumnSelector to minimize the probability of accidential + * @deprecated This method is marked as deprecated in LongColumnSelector to minimize the probability of accidental * calling. "Polymorphism" of LongColumnSelector should be used only when operating on {@link ColumnValueSelector} * objects. */ @@ -55,7 +55,7 @@ public interface LongColumnSelector extends ColumnValueSelector } /** - * @deprecated This method is marked as deprecated in LongColumnSelector to minimize the probability of accidential + * @deprecated This method is marked as deprecated in LongColumnSelector to minimize the probability of accidental * calling. "Polymorphism" of LongColumnSelector should be used only when operating on {@link ColumnValueSelector} * objects. */ @@ -71,7 +71,7 @@ public interface LongColumnSelector extends ColumnValueSelector } /** - * @deprecated This method is marked as deprecated in LongColumnSelector to minimize the probability of accidential + * @deprecated This method is marked as deprecated in LongColumnSelector to minimize the probability of accidental * calling. "Polymorphism" of LongColumnSelector should be used only when operating on {@link ColumnValueSelector} * objects. */ diff --git a/processing/src/main/java/org/apache/druid/segment/LongColumnSerializer.java b/processing/src/main/java/org/apache/druid/segment/LongColumnSerializer.java index 0bf57e98e5d..8f4cc586bc3 100644 --- a/processing/src/main/java/org/apache/druid/segment/LongColumnSerializer.java +++ b/processing/src/main/java/org/apache/druid/segment/LongColumnSerializer.java @@ -21,10 +21,10 @@ package org.apache.druid.segment; import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.java.util.common.io.smoosh.FileSmoosher; -import org.apache.druid.segment.writeout.SegmentWriteOutMedium; +import org.apache.druid.segment.data.ColumnarLongsSerializer; import org.apache.druid.segment.data.CompressionFactory; import org.apache.druid.segment.data.CompressionStrategy; -import org.apache.druid.segment.data.ColumnarLongsSerializer; +import org.apache.druid.segment.writeout.SegmentWriteOutMedium; import java.io.IOException; import java.nio.ByteOrder; @@ -33,7 +33,7 @@ import java.nio.channels.WritableByteChannel; /** * Unsafe for concurrent use from multiple threads. */ -public class LongColumnSerializer implements GenericColumnSerializer +public class LongColumnSerializer implements GenericColumnSerializer { public static LongColumnSerializer create( SegmentWriteOutMedium segmentWriteOutMedium, @@ -81,7 +81,7 @@ public class LongColumnSerializer implements GenericColumnSerializer } @Override - public void serialize(ColumnValueSelector selector) throws IOException + public void serialize(ColumnValueSelector selector) throws IOException { writer.add(selector.getLong()); } diff --git a/processing/src/main/java/org/apache/druid/segment/LongColumnSerializerV2.java b/processing/src/main/java/org/apache/druid/segment/LongColumnSerializerV2.java index f6927297b8c..cacac5910ca 100644 --- a/processing/src/main/java/org/apache/druid/segment/LongColumnSerializerV2.java +++ b/processing/src/main/java/org/apache/druid/segment/LongColumnSerializerV2.java @@ -40,9 +40,9 @@ import java.nio.channels.WritableByteChannel; * Column Serializer for long column. * The column is serialized in two parts, first a bitmap indicating the nullability of row values * and second the actual row values. - * This class is Unsafe for concurrent use from multiple threads. + * This class is unsafe for concurrent use from multiple threads. */ -public class LongColumnSerializerV2 implements GenericColumnSerializer +public class LongColumnSerializerV2 implements GenericColumnSerializer { public static LongColumnSerializerV2 create( SegmentWriteOutMedium segmentWriteOutMedium, @@ -111,7 +111,7 @@ public class LongColumnSerializerV2 implements GenericColumnSerializer } @Override - public void serialize(ColumnValueSelector selector) throws IOException + public void serialize(ColumnValueSelector selector) throws IOException { if (selector.isNull()) { nullRowsBitmap.add(rowCount); diff --git a/processing/src/main/java/org/apache/druid/segment/LongDimensionHandler.java b/processing/src/main/java/org/apache/druid/segment/LongDimensionHandler.java index 0fc176409f2..f8635c603c0 100644 --- a/processing/src/main/java/org/apache/druid/segment/LongDimensionHandler.java +++ b/processing/src/main/java/org/apache/druid/segment/LongDimensionHandler.java @@ -19,6 +19,7 @@ package org.apache.druid.segment; +import org.apache.druid.java.util.common.io.Closer; import org.apache.druid.segment.column.ColumnCapabilities; import org.apache.druid.segment.selector.settable.SettableColumnValueSelector; import org.apache.druid.segment.selector.settable.SettableLongColumnValueSelector; @@ -62,7 +63,8 @@ public class LongDimensionHandler implements DimensionHandler IndexSpec indexSpec, SegmentWriteOutMedium segmentWriteOutMedium, ColumnCapabilities capabilities, - ProgressIndicator progress + ProgressIndicator progress, + Closer closer ) { return new LongDimensionMergerV9( diff --git a/processing/src/main/java/org/apache/druid/segment/LongDimensionIndexer.java b/processing/src/main/java/org/apache/druid/segment/LongDimensionIndexer.java index 20f192d7598..0f7c13d24ac 100644 --- a/processing/src/main/java/org/apache/druid/segment/LongDimensionIndexer.java +++ b/processing/src/main/java/org/apache/druid/segment/LongDimensionIndexer.java @@ -25,7 +25,7 @@ import org.apache.druid.common.config.NullHandling; import org.apache.druid.java.util.common.guava.Comparators; import org.apache.druid.query.dimension.DimensionSpec; import org.apache.druid.query.monomorphicprocessing.RuntimeShapeInspector; -import org.apache.druid.segment.data.Indexed; +import org.apache.druid.segment.data.CloseableIndexed; import org.apache.druid.segment.incremental.IncrementalIndex; import org.apache.druid.segment.incremental.IncrementalIndexRowHolder; @@ -61,7 +61,7 @@ public class LongDimensionIndexer implements DimensionIndexer } @Override - public Indexed getSortedIndexedValues() + public CloseableIndexed getSortedIndexedValues() { throw new UnsupportedOperationException("Numeric columns do not support value dictionaries."); } @@ -167,7 +167,7 @@ public class LongDimensionIndexer implements DimensionIndexer } @Override - public Object convertUnsortedEncodedKeyComponentToActualArrayOrList(Long key, boolean asList) + public Object convertUnsortedEncodedKeyComponentToActualList(Long key) { return key; } diff --git a/processing/src/main/java/org/apache/druid/segment/LongWrappingDimensionSelector.java b/processing/src/main/java/org/apache/druid/segment/LongWrappingDimensionSelector.java index ced7b1a3093..1388dcf0480 100644 --- a/processing/src/main/java/org/apache/druid/segment/LongWrappingDimensionSelector.java +++ b/processing/src/main/java/org/apache/druid/segment/LongWrappingDimensionSelector.java @@ -21,21 +21,22 @@ package org.apache.druid.segment; import org.apache.druid.query.extraction.ExtractionFn; import org.apache.druid.query.monomorphicprocessing.RuntimeShapeInspector; -import org.apache.druid.segment.virtual.BaseSingleValueDimensionSelector; import javax.annotation.Nullable; public class LongWrappingDimensionSelector extends BaseSingleValueDimensionSelector { private final BaseLongColumnValueSelector selector; + @Nullable private final ExtractionFn extractionFn; - public LongWrappingDimensionSelector(BaseLongColumnValueSelector selector, ExtractionFn extractionFn) + public LongWrappingDimensionSelector(BaseLongColumnValueSelector selector, @Nullable ExtractionFn extractionFn) { this.selector = selector; this.extractionFn = extractionFn; } + @Nullable @Override protected String getValue() { @@ -46,19 +47,6 @@ public class LongWrappingDimensionSelector extends BaseSingleValueDimensionSelec } } - @Nullable - @Override - public Object getObject() - { - return getValue(); - } - - @Override - public Class classOfObject() - { - return String.class; - } - @Override public void inspectRuntimeShape(RuntimeShapeInspector inspector) { diff --git a/processing/src/main/java/org/apache/druid/segment/MergingRowIterator.java b/processing/src/main/java/org/apache/druid/segment/MergingRowIterator.java index b9162af1e2c..73afc87cf2f 100644 --- a/processing/src/main/java/org/apache/druid/segment/MergingRowIterator.java +++ b/processing/src/main/java/org/apache/druid/segment/MergingRowIterator.java @@ -19,8 +19,8 @@ package org.apache.druid.segment; -import org.apache.druid.java.util.common.io.Closer; import it.unimi.dsi.fastutil.objects.ObjectHeaps; +import org.apache.druid.java.util.common.io.Closer; import javax.annotation.Nullable; import java.io.IOException; diff --git a/processing/src/main/java/org/apache/druid/segment/MetricHolder.java b/processing/src/main/java/org/apache/druid/segment/MetricHolder.java index f68246d59b5..770573509e2 100644 --- a/processing/src/main/java/org/apache/druid/segment/MetricHolder.java +++ b/processing/src/main/java/org/apache/druid/segment/MetricHolder.java @@ -21,11 +21,8 @@ package org.apache.druid.segment; import org.apache.druid.common.utils.SerializerUtils; import org.apache.druid.java.util.common.ISE; -import org.apache.druid.java.util.common.io.smoosh.SmooshedFileMapper; import org.apache.druid.segment.data.CompressedColumnarFloatsSupplier; import org.apache.druid.segment.data.GenericIndexed; -import org.apache.druid.segment.data.Indexed; -import org.apache.druid.segment.data.ObjectStrategy; import org.apache.druid.segment.serde.ComplexMetricSerde; import org.apache.druid.segment.serde.ComplexMetrics; @@ -39,12 +36,7 @@ public class MetricHolder private static final byte[] version = new byte[]{0x0}; private static final SerializerUtils serializerUtils = new SerializerUtils(); - public static MetricHolder fromByteBuffer(ByteBuffer buf, SmooshedFileMapper mapper) - { - return fromByteBuffer(buf, null, mapper); - } - - public static MetricHolder fromByteBuffer(ByteBuffer buf, ObjectStrategy strategy, SmooshedFileMapper mapper) + public static MetricHolder fromByteBuffer(ByteBuffer buf) { final byte ver = buf.get(); if (version[0] != ver) { @@ -60,17 +52,13 @@ public class MetricHolder holder.floatType = CompressedColumnarFloatsSupplier.fromByteBuffer(buf, ByteOrder.nativeOrder()); break; case COMPLEX: - if (strategy != null) { - holder.complexType = GenericIndexed.read(buf, strategy, mapper); - } else { - final ComplexMetricSerde serdeForType = ComplexMetrics.getSerdeForType(holder.getTypeName()); + final ComplexMetricSerde serdeForType = ComplexMetrics.getSerdeForType(holder.getTypeName()); - if (serdeForType == null) { - throw new ISE("Unknown type[%s], cannot load.", holder.getTypeName()); - } - - holder.complexType = GenericIndexed.read(buf, serdeForType.getObjectStrategy()); + if (serdeForType == null) { + throw new ISE("Unknown type[%s], cannot load.", holder.getTypeName()); } + + holder.complexType = read(buf, serdeForType); break; case LONG: case DOUBLE: @@ -80,9 +68,10 @@ public class MetricHolder return holder; } - private final String name; - private final String typeName; - private final MetricType type; + private static GenericIndexed read(ByteBuffer buf, ComplexMetricSerde serde) + { + return GenericIndexed.read(buf, serde.getObjectStrategy()); + } public enum MetricType { @@ -104,8 +93,11 @@ public class MetricHolder } } + private final String name; + private final String typeName; + private final MetricType type; CompressedColumnarFloatsSupplier floatType = null; - Indexed complexType = null; + GenericIndexed complexType = null; private MetricHolder( String name, diff --git a/processing/src/main/java/org/apache/druid/segment/NullDimensionSelector.java b/processing/src/main/java/org/apache/druid/segment/NullDimensionSelector.java index 0c91e342c82..6403dceeae0 100644 --- a/processing/src/main/java/org/apache/druid/segment/NullDimensionSelector.java +++ b/processing/src/main/java/org/apache/druid/segment/NullDimensionSelector.java @@ -63,7 +63,7 @@ public class NullDimensionSelector implements SingleValueHistoricalDimensionSele } @Override - public ValueMatcher makeValueMatcher(String value) + public ValueMatcher makeValueMatcher(@Nullable String value) { return BooleanValueMatcher.of(value == null); } @@ -102,7 +102,7 @@ public class NullDimensionSelector implements SingleValueHistoricalDimensionSele } @Override - public int lookupId(String name) + public int lookupId(@Nullable String name) { return NullHandling.isNullOrEquivalent(name) ? 0 : -1; } diff --git a/processing/src/main/java/org/apache/druid/segment/ObjectColumnSelector.java b/processing/src/main/java/org/apache/druid/segment/ObjectColumnSelector.java index fb8617b289c..77a69ebd827 100644 --- a/processing/src/main/java/org/apache/druid/segment/ObjectColumnSelector.java +++ b/processing/src/main/java/org/apache/druid/segment/ObjectColumnSelector.java @@ -30,7 +30,7 @@ package org.apache.druid.segment; public abstract class ObjectColumnSelector implements ColumnValueSelector { /** - * @deprecated This method is marked as deprecated in ObjectColumnSelector to minimize the probability of accidential + * @deprecated This method is marked as deprecated in ObjectColumnSelector to minimize the probability of accidental * calling. "Polymorphism" of ObjectColumnSelector should be used only when operating on {@link ColumnValueSelector} * objects. */ @@ -46,7 +46,7 @@ public abstract class ObjectColumnSelector implements ColumnValueSelector } /** - * @deprecated This method is marked as deprecated in ObjectColumnSelector to minimize the probability of accidential + * @deprecated This method is marked as deprecated in ObjectColumnSelector to minimize the probability of accidental * calling. "Polymorphism" of ObjectColumnSelector should be used only when operating on {@link ColumnValueSelector} * objects. */ @@ -62,7 +62,7 @@ public abstract class ObjectColumnSelector implements ColumnValueSelector } /** - * @deprecated This method is marked as deprecated in ObjectColumnSelector to minimize the probability of accidential + * @deprecated This method is marked as deprecated in ObjectColumnSelector to minimize the probability of accidental * calling. "Polymorphism" of ObjectColumnSelector should be used only when operating on {@link ColumnValueSelector} * objects. */ diff --git a/processing/src/main/java/org/apache/druid/segment/QueryableIndexColumnSelectorFactory.java b/processing/src/main/java/org/apache/druid/segment/QueryableIndexColumnSelectorFactory.java index f6193ed4e50..2beca4a0d27 100644 --- a/processing/src/main/java/org/apache/druid/segment/QueryableIndexColumnSelectorFactory.java +++ b/processing/src/main/java/org/apache/druid/segment/QueryableIndexColumnSelectorFactory.java @@ -19,13 +19,12 @@ package org.apache.druid.segment; -import org.apache.druid.java.util.common.ISE; import org.apache.druid.java.util.common.io.Closer; import org.apache.druid.query.dimension.DimensionSpec; import org.apache.druid.query.extraction.ExtractionFn; import org.apache.druid.segment.column.BaseColumn; -import org.apache.druid.segment.column.Column; import org.apache.druid.segment.column.ColumnCapabilities; +import org.apache.druid.segment.column.ColumnHolder; import org.apache.druid.segment.column.DictionaryEncodedColumn; import org.apache.druid.segment.column.ValueType; import org.apache.druid.segment.data.ReadableOffset; @@ -35,7 +34,8 @@ import java.util.Map; /** * The basic implementation of {@link ColumnSelectorFactory} over a historical segment (i. e. {@link QueryableIndex}). - * It's counterpart for incremental index is {@link org.apache.druid.segment.incremental.IncrementalIndexColumnSelectorFactory}. + * It's counterpart for incremental index is {@link + * org.apache.druid.segment.incremental.IncrementalIndexColumnSelectorFactory}. */ class QueryableIndexColumnSelectorFactory implements ColumnSelectorFactory { @@ -79,28 +79,36 @@ class QueryableIndexColumnSelectorFactory implements ColumnSelectorFactory final String dimension = dimensionSpec.getDimension(); final ExtractionFn extractionFn = dimensionSpec.getExtractionFn(); - final Column columnDesc = index.getColumn(dimension); - if (columnDesc == null) { + final ColumnHolder columnHolder = index.getColumnHolder(dimension); + if (columnHolder == null) { return DimensionSelectorUtils.constantSelector(null, extractionFn); } - if (dimension.equals(Column.TIME_COLUMN_NAME)) { - return new SingleScanTimeDimSelector(makeColumnValueSelector(dimension), extractionFn, descending); + if (dimension.equals(ColumnHolder.TIME_COLUMN_NAME)) { + return new SingleScanTimeDimensionSelector(makeColumnValueSelector(dimension), extractionFn, descending); } - ValueType type = columnDesc.getCapabilities().getType(); + ValueType type = columnHolder.getCapabilities().getType(); if (type.isNumeric()) { return type.makeNumericWrappingDimensionSelector(makeColumnValueSelector(dimension), extractionFn); } - @SuppressWarnings("unchecked") - DictionaryEncodedColumn column = (DictionaryEncodedColumn) - columnCache.computeIfAbsent(dimension, d -> closer.register(columnDesc.getDictionaryEncoding())); + BaseColumn column = columnCache.computeIfAbsent(dimension, d -> { + BaseColumn col = columnHolder.getColumn(); + if (col instanceof DictionaryEncodedColumn) { + return closer.register(col); + } else { + // Return null from the lambda in computeIfAbsent() results in no recorded value in the columnCache and + // the column variable is set to null. + return null; + } + }); - if (column == null) { - return DimensionSelectorUtils.constantSelector(null, extractionFn); + if (column instanceof DictionaryEncodedColumn) { + //noinspection unchecked + return ((DictionaryEncodedColumn) column).makeDimensionSelector(offset, extractionFn); } else { - return column.makeDimensionSelector(offset, extractionFn); + return DimensionSelectorUtils.constantSelector(null, extractionFn); } } @@ -111,31 +119,20 @@ class QueryableIndexColumnSelectorFactory implements ColumnSelectorFactory return virtualColumns.makeColumnValueSelector(columnName, this); } - BaseColumn column = columnCache.get(columnName); - - if (column == null) { - Column holder = index.getColumn(columnName); - + BaseColumn column = columnCache.computeIfAbsent(columnName, name -> { + ColumnHolder holder = index.getColumnHolder(name); if (holder != null) { - final ColumnCapabilities capabilities = holder.getCapabilities(); - - if (capabilities.isDictionaryEncoded()) { - column = holder.getDictionaryEncoding(); - } else if (capabilities.getType() == ValueType.COMPLEX) { - column = holder.getComplexColumn(); - } else if (capabilities.getType().isNumeric()) { - column = holder.getGenericColumn(); - } else { - throw new ISE("Unknown column type: %s", capabilities.getType()); - } - closer.register(column); - columnCache.put(columnName, column); + return closer.register(holder.getColumn()); } else { - return NilColumnValueSelector.instance(); + return null; } - } + }); - return column.makeColumnValueSelector(offset); + if (column != null) { + return column.makeColumnValueSelector(offset); + } else { + return NilColumnValueSelector.instance(); + } } @Override diff --git a/processing/src/main/java/org/apache/druid/segment/QueryableIndexIndexableAdapter.java b/processing/src/main/java/org/apache/druid/segment/QueryableIndexIndexableAdapter.java index 429b34695d7..2353a9b8a05 100644 --- a/processing/src/main/java/org/apache/druid/segment/QueryableIndexIndexableAdapter.java +++ b/processing/src/main/java/org/apache/druid/segment/QueryableIndexIndexableAdapter.java @@ -25,24 +25,24 @@ import com.google.common.collect.Sets; import org.apache.druid.java.util.common.ISE; import org.apache.druid.java.util.common.guava.CloseQuietly; import org.apache.druid.java.util.common.io.Closer; -import org.apache.druid.java.util.common.logger.Logger; import org.apache.druid.query.monomorphicprocessing.RuntimeShapeInspector; import org.apache.druid.segment.column.BaseColumn; import org.apache.druid.segment.column.BitmapIndex; -import org.apache.druid.segment.column.Column; import org.apache.druid.segment.column.ColumnCapabilities; +import org.apache.druid.segment.column.ColumnHolder; import org.apache.druid.segment.column.ComplexColumn; import org.apache.druid.segment.column.DictionaryEncodedColumn; import org.apache.druid.segment.column.ValueType; import org.apache.druid.segment.data.BitmapValues; +import org.apache.druid.segment.data.CloseableIndexed; import org.apache.druid.segment.data.ImmutableBitmapValues; -import org.apache.druid.segment.data.Indexed; import org.apache.druid.segment.data.IndexedIterable; import org.apache.druid.segment.selector.settable.SettableColumnValueSelector; import org.apache.druid.segment.selector.settable.SettableLongColumnValueSelector; import org.joda.time.Interval; import javax.annotation.Nullable; +import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; @@ -55,8 +55,6 @@ import java.util.Set; */ public class QueryableIndexIndexableAdapter implements IndexableAdapter { - private static final Logger log = new Logger(QueryableIndexIndexableAdapter.class); - private final int numRows; private final QueryableIndex input; private final ImmutableList availableDimensions; @@ -66,25 +64,7 @@ public class QueryableIndexIndexableAdapter implements IndexableAdapter { this.input = input; numRows = input.getNumRows(); - - // It appears possible that the dimensions have some columns listed which do not have a DictionaryEncodedColumn - // This breaks current logic, but should be fine going forward. This is a work-around to make things work - // in the current state. This code shouldn't be needed once github tracker issue #55 is finished. - ImmutableList.Builder availableDimensions = ImmutableList.builder(); - for (String dim : input.getAvailableDimensions()) { - final Column col = input.getColumn(dim); - - if (col == null) { - log.warn("Wtf!? column[%s] didn't exist!?!?!?", dim); - } else { - if (col.getDictionaryEncoding() == null) { - log.info("No dictionary on dimension[%s]", dim); - } - availableDimensions.add(dim); - } - } - this.availableDimensions = availableDimensions.build(); - + availableDimensions = ImmutableList.copyOf(input.getAvailableDimensions()); this.metadata = input.getMetadata(); } @@ -116,27 +96,25 @@ public class QueryableIndexIndexableAdapter implements IndexableAdapter @Nullable @Override - public > Indexed getDimValueLookup(String dimension) + public > CloseableIndexed getDimValueLookup(String dimension) { - final Column column = input.getColumn(dimension); + final ColumnHolder columnHolder = input.getColumnHolder(dimension); - if (column == null) { + if (columnHolder == null) { return null; } - final DictionaryEncodedColumn dict = column.getDictionaryEncoding(); + final BaseColumn col = columnHolder.getColumn(); - if (dict == null) { + if (!(col instanceof DictionaryEncodedColumn)) { return null; } - return new Indexed() + @SuppressWarnings("unchecked") + DictionaryEncodedColumn dict = (DictionaryEncodedColumn) col; + + return new CloseableIndexed() { - @Override - public Class getClazz() - { - return dict.getClazz(); - } @Override public int size() @@ -167,6 +145,12 @@ public class QueryableIndexIndexableAdapter implements IndexableAdapter { inspector.visit("dict", dict); } + + @Override + public void close() throws IOException + { + dict.close(); + } }; } @@ -199,18 +183,18 @@ public class QueryableIndexIndexableAdapter implements IndexableAdapter private final SimpleAscendingOffset offset = new SimpleAscendingOffset(numRows); private final int maxValidOffset = numRows - 1; - private final ColumnValueSelector offsetTimestampSelector; - private final ColumnValueSelector[] offsetDimensionValueSelectors; - private final ColumnValueSelector[] offsetMetricSelectors; + private final ColumnValueSelector offsetTimestampSelector; + private final ColumnValueSelector[] offsetDimensionValueSelectors; + private final ColumnValueSelector[] offsetMetricSelectors; private final SettableLongColumnValueSelector rowTimestampSelector = new SettableLongColumnValueSelector(); - private final SettableColumnValueSelector[] rowDimensionValueSelectors; - private final SettableColumnValueSelector[] rowMetricSelectors; + private final SettableColumnValueSelector[] rowDimensionValueSelectors; + private final SettableColumnValueSelector[] rowMetricSelectors; private final RowPointer rowPointer; private final SettableLongColumnValueSelector markedTimestampSelector = new SettableLongColumnValueSelector(); - private final SettableColumnValueSelector[] markedDimensionValueSelectors; - private final SettableColumnValueSelector[] markedMetricSelectors; + private final SettableColumnValueSelector[] markedDimensionValueSelectors; + private final SettableColumnValueSelector[] markedMetricSelectors; private final TimeAndDimsPointer markedRowPointer; boolean first = true; @@ -227,7 +211,7 @@ public class QueryableIndexIndexableAdapter implements IndexableAdapter columnCache ); - offsetTimestampSelector = columnSelectorFactory.makeColumnValueSelector(Column.TIME_COLUMN_NAME); + offsetTimestampSelector = columnSelectorFactory.makeColumnValueSelector(ColumnHolder.TIME_COLUMN_NAME); final List dimensionHandlers = new ArrayList<>(input.getDimensionHandlers().values()); @@ -247,7 +231,7 @@ public class QueryableIndexIndexableAdapter implements IndexableAdapter .toArray(SettableColumnValueSelector[]::new); rowMetricSelectors = metricNames .stream() - .map(metric -> input.getColumn(metric).makeSettableColumnValueSelector()) + .map(metric -> input.getColumnHolder(metric).makeNewSettableColumnValueSelector()) .toArray(SettableColumnValueSelector[]::new); rowPointer = new RowPointer( @@ -266,7 +250,7 @@ public class QueryableIndexIndexableAdapter implements IndexableAdapter .toArray(SettableColumnValueSelector[]::new); markedMetricSelectors = metricNames .stream() - .map(metric -> input.getColumn(metric).makeSettableColumnValueSelector()) + .map(metric -> input.getColumnHolder(metric).makeNewSettableColumnValueSelector()) .toArray(SettableColumnValueSelector[]::new); markedRowPointer = new TimeAndDimsPointer( markedTimestampSelector, @@ -370,9 +354,9 @@ public class QueryableIndexIndexableAdapter implements IndexableAdapter @Override public String getMetricType(String metric) { - final Column column = input.getColumn(metric); + final ColumnHolder columnHolder = input.getColumnHolder(metric); - final ValueType type = column.getCapabilities().getType(); + final ValueType type = columnHolder.getCapabilities().getType(); switch (type) { case FLOAT: return "float"; @@ -381,7 +365,7 @@ public class QueryableIndexIndexableAdapter implements IndexableAdapter case DOUBLE: return "double"; case COMPLEX: { - try (ComplexColumn complexColumn = column.getComplexColumn()) { + try (ComplexColumn complexColumn = (ComplexColumn) columnHolder.getColumn()) { return complexColumn.getTypeName(); } } @@ -393,18 +377,18 @@ public class QueryableIndexIndexableAdapter implements IndexableAdapter @Override public ColumnCapabilities getCapabilities(String column) { - return input.getColumn(column).getCapabilities(); + return input.getColumnHolder(column).getCapabilities(); } @Override public BitmapValues getBitmapValues(String dimension, int dictId) { - final Column column = input.getColumn(dimension); - if (column == null) { + final ColumnHolder columnHolder = input.getColumnHolder(dimension); + if (columnHolder == null) { return BitmapValues.EMPTY; } - final BitmapIndex bitmaps = column.getBitmapIndex(); + final BitmapIndex bitmaps = columnHolder.getBitmapIndex(); if (bitmaps == null) { return BitmapValues.EMPTY; } @@ -419,13 +403,13 @@ public class QueryableIndexIndexableAdapter implements IndexableAdapter @VisibleForTesting BitmapValues getBitmapIndex(String dimension, String value) { - final Column column = input.getColumn(dimension); + final ColumnHolder columnHolder = input.getColumnHolder(dimension); - if (column == null) { + if (columnHolder == null) { return BitmapValues.EMPTY; } - final BitmapIndex bitmaps = column.getBitmapIndex(); + final BitmapIndex bitmaps = columnHolder.getBitmapIndex(); if (bitmaps == null) { return BitmapValues.EMPTY; } diff --git a/processing/src/main/java/org/apache/druid/segment/QueryableIndexStorageAdapter.java b/processing/src/main/java/org/apache/druid/segment/QueryableIndexStorageAdapter.java index a74b403e922..779b06033dd 100644 --- a/processing/src/main/java/org/apache/druid/segment/QueryableIndexStorageAdapter.java +++ b/processing/src/main/java/org/apache/druid/segment/QueryableIndexStorageAdapter.java @@ -37,10 +37,11 @@ import org.apache.druid.query.filter.Filter; import org.apache.druid.query.monomorphicprocessing.RuntimeShapeInspector; import org.apache.druid.segment.column.BaseColumn; import org.apache.druid.segment.column.BitmapIndex; -import org.apache.druid.segment.column.Column; import org.apache.druid.segment.column.ColumnCapabilities; +import org.apache.druid.segment.column.ColumnHolder; import org.apache.druid.segment.column.ComplexColumn; -import org.apache.druid.segment.column.GenericColumn; +import org.apache.druid.segment.column.DictionaryEncodedColumn; +import org.apache.druid.segment.column.NumericColumn; import org.apache.druid.segment.data.Indexed; import org.apache.druid.segment.data.Offset; import org.apache.druid.segment.data.ReadableOffset; @@ -50,6 +51,8 @@ import org.joda.time.DateTime; import org.joda.time.Interval; import javax.annotation.Nullable; +import java.io.IOException; +import java.io.UncheckedIOException; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; @@ -97,18 +100,19 @@ public class QueryableIndexStorageAdapter implements StorageAdapter @Override public int getDimensionCardinality(String dimension) { - if (dimension == null) { + ColumnHolder columnHolder = index.getColumnHolder(dimension); + if (columnHolder == null) { return 0; } - - Column column = index.getColumn(dimension); - if (column == null) { - return 0; + try (BaseColumn col = columnHolder.getColumn()) { + if (!(col instanceof DictionaryEncodedColumn)) { + return Integer.MAX_VALUE; + } + return ((DictionaryEncodedColumn) col).getCardinality(); } - if (!column.getCapabilities().isDictionaryEncoded()) { - return Integer.MAX_VALUE; + catch (IOException e) { + throw new UncheckedIOException(e); } - return column.getDictionaryEncoding().getCardinality(); } @Override @@ -120,7 +124,7 @@ public class QueryableIndexStorageAdapter implements StorageAdapter @Override public DateTime getMinTime() { - try (final GenericColumn column = index.getColumn(Column.TIME_COLUMN_NAME).getGenericColumn()) { + try (final NumericColumn column = (NumericColumn) index.getColumnHolder(ColumnHolder.TIME_COLUMN_NAME).getColumn()) { return DateTimes.utc(column.getLongSingleValueRow(0)); } } @@ -128,7 +132,7 @@ public class QueryableIndexStorageAdapter implements StorageAdapter @Override public DateTime getMaxTime() { - try (final GenericColumn column = index.getColumn(Column.TIME_COLUMN_NAME).getGenericColumn()) { + try (final NumericColumn column = (NumericColumn) index.getColumnHolder(ColumnHolder.TIME_COLUMN_NAME).getColumn()) { return DateTimes.utc(column.getLongSingleValueRow(column.length() - 1)); } } @@ -137,9 +141,9 @@ public class QueryableIndexStorageAdapter implements StorageAdapter @Nullable public Comparable getMinValue(String dimension) { - Column column = index.getColumn(dimension); - if (column != null && column.getCapabilities().hasBitmapIndexes()) { - BitmapIndex bitmap = column.getBitmapIndex(); + ColumnHolder columnHolder = index.getColumnHolder(dimension); + if (columnHolder != null && columnHolder.getCapabilities().hasBitmapIndexes()) { + BitmapIndex bitmap = columnHolder.getBitmapIndex(); return bitmap.getCardinality() > 0 ? bitmap.getValue(0) : null; } return null; @@ -149,9 +153,9 @@ public class QueryableIndexStorageAdapter implements StorageAdapter @Nullable public Comparable getMaxValue(String dimension) { - Column column = index.getColumn(dimension); - if (column != null && column.getCapabilities().hasBitmapIndexes()) { - BitmapIndex bitmap = column.getBitmapIndex(); + ColumnHolder columnHolder = index.getColumnHolder(dimension); + if (columnHolder != null && columnHolder.getCapabilities().hasBitmapIndexes()) { + BitmapIndex bitmap = columnHolder.getBitmapIndex(); return bitmap.getCardinality() > 0 ? bitmap.getValue(bitmap.getCardinality() - 1) : null; } return null; @@ -173,9 +177,16 @@ public class QueryableIndexStorageAdapter implements StorageAdapter @Override public String getColumnTypeName(String columnName) { - final Column column = index.getColumn(columnName); - try (final ComplexColumn complexColumn = column.getComplexColumn()) { - return complexColumn != null ? complexColumn.getTypeName() : column.getCapabilities().getType().toString(); + final ColumnHolder columnHolder = index.getColumnHolder(columnName); + try (final BaseColumn col = columnHolder.getColumn()) { + if (col instanceof ComplexColumn) { + return ((ComplexColumn) col).getTypeName(); + } else { + return columnHolder.getCapabilities().getType().toString(); + } + } + catch (IOException e) { + throw new UncheckedIOException(e); } } @@ -318,11 +329,11 @@ public class QueryableIndexStorageAdapter implements StorageAdapter @Nullable static ColumnCapabilities getColumnCapabilities(ColumnSelector index, String columnName) { - Column columnObj = index.getColumn(columnName); - if (columnObj == null) { + ColumnHolder columnHolder = index.getColumnHolder(columnName); + if (columnHolder == null) { return null; } - return columnObj.getCapabilities(); + return columnHolder.getCapabilities(); } private static class CursorSequenceBuilder @@ -371,7 +382,7 @@ public class QueryableIndexStorageAdapter implements StorageAdapter // Column caches shared amongst all cursors in this sequence. final Map columnCache = new HashMap<>(); - final GenericColumn timestamps = index.getColumn(Column.TIME_COLUMN_NAME).getGenericColumn(); + final NumericColumn timestamps = (NumericColumn) index.getColumnHolder(ColumnHolder.TIME_COLUMN_NAME).getColumn(); final Closer closer = Closer.create(); closer.register(timestamps); @@ -537,13 +548,13 @@ public class QueryableIndexStorageAdapter implements StorageAdapter public abstract static class TimestampCheckingOffset extends Offset { final Offset baseOffset; - final GenericColumn timestamps; + final NumericColumn timestamps; final long timeLimit; final boolean allWithinThreshold; TimestampCheckingOffset( Offset baseOffset, - GenericColumn timestamps, + NumericColumn timestamps, long timeLimit, boolean allWithinThreshold ) @@ -614,7 +625,7 @@ public class QueryableIndexStorageAdapter implements StorageAdapter { AscendingTimestampCheckingOffset( Offset baseOffset, - GenericColumn timestamps, + NumericColumn timestamps, long timeLimit, boolean allWithinThreshold ) @@ -647,7 +658,7 @@ public class QueryableIndexStorageAdapter implements StorageAdapter { DescendingTimestampCheckingOffset( Offset baseOffset, - GenericColumn timestamps, + NumericColumn timestamps, long timeLimit, boolean allWithinThreshold ) diff --git a/processing/src/main/java/org/apache/druid/segment/RowFilteringIndexAdapter.java b/processing/src/main/java/org/apache/druid/segment/RowFilteringIndexAdapter.java index 289d74d61f6..0083c87f773 100644 --- a/processing/src/main/java/org/apache/druid/segment/RowFilteringIndexAdapter.java +++ b/processing/src/main/java/org/apache/druid/segment/RowFilteringIndexAdapter.java @@ -21,7 +21,7 @@ package org.apache.druid.segment; import org.apache.druid.segment.column.ColumnCapabilities; import org.apache.druid.segment.data.BitmapValues; -import org.apache.druid.segment.data.Indexed; +import org.apache.druid.segment.data.CloseableIndexed; import org.joda.time.Interval; import java.util.List; @@ -65,7 +65,7 @@ public class RowFilteringIndexAdapter implements IndexableAdapter } @Override - public > Indexed getDimValueLookup(String dimension) + public > CloseableIndexed getDimValueLookup(String dimension) { return baseAdapter.getDimValueLookup(dimension); } diff --git a/processing/src/main/java/org/apache/druid/segment/Segment.java b/processing/src/main/java/org/apache/druid/segment/Segment.java index 3f7395430c1..09dd001fcc3 100644 --- a/processing/src/main/java/org/apache/druid/segment/Segment.java +++ b/processing/src/main/java/org/apache/druid/segment/Segment.java @@ -22,6 +22,7 @@ package org.apache.druid.segment; import org.apache.druid.guice.annotations.PublicApi; import org.joda.time.Interval; +import javax.annotation.Nullable; import java.io.Closeable; /** @@ -31,6 +32,7 @@ public interface Segment extends Closeable { String getIdentifier(); Interval getDataInterval(); + @Nullable QueryableIndex asQueryableIndex(); StorageAdapter asStorageAdapter(); diff --git a/processing/src/main/java/org/apache/druid/segment/SimpleQueryableIndex.java b/processing/src/main/java/org/apache/druid/segment/SimpleQueryableIndex.java index 2ff1b637cf4..4fa025648bd 100644 --- a/processing/src/main/java/org/apache/druid/segment/SimpleQueryableIndex.java +++ b/processing/src/main/java/org/apache/druid/segment/SimpleQueryableIndex.java @@ -25,8 +25,8 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.Maps; import org.apache.druid.collections.bitmap.BitmapFactory; import org.apache.druid.java.util.common.io.smoosh.SmooshedFileMapper; -import org.apache.druid.segment.column.Column; import org.apache.druid.segment.column.ColumnCapabilities; +import org.apache.druid.segment.column.ColumnHolder; import org.apache.druid.segment.data.Indexed; import org.joda.time.Interval; @@ -42,7 +42,7 @@ public class SimpleQueryableIndex extends AbstractIndex implements QueryableInde private final List columnNames; private final Indexed availableDimensions; private final BitmapFactory bitmapFactory; - private final Map columns; + private final Map columns; private final SmooshedFileMapper fileMapper; @Nullable private final Metadata metadata; @@ -51,16 +51,16 @@ public class SimpleQueryableIndex extends AbstractIndex implements QueryableInde public SimpleQueryableIndex( Interval dataInterval, Indexed dimNames, BitmapFactory bitmapFactory, - Map columns, + Map columns, SmooshedFileMapper fileMapper, @Nullable Metadata metadata ) { - Preconditions.checkNotNull(columns.get(Column.TIME_COLUMN_NAME)); + Preconditions.checkNotNull(columns.get(ColumnHolder.TIME_COLUMN_NAME)); this.dataInterval = Preconditions.checkNotNull(dataInterval, "dataInterval"); ImmutableList.Builder columnNamesBuilder = ImmutableList.builder(); for (String column : columns.keySet()) { - if (!Column.TIME_COLUMN_NAME.equals(column)) { + if (!ColumnHolder.TIME_COLUMN_NAME.equals(column)) { columnNamesBuilder.add(column); } } @@ -80,7 +80,7 @@ public class SimpleQueryableIndex extends AbstractIndex implements QueryableInde List columnNames, Indexed availableDimensions, BitmapFactory bitmapFactory, - Map columns, + Map columns, SmooshedFileMapper fileMapper, @Nullable Metadata metadata, Map dimensionHandlers @@ -105,7 +105,7 @@ public class SimpleQueryableIndex extends AbstractIndex implements QueryableInde @Override public int getNumRows() { - return columns.get(Column.TIME_COLUMN_NAME).getLength(); + return columns.get(ColumnHolder.TIME_COLUMN_NAME).getLength(); } @Override @@ -134,13 +134,13 @@ public class SimpleQueryableIndex extends AbstractIndex implements QueryableInde @Nullable @Override - public Column getColumn(String columnName) + public ColumnHolder getColumnHolder(String columnName) { return columns.get(columnName); } @VisibleForTesting - public Map getColumns() + public Map getColumns() { return columns; } @@ -172,7 +172,7 @@ public class SimpleQueryableIndex extends AbstractIndex implements QueryableInde private void initDimensionHandlers() { for (String dim : availableDimensions) { - ColumnCapabilities capabilities = getColumn(dim).getCapabilities(); + ColumnCapabilities capabilities = getColumnHolder(dim).getCapabilities(); DimensionHandler handler = DimensionHandlerUtils.getHandlerFromCapabilities(dim, capabilities, null); dimensionHandlers.put(dim, handler); } diff --git a/processing/src/main/java/org/apache/druid/segment/SingleScanTimeDimSelector.java b/processing/src/main/java/org/apache/druid/segment/SingleScanTimeDimensionSelector.java similarity index 83% rename from processing/src/main/java/org/apache/druid/segment/SingleScanTimeDimSelector.java rename to processing/src/main/java/org/apache/druid/segment/SingleScanTimeDimensionSelector.java index 265297bf3fd..8a1be5a9eb6 100644 --- a/processing/src/main/java/org/apache/druid/segment/SingleScanTimeDimSelector.java +++ b/processing/src/main/java/org/apache/druid/segment/SingleScanTimeDimensionSelector.java @@ -19,6 +19,7 @@ package org.apache.druid.segment; +import com.google.common.base.Preconditions; import com.google.common.base.Predicate; import org.apache.druid.query.extraction.ExtractionFn; import org.apache.druid.query.filter.ValueMatcher; @@ -31,7 +32,13 @@ import java.util.ArrayList; import java.util.List; import java.util.Objects; -public class SingleScanTimeDimSelector implements DimensionSelector +/** + * A special {@link DimensionSelector} for projected time columns + * - it assumes time values are scanned once and values are grouped together + * (i.e. we never revisit a timestamp we have seen before, unless it is the same as the last accessed one) + * - it also applies and caches extraction function values at the {@link DimensionSelector} level to speed things up + */ +public class SingleScanTimeDimensionSelector implements DimensionSelector { private final ExtractionFn extractionFn; private final BaseLongColumnValueSelector selector; @@ -43,17 +50,13 @@ public class SingleScanTimeDimSelector implements DimensionSelector private long currentTimestamp = Long.MIN_VALUE; private int index = -1; - - // Use a special DimSelector for projected time columns - // - it assumes time values are scanned once and values are grouped together - // (i.e. we never revisit a timestamp we have seen before, unless it is the same as the last accessed one) - // - it also applies and caches extraction function values at the DimSelector level to speed things up - public SingleScanTimeDimSelector(BaseLongColumnValueSelector selector, ExtractionFn extractionFn, boolean descending) + public SingleScanTimeDimensionSelector( + BaseLongColumnValueSelector selector, + @Nullable ExtractionFn extractionFn, + boolean descending + ) { - if (extractionFn == null) { - throw new UnsupportedOperationException("time dimension must provide an extraction function"); - } - + Preconditions.checkNotNull(extractionFn, "time dimension must provide an extraction function"); this.extractionFn = extractionFn; this.selector = selector; this.descending = descending; @@ -67,7 +70,7 @@ public class SingleScanTimeDimSelector implements DimensionSelector } @Override - public ValueMatcher makeValueMatcher(final String value) + public ValueMatcher makeValueMatcher(final @Nullable String value) { return new ValueMatcher() { @@ -80,7 +83,7 @@ public class SingleScanTimeDimSelector implements DimensionSelector @Override public void inspectRuntimeShape(RuntimeShapeInspector inspector) { - inspector.visit("selector", SingleScanTimeDimSelector.this); + inspector.visit("selector", SingleScanTimeDimensionSelector.this); } }; } @@ -99,7 +102,7 @@ public class SingleScanTimeDimSelector implements DimensionSelector @Override public void inspectRuntimeShape(RuntimeShapeInspector inspector) { - inspector.visit("selector", SingleScanTimeDimSelector.this); + inspector.visit("selector", SingleScanTimeDimensionSelector.this); inspector.visit("predicate", predicate); } }; @@ -174,13 +177,13 @@ public class SingleScanTimeDimSelector implements DimensionSelector @Nullable @Override - public Object getObject() + public String getObject() { return currentValue; } @Override - public Class classOfObject() + public Class classOfObject() { return String.class; } diff --git a/processing/src/main/java/org/apache/druid/segment/StorageAdapter.java b/processing/src/main/java/org/apache/druid/segment/StorageAdapter.java index 009759c964d..3319d09c007 100644 --- a/processing/src/main/java/org/apache/druid/segment/StorageAdapter.java +++ b/processing/src/main/java/org/apache/druid/segment/StorageAdapter.java @@ -39,12 +39,8 @@ public interface StorageAdapter extends CursorFactory Iterable getAvailableMetrics(); /** - * Returns the number of distinct values for the given dimension column - * For dimensions of unknown cardinality, e.g. __time this currently returns - * Integer.MAX_VALUE - * - * @param column - * @return + * Returns the number of distinct values for the given column if known, or {@link Integer#MAX_VALUE} if unknown, + * e. g. the column is numeric. If the column doesn't exist, returns 0. */ int getDimensionCardinality(String column); DateTime getMinTime(); diff --git a/processing/src/main/java/org/apache/druid/segment/StringDimensionHandler.java b/processing/src/main/java/org/apache/druid/segment/StringDimensionHandler.java index cafc5c8843d..ff7809351db 100644 --- a/processing/src/main/java/org/apache/druid/segment/StringDimensionHandler.java +++ b/processing/src/main/java/org/apache/druid/segment/StringDimensionHandler.java @@ -21,6 +21,7 @@ package org.apache.druid.segment; import org.apache.druid.data.input.impl.DimensionSchema.MultiValueHandling; import org.apache.druid.java.util.common.ISE; +import org.apache.druid.java.util.common.io.Closer; import org.apache.druid.segment.column.ColumnCapabilities; import org.apache.druid.segment.data.IndexedInts; import org.apache.druid.segment.data.ZeroIndexedInts; @@ -161,7 +162,8 @@ public class StringDimensionHandler implements DimensionHandler { - private static String emptytoNullIfNeeded(Object o) + @Nullable + private static String emptyToNullIfNeeded(@Nullable Object o) { - return o != null - ? NullHandling.emptyToNullIfNeeded(o.toString()) - : null; + return o != null ? NullHandling.emptyToNullIfNeeded(o.toString()) : null; } private static final int ABSENT_VALUE_ID = -1; @@ -258,12 +256,12 @@ public class StringDimensionIndexer implements DimensionIndexer getSortedIndexedValues() + public CloseableIndexed getSortedIndexedValues() { - return new Indexed() + return new CloseableIndexed() { - @Override - public Class getClazz() - { - return String.class; - } @Override public int size() @@ -365,6 +358,12 @@ public class StringDimensionIndexer implements DimensionIndexer rowVals = new ArrayList<>(key.length); - for (int id : key) { - String val = getActualValue(id, false); - rowVals.add(NullHandling.nullToEmptyIfNeeded(val)); - } - return rowVals; - } else { - String[] rowArray = new String[key.length]; - for (int i = 0; i < key.length; i++) { - String val = getActualValue(key[i], false); - rowArray[i] = NullHandling.nullToEmptyIfNeeded(val); - } - return rowArray; + String[] rowArray = new String[key.length]; + for (int i = 0; i < key.length; i++) { + String val = getActualValue(key[i], false); + rowArray[i] = NullHandling.nullToEmptyIfNeeded(val); } + return Arrays.asList(rowArray); } } diff --git a/processing/src/main/java/org/apache/druid/segment/StringDimensionMergerV9.java b/processing/src/main/java/org/apache/druid/segment/StringDimensionMergerV9.java index 40146dad52f..050163bb7f7 100644 --- a/processing/src/main/java/org/apache/druid/segment/StringDimensionMergerV9.java +++ b/processing/src/main/java/org/apache/druid/segment/StringDimensionMergerV9.java @@ -22,6 +22,8 @@ package org.apache.druid.segment; import com.google.common.base.Predicate; import com.google.common.base.Splitter; import com.google.common.collect.Lists; +import it.unimi.dsi.fastutil.ints.IntIterable; +import it.unimi.dsi.fastutil.ints.IntIterator; import org.apache.druid.collections.bitmap.BitmapFactory; import org.apache.druid.collections.bitmap.ImmutableBitmap; import org.apache.druid.collections.bitmap.MutableBitmap; @@ -31,16 +33,17 @@ import org.apache.druid.collections.spatial.split.LinearGutmanSplitStrategy; import org.apache.druid.common.config.NullHandling; import org.apache.druid.java.util.common.ISE; import org.apache.druid.java.util.common.StringUtils; +import org.apache.druid.java.util.common.io.Closer; import org.apache.druid.java.util.common.logger.Logger; import org.apache.druid.query.filter.ValueMatcher; import org.apache.druid.query.monomorphicprocessing.RuntimeShapeInspector; import org.apache.druid.segment.column.ColumnCapabilities; import org.apache.druid.segment.column.ColumnDescriptor; import org.apache.druid.segment.column.ValueType; -import org.apache.druid.segment.data.ArrayIndexed; import org.apache.druid.segment.data.BitmapSerdeFactory; import org.apache.druid.segment.data.BitmapValues; import org.apache.druid.segment.data.ByteBufferWriter; +import org.apache.druid.segment.data.CloseableIndexed; import org.apache.druid.segment.data.ColumnarIntsSerializer; import org.apache.druid.segment.data.ColumnarMultiIntsSerializer; import org.apache.druid.segment.data.CompressedVSizeColumnarIntsSerializer; @@ -50,27 +53,28 @@ import org.apache.druid.segment.data.GenericIndexedWriter; import org.apache.druid.segment.data.ImmutableRTreeObjectStrategy; import org.apache.druid.segment.data.Indexed; import org.apache.druid.segment.data.IndexedInts; +import org.apache.druid.segment.data.ListIndexed; import org.apache.druid.segment.data.SingleValueColumnarIntsSerializer; import org.apache.druid.segment.data.V3CompressedVSizeColumnarMultiIntsSerializer; import org.apache.druid.segment.data.VSizeColumnarIntsSerializer; import org.apache.druid.segment.data.VSizeColumnarMultiIntsSerializer; import org.apache.druid.segment.serde.DictionaryEncodedColumnPartSerde; import org.apache.druid.segment.writeout.SegmentWriteOutMedium; -import it.unimi.dsi.fastutil.ints.IntIterable; -import it.unimi.dsi.fastutil.ints.IntIterator; import javax.annotation.Nonnull; import javax.annotation.Nullable; import java.io.IOException; +import java.io.UncheckedIOException; import java.nio.IntBuffer; import java.util.ArrayList; +import java.util.Collections; import java.util.List; public class StringDimensionMergerV9 implements DimensionMergerV9 { private static final Logger log = new Logger(StringDimensionMergerV9.class); - private static final Indexed NULL_STR_DIM_VAL = new ArrayIndexed<>(new String[]{null}, String.class); + private static final Indexed NULL_STR_DIM_VAL = new ListIndexed<>(Collections.singletonList(null)); private static final Splitter SPLITTER = Splitter.on(","); private ColumnarIntsSerializer encodedValueSerializer; @@ -89,24 +93,29 @@ public class StringDimensionMergerV9 implements DimensionMergerV9 private int rowCount = 0; private ColumnCapabilities capabilities; private List adapters; - private ProgressIndicator progress; private final IndexSpec indexSpec; private IndexMerger.DictionaryMergeIterator dictionaryMergeIterator; + private final ProgressIndicator progress; + private final Closer closer; + public StringDimensionMergerV9( String dimensionName, IndexSpec indexSpec, SegmentWriteOutMedium segmentWriteOutMedium, ColumnCapabilities capabilities, - ProgressIndicator progress + ProgressIndicator progress, + Closer closer ) { this.dimensionName = dimensionName; this.indexSpec = indexSpec; this.capabilities = capabilities; this.segmentWriteOutMedium = segmentWriteOutMedium; - this.progress = progress; nullRowsBitmap = indexSpec.getBitmapSerdeFactory().getBitmapFactory().makeEmptyMutableBitmap(); + + this.progress = progress; + this.closer = closer; } @Override @@ -128,7 +137,8 @@ public class StringDimensionMergerV9 implements DimensionMergerV9 Indexed dimValueLookup = null; Indexed[] dimValueLookups = new Indexed[adapters.size() + 1]; for (int i = 0; i < adapters.size(); i++) { - Indexed dimValues = adapters.get(i).getDimValueLookup(dimensionName); + @SuppressWarnings("MustBeClosedChecker") // we register dimValues in the closer + Indexed dimValues = closer.register(adapters.get(i).getDimValueLookup(dimensionName)); if (dimValues != null && !allNull(dimValues)) { dimHasValues = true; hasNull |= dimValues.indexOf(null) >= 0; @@ -667,8 +677,12 @@ public class StringDimensionMergerV9 implements DimensionMergerV9 if (dimConversion != null) { seekers[i] = new IndexSeekerWithConversion((IntBuffer) dimConversion.asReadOnlyBuffer().rewind()); } else { - Indexed dimValueLookup = adapters.get(i).getDimValueLookup(dimension); - seekers[i] = new IndexSeekerWithoutConversion(dimValueLookup == null ? 0 : dimValueLookup.size()); + try (CloseableIndexed dimValueLookup = adapters.get(i).getDimValueLookup(dimension)) { + seekers[i] = new IndexSeekerWithoutConversion(dimValueLookup == null ? 0 : dimValueLookup.size()); + } + catch (IOException e) { + throw new UncheckedIOException(e); + } } } return seekers; diff --git a/processing/src/main/java/org/apache/druid/segment/TimeAndDimsPointer.java b/processing/src/main/java/org/apache/druid/segment/TimeAndDimsPointer.java index 2ee41711dbe..56eeba56655 100644 --- a/processing/src/main/java/org/apache/druid/segment/TimeAndDimsPointer.java +++ b/processing/src/main/java/org/apache/druid/segment/TimeAndDimsPointer.java @@ -28,6 +28,7 @@ import java.util.Comparator; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; /** * TimeAndDimsPointer is used in conjunction with {@link TimeAndDimsIterator}, it's an _immutable_ object that points to @@ -178,9 +179,9 @@ public class TimeAndDimsPointer implements Comparable throw new UnsupportedOperationException("Should not compute hashCode() on TimeAndDimsPointer"); } - Object[] getDimensionValuesForDebug() + List getDimensionValuesForDebug() { - return Arrays.stream(dimensionSelectors).map(ColumnValueSelector::getObject).toArray(); + return Arrays.stream(dimensionSelectors).map(ColumnValueSelector::getObject).collect(Collectors.toList()); } @Override @@ -198,9 +199,6 @@ public class TimeAndDimsPointer implements Comparable LinkedHashMap result = new LinkedHashMap<>(); for (int i = 0; i < getNumDimensions(); i++) { Object value = dimensionSelectors[i].getObject(); - if (value instanceof Object[]) { - value = Arrays.asList((Object[]) value); - } result.put(dimensionHandlers.get(i).getDimensionName(), value); } return result; diff --git a/processing/src/main/java/org/apache/druid/segment/VirtualColumns.java b/processing/src/main/java/org/apache/druid/segment/VirtualColumns.java index 8b66444b1aa..5e4e6eb5ff2 100644 --- a/processing/src/main/java/org/apache/druid/segment/VirtualColumns.java +++ b/processing/src/main/java/org/apache/druid/segment/VirtualColumns.java @@ -32,8 +32,8 @@ import org.apache.druid.java.util.common.IAE; import org.apache.druid.java.util.common.Pair; import org.apache.druid.query.cache.CacheKeyBuilder; import org.apache.druid.query.dimension.DimensionSpec; -import org.apache.druid.segment.column.Column; import org.apache.druid.segment.column.ColumnCapabilities; +import org.apache.druid.segment.column.ColumnHolder; import org.apache.druid.segment.virtual.VirtualizedColumnSelectorFactory; import javax.annotation.Nullable; @@ -83,7 +83,7 @@ public class VirtualColumns implements Cacheable throw new IAE("Empty or null virtualColumn name"); } - if (vc.getOutputName().equals(Column.TIME_COLUMN_NAME)) { + if (vc.getOutputName().equals(ColumnHolder.TIME_COLUMN_NAME)) { throw new IAE("virtualColumn name[%s] not allowed", vc.getOutputName()); } diff --git a/processing/src/main/java/org/apache/druid/segment/column/BaseColumn.java b/processing/src/main/java/org/apache/druid/segment/column/BaseColumn.java index 8de067ee8e6..d692725fd12 100644 --- a/processing/src/main/java/org/apache/druid/segment/column/BaseColumn.java +++ b/processing/src/main/java/org/apache/druid/segment/column/BaseColumn.java @@ -26,5 +26,5 @@ import java.io.Closeable; public interface BaseColumn extends Closeable { - ColumnValueSelector makeColumnValueSelector(ReadableOffset offset); + ColumnValueSelector makeColumnValueSelector(ReadableOffset offset); } diff --git a/processing/src/main/java/org/apache/druid/segment/column/BitmapIndex.java b/processing/src/main/java/org/apache/druid/segment/column/BitmapIndex.java index 8de489cd3df..acb7e26aec1 100644 --- a/processing/src/main/java/org/apache/druid/segment/column/BitmapIndex.java +++ b/processing/src/main/java/org/apache/druid/segment/column/BitmapIndex.java @@ -22,6 +22,8 @@ package org.apache.druid.segment.column; import org.apache.druid.collections.bitmap.BitmapFactory; import org.apache.druid.collections.bitmap.ImmutableBitmap; +import javax.annotation.Nullable; + /** */ public interface BitmapIndex @@ -41,7 +43,7 @@ public interface BitmapIndex * @param value value to search for * @return index of value, or negative number equal to (-(insertion point) - 1). */ - int getIndex(String value); + int getIndex(@Nullable String value); ImmutableBitmap getBitmap(int idx); } diff --git a/processing/src/main/java/org/apache/druid/segment/column/ColumnBuilder.java b/processing/src/main/java/org/apache/druid/segment/column/ColumnBuilder.java index c5f0e5012a1..7ef78c674e5 100644 --- a/processing/src/main/java/org/apache/druid/segment/column/ColumnBuilder.java +++ b/processing/src/main/java/org/apache/druid/segment/column/ColumnBuilder.java @@ -31,9 +31,8 @@ public class ColumnBuilder private boolean hasMultipleValues = false; private boolean filterable = false; - private Supplier dictionaryEncodedColumn = null; - private Supplier genericColumn = null; - private Supplier complexColumn = null; + private Supplier columnSupplier = null; + private boolean dictionaryEncoded = false; private Supplier bitmapIndex = null; private Supplier spatialIndex = null; private SmooshedFileMapper fileMapper = null; @@ -61,6 +60,13 @@ public class ColumnBuilder return this; } + public ColumnBuilder setDictionaryEncodedColumnSupplier(Supplier> columnSupplier) + { + this.columnSupplier = columnSupplier; + this.dictionaryEncoded = true; + return this; + } + @SuppressWarnings("unused") public ColumnBuilder setFilterable(boolean filterable) { @@ -68,21 +74,15 @@ public class ColumnBuilder return this; } - public ColumnBuilder setDictionaryEncodedColumn(Supplier dictionaryEncodedColumn) + public ColumnBuilder setComplexColumnSupplier(Supplier columnSupplier) { - this.dictionaryEncodedColumn = dictionaryEncodedColumn; + this.columnSupplier = columnSupplier; return this; } - public ColumnBuilder setGenericColumn(Supplier genericColumn) + public ColumnBuilder setNumericColumnSupplier(Supplier columnSupplier) { - this.genericColumn = genericColumn; - return this; - } - - public ColumnBuilder setComplexColumn(Supplier complexColumn) - { - this.complexColumn = complexColumn; + this.columnSupplier = columnSupplier; return this; } @@ -98,21 +98,19 @@ public class ColumnBuilder return this; } - public Column build() + public ColumnHolder build() { Preconditions.checkState(type != null, "Type must be set."); - return new SimpleColumn( + return new SimpleColumnHolder( new ColumnCapabilitiesImpl() .setType(type) - .setDictionaryEncoded(dictionaryEncodedColumn != null) + .setDictionaryEncoded(dictionaryEncoded) .setHasBitmapIndexes(bitmapIndex != null) .setHasSpatialIndexes(spatialIndex != null) .setHasMultipleValues(hasMultipleValues) .setFilterable(filterable), - dictionaryEncodedColumn, - genericColumn, - complexColumn, + columnSupplier, bitmapIndex, spatialIndex ); diff --git a/processing/src/main/java/org/apache/druid/segment/column/ColumnDescriptor.java b/processing/src/main/java/org/apache/druid/segment/column/ColumnDescriptor.java index 3fe4c892697..dd341eb686c 100644 --- a/processing/src/main/java/org/apache/druid/segment/column/ColumnDescriptor.java +++ b/processing/src/main/java/org/apache/druid/segment/column/ColumnDescriptor.java @@ -95,7 +95,7 @@ public class ColumnDescriptor implements Serializer } } - public Column read(ByteBuffer buffer, ColumnConfig columnConfig, SmooshedFileMapper smooshedFiles) + public ColumnHolder read(ByteBuffer buffer, ColumnConfig columnConfig, SmooshedFileMapper smooshedFiles) { final ColumnBuilder builder = new ColumnBuilder() .setType(valueType) diff --git a/processing/src/main/java/org/apache/druid/segment/column/Column.java b/processing/src/main/java/org/apache/druid/segment/column/ColumnHolder.java similarity index 87% rename from processing/src/main/java/org/apache/druid/segment/column/Column.java rename to processing/src/main/java/org/apache/druid/segment/column/ColumnHolder.java index 85cde8fe3da..c7454df05ba 100644 --- a/processing/src/main/java/org/apache/druid/segment/column/Column.java +++ b/processing/src/main/java/org/apache/druid/segment/column/ColumnHolder.java @@ -22,9 +22,11 @@ package org.apache.druid.segment.column; import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.segment.selector.settable.SettableColumnValueSelector; +import javax.annotation.Nullable; + /** */ -public interface Column +public interface ColumnHolder { String TIME_COLUMN_NAME = "__time"; String DOUBLE_STORAGE_TYPE_PROPERTY = "druid.indexing.doubleStorage"; @@ -38,15 +40,14 @@ public interface Column ColumnCapabilities getCapabilities(); int getLength(); - DictionaryEncodedColumn getDictionaryEncoding(); - - GenericColumn getGenericColumn(); - ComplexColumn getComplexColumn(); + BaseColumn getColumn(); + @Nullable BitmapIndex getBitmapIndex(); + @Nullable SpatialIndex getSpatialIndex(); /** * Returns a new instance of a {@link SettableColumnValueSelector}, corresponding to the type of this column. */ - SettableColumnValueSelector makeSettableColumnValueSelector(); + SettableColumnValueSelector makeNewSettableColumnValueSelector(); } diff --git a/processing/src/main/java/org/apache/druid/segment/column/ComplexColumn.java b/processing/src/main/java/org/apache/druid/segment/column/ComplexColumn.java index 7075e301b22..1a7981eec18 100644 --- a/processing/src/main/java/org/apache/druid/segment/column/ComplexColumn.java +++ b/processing/src/main/java/org/apache/druid/segment/column/ComplexColumn.java @@ -22,24 +22,42 @@ package org.apache.druid.segment.column; import org.apache.druid.query.monomorphicprocessing.RuntimeShapeInspector; import org.apache.druid.segment.ColumnValueSelector; import org.apache.druid.segment.ObjectColumnSelector; +import org.apache.druid.segment.data.GenericIndexed; import org.apache.druid.segment.data.ReadableOffset; import javax.annotation.Nullable; /** - */ -public interface ComplexColumn extends BaseColumn +*/ +public class ComplexColumn implements BaseColumn { - Class getClazz(); - String getTypeName(); - Object getRowValue(int rowNum); - int getLength(); + private final GenericIndexed index; + private final String typeName; + + public ComplexColumn(String typeName, GenericIndexed index) + { + this.index = index; + this.typeName = typeName; + } + + public String getTypeName() + { + return typeName; + } + + @Nullable + public Object getRowValue(int rowNum) + { + return index.get(rowNum); + } + + public int getLength() + { + return index.size(); + } @Override - void close(); - - @Override - default ColumnValueSelector makeColumnValueSelector(ReadableOffset offset) + public ColumnValueSelector makeColumnValueSelector(ReadableOffset offset) { return new ObjectColumnSelector() { @@ -53,7 +71,7 @@ public interface ComplexColumn extends BaseColumn @Override public Class classOfObject() { - return getClazz(); + return index.getClazz(); } @Override @@ -63,4 +81,10 @@ public interface ComplexColumn extends BaseColumn } }; } + + @Override + public void close() + { + // nothing to close + } } diff --git a/processing/src/main/java/org/apache/druid/segment/column/DictionaryEncodedColumn.java b/processing/src/main/java/org/apache/druid/segment/column/DictionaryEncodedColumn.java index d493c46e82c..2e67a44ad4f 100644 --- a/processing/src/main/java/org/apache/druid/segment/column/DictionaryEncodedColumn.java +++ b/processing/src/main/java/org/apache/druid/segment/column/DictionaryEncodedColumn.java @@ -29,9 +29,8 @@ import javax.annotation.Nullable; /** */ -public interface DictionaryEncodedColumn extends BaseColumn +public interface DictionaryEncodedColumn> extends BaseColumn { - Class getClazz(); int length(); boolean hasMultipleValues(); int getSingleValueRow(int rowNum); @@ -43,7 +42,7 @@ public interface DictionaryEncodedColumn extends DimensionSelector makeDimensionSelector(ReadableOffset offset, @Nullable ExtractionFn extractionFn); @Override - default ColumnValueSelector makeColumnValueSelector(ReadableOffset offset) + default ColumnValueSelector makeColumnValueSelector(ReadableOffset offset) { return makeDimensionSelector(offset, null); } diff --git a/processing/src/main/java/org/apache/druid/segment/column/DoublesColumn.java b/processing/src/main/java/org/apache/druid/segment/column/DoublesColumn.java index 753e45047b3..80a7d2ffe41 100644 --- a/processing/src/main/java/org/apache/druid/segment/column/DoublesColumn.java +++ b/processing/src/main/java/org/apache/druid/segment/column/DoublesColumn.java @@ -29,7 +29,7 @@ import org.apache.druid.segment.data.ReadableOffset; /** */ -public class DoublesColumn implements GenericColumn +public class DoublesColumn implements NumericColumn { /** * Factory method to create DoublesColumn. @@ -57,7 +57,7 @@ public class DoublesColumn implements GenericColumn } @Override - public ColumnValueSelector makeColumnValueSelector(ReadableOffset offset) + public ColumnValueSelector makeColumnValueSelector(ReadableOffset offset) { return column.makeColumnValueSelector(offset, IndexIO.LEGACY_FACTORY.getBitmapFactory().makeEmptyImmutableBitmap()); } diff --git a/processing/src/main/java/org/apache/druid/segment/column/DoublesColumnWithNulls.java b/processing/src/main/java/org/apache/druid/segment/column/DoublesColumnWithNulls.java index 905a1db6294..ee188234d91 100644 --- a/processing/src/main/java/org/apache/druid/segment/column/DoublesColumnWithNulls.java +++ b/processing/src/main/java/org/apache/druid/segment/column/DoublesColumnWithNulls.java @@ -39,7 +39,7 @@ class DoublesColumnWithNulls extends DoublesColumn } @Override - public ColumnValueSelector makeColumnValueSelector(ReadableOffset offset) + public ColumnValueSelector makeColumnValueSelector(ReadableOffset offset) { return column.makeColumnValueSelector(offset, nullValueBitmap); } diff --git a/processing/src/main/java/org/apache/druid/segment/column/FloatsColumn.java b/processing/src/main/java/org/apache/druid/segment/column/FloatsColumn.java index 0337d30fb60..2e42070df69 100644 --- a/processing/src/main/java/org/apache/druid/segment/column/FloatsColumn.java +++ b/processing/src/main/java/org/apache/druid/segment/column/FloatsColumn.java @@ -28,7 +28,7 @@ import org.apache.druid.segment.data.ReadableOffset; /** */ -public class FloatsColumn implements GenericColumn +public class FloatsColumn implements NumericColumn { /** * Factory method to create FloatsColumn. @@ -56,7 +56,7 @@ public class FloatsColumn implements GenericColumn } @Override - public ColumnValueSelector makeColumnValueSelector(ReadableOffset offset) + public ColumnValueSelector makeColumnValueSelector(ReadableOffset offset) { return column.makeColumnValueSelector(offset, IndexIO.LEGACY_FACTORY.getBitmapFactory().makeEmptyImmutableBitmap()); } diff --git a/processing/src/main/java/org/apache/druid/segment/column/FloatsColumnWithNulls.java b/processing/src/main/java/org/apache/druid/segment/column/FloatsColumnWithNulls.java index 0ec0d167fea..cdde6e83393 100644 --- a/processing/src/main/java/org/apache/druid/segment/column/FloatsColumnWithNulls.java +++ b/processing/src/main/java/org/apache/druid/segment/column/FloatsColumnWithNulls.java @@ -39,7 +39,7 @@ class FloatsColumnWithNulls extends FloatsColumn } @Override - public ColumnValueSelector makeColumnValueSelector(ReadableOffset offset) + public ColumnValueSelector makeColumnValueSelector(ReadableOffset offset) { return column.makeColumnValueSelector(offset, nullValueBitmap); } diff --git a/processing/src/main/java/org/apache/druid/segment/column/LongsColumn.java b/processing/src/main/java/org/apache/druid/segment/column/LongsColumn.java index 6100dbb7a06..acff61d8a6e 100644 --- a/processing/src/main/java/org/apache/druid/segment/column/LongsColumn.java +++ b/processing/src/main/java/org/apache/druid/segment/column/LongsColumn.java @@ -28,7 +28,7 @@ import org.apache.druid.segment.data.ReadableOffset; /** */ -public class LongsColumn implements GenericColumn +public class LongsColumn implements NumericColumn { /** * Factory method to create LongsColumn. @@ -56,10 +56,9 @@ public class LongsColumn implements GenericColumn } @Override - public ColumnValueSelector makeColumnValueSelector(ReadableOffset offset) + public ColumnValueSelector makeColumnValueSelector(ReadableOffset offset) { - return column.makeColumnValueSelector(offset, IndexIO.LEGACY_FACTORY.getBitmapFactory() - .makeEmptyImmutableBitmap()); + return column.makeColumnValueSelector(offset, IndexIO.LEGACY_FACTORY.getBitmapFactory().makeEmptyImmutableBitmap()); } @Override diff --git a/processing/src/main/java/org/apache/druid/segment/column/LongsColumnWithNulls.java b/processing/src/main/java/org/apache/druid/segment/column/LongsColumnWithNulls.java index 9c2500d2974..19937e77d2b 100644 --- a/processing/src/main/java/org/apache/druid/segment/column/LongsColumnWithNulls.java +++ b/processing/src/main/java/org/apache/druid/segment/column/LongsColumnWithNulls.java @@ -39,7 +39,7 @@ class LongsColumnWithNulls extends LongsColumn } @Override - public ColumnValueSelector makeColumnValueSelector(ReadableOffset offset) + public ColumnValueSelector makeColumnValueSelector(ReadableOffset offset) { return column.makeColumnValueSelector(offset, nullValueBitmap); } diff --git a/processing/src/main/java/org/apache/druid/segment/column/GenericColumn.java b/processing/src/main/java/org/apache/druid/segment/column/NumericColumn.java similarity index 94% rename from processing/src/main/java/org/apache/druid/segment/column/GenericColumn.java rename to processing/src/main/java/org/apache/druid/segment/column/NumericColumn.java index 2b12c1cf793..ce6350262ca 100644 --- a/processing/src/main/java/org/apache/druid/segment/column/GenericColumn.java +++ b/processing/src/main/java/org/apache/druid/segment/column/NumericColumn.java @@ -24,7 +24,7 @@ import org.apache.druid.query.monomorphicprocessing.HotLoopCallee; /** */ -public interface GenericColumn extends BaseColumn, HotLoopCallee +public interface NumericColumn extends BaseColumn, HotLoopCallee { int length(); diff --git a/processing/src/main/java/org/apache/druid/segment/column/SimpleColumn.java b/processing/src/main/java/org/apache/druid/segment/column/SimpleColumnHolder.java similarity index 59% rename from processing/src/main/java/org/apache/druid/segment/column/SimpleColumn.java rename to processing/src/main/java/org/apache/druid/segment/column/SimpleColumnHolder.java index 71d30e74554..a340d4f3ab5 100644 --- a/processing/src/main/java/org/apache/druid/segment/column/SimpleColumn.java +++ b/processing/src/main/java/org/apache/druid/segment/column/SimpleColumnHolder.java @@ -22,30 +22,28 @@ package org.apache.druid.segment.column; import com.google.common.base.Supplier; import org.apache.druid.segment.selector.settable.SettableColumnValueSelector; +import javax.annotation.Nullable; + /** */ -class SimpleColumn implements Column +class SimpleColumnHolder implements ColumnHolder { private final ColumnCapabilities capabilities; - private final Supplier dictionaryEncodedColumn; - private final Supplier genericColumn; - private final Supplier complexColumn; + private final Supplier columnSupplier; + @Nullable private final Supplier bitmapIndex; + @Nullable private final Supplier spatialIndex; - SimpleColumn( + SimpleColumnHolder( ColumnCapabilities capabilities, - Supplier dictionaryEncodedColumn, - Supplier genericColumn, - Supplier complexColumn, - Supplier bitmapIndex, - Supplier spatialIndex + Supplier columnSupplier, + @Nullable Supplier bitmapIndex, + @Nullable Supplier spatialIndex ) { this.capabilities = capabilities; - this.dictionaryEncodedColumn = dictionaryEncodedColumn; - this.genericColumn = genericColumn; - this.complexColumn = complexColumn; + this.columnSupplier = columnSupplier; this.bitmapIndex = bitmapIndex; this.spatialIndex = spatialIndex; } @@ -59,35 +57,25 @@ class SimpleColumn implements Column @Override public int getLength() { - try (final GenericColumn column = genericColumn.get()) { + try (final NumericColumn column = (NumericColumn) columnSupplier.get()) { return column.length(); } } @Override - public DictionaryEncodedColumn getDictionaryEncoding() + public BaseColumn getColumn() { - return dictionaryEncodedColumn == null ? null : dictionaryEncodedColumn.get(); - } - - @Override - public GenericColumn getGenericColumn() - { - return genericColumn == null ? null : genericColumn.get(); - } - - @Override - public ComplexColumn getComplexColumn() - { - return complexColumn == null ? null : complexColumn.get(); + return columnSupplier.get(); } + @Nullable @Override public BitmapIndex getBitmapIndex() { return bitmapIndex == null ? null : bitmapIndex.get(); } + @Nullable @Override public SpatialIndex getSpatialIndex() { @@ -95,8 +83,8 @@ class SimpleColumn implements Column } @Override - public SettableColumnValueSelector makeSettableColumnValueSelector() + public SettableColumnValueSelector makeNewSettableColumnValueSelector() { - return getCapabilities().getType().makeSettableColumnValueSelector(); + return getCapabilities().getType().makeNewSettableColumnValueSelector(); } } diff --git a/processing/src/main/java/org/apache/druid/segment/column/SimpleDictionaryEncodedColumn.java b/processing/src/main/java/org/apache/druid/segment/column/StringDictionaryEncodedColumn.java similarity index 90% rename from processing/src/main/java/org/apache/druid/segment/column/SimpleDictionaryEncodedColumn.java rename to processing/src/main/java/org/apache/druid/segment/column/StringDictionaryEncodedColumn.java index ef0e8ad9413..7bddc80f37e 100644 --- a/processing/src/main/java/org/apache/druid/segment/column/SimpleDictionaryEncodedColumn.java +++ b/processing/src/main/java/org/apache/druid/segment/column/StringDictionaryEncodedColumn.java @@ -25,6 +25,7 @@ import org.apache.druid.java.util.common.guava.CloseQuietly; import org.apache.druid.query.extraction.ExtractionFn; import org.apache.druid.query.filter.ValueMatcher; import org.apache.druid.query.monomorphicprocessing.RuntimeShapeInspector; +import org.apache.druid.segment.AbstractDimensionSelector; import org.apache.druid.segment.DimensionSelectorUtils; import org.apache.druid.segment.IdLookup; import org.apache.druid.segment.data.CachingIndexed; @@ -43,15 +44,17 @@ import java.util.BitSet; /** */ -public class SimpleDictionaryEncodedColumn implements DictionaryEncodedColumn +public class StringDictionaryEncodedColumn implements DictionaryEncodedColumn { + @Nullable private final ColumnarInts column; + @Nullable private final ColumnarMultiInts multiValueColumn; private final CachingIndexed cachedLookups; - public SimpleDictionaryEncodedColumn( - ColumnarInts singleValueColumn, - ColumnarMultiInts multiValueColumn, + public StringDictionaryEncodedColumn( + @Nullable ColumnarInts singleValueColumn, + @Nullable ColumnarMultiInts multiValueColumn, CachingIndexed cachedLookups ) { @@ -60,12 +63,6 @@ public class SimpleDictionaryEncodedColumn implements DictionaryEncodedColumn getClazz() - { - return String.class; - } - @Override public int length() { @@ -115,7 +112,8 @@ public class SimpleDictionaryEncodedColumn implements DictionaryEncodedColumn getClazz() - { - return column.getClazz(); - } - - @Override - public String getTypeName() - { - return typeName; - } - - @Override - public Object getRowValue(int rowNum) - { - return column.get(rowNum); - } - - @Override - public int getLength() - { - return column.size(); - } - - @Override - public void close() - { - } -} +import org.apache.druid.annotations.EverythingIsNonnullByDefault; diff --git a/processing/src/main/java/org/apache/druid/segment/data/ArrayBasedIndexedInts.java b/processing/src/main/java/org/apache/druid/segment/data/ArrayBasedIndexedInts.java index 450b3e2bb56..2c48674c46b 100644 --- a/processing/src/main/java/org/apache/druid/segment/data/ArrayBasedIndexedInts.java +++ b/processing/src/main/java/org/apache/druid/segment/data/ArrayBasedIndexedInts.java @@ -19,9 +19,9 @@ package org.apache.druid.segment.data; +import it.unimi.dsi.fastutil.ints.IntArrays; import org.apache.druid.java.util.common.IAE; import org.apache.druid.query.monomorphicprocessing.RuntimeShapeInspector; -import it.unimi.dsi.fastutil.ints.IntArrays; /** */ diff --git a/processing/src/main/java/org/apache/druid/segment/data/ArrayIndexed.java b/processing/src/main/java/org/apache/druid/segment/data/ArrayIndexed.java deleted file mode 100644 index 7dca91d36d0..00000000000 --- a/processing/src/main/java/org/apache/druid/segment/data/ArrayIndexed.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * 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.data; - -import org.apache.druid.query.monomorphicprocessing.RuntimeShapeInspector; - -import java.util.Arrays; -import java.util.Iterator; - -/** - */ -public class ArrayIndexed implements Indexed -{ - private final T[] baseArray; - private final Class clazz; - - public ArrayIndexed( - T[] baseArray, - Class clazz - ) - { - this.baseArray = baseArray; - this.clazz = clazz; - } - - @Override - public Class getClazz() - { - return clazz; - } - - @Override - public int size() - { - return baseArray.length; - } - - @Override - public T get(int index) - { - return baseArray[index]; - } - - @Override - public int indexOf(T value) - { - return Arrays.asList(baseArray).indexOf(value); - } - - @Override - public Iterator iterator() - { - return Arrays.asList(baseArray).iterator(); - } - - @Override - public void inspectRuntimeShape(RuntimeShapeInspector inspector) - { - // nothing to inspect - } -} diff --git a/processing/src/main/java/org/apache/druid/segment/data/BitmapValues.java b/processing/src/main/java/org/apache/druid/segment/data/BitmapValues.java index 00ecde570dd..41133092a44 100644 --- a/processing/src/main/java/org/apache/druid/segment/data/BitmapValues.java +++ b/processing/src/main/java/org/apache/druid/segment/data/BitmapValues.java @@ -23,7 +23,7 @@ import it.unimi.dsi.fastutil.ints.IntIterator; import it.unimi.dsi.fastutil.ints.IntIterators; /** - * Doesn't extend {@link it.unimi.dsi.fastutil.ints.IntIterable} to avoid accidential for-each iteration with boxing. + * Doesn't extend {@link it.unimi.dsi.fastutil.ints.IntIterable} to avoid accidental for-each iteration with boxing. */ public interface BitmapValues { diff --git a/processing/src/main/java/org/apache/druid/segment/data/BlockLayoutColumnarFloatsSerializer.java b/processing/src/main/java/org/apache/druid/segment/data/BlockLayoutColumnarFloatsSerializer.java index 4411c0898c8..84d2e26bbb6 100644 --- a/processing/src/main/java/org/apache/druid/segment/data/BlockLayoutColumnarFloatsSerializer.java +++ b/processing/src/main/java/org/apache/druid/segment/data/BlockLayoutColumnarFloatsSerializer.java @@ -21,9 +21,9 @@ package org.apache.druid.segment.data; import org.apache.druid.java.util.common.io.Closer; import org.apache.druid.java.util.common.io.smoosh.FileSmoosher; -import org.apache.druid.segment.writeout.SegmentWriteOutMedium; import org.apache.druid.segment.CompressedPools; import org.apache.druid.segment.serde.MetaSerdeHelper; +import org.apache.druid.segment.writeout.SegmentWriteOutMedium; import java.io.IOException; import java.nio.ByteBuffer; diff --git a/processing/src/main/java/org/apache/druid/segment/data/BlockLayoutColumnarLongsSerializer.java b/processing/src/main/java/org/apache/druid/segment/data/BlockLayoutColumnarLongsSerializer.java index cad801d4bec..8aadff24a7a 100644 --- a/processing/src/main/java/org/apache/druid/segment/data/BlockLayoutColumnarLongsSerializer.java +++ b/processing/src/main/java/org/apache/druid/segment/data/BlockLayoutColumnarLongsSerializer.java @@ -20,9 +20,9 @@ package org.apache.druid.segment.data; import org.apache.druid.java.util.common.io.smoosh.FileSmoosher; -import org.apache.druid.segment.writeout.SegmentWriteOutMedium; import org.apache.druid.segment.CompressedPools; import org.apache.druid.segment.serde.MetaSerdeHelper; +import org.apache.druid.segment.writeout.SegmentWriteOutMedium; import java.io.IOException; import java.nio.ByteBuffer; diff --git a/processing/src/main/java/org/apache/druid/segment/data/CachingIndexed.java b/processing/src/main/java/org/apache/druid/segment/data/CachingIndexed.java index 863f2fc2b49..432572f208f 100644 --- a/processing/src/main/java/org/apache/druid/segment/data/CachingIndexed.java +++ b/processing/src/main/java/org/apache/druid/segment/data/CachingIndexed.java @@ -23,6 +23,7 @@ import org.apache.druid.java.util.common.Pair; import org.apache.druid.java.util.common.logger.Logger; import org.apache.druid.query.monomorphicprocessing.RuntimeShapeInspector; +import javax.annotation.Nullable; import java.io.Closeable; import java.util.Iterator; import java.util.LinkedHashMap; @@ -30,11 +31,12 @@ import java.util.Map; public class CachingIndexed implements Indexed, Closeable { - public static final int INITIAL_CACHE_CAPACITY = 16384; + private static final int INITIAL_CACHE_CAPACITY = 16384; private static final Logger log = new Logger(CachingIndexed.class); private final GenericIndexed.BufferIndexed delegate; + @Nullable private final SizedLRUMap cachedValues; /** @@ -58,12 +60,6 @@ public class CachingIndexed implements Indexed, Closeable } } - @Override - public Class getClazz() - { - return delegate.getClazz(); - } - @Override public int size() { @@ -88,7 +84,7 @@ public class CachingIndexed implements Indexed, Closeable } @Override - public int indexOf(T value) + public int indexOf(@Nullable T value) { return delegate.indexOf(value); } @@ -120,7 +116,7 @@ public class CachingIndexed implements Indexed, Closeable private final int maxBytes; private int numBytes = 0; - public SizedLRUMap(int initialCapacity, int maxBytes) + SizedLRUMap(int initialCapacity, int maxBytes) { super(initialCapacity, 0.75f, true); this.maxBytes = maxBytes; @@ -136,13 +132,14 @@ public class CachingIndexed implements Indexed, Closeable return false; } - public void put(K key, V value, int size) + public void put(K key, @Nullable V value, int size) { final int totalSize = size + 48; // add approximate object overhead numBytes += totalSize; super.put(key, new Pair<>(totalSize, value)); } + @Nullable public V getValue(Object key) { final Pair sizeValuePair = super.get(key); diff --git a/processing/src/main/java/org/apache/druid/segment/data/CacheableObjectStrategy.java b/processing/src/main/java/org/apache/druid/segment/data/CloseableIndexed.java similarity index 78% rename from processing/src/main/java/org/apache/druid/segment/data/CacheableObjectStrategy.java rename to processing/src/main/java/org/apache/druid/segment/data/CloseableIndexed.java index 25b454b3fce..a5ab96689d2 100644 --- a/processing/src/main/java/org/apache/druid/segment/data/CacheableObjectStrategy.java +++ b/processing/src/main/java/org/apache/druid/segment/data/CloseableIndexed.java @@ -19,8 +19,8 @@ package org.apache.druid.segment.data; -/** - * Implementing CacheableObjectStrategy instead of ObjectSrategy indicates - * that a column scan may cache the results of {@link #fromByteBuffer}. - */ -public interface CacheableObjectStrategy extends ObjectStrategy {} +import java.io.Closeable; + +public interface CloseableIndexed extends Indexed, Closeable +{ +} diff --git a/processing/src/main/java/org/apache/druid/segment/data/ColumnarInts.java b/processing/src/main/java/org/apache/druid/segment/data/ColumnarInts.java index 458be0b9ba5..dc2adbbb671 100644 --- a/processing/src/main/java/org/apache/druid/segment/data/ColumnarInts.java +++ b/processing/src/main/java/org/apache/druid/segment/data/ColumnarInts.java @@ -23,8 +23,8 @@ import java.io.Closeable; /** * Resource that provides random access to a packed array of primitive int values. Typically backs up dictionary-encoded - * string columns (see {@link org.apache.druid.segment.column.DictionaryEncodedColumn}), either directly for single-valued - * string columns, or indirectly as part of implementation of {@link ColumnarMultiInts}. + * columns (see {@link org.apache.druid.segment.column.DictionaryEncodedColumn}), either directly for single-valued + * columns, or indirectly as part of implementation of {@link ColumnarMultiInts}. */ public interface ColumnarInts extends IndexedInts, Closeable { diff --git a/processing/src/main/java/org/apache/druid/segment/data/CompressedColumnarIntsSupplier.java b/processing/src/main/java/org/apache/druid/segment/data/CompressedColumnarIntsSupplier.java index b3161f2f459..ca154a93667 100644 --- a/processing/src/main/java/org/apache/druid/segment/data/CompressedColumnarIntsSupplier.java +++ b/processing/src/main/java/org/apache/druid/segment/data/CompressedColumnarIntsSupplier.java @@ -21,6 +21,7 @@ package org.apache.druid.segment.data; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Preconditions; +import it.unimi.dsi.fastutil.ints.IntArrayList; import org.apache.druid.collections.ResourceHolder; import org.apache.druid.java.util.common.IAE; import org.apache.druid.java.util.common.guava.CloseQuietly; @@ -29,7 +30,6 @@ import org.apache.druid.java.util.common.io.smoosh.FileSmoosher; import org.apache.druid.query.monomorphicprocessing.RuntimeShapeInspector; import org.apache.druid.segment.CompressedPools; import org.apache.druid.segment.serde.MetaSerdeHelper; -import it.unimi.dsi.fastutil.ints.IntArrayList; import java.io.IOException; import java.nio.ByteBuffer; diff --git a/processing/src/main/java/org/apache/druid/segment/data/CompressedVSizeColumnarIntsSupplier.java b/processing/src/main/java/org/apache/druid/segment/data/CompressedVSizeColumnarIntsSupplier.java index 200fa1dcaae..335dabfe154 100644 --- a/processing/src/main/java/org/apache/druid/segment/data/CompressedVSizeColumnarIntsSupplier.java +++ b/processing/src/main/java/org/apache/druid/segment/data/CompressedVSizeColumnarIntsSupplier.java @@ -21,6 +21,7 @@ package org.apache.druid.segment.data; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Preconditions; +import it.unimi.dsi.fastutil.ints.IntList; import org.apache.druid.collections.ResourceHolder; import org.apache.druid.common.utils.ByteUtils; import org.apache.druid.java.util.common.IAE; @@ -30,7 +31,6 @@ import org.apache.druid.java.util.common.io.smoosh.FileSmoosher; import org.apache.druid.query.monomorphicprocessing.RuntimeShapeInspector; import org.apache.druid.segment.CompressedPools; import org.apache.druid.segment.serde.MetaSerdeHelper; -import it.unimi.dsi.fastutil.ints.IntList; import java.io.IOException; import java.nio.ByteBuffer; diff --git a/processing/src/main/java/org/apache/druid/segment/data/CompressedVSizeColumnarMultiIntsSupplier.java b/processing/src/main/java/org/apache/druid/segment/data/CompressedVSizeColumnarMultiIntsSupplier.java index 8b7f84ba5bc..4df38560646 100644 --- a/processing/src/main/java/org/apache/druid/segment/data/CompressedVSizeColumnarMultiIntsSupplier.java +++ b/processing/src/main/java/org/apache/druid/segment/data/CompressedVSizeColumnarMultiIntsSupplier.java @@ -20,13 +20,13 @@ package org.apache.druid.segment.data; import com.google.common.annotations.VisibleForTesting; +import it.unimi.dsi.fastutil.ints.IntArrayList; +import it.unimi.dsi.fastutil.ints.IntList; import org.apache.druid.io.Channels; import org.apache.druid.java.util.common.IAE; import org.apache.druid.java.util.common.io.Closer; import org.apache.druid.java.util.common.io.smoosh.FileSmoosher; import org.apache.druid.query.monomorphicprocessing.RuntimeShapeInspector; -import it.unimi.dsi.fastutil.ints.IntArrayList; -import it.unimi.dsi.fastutil.ints.IntList; import java.io.IOException; import java.nio.ByteBuffer; @@ -163,12 +163,6 @@ public class CompressedVSizeColumnarMultiIntsSupplier implements WritableSupplie values.close(); } - @Override - public Class getClazz() - { - return IndexedInts.class; - } - @Override public int size() { diff --git a/processing/src/main/java/org/apache/druid/segment/data/CompressionStrategy.java b/processing/src/main/java/org/apache/druid/segment/data/CompressionStrategy.java index a1304d7848e..526735c3de8 100644 --- a/processing/src/main/java/org/apache/druid/segment/data/CompressionStrategy.java +++ b/processing/src/main/java/org/apache/druid/segment/data/CompressionStrategy.java @@ -25,14 +25,14 @@ import com.google.common.collect.Maps; import com.ning.compress.BufferRecycler; import com.ning.compress.lzf.LZFDecoder; import com.ning.compress.lzf.LZFEncoder; +import net.jpountz.lz4.LZ4Factory; +import net.jpountz.lz4.LZ4SafeDecompressor; +import org.apache.commons.lang.ArrayUtils; import org.apache.druid.collections.ResourceHolder; import org.apache.druid.java.util.common.ByteBufferUtils; import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.java.util.common.io.Closer; import org.apache.druid.segment.CompressedPools; -import net.jpountz.lz4.LZ4Factory; -import net.jpountz.lz4.LZ4SafeDecompressor; -import org.apache.commons.lang.ArrayUtils; import java.io.IOException; import java.nio.ByteBuffer; diff --git a/processing/src/main/java/org/apache/druid/segment/data/ConciseBitmapSerdeFactory.java b/processing/src/main/java/org/apache/druid/segment/data/ConciseBitmapSerdeFactory.java index 1d08867a288..3788b9247a3 100644 --- a/processing/src/main/java/org/apache/druid/segment/data/ConciseBitmapSerdeFactory.java +++ b/processing/src/main/java/org/apache/druid/segment/data/ConciseBitmapSerdeFactory.java @@ -58,7 +58,7 @@ public class ConciseBitmapSerdeFactory implements BitmapSerdeFactory public WrappedImmutableConciseBitmap fromByteBuffer(ByteBuffer buffer, int numBytes) { buffer.limit(buffer.position() + numBytes); - return new WrappedImmutableConciseBitmap(new ImmutableConciseSet(buffer)); + return new WrappedImmutableConciseBitmap(new ImmutableConciseSet(buffer.asIntBuffer())); } @Override diff --git a/processing/src/main/java/org/apache/druid/segment/data/DecompressingByteBufferObjectStrategy.java b/processing/src/main/java/org/apache/druid/segment/data/DecompressingByteBufferObjectStrategy.java index c3967b96752..8ae83ea7511 100644 --- a/processing/src/main/java/org/apache/druid/segment/data/DecompressingByteBufferObjectStrategy.java +++ b/processing/src/main/java/org/apache/druid/segment/data/DecompressingByteBufferObjectStrategy.java @@ -38,7 +38,7 @@ public class DecompressingByteBufferObjectStrategy implements ObjectStrategy> getClazz() + public Class> getClazz() { return (Class) ResourceHolder.class; } diff --git a/processing/src/main/java/org/apache/druid/segment/data/EntireLayoutColumnarFloatsSerializer.java b/processing/src/main/java/org/apache/druid/segment/data/EntireLayoutColumnarFloatsSerializer.java index 74547242820..dc7e6063afe 100644 --- a/processing/src/main/java/org/apache/druid/segment/data/EntireLayoutColumnarFloatsSerializer.java +++ b/processing/src/main/java/org/apache/druid/segment/data/EntireLayoutColumnarFloatsSerializer.java @@ -20,9 +20,9 @@ package org.apache.druid.segment.data; import org.apache.druid.java.util.common.io.smoosh.FileSmoosher; -import org.apache.druid.segment.writeout.WriteOutBytes; -import org.apache.druid.segment.writeout.SegmentWriteOutMedium; import org.apache.druid.segment.serde.MetaSerdeHelper; +import org.apache.druid.segment.writeout.SegmentWriteOutMedium; +import org.apache.druid.segment.writeout.WriteOutBytes; import java.io.IOException; import java.nio.ByteOrder; diff --git a/processing/src/main/java/org/apache/druid/segment/data/GenericIndexed.java b/processing/src/main/java/org/apache/druid/segment/data/GenericIndexed.java index bd13ca5c36e..5091294092b 100644 --- a/processing/src/main/java/org/apache/druid/segment/data/GenericIndexed.java +++ b/processing/src/main/java/org/apache/druid/segment/data/GenericIndexed.java @@ -76,7 +76,7 @@ import java.util.Iterator; * value files are identified as: StringUtils.format("%s_value_%d", columnName, fileNumber) * number of value files == numElements/numberOfElementsPerValueFile */ -public class GenericIndexed implements Indexed, Serializer +public class GenericIndexed implements CloseableIndexed, Serializer { static final byte VERSION_ONE = 0x1; static final byte VERSION_TWO = 0x2; @@ -93,10 +93,10 @@ public class GenericIndexed implements Indexed, Serializer private static final SerializerUtils SERIALIZER_UTILS = new SerializerUtils(); - public static final ObjectStrategy STRING_STRATEGY = new CacheableObjectStrategy() + public static final ObjectStrategy STRING_STRATEGY = new ObjectStrategy() { @Override - public Class getClazz() + public Class getClazz() { return String.class; } @@ -109,7 +109,7 @@ public class GenericIndexed implements Indexed, Serializer @Override @Nullable - public byte[] toBytes(String val) + public byte[] toBytes(@Nullable String val) { return StringUtils.toUtf8Nullable(NullHandling.nullToEmptyIfNeeded(val)); } @@ -272,7 +272,6 @@ public class GenericIndexed implements Indexed, Serializer } } - @Override public Class getClazz() { return strategy.getClazz(); @@ -300,12 +299,12 @@ public class GenericIndexed implements Indexed, Serializer * @return index of value, or negative number equal to (-(insertion point) - 1). */ @Override - public int indexOf(T value) + public int indexOf(@Nullable T value) { return indexOf(this, value); } - private int indexOf(Indexed indexed, T value) + private int indexOf(Indexed indexed, @Nullable T value) { if (!allowReverseLookup) { throw new UnsupportedOperationException("Reverse lookup not allowed."); @@ -368,6 +367,7 @@ public class GenericIndexed implements Indexed, Serializer return versionOne ? singleThreadedVersionOne() : singleThreadedVersionTwo(); } + @Nullable private T copyBufferAndGet(ByteBuffer valueBuffer, int startOffset, int endOffset) { ByteBuffer copyValueBuffer = valueBuffer.asReadOnlyBuffer(); @@ -417,18 +417,13 @@ public class GenericIndexed implements Indexed, Serializer { int lastReadSize; - @Override - public Class getClazz() - { - return strategy.getClazz(); - } - @Override public int size() { return size; } + @Nullable T bufferedIndexedGet(ByteBuffer copyValueBuffer, int startOffset, int endOffset) { int size = endOffset - startOffset; @@ -460,7 +455,7 @@ public class GenericIndexed implements Indexed, Serializer } @Override - public int indexOf(T value) + public int indexOf(@Nullable T value) { return GenericIndexed.this.indexOf(this, value); } @@ -472,6 +467,12 @@ public class GenericIndexed implements Indexed, Serializer } } + @Override + public void close() throws IOException + { + // nothing to close + } + /////////////// // VERSION ONE /////////////// @@ -518,9 +519,11 @@ public class GenericIndexed implements Indexed, Serializer allowReverseLookup = false; } - valuesOut.writeInt(next == null ? NULL_VALUE_SIZE_MARKER : 0); if (next != null) { + valuesOut.writeInt(0); strategy.writeTo(next, valuesOut); + } else { + valuesOut.writeInt(NULL_VALUE_SIZE_MARKER); } headerOut.writeInt(Ints.checkedCast(valuesOut.size())); @@ -553,6 +556,7 @@ public class GenericIndexed implements Indexed, Serializer return metaSerdeHelper.size(this) + (long) theBuffer.remaining(); } + @Nullable private T getVersionOne(int index) { checkIndex(index); @@ -654,6 +658,7 @@ public class GenericIndexed implements Indexed, Serializer } } + @Nullable private T getVersionTwo(int index) { checkIndex(index); diff --git a/processing/src/main/java/org/apache/druid/segment/data/GenericIndexedWriter.java b/processing/src/main/java/org/apache/druid/segment/data/GenericIndexedWriter.java index 4b3d0ea7669..77bcd916f81 100644 --- a/processing/src/main/java/org/apache/druid/segment/data/GenericIndexedWriter.java +++ b/processing/src/main/java/org/apache/druid/segment/data/GenericIndexedWriter.java @@ -21,6 +21,8 @@ package org.apache.druid.segment.data; import com.google.common.base.Preconditions; import com.google.common.primitives.Ints; +import it.unimi.dsi.fastutil.longs.LongArrayList; +import it.unimi.dsi.fastutil.longs.LongList; import org.apache.druid.java.util.common.IAE; import org.apache.druid.java.util.common.ISE; import org.apache.druid.java.util.common.StringUtils; @@ -31,8 +33,6 @@ import org.apache.druid.segment.serde.MetaSerdeHelper; import org.apache.druid.segment.serde.Serializer; import org.apache.druid.segment.writeout.SegmentWriteOutMedium; import org.apache.druid.segment.writeout.WriteOutBytes; -import it.unimi.dsi.fastutil.longs.LongArrayList; -import it.unimi.dsi.fastutil.longs.LongList; import javax.annotation.Nullable; import java.io.DataInput; @@ -138,6 +138,7 @@ public class GenericIndexedWriter implements Serializer private final int fileSizeLimit; private final byte[] fileNameByteArray; private boolean objectsSorted = true; + @Nullable private T prevObject = null; private WriteOutBytes headerOut = null; private WriteOutBytes valuesOut = null; @@ -207,7 +208,7 @@ public class GenericIndexedWriter implements Serializer objectsSorted = false; } - public void write(T objectToWrite) throws IOException + public void write(@Nullable T objectToWrite) throws IOException { if (objectsSorted && prevObject != null && strategy.compare(prevObject, objectToWrite) >= 0) { objectsSorted = false; diff --git a/processing/src/main/java/org/apache/druid/segment/data/ImmutableBitmapValues.java b/processing/src/main/java/org/apache/druid/segment/data/ImmutableBitmapValues.java index ccfa765fb14..3b629bdbd49 100644 --- a/processing/src/main/java/org/apache/druid/segment/data/ImmutableBitmapValues.java +++ b/processing/src/main/java/org/apache/druid/segment/data/ImmutableBitmapValues.java @@ -19,9 +19,9 @@ package org.apache.druid.segment.data; +import it.unimi.dsi.fastutil.ints.IntIterator; import org.apache.druid.collections.bitmap.ImmutableBitmap; import org.apache.druid.segment.IntIteratorUtils; -import it.unimi.dsi.fastutil.ints.IntIterator; /** */ diff --git a/processing/src/main/java/org/apache/druid/segment/data/ImmutableRTreeObjectStrategy.java b/processing/src/main/java/org/apache/druid/segment/data/ImmutableRTreeObjectStrategy.java index bf26e4d0603..4d90538280a 100644 --- a/processing/src/main/java/org/apache/druid/segment/data/ImmutableRTreeObjectStrategy.java +++ b/processing/src/main/java/org/apache/druid/segment/data/ImmutableRTreeObjectStrategy.java @@ -57,7 +57,7 @@ public class ImmutableRTreeObjectStrategy implements ObjectStrategy getClazz() + public Class getClazz() { return ImmutableRTree.class; } diff --git a/processing/src/main/java/org/apache/druid/segment/data/Indexed.java b/processing/src/main/java/org/apache/druid/segment/data/Indexed.java index e1c2b0ad6e9..f761d258a4e 100644 --- a/processing/src/main/java/org/apache/druid/segment/data/Indexed.java +++ b/processing/src/main/java/org/apache/druid/segment/data/Indexed.java @@ -23,14 +23,16 @@ import org.apache.druid.guice.annotations.PublicApi; import org.apache.druid.query.monomorphicprocessing.CalledFromHotLoop; import org.apache.druid.query.monomorphicprocessing.HotLoopCallee; +import javax.annotation.Nullable; + @PublicApi public interface Indexed extends Iterable, HotLoopCallee { - Class getClazz(); int size(); @CalledFromHotLoop + @Nullable T get(int index); /** @@ -42,5 +44,5 @@ public interface Indexed extends Iterable, HotLoopCallee * * @return index of value, or a negative number */ - int indexOf(T value); + int indexOf(@Nullable T value); } diff --git a/processing/src/main/java/org/apache/druid/segment/data/IndexedInts.java b/processing/src/main/java/org/apache/druid/segment/data/IndexedInts.java index b075f633371..1844ac88357 100644 --- a/processing/src/main/java/org/apache/druid/segment/data/IndexedInts.java +++ b/processing/src/main/java/org/apache/druid/segment/data/IndexedInts.java @@ -28,7 +28,7 @@ import java.util.function.IntConsumer; /** * Get a int an index (array or list lookup abstraction without boxing). * - * Doesn't extend {@link Iterable} (or {@link it.unimi.dsi.fastutil.ints.IntIterable} to avoid accidential + * Doesn't extend {@link Iterable} (or {@link it.unimi.dsi.fastutil.ints.IntIterable} to avoid accidental * for-each iteration with boxing. */ @PublicApi diff --git a/processing/src/main/java/org/apache/druid/segment/data/IntermediateColumnarLongsSerializer.java b/processing/src/main/java/org/apache/druid/segment/data/IntermediateColumnarLongsSerializer.java index 97b81bc3632..e57e81df00a 100644 --- a/processing/src/main/java/org/apache/druid/segment/data/IntermediateColumnarLongsSerializer.java +++ b/processing/src/main/java/org/apache/druid/segment/data/IntermediateColumnarLongsSerializer.java @@ -20,12 +20,12 @@ package org.apache.druid.segment.data; import com.google.common.math.LongMath; -import org.apache.druid.java.util.common.io.smoosh.FileSmoosher; -import org.apache.druid.segment.writeout.SegmentWriteOutMedium; import it.unimi.dsi.fastutil.longs.Long2IntMap; import it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap; import it.unimi.dsi.fastutil.longs.LongArrayList; import it.unimi.dsi.fastutil.longs.LongList; +import org.apache.druid.java.util.common.io.smoosh.FileSmoosher; +import org.apache.druid.segment.writeout.SegmentWriteOutMedium; import java.io.IOException; import java.nio.ByteOrder; diff --git a/processing/src/main/java/org/apache/druid/segment/data/ListIndexed.java b/processing/src/main/java/org/apache/druid/segment/data/ListIndexed.java index 6443f3f0b3d..074ebd02836 100644 --- a/processing/src/main/java/org/apache/druid/segment/data/ListIndexed.java +++ b/processing/src/main/java/org/apache/druid/segment/data/ListIndexed.java @@ -21,6 +21,8 @@ package org.apache.druid.segment.data; import org.apache.druid.query.monomorphicprocessing.RuntimeShapeInspector; +import javax.annotation.Nullable; +import java.util.Arrays; import java.util.Iterator; import java.util.List; @@ -29,21 +31,16 @@ import java.util.List; public class ListIndexed implements Indexed { private final List baseList; - private final Class clazz; - public ListIndexed( - List baseList, - Class clazz - ) + public ListIndexed(List baseList) { this.baseList = baseList; - this.clazz = clazz; } - @Override - public Class getClazz() + @SafeVarargs + public ListIndexed(T... values) { - return clazz; + this(Arrays.asList(values)); } @Override @@ -59,7 +56,7 @@ public class ListIndexed implements Indexed } @Override - public int indexOf(T value) + public int indexOf(@Nullable T value) { return baseList.indexOf(value); } diff --git a/processing/src/main/java/org/apache/druid/segment/data/ObjectStrategy.java b/processing/src/main/java/org/apache/druid/segment/data/ObjectStrategy.java index 36387292a66..ed4410b8218 100644 --- a/processing/src/main/java/org/apache/druid/segment/data/ObjectStrategy.java +++ b/processing/src/main/java/org/apache/druid/segment/data/ObjectStrategy.java @@ -68,7 +68,7 @@ public interface ObjectStrategy extends Comparator { byte[] bytes = toBytes(val); if (bytes != null) { - out.write(toBytes(val)); + out.write(bytes); } } } diff --git a/processing/src/main/java/org/apache/druid/segment/data/RoaringBitmapSerdeFactory.java b/processing/src/main/java/org/apache/druid/segment/data/RoaringBitmapSerdeFactory.java index 09c007c0aed..5f34d0bc674 100644 --- a/processing/src/main/java/org/apache/druid/segment/data/RoaringBitmapSerdeFactory.java +++ b/processing/src/main/java/org/apache/druid/segment/data/RoaringBitmapSerdeFactory.java @@ -42,7 +42,7 @@ public class RoaringBitmapSerdeFactory implements BitmapSerdeFactory @JsonCreator public RoaringBitmapSerdeFactory( - @JsonProperty("compressRunOnSerialization") Boolean compressRunOnSerialization + @JsonProperty("compressRunOnSerialization") @Nullable Boolean compressRunOnSerialization ) { this.compressRunOnSerialization = compressRunOnSerialization == null @@ -85,8 +85,9 @@ public class RoaringBitmapSerdeFactory implements BitmapSerdeFactory return new WrappedImmutableRoaringBitmap(new ImmutableRoaringBitmap(buffer)); } + @Nullable @Override - public byte[] toBytes(ImmutableBitmap val) + public byte[] toBytes(@Nullable ImmutableBitmap val) { if (val == null || val.size() == 0) { return new byte[]{}; diff --git a/processing/src/main/java/org/apache/druid/segment/data/TableLongEncodingWriter.java b/processing/src/main/java/org/apache/druid/segment/data/TableLongEncodingWriter.java index 456b290332f..db99d3f0f6a 100644 --- a/processing/src/main/java/org/apache/druid/segment/data/TableLongEncodingWriter.java +++ b/processing/src/main/java/org/apache/druid/segment/data/TableLongEncodingWriter.java @@ -19,10 +19,10 @@ package org.apache.druid.segment.data; -import org.apache.druid.java.util.common.IAE; -import org.apache.druid.segment.writeout.WriteOutBytes; import it.unimi.dsi.fastutil.longs.Long2IntMap; import it.unimi.dsi.fastutil.longs.LongList; +import org.apache.druid.java.util.common.IAE; +import org.apache.druid.segment.writeout.WriteOutBytes; import java.io.IOException; import java.nio.ByteBuffer; diff --git a/processing/src/main/java/org/apache/druid/segment/data/V3CompressedVSizeColumnarMultiIntsSupplier.java b/processing/src/main/java/org/apache/druid/segment/data/V3CompressedVSizeColumnarMultiIntsSupplier.java index b69d320cca1..2beb43d9611 100644 --- a/processing/src/main/java/org/apache/druid/segment/data/V3CompressedVSizeColumnarMultiIntsSupplier.java +++ b/processing/src/main/java/org/apache/druid/segment/data/V3CompressedVSizeColumnarMultiIntsSupplier.java @@ -20,10 +20,10 @@ package org.apache.druid.segment.data; import com.google.common.annotations.VisibleForTesting; +import it.unimi.dsi.fastutil.ints.IntArrayList; import org.apache.druid.java.util.common.IAE; import org.apache.druid.java.util.common.io.Closer; import org.apache.druid.java.util.common.io.smoosh.FileSmoosher; -import it.unimi.dsi.fastutil.ints.IntArrayList; import java.io.IOException; import java.nio.ByteBuffer; diff --git a/processing/src/main/java/org/apache/druid/segment/data/VSizeColumnarMultiInts.java b/processing/src/main/java/org/apache/druid/segment/data/VSizeColumnarMultiInts.java index f278bbb5f9c..4d579e47b33 100644 --- a/processing/src/main/java/org/apache/druid/segment/data/VSizeColumnarMultiInts.java +++ b/processing/src/main/java/org/apache/druid/segment/data/VSizeColumnarMultiInts.java @@ -108,12 +108,6 @@ public class VSizeColumnarMultiInts implements ColumnarMultiInts, WritableSuppli bufferBytes = 4 - numBytes; } - @Override - public Class getClazz() - { - return VSizeColumnarInts.class; - } - @Override public int size() { diff --git a/processing/src/main/java/org/apache/druid/segment/data/package-info.java b/processing/src/main/java/org/apache/druid/segment/data/package-info.java new file mode 100644 index 00000000000..f4a90c4e44e --- /dev/null +++ b/processing/src/main/java/org/apache/druid/segment/data/package-info.java @@ -0,0 +1,23 @@ +/* + * 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. + */ + +@EverythingIsNonnullByDefault +package org.apache.druid.segment.data; + +import org.apache.druid.annotations.EverythingIsNonnullByDefault; diff --git a/processing/src/main/java/org/apache/druid/segment/filter/BoundFilter.java b/processing/src/main/java/org/apache/druid/segment/filter/BoundFilter.java index 840407e21cb..d648e817dbf 100644 --- a/processing/src/main/java/org/apache/druid/segment/filter/BoundFilter.java +++ b/processing/src/main/java/org/apache/druid/segment/filter/BoundFilter.java @@ -21,6 +21,7 @@ package org.apache.druid.segment.filter; import com.google.common.base.Predicate; import com.google.common.base.Supplier; +import it.unimi.dsi.fastutil.ints.IntList; import org.apache.druid.collections.bitmap.ImmutableBitmap; import org.apache.druid.common.config.NullHandling; import org.apache.druid.java.util.common.Pair; @@ -39,7 +40,6 @@ import org.apache.druid.segment.ColumnSelector; import org.apache.druid.segment.ColumnSelectorFactory; import org.apache.druid.segment.IntListUtils; import org.apache.druid.segment.column.BitmapIndex; -import it.unimi.dsi.fastutil.ints.IntList; import java.util.Comparator; diff --git a/processing/src/main/java/org/apache/druid/segment/filter/Filters.java b/processing/src/main/java/org/apache/druid/segment/filter/Filters.java index c6d485d2cb7..db3c6d8b482 100644 --- a/processing/src/main/java/org/apache/druid/segment/filter/Filters.java +++ b/processing/src/main/java/org/apache/druid/segment/filter/Filters.java @@ -24,6 +24,9 @@ import com.google.common.base.Preconditions; import com.google.common.base.Predicate; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; +import it.unimi.dsi.fastutil.ints.IntIterable; +import it.unimi.dsi.fastutil.ints.IntIterator; +import it.unimi.dsi.fastutil.ints.IntList; import org.apache.druid.collections.bitmap.ImmutableBitmap; import org.apache.druid.java.util.common.guava.FunctionalIterable; import org.apache.druid.query.BitmapResultFactory; @@ -46,15 +49,15 @@ import org.apache.druid.segment.ColumnSelectorFactory; import org.apache.druid.segment.DimensionHandlerUtils; import org.apache.druid.segment.IntIteratorUtils; import org.apache.druid.segment.column.BitmapIndex; -import org.apache.druid.segment.column.Column; import org.apache.druid.segment.column.ColumnCapabilities; +import org.apache.druid.segment.column.ColumnHolder; import org.apache.druid.segment.column.ValueType; +import org.apache.druid.segment.data.CloseableIndexed; import org.apache.druid.segment.data.Indexed; -import it.unimi.dsi.fastutil.ints.IntIterable; -import it.unimi.dsi.fastutil.ints.IntIterator; -import it.unimi.dsi.fastutil.ints.IntList; import javax.annotation.Nullable; +import java.io.IOException; +import java.io.UncheckedIOException; import java.util.ArrayList; import java.util.Iterator; import java.util.List; @@ -268,14 +271,18 @@ public class Filters Preconditions.checkNotNull(predicate, "predicate"); // Missing dimension -> match all rows if the predicate matches null; match no rows otherwise - final Indexed dimValues = selector.getDimensionValues(dimension); - if (dimValues == null || dimValues.size() == 0) { - return ImmutableList.of(predicate.apply(null) ? allTrue(selector) : allFalse(selector)); - } + try (final CloseableIndexed dimValues = selector.getDimensionValues(dimension)) { + if (dimValues == null || dimValues.size() == 0) { + return ImmutableList.of(predicate.apply(null) ? allTrue(selector) : allFalse(selector)); + } - // Apply predicate to all dimension values and union the matching bitmaps - final BitmapIndex bitmapIndex = selector.getBitmapIndex(dimension); - return makePredicateQualifyingBitmapIterable(bitmapIndex, predicate, dimValues); + // Apply predicate to all dimension values and union the matching bitmaps + final BitmapIndex bitmapIndex = selector.getBitmapIndex(dimension); + return makePredicateQualifyingBitmapIterable(bitmapIndex, predicate, dimValues); + } + catch (IOException e) { + throw new UncheckedIOException(e); + } } /** @@ -300,18 +307,24 @@ public class Filters Preconditions.checkNotNull(predicate, "predicate"); // Missing dimension -> match all rows if the predicate matches null; match no rows otherwise - final Indexed dimValues = indexSelector.getDimensionValues(dimension); - if (dimValues == null || dimValues.size() == 0) { - return predicate.apply(null) ? 1. : 0.; - } + try (final CloseableIndexed dimValues = indexSelector.getDimensionValues(dimension)) { + if (dimValues == null || dimValues.size() == 0) { + return predicate.apply(null) ? 1. : 0.; + } - // Apply predicate to all dimension values and union the matching bitmaps - final BitmapIndex bitmapIndex = indexSelector.getBitmapIndex(dimension); - return estimateSelectivity( - bitmapIndex, - IntIteratorUtils.toIntList(makePredicateQualifyingIndexIterable(bitmapIndex, predicate, dimValues).iterator()), - indexSelector.getNumRows() - ); + // Apply predicate to all dimension values and union the matching bitmaps + final BitmapIndex bitmapIndex = indexSelector.getBitmapIndex(dimension); + return estimateSelectivity( + bitmapIndex, + IntIteratorUtils.toIntList( + makePredicateQualifyingIndexIterable(bitmapIndex, predicate, dimValues).iterator() + ), + indexSelector.getNumRows() + ); + } + catch (IOException e) { + throw new UncheckedIOException(e); + } } /** @@ -432,9 +445,9 @@ public class Filters ) { if (filter.supportsBitmapIndex(indexSelector)) { - final Column column = columnSelector.getColumn(dimension); - if (column != null) { - return !column.getCapabilities().hasMultipleValues(); + final ColumnHolder columnHolder = columnSelector.getColumnHolder(dimension); + if (columnHolder != null) { + return !columnHolder.getCapabilities().hasMultipleValues(); } } return false; diff --git a/processing/src/main/java/org/apache/druid/segment/filter/InFilter.java b/processing/src/main/java/org/apache/druid/segment/filter/InFilter.java index d615848ccc8..0b3ad14431c 100644 --- a/processing/src/main/java/org/apache/druid/segment/filter/InFilter.java +++ b/processing/src/main/java/org/apache/druid/segment/filter/InFilter.java @@ -21,6 +21,8 @@ package org.apache.druid.segment.filter; import com.google.common.base.Predicate; import com.google.common.base.Supplier; +import it.unimi.dsi.fastutil.ints.IntIterable; +import it.unimi.dsi.fastutil.ints.IntIterator; import org.apache.druid.collections.bitmap.ImmutableBitmap; import org.apache.druid.query.BitmapResultFactory; import org.apache.druid.query.extraction.ExtractionFn; @@ -35,8 +37,6 @@ import org.apache.druid.segment.ColumnSelector; import org.apache.druid.segment.ColumnSelectorFactory; import org.apache.druid.segment.IntIteratorUtils; import org.apache.druid.segment.column.BitmapIndex; -import it.unimi.dsi.fastutil.ints.IntIterable; -import it.unimi.dsi.fastutil.ints.IntIterator; import java.util.Iterator; import java.util.Set; diff --git a/processing/src/main/java/org/apache/druid/segment/filter/LikeFilter.java b/processing/src/main/java/org/apache/druid/segment/filter/LikeFilter.java index 665227960ed..b77e9554c21 100644 --- a/processing/src/main/java/org/apache/druid/segment/filter/LikeFilter.java +++ b/processing/src/main/java/org/apache/druid/segment/filter/LikeFilter.java @@ -20,6 +20,8 @@ package org.apache.druid.segment.filter; import com.google.common.collect.ImmutableList; +import it.unimi.dsi.fastutil.ints.IntIterable; +import it.unimi.dsi.fastutil.ints.IntIterator; import org.apache.druid.collections.bitmap.ImmutableBitmap; import org.apache.druid.common.config.NullHandling; import org.apache.druid.query.BitmapResultFactory; @@ -31,10 +33,11 @@ import org.apache.druid.query.filter.ValueMatcher; import org.apache.druid.segment.ColumnSelector; import org.apache.druid.segment.ColumnSelectorFactory; import org.apache.druid.segment.column.BitmapIndex; +import org.apache.druid.segment.data.CloseableIndexed; import org.apache.druid.segment.data.Indexed; -import it.unimi.dsi.fastutil.ints.IntIterable; -import it.unimi.dsi.fastutil.ints.IntIterator; +import java.io.IOException; +import java.io.UncheckedIOException; import java.util.NoSuchElementException; public class LikeFilter implements Filter @@ -106,14 +109,15 @@ public class LikeFilter implements Filter } // search for start, end indexes in the bitmaps; then include all matching bitmaps between those points - final Indexed dimValues = selector.getDimensionValues(dimension); + try (final CloseableIndexed dimValues = selector.getDimensionValues(dimension)) { - // Union bitmaps for all matching dimension values in range. - // Use lazy iterator to allow unioning bitmaps one by one and avoid materializing all of them at once. - return Filters.bitmapsFromIndexes( - getDimValueIndexIterableForPrefixMatch(bitmapIndex, dimValues), - bitmapIndex - ); + // Union bitmaps for all matching dimension values in range. + // Use lazy iterator to allow unioning bitmaps one by one and avoid materializing all of them at once. + return Filters.bitmapsFromIndexes(getDimValueIndexIterableForPrefixMatch(bitmapIndex, dimValues), bitmapIndex); + } + catch (IOException e) { + throw new UncheckedIOException(e); + } } else { // fallback return Filters.matchPredicateNoUnion( diff --git a/processing/src/main/java/org/apache/druid/segment/incremental/IncrementalIndex.java b/processing/src/main/java/org/apache/druid/segment/incremental/IncrementalIndex.java index f95fba86713..08d722544db 100644 --- a/processing/src/main/java/org/apache/druid/segment/incremental/IncrementalIndex.java +++ b/processing/src/main/java/org/apache/druid/segment/incremental/IncrementalIndex.java @@ -65,9 +65,9 @@ import org.apache.druid.segment.NilColumnValueSelector; import org.apache.druid.segment.ObjectColumnSelector; import org.apache.druid.segment.StorageAdapter; import org.apache.druid.segment.VirtualColumns; -import org.apache.druid.segment.column.Column; import org.apache.druid.segment.column.ColumnCapabilities; import org.apache.druid.segment.column.ColumnCapabilitiesImpl; +import org.apache.druid.segment.column.ColumnHolder; import org.apache.druid.segment.column.ValueType; import org.apache.druid.segment.serde.ComplexMetricExtractor; import org.apache.druid.segment.serde.ComplexMetricSerde; @@ -190,6 +190,7 @@ public abstract class IncrementalIndex extends AbstractIndex imp return extractor.extractedClass(); } + @Nullable @Override public Object getObject() { @@ -320,7 +321,7 @@ public abstract class IncrementalIndex extends AbstractIndex imp //__time capabilities ColumnCapabilitiesImpl timeCapabilities = new ColumnCapabilitiesImpl(); timeCapabilities.setType(ValueType.LONG); - columnCapabilities.put(Column.TIME_COLUMN_NAME, timeCapabilities); + columnCapabilities.put(ColumnHolder.TIME_COLUMN_NAME, timeCapabilities); // This should really be more generic List spatialDimensions = dimensionsSpec.getSpatialDimensions(); @@ -823,6 +824,7 @@ public abstract class IncrementalIndex extends AbstractIndex imp } } + @Nullable public DimensionDesc getDimension(String dimension) { synchronized (dimensionDescs) { @@ -1006,7 +1008,7 @@ public abstract class IncrementalIndex extends AbstractIndex imp continue; } final DimensionIndexer indexer = dimensionDesc.getIndexer(); - Object rowVals = indexer.convertUnsortedEncodedKeyComponentToActualArrayOrList(dim, DimensionIndexer.LIST); + Object rowVals = indexer.convertUnsortedEncodedKeyComponentToActualList(dim); theVals.put(dimensionName, rowVals); } diff --git a/processing/src/main/java/org/apache/druid/segment/incremental/IncrementalIndexAdapter.java b/processing/src/main/java/org/apache/druid/segment/incremental/IncrementalIndexAdapter.java index 4a119d9bfba..2493bdd391e 100644 --- a/processing/src/main/java/org/apache/druid/segment/incremental/IncrementalIndexAdapter.java +++ b/processing/src/main/java/org/apache/druid/segment/incremental/IncrementalIndexAdapter.java @@ -19,6 +19,7 @@ package org.apache.druid.segment.incremental; +import it.unimi.dsi.fastutil.ints.IntIterator; import org.apache.druid.collections.bitmap.BitmapFactory; import org.apache.druid.collections.bitmap.MutableBitmap; import org.apache.druid.segment.DimensionIndexer; @@ -28,8 +29,7 @@ import org.apache.druid.segment.Metadata; import org.apache.druid.segment.TransformableRowIterator; import org.apache.druid.segment.column.ColumnCapabilities; import org.apache.druid.segment.data.BitmapValues; -import org.apache.druid.segment.data.Indexed; -import it.unimi.dsi.fastutil.ints.IntIterator; +import org.apache.druid.segment.data.CloseableIndexed; import org.joda.time.Interval; import javax.annotation.Nullable; @@ -143,7 +143,7 @@ public class IncrementalIndexAdapter implements IndexableAdapter @Nullable @Override - public > Indexed getDimValueLookup(String dimension) + public > CloseableIndexed getDimValueLookup(String dimension) { final DimensionAccessor accessor = accessors.get(dimension); if (accessor == null) { diff --git a/processing/src/main/java/org/apache/druid/segment/incremental/IncrementalIndexColumnSelectorFactory.java b/processing/src/main/java/org/apache/druid/segment/incremental/IncrementalIndexColumnSelectorFactory.java index bffceb1f17d..970ccfd179e 100644 --- a/processing/src/main/java/org/apache/druid/segment/incremental/IncrementalIndexColumnSelectorFactory.java +++ b/processing/src/main/java/org/apache/druid/segment/incremental/IncrementalIndexColumnSelectorFactory.java @@ -26,10 +26,10 @@ import org.apache.druid.segment.ColumnValueSelector; import org.apache.druid.segment.DimensionIndexer; import org.apache.druid.segment.DimensionSelector; import org.apache.druid.segment.DimensionSelectorUtils; -import org.apache.druid.segment.SingleScanTimeDimSelector; +import org.apache.druid.segment.SingleScanTimeDimensionSelector; import org.apache.druid.segment.VirtualColumns; -import org.apache.druid.segment.column.Column; import org.apache.druid.segment.column.ColumnCapabilities; +import org.apache.druid.segment.column.ColumnHolder; import javax.annotation.Nullable; @@ -72,8 +72,8 @@ class IncrementalIndexColumnSelectorFactory implements ColumnSelectorFactory final String dimension = dimensionSpec.getDimension(); final ExtractionFn extractionFn = dimensionSpec.getExtractionFn(); - if (dimension.equals(Column.TIME_COLUMN_NAME)) { - return new SingleScanTimeDimSelector(makeColumnValueSelector(dimension), extractionFn, descending); + if (dimension.equals(ColumnHolder.TIME_COLUMN_NAME)) { + return new SingleScanTimeDimensionSelector(makeColumnValueSelector(dimension), extractionFn, descending); } final IncrementalIndex.DimensionDesc dimensionDesc = index.getDimension(dimensionSpec.getDimension()); @@ -105,7 +105,7 @@ class IncrementalIndexColumnSelectorFactory implements ColumnSelectorFactory return virtualColumns.makeColumnValueSelector(columnName, this); } - if (columnName.equals(Column.TIME_COLUMN_NAME)) { + if (columnName.equals(ColumnHolder.TIME_COLUMN_NAME)) { return rowHolder; } diff --git a/processing/src/main/java/org/apache/druid/segment/incremental/IncrementalIndexStorageAdapter.java b/processing/src/main/java/org/apache/druid/segment/incremental/IncrementalIndexStorageAdapter.java index 94c3cf2749c..ae8e14a2aad 100644 --- a/processing/src/main/java/org/apache/druid/segment/incremental/IncrementalIndexStorageAdapter.java +++ b/processing/src/main/java/org/apache/druid/segment/incremental/IncrementalIndexStorageAdapter.java @@ -33,11 +33,12 @@ import org.apache.druid.segment.Capabilities; import org.apache.druid.segment.ColumnSelectorFactory; import org.apache.druid.segment.Cursor; import org.apache.druid.segment.DimensionIndexer; +import org.apache.druid.segment.DimensionSelector; import org.apache.druid.segment.Metadata; import org.apache.druid.segment.StorageAdapter; import org.apache.druid.segment.VirtualColumns; -import org.apache.druid.segment.column.Column; import org.apache.druid.segment.column.ColumnCapabilities; +import org.apache.druid.segment.column.ColumnHolder; import org.apache.druid.segment.data.Indexed; import org.apache.druid.segment.data.ListIndexed; import org.apache.druid.segment.filter.BooleanValueMatcher; @@ -73,7 +74,7 @@ public class IncrementalIndexStorageAdapter implements StorageAdapter @Override public Indexed getAvailableDimensions() { - return new ListIndexed<>(index.getDimensionNames(), String.class); + return new ListIndexed<>(index.getDimensionNames()); } @Override @@ -85,7 +86,7 @@ public class IncrementalIndexStorageAdapter implements StorageAdapter @Override public int getDimensionCardinality(String dimension) { - if (dimension.equals(Column.TIME_COLUMN_NAME)) { + if (dimension.equals(ColumnHolder.TIME_COLUMN_NAME)) { return Integer.MAX_VALUE; } @@ -94,8 +95,9 @@ public class IncrementalIndexStorageAdapter implements StorageAdapter return 0; } - DimensionIndexer indexer = index.getDimension(dimension).getIndexer(); - return indexer.getCardinality(); + DimensionIndexer indexer = desc.getIndexer(); + int cardinality = indexer.getCardinality(); + return cardinality != DimensionSelector.CARDINALITY_UNKNOWN ? cardinality : Integer.MAX_VALUE; } @Override diff --git a/processing/src/main/java/org/apache/druid/segment/incremental/OffheapIncrementalIndex.java b/processing/src/main/java/org/apache/druid/segment/incremental/OffheapIncrementalIndex.java index 74b638d22db..3f7f2fedd7b 100644 --- a/processing/src/main/java/org/apache/druid/segment/incremental/OffheapIncrementalIndex.java +++ b/processing/src/main/java/org/apache/druid/segment/incremental/OffheapIncrementalIndex.java @@ -123,7 +123,7 @@ public class OffheapIncrementalIndex extends IncrementalIndex selectors.put( agg.getName(), - new OnheapIncrementalIndex.ObjectCachingColumnSelectorFactory(columnSelectorFactory, concurrentEventAdd) + new OnheapIncrementalIndex.CachingColumnSelectorFactory(columnSelectorFactory, concurrentEventAdd) ); if (i == 0) { diff --git a/processing/src/main/java/org/apache/druid/segment/incremental/OnheapIncrementalIndex.java b/processing/src/main/java/org/apache/druid/segment/incremental/OnheapIncrementalIndex.java index 50fb3ddfc47..02f0a37cee5 100644 --- a/processing/src/main/java/org/apache/druid/segment/incremental/OnheapIncrementalIndex.java +++ b/processing/src/main/java/org/apache/druid/segment/incremental/OnheapIncrementalIndex.java @@ -129,7 +129,7 @@ public class OnheapIncrementalIndex extends IncrementalIndex for (AggregatorFactory agg : metrics) { selectors.put( agg.getName(), - new ObjectCachingColumnSelectorFactory( + new CachingColumnSelectorFactory( makeColumnSelectorFactory(agg, rowSupplier, deserializeComplexMetrics), concurrentEventAdd ) @@ -385,16 +385,17 @@ public class OnheapIncrementalIndex extends IncrementalIndex } } - // Caches references to selector objects for each column instead of creating a new object each time in order to save heap space. - // In general the selectorFactory need not to thread-safe. - // If required, set concurrentEventAdd to true to use concurrent hash map instead of vanilla hash map for thread-safe - // operations. - static class ObjectCachingColumnSelectorFactory implements ColumnSelectorFactory + /** + * Caches references to selector objects for each column instead of creating a new object each time in order to save + * heap space. In general the selectorFactory need not to thread-safe. If required, set concurrentEventAdd to true to + * use concurrent hash map instead of vanilla hash map for thread-safe operations. + */ + static class CachingColumnSelectorFactory implements ColumnSelectorFactory { private final Map> columnSelectorMap; private final ColumnSelectorFactory delegate; - public ObjectCachingColumnSelectorFactory(ColumnSelectorFactory delegate, boolean concurrentEventAdd) + public CachingColumnSelectorFactory(ColumnSelectorFactory delegate, boolean concurrentEventAdd) { this.delegate = delegate; diff --git a/processing/src/main/java/org/apache/druid/segment/selector/settable/SettableColumnValueSelector.java b/processing/src/main/java/org/apache/druid/segment/selector/settable/SettableColumnValueSelector.java index 1aa2fc46edc..580dfaf6df5 100644 --- a/processing/src/main/java/org/apache/druid/segment/selector/settable/SettableColumnValueSelector.java +++ b/processing/src/main/java/org/apache/druid/segment/selector/settable/SettableColumnValueSelector.java @@ -27,7 +27,7 @@ import org.apache.druid.segment.ColumnValueSelector; */ public interface SettableColumnValueSelector extends ColumnValueSelector { - void setValueFrom(ColumnValueSelector selector); + void setValueFrom(ColumnValueSelector selector); @Override default void inspectRuntimeShape(RuntimeShapeInspector inspector) diff --git a/processing/src/main/java/org/apache/druid/segment/selector/settable/SettableDimensionValueSelector.java b/processing/src/main/java/org/apache/druid/segment/selector/settable/SettableDimensionValueSelector.java index 16ee188fae5..f21f9f289bf 100644 --- a/processing/src/main/java/org/apache/druid/segment/selector/settable/SettableDimensionValueSelector.java +++ b/processing/src/main/java/org/apache/druid/segment/selector/settable/SettableDimensionValueSelector.java @@ -33,14 +33,14 @@ import java.util.Objects; /** * Settable implementation of {@link DimensionSelector}. */ -public class SettableDimensionValueSelector implements SettableColumnValueSelector, DimensionSelector +public class SettableDimensionValueSelector implements DimensionSelector, SettableColumnValueSelector { @Nullable private DimensionSelector keptSelector; private final ArrayBasedIndexedInts keptRow = new ArrayBasedIndexedInts(); @Override - public void setValueFrom(ColumnValueSelector selector) + public void setValueFrom(ColumnValueSelector selector) { DimensionSelector dimensionSelector = (DimensionSelector) selector; keptSelector = dimensionSelector; diff --git a/processing/src/main/java/org/apache/druid/segment/selector/settable/SettableDoubleColumnValueSelector.java b/processing/src/main/java/org/apache/druid/segment/selector/settable/SettableDoubleColumnValueSelector.java index 0aae27b7c33..55c036188bd 100644 --- a/processing/src/main/java/org/apache/druid/segment/selector/settable/SettableDoubleColumnValueSelector.java +++ b/processing/src/main/java/org/apache/druid/segment/selector/settable/SettableDoubleColumnValueSelector.java @@ -29,7 +29,7 @@ public class SettableDoubleColumnValueSelector implements SettableColumnValueSel private double value; @Override - public void setValueFrom(ColumnValueSelector selector) + public void setValueFrom(ColumnValueSelector selector) { isNull = selector.isNull(); if (!isNull) { diff --git a/processing/src/main/java/org/apache/druid/segment/selector/settable/SettableFloatColumnValueSelector.java b/processing/src/main/java/org/apache/druid/segment/selector/settable/SettableFloatColumnValueSelector.java index 8fd2a79d7ec..54efd6fa806 100644 --- a/processing/src/main/java/org/apache/druid/segment/selector/settable/SettableFloatColumnValueSelector.java +++ b/processing/src/main/java/org/apache/druid/segment/selector/settable/SettableFloatColumnValueSelector.java @@ -29,7 +29,7 @@ public class SettableFloatColumnValueSelector implements SettableColumnValueSele private float value; @Override - public void setValueFrom(ColumnValueSelector selector) + public void setValueFrom(ColumnValueSelector selector) { isNull = selector.isNull(); if (!isNull) { diff --git a/processing/src/main/java/org/apache/druid/segment/selector/settable/SettableLongColumnValueSelector.java b/processing/src/main/java/org/apache/druid/segment/selector/settable/SettableLongColumnValueSelector.java index a03c6eb0124..8445c000fb4 100644 --- a/processing/src/main/java/org/apache/druid/segment/selector/settable/SettableLongColumnValueSelector.java +++ b/processing/src/main/java/org/apache/druid/segment/selector/settable/SettableLongColumnValueSelector.java @@ -29,7 +29,7 @@ public class SettableLongColumnValueSelector implements SettableColumnValueSelec private long value; @Override - public void setValueFrom(ColumnValueSelector selector) + public void setValueFrom(ColumnValueSelector selector) { isNull = selector.isNull(); if (!isNull) { diff --git a/processing/src/main/java/org/apache/druid/segment/selector/settable/package-info.java b/processing/src/main/java/org/apache/druid/segment/selector/settable/package-info.java new file mode 100644 index 00000000000..f65c301b9ba --- /dev/null +++ b/processing/src/main/java/org/apache/druid/segment/selector/settable/package-info.java @@ -0,0 +1,23 @@ +/* + * 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. + */ + +@EverythingIsNonnullByDefault +package org.apache.druid.segment.selector.settable; + +import org.apache.druid.annotations.EverythingIsNonnullByDefault; diff --git a/processing/src/main/java/org/apache/druid/segment/serde/BitmapIndexColumnPartSupplier.java b/processing/src/main/java/org/apache/druid/segment/serde/BitmapIndexColumnPartSupplier.java index 7660253408c..352777122dc 100644 --- a/processing/src/main/java/org/apache/druid/segment/serde/BitmapIndexColumnPartSupplier.java +++ b/processing/src/main/java/org/apache/druid/segment/serde/BitmapIndexColumnPartSupplier.java @@ -25,6 +25,8 @@ import org.apache.druid.collections.bitmap.ImmutableBitmap; import org.apache.druid.segment.column.BitmapIndex; import org.apache.druid.segment.data.GenericIndexed; +import javax.annotation.Nullable; + /** */ public class BitmapIndexColumnPartSupplier implements Supplier @@ -74,7 +76,7 @@ public class BitmapIndexColumnPartSupplier implements Supplier } @Override - public int getIndex(String value) + public int getIndex(@Nullable String value) { // GenericIndexed.indexOf satisfies contract needed by BitmapIndex.indexOf return dictionary.indexOf(value); diff --git a/processing/src/main/java/org/apache/druid/segment/serde/ColumnPartSerde.java b/processing/src/main/java/org/apache/druid/segment/serde/ColumnPartSerde.java index 0c43cbe393e..d862dbaeade 100644 --- a/processing/src/main/java/org/apache/druid/segment/serde/ColumnPartSerde.java +++ b/processing/src/main/java/org/apache/druid/segment/serde/ColumnPartSerde.java @@ -24,6 +24,7 @@ import com.fasterxml.jackson.annotation.JsonTypeInfo; import org.apache.druid.segment.column.ColumnBuilder; import org.apache.druid.segment.column.ColumnConfig; +import javax.annotation.Nullable; import java.nio.ByteBuffer; /** @@ -31,16 +32,17 @@ import java.nio.ByteBuffer; @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type") @JsonSubTypes(value = { @JsonSubTypes.Type(name = "complex", value = ComplexColumnPartSerde.class), - @JsonSubTypes.Type(name = "float", value = FloatGenericColumnPartSerde.class), - @JsonSubTypes.Type(name = "long", value = LongGenericColumnPartSerde.class), - @JsonSubTypes.Type(name = "double", value = DoubleGenericColumnPartSerde.class), + @JsonSubTypes.Type(name = "float", value = FloatNumericColumnPartSerde.class), + @JsonSubTypes.Type(name = "long", value = LongNumericColumnPartSerde.class), + @JsonSubTypes.Type(name = "double", value = DoubleNumericColumnPartSerde.class), @JsonSubTypes.Type(name = "stringDictionary", value = DictionaryEncodedColumnPartSerde.class), - @JsonSubTypes.Type(name = "floatV2", value = FloatGenericColumnPartSerdeV2.class), - @JsonSubTypes.Type(name = "longV2", value = LongGenericColumnPartSerdeV2.class), - @JsonSubTypes.Type(name = "doubleV2", value = DoubleGenericColumnPartSerdeV2.class), + @JsonSubTypes.Type(name = "floatV2", value = FloatNumericColumnPartSerdeV2.class), + @JsonSubTypes.Type(name = "longV2", value = LongNumericColumnPartSerdeV2.class), + @JsonSubTypes.Type(name = "doubleV2", value = DoubleNumericColumnPartSerdeV2.class), }) public interface ColumnPartSerde { + @Nullable Serializer getSerializer(); Deserializer getDeserializer(); diff --git a/processing/src/main/java/org/apache/druid/segment/serde/ComplexColumnPartSupplier.java b/processing/src/main/java/org/apache/druid/segment/serde/ComplexColumnPartSupplier.java index de22f00f2a1..9ef7ce52171 100644 --- a/processing/src/main/java/org/apache/druid/segment/serde/ComplexColumnPartSupplier.java +++ b/processing/src/main/java/org/apache/druid/segment/serde/ComplexColumnPartSupplier.java @@ -21,17 +21,16 @@ package org.apache.druid.segment.serde; import com.google.common.base.Supplier; import org.apache.druid.segment.column.ComplexColumn; -import org.apache.druid.segment.column.IndexedComplexColumn; import org.apache.druid.segment.data.GenericIndexed; /** */ public class ComplexColumnPartSupplier implements Supplier { - private final GenericIndexed complexType; + private final GenericIndexed complexType; private final String typeName; - public ComplexColumnPartSupplier(final String typeName, final GenericIndexed complexType) + public ComplexColumnPartSupplier(final String typeName, final GenericIndexed complexType) { this.complexType = complexType; this.typeName = typeName; @@ -40,6 +39,6 @@ public class ComplexColumnPartSupplier implements Supplier @Override public ComplexColumn get() { - return new IndexedComplexColumn(typeName, complexType); + return new ComplexColumn(typeName, complexType); } } diff --git a/processing/src/main/java/org/apache/druid/segment/serde/ComplexColumnSerializer.java b/processing/src/main/java/org/apache/druid/segment/serde/ComplexColumnSerializer.java index fb2866f09f2..1441c782f18 100644 --- a/processing/src/main/java/org/apache/druid/segment/serde/ComplexColumnSerializer.java +++ b/processing/src/main/java/org/apache/druid/segment/serde/ComplexColumnSerializer.java @@ -31,7 +31,7 @@ import org.apache.druid.segment.writeout.SegmentWriteOutMedium; import java.io.IOException; import java.nio.channels.WritableByteChannel; -public class ComplexColumnSerializer implements GenericColumnSerializer +public class ComplexColumnSerializer implements GenericColumnSerializer { @PublicApi public static ComplexColumnSerializer create(SegmentWriteOutMedium segmentWriteOutMedium, String filenameBase, ObjectStrategy strategy) @@ -60,7 +60,7 @@ public class ComplexColumnSerializer implements GenericColumnSerializer } @Override - public void serialize(ColumnValueSelector selector) throws IOException + public void serialize(ColumnValueSelector selector) throws IOException { writer.write(selector.getObject()); } diff --git a/processing/src/main/java/org/apache/druid/segment/serde/ComplexMetricExtractor.java b/processing/src/main/java/org/apache/druid/segment/serde/ComplexMetricExtractor.java index 81f60a7c8c7..6e237f31f19 100644 --- a/processing/src/main/java/org/apache/druid/segment/serde/ComplexMetricExtractor.java +++ b/processing/src/main/java/org/apache/druid/segment/serde/ComplexMetricExtractor.java @@ -22,11 +22,15 @@ package org.apache.druid.segment.serde; import org.apache.druid.data.input.InputRow; import org.apache.druid.guice.annotations.ExtensionPoint; +import javax.annotation.Nullable; + /** */ @ExtensionPoint -public interface ComplexMetricExtractor +public interface ComplexMetricExtractor { - Class extractedClass(); - Object extractValue(InputRow inputRow, String metricName); + Class extractedClass(); + + @Nullable + T extractValue(InputRow inputRow, String metricName); } diff --git a/processing/src/main/java/org/apache/druid/segment/serde/ComplexMetricSerde.java b/processing/src/main/java/org/apache/druid/segment/serde/ComplexMetricSerde.java index 81f0dc40514..300e3ad99f1 100644 --- a/processing/src/main/java/org/apache/druid/segment/serde/ComplexMetricSerde.java +++ b/processing/src/main/java/org/apache/druid/segment/serde/ComplexMetricSerde.java @@ -20,12 +20,14 @@ package org.apache.druid.segment.serde; import com.google.common.base.Function; +import it.unimi.dsi.fastutil.bytes.ByteArrays; import org.apache.druid.guice.annotations.ExtensionPoint; import org.apache.druid.segment.GenericColumnSerializer; import org.apache.druid.segment.column.ColumnBuilder; import org.apache.druid.segment.data.ObjectStrategy; import org.apache.druid.segment.writeout.SegmentWriteOutMedium; +import javax.annotation.Nullable; import java.nio.ByteBuffer; /** @@ -80,9 +82,14 @@ public abstract class ComplexMetricSerde * * @return serialized intermediate representation of aggregate in byte[] */ - public byte[] toBytes(Object val) + public byte[] toBytes(@Nullable Object val) { - return getObjectStrategy().toBytes(val); + if (val != null) { + byte[] bytes = getObjectStrategy().toBytes(val); + return bytes != null ? bytes : ByteArrays.EMPTY_ARRAY; + } else { + return ByteArrays.EMPTY_ARRAY; + } } /** @@ -105,8 +112,8 @@ public abstract class ComplexMetricSerde /** * This method provides the ability for a ComplexMetricSerde to control its own serialization. - * For large column (i.e columns greater than Integer.MAX) use - * (@link LargeColumnSupportedComplexColumnSerializer) + * For large column (i.e columns greater than {@link Integer#MAX_VALUE}) use + * {@link LargeColumnSupportedComplexColumnSerializer} * * @return an instance of GenericColumnSerializer used for serialization. */ diff --git a/processing/src/main/java/org/apache/druid/segment/serde/ComplexMetrics.java b/processing/src/main/java/org/apache/druid/segment/serde/ComplexMetrics.java index 9e837ec486c..314326b9bb4 100644 --- a/processing/src/main/java/org/apache/druid/segment/serde/ComplexMetrics.java +++ b/processing/src/main/java/org/apache/druid/segment/serde/ComplexMetrics.java @@ -22,6 +22,7 @@ package org.apache.druid.segment.serde; import com.google.common.collect.Maps; import org.apache.druid.java.util.common.ISE; +import javax.annotation.Nullable; import java.util.Map; /** @@ -30,6 +31,7 @@ public class ComplexMetrics { private static final Map complexSerializers = Maps.newHashMap(); + @Nullable public static ComplexMetricSerde getSerdeForType(String type) { return complexSerializers.get(type); diff --git a/processing/src/main/java/org/apache/druid/segment/serde/DictionaryEncodedColumnPartSerde.java b/processing/src/main/java/org/apache/druid/segment/serde/DictionaryEncodedColumnPartSerde.java index 2bb64f785fa..373649fc4a7 100644 --- a/processing/src/main/java/org/apache/druid/segment/serde/DictionaryEncodedColumnPartSerde.java +++ b/processing/src/main/java/org/apache/druid/segment/serde/DictionaryEncodedColumnPartSerde.java @@ -319,7 +319,9 @@ public class DictionaryEncodedColumnPartSerde implements ColumnPartSerde rMultiValuedColumn, columnConfig.columnCacheSizeBytes() ); - builder.setHasMultipleValues(hasMultipleValues).setDictionaryEncodedColumn(dictionaryEncodedColumnSupplier); + builder + .setHasMultipleValues(hasMultipleValues) + .setDictionaryEncodedColumnSupplier(dictionaryEncodedColumnSupplier); if (!Feature.NO_BITMAP_INDEX.isSet(rFlags)) { GenericIndexed rBitmaps = GenericIndexed.read( diff --git a/processing/src/main/java/org/apache/druid/segment/serde/DictionaryEncodedColumnSupplier.java b/processing/src/main/java/org/apache/druid/segment/serde/DictionaryEncodedColumnSupplier.java index d8de21684ed..d0fb888a19c 100644 --- a/processing/src/main/java/org/apache/druid/segment/serde/DictionaryEncodedColumnSupplier.java +++ b/processing/src/main/java/org/apache/druid/segment/serde/DictionaryEncodedColumnSupplier.java @@ -21,25 +21,27 @@ package org.apache.druid.segment.serde; import com.google.common.base.Supplier; import org.apache.druid.segment.column.DictionaryEncodedColumn; -import org.apache.druid.segment.column.SimpleDictionaryEncodedColumn; +import org.apache.druid.segment.column.StringDictionaryEncodedColumn; import org.apache.druid.segment.data.CachingIndexed; import org.apache.druid.segment.data.ColumnarInts; import org.apache.druid.segment.data.ColumnarMultiInts; import org.apache.druid.segment.data.GenericIndexed; +import javax.annotation.Nullable; + /** -*/ -public class DictionaryEncodedColumnSupplier implements Supplier + */ +public class DictionaryEncodedColumnSupplier implements Supplier> { private final GenericIndexed dictionary; - private final Supplier singleValuedColumn; - private final Supplier multiValuedColumn; + private final @Nullable Supplier singleValuedColumn; + private final @Nullable Supplier multiValuedColumn; private final int lookupCacheSize; public DictionaryEncodedColumnSupplier( GenericIndexed dictionary, - Supplier singleValuedColumn, - Supplier multiValuedColumn, + @Nullable Supplier singleValuedColumn, + @Nullable Supplier multiValuedColumn, int lookupCacheSize ) { @@ -50,9 +52,9 @@ public class DictionaryEncodedColumnSupplier implements Supplier get() { - return new SimpleDictionaryEncodedColumn( + return new StringDictionaryEncodedColumn( singleValuedColumn != null ? singleValuedColumn.get() : null, multiValuedColumn != null ? multiValuedColumn.get() : null, new CachingIndexed<>(dictionary, lookupCacheSize) diff --git a/processing/src/main/java/org/apache/druid/segment/serde/DoubleGenericColumnPartSerde.java b/processing/src/main/java/org/apache/druid/segment/serde/DoubleNumericColumnPartSerde.java similarity index 79% rename from processing/src/main/java/org/apache/druid/segment/serde/DoubleGenericColumnPartSerde.java rename to processing/src/main/java/org/apache/druid/segment/serde/DoubleNumericColumnPartSerde.java index 4381b42870c..82ebfc2d683 100644 --- a/processing/src/main/java/org/apache/druid/segment/serde/DoubleGenericColumnPartSerde.java +++ b/processing/src/main/java/org/apache/druid/segment/serde/DoubleNumericColumnPartSerde.java @@ -29,23 +29,25 @@ import org.apache.druid.segment.column.ValueType; import org.apache.druid.segment.data.ColumnarDoubles; import org.apache.druid.segment.data.CompressedColumnarDoublesSuppliers; +import javax.annotation.Nullable; import java.nio.ByteBuffer; import java.nio.ByteOrder; -public class DoubleGenericColumnPartSerde implements ColumnPartSerde +public class DoubleNumericColumnPartSerde implements ColumnPartSerde { @JsonCreator - public static DoubleGenericColumnPartSerde getDoubleGenericColumnPartSerde( + public static DoubleNumericColumnPartSerde getDoubleGenericColumnPartSerde( @JsonProperty("byteOrder") ByteOrder byteOrder ) { - return new DoubleGenericColumnPartSerde(byteOrder, null); + return new DoubleNumericColumnPartSerde(byteOrder, null); } private final ByteOrder byteOrder; + @Nullable private final Serializer serializer; - private DoubleGenericColumnPartSerde(ByteOrder byteOrder, Serializer serializer) + private DoubleNumericColumnPartSerde(ByteOrder byteOrder, @Nullable Serializer serializer) { this.byteOrder = byteOrder; this.serializer = serializer; @@ -79,12 +81,13 @@ public class DoubleGenericColumnPartSerde implements ColumnPartSerde return this; } - public DoubleGenericColumnPartSerde build() + public DoubleNumericColumnPartSerde build() { - return new DoubleGenericColumnPartSerde(byteOrder, delegate); + return new DoubleNumericColumnPartSerde(byteOrder, delegate); } } + @Nullable @Override public Serializer getSerializer() { @@ -103,10 +106,13 @@ public class DoubleGenericColumnPartSerde implements ColumnPartSerde buffer, byteOrder ); + DoubleNumericColumnSupplier columnSupplier = new DoubleNumericColumnSupplier( + column, + IndexIO.LEGACY_FACTORY.getBitmapFactory().makeEmptyImmutableBitmap() + ); builder.setType(ValueType.DOUBLE) .setHasMultipleValues(false) - .setGenericColumn(new DoubleGenericColumnSupplier(column, IndexIO.LEGACY_FACTORY.getBitmapFactory() - .makeEmptyImmutableBitmap())); + .setNumericColumnSupplier(columnSupplier); } }; diff --git a/processing/src/main/java/org/apache/druid/segment/serde/DoubleGenericColumnPartSerdeV2.java b/processing/src/main/java/org/apache/druid/segment/serde/DoubleNumericColumnPartSerdeV2.java similarity index 79% rename from processing/src/main/java/org/apache/druid/segment/serde/DoubleGenericColumnPartSerdeV2.java rename to processing/src/main/java/org/apache/druid/segment/serde/DoubleNumericColumnPartSerdeV2.java index 05c0c272d92..b822dbf0dcc 100644 --- a/processing/src/main/java/org/apache/druid/segment/serde/DoubleGenericColumnPartSerdeV2.java +++ b/processing/src/main/java/org/apache/druid/segment/serde/DoubleNumericColumnPartSerdeV2.java @@ -19,7 +19,6 @@ package org.apache.druid.segment.serde; - import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.google.common.base.Supplier; @@ -38,15 +37,15 @@ import java.nio.channels.WritableByteChannel; /** */ -public class DoubleGenericColumnPartSerdeV2 implements ColumnPartSerde +public class DoubleNumericColumnPartSerdeV2 implements ColumnPartSerde { @JsonCreator - public static DoubleGenericColumnPartSerdeV2 getDoubleGenericColumnPartSerde( + public static DoubleNumericColumnPartSerdeV2 getDoubleGenericColumnPartSerde( @JsonProperty("byteOrder") ByteOrder byteOrder, @Nullable @JsonProperty("bitmapSerdeFactory") BitmapSerdeFactory bitmapSerdeFactory ) { - return new DoubleGenericColumnPartSerdeV2( + return new DoubleNumericColumnPartSerdeV2( byteOrder, bitmapSerdeFactory != null ? bitmapSerdeFactory : new BitmapSerde.LegacyBitmapSerdeFactory(), null @@ -54,18 +53,19 @@ public class DoubleGenericColumnPartSerdeV2 implements ColumnPartSerde } private final ByteOrder byteOrder; - private Serializer serialize; + @Nullable + private Serializer serializer; private final BitmapSerdeFactory bitmapSerdeFactory; - public DoubleGenericColumnPartSerdeV2( + public DoubleNumericColumnPartSerdeV2( ByteOrder byteOrder, BitmapSerdeFactory bitmapSerdeFactory, - Serializer serialize + @Nullable Serializer serializer ) { this.byteOrder = byteOrder; this.bitmapSerdeFactory = bitmapSerdeFactory; - this.serialize = serialize; + this.serializer = serializer; } @JsonProperty @@ -109,33 +109,31 @@ public class DoubleGenericColumnPartSerdeV2 implements ColumnPartSerde return this; } - public DoubleGenericColumnPartSerdeV2 build() + public DoubleNumericColumnPartSerdeV2 build() { - return new DoubleGenericColumnPartSerdeV2( - byteOrder, - bitmapSerdeFactory, - new Serializer() - { - @Override - public long getSerializedSize() throws IOException - { - return delegate.getSerializedSize(); - } + Serializer serializer = new Serializer() + { + @Override + public long getSerializedSize() throws IOException + { + return delegate.getSerializedSize(); + } - @Override - public void writeTo(WritableByteChannel channel, FileSmoosher fileSmoosher) throws IOException - { - delegate.writeTo(channel, fileSmoosher); - } - } - ); + @Override + public void writeTo(WritableByteChannel channel, FileSmoosher fileSmoosher) throws IOException + { + delegate.writeTo(channel, fileSmoosher); + } + }; + return new DoubleNumericColumnPartSerdeV2(byteOrder, bitmapSerdeFactory, serializer); } } + @Nullable @Override public Serializer getSerializer() { - return serialize; + return serializer; } @Override @@ -158,7 +156,7 @@ public class DoubleGenericColumnPartSerdeV2 implements ColumnPartSerde } builder.setType(ValueType.DOUBLE) .setHasMultipleValues(false) - .setGenericColumn(new DoubleGenericColumnSupplier(column, bitmap)); + .setNumericColumnSupplier(new DoubleNumericColumnSupplier(column, bitmap)); }; } } diff --git a/processing/src/main/java/org/apache/druid/segment/serde/DoubleGenericColumnSupplier.java b/processing/src/main/java/org/apache/druid/segment/serde/DoubleNumericColumnSupplier.java similarity index 86% rename from processing/src/main/java/org/apache/druid/segment/serde/DoubleGenericColumnSupplier.java rename to processing/src/main/java/org/apache/druid/segment/serde/DoubleNumericColumnSupplier.java index 8c8698d0fce..952bd33189e 100644 --- a/processing/src/main/java/org/apache/druid/segment/serde/DoubleGenericColumnSupplier.java +++ b/processing/src/main/java/org/apache/druid/segment/serde/DoubleNumericColumnSupplier.java @@ -22,22 +22,22 @@ package org.apache.druid.segment.serde; import com.google.common.base.Supplier; import org.apache.druid.collections.bitmap.ImmutableBitmap; import org.apache.druid.segment.column.DoublesColumn; -import org.apache.druid.segment.column.GenericColumn; +import org.apache.druid.segment.column.NumericColumn; import org.apache.druid.segment.data.ColumnarDoubles; -public class DoubleGenericColumnSupplier implements Supplier +public class DoubleNumericColumnSupplier implements Supplier { private final Supplier column; private final ImmutableBitmap nullValueBitmap; - DoubleGenericColumnSupplier(Supplier column, ImmutableBitmap nullValueBitmap) + DoubleNumericColumnSupplier(Supplier column, ImmutableBitmap nullValueBitmap) { this.column = column; this.nullValueBitmap = nullValueBitmap; } @Override - public GenericColumn get() + public NumericColumn get() { return DoublesColumn.create(column.get(), nullValueBitmap); } diff --git a/processing/src/main/java/org/apache/druid/segment/serde/FloatGenericColumnPartSerde.java b/processing/src/main/java/org/apache/druid/segment/serde/FloatNumericColumnPartSerde.java similarity index 79% rename from processing/src/main/java/org/apache/druid/segment/serde/FloatGenericColumnPartSerde.java rename to processing/src/main/java/org/apache/druid/segment/serde/FloatNumericColumnPartSerde.java index c5480365665..46cc40b62e9 100644 --- a/processing/src/main/java/org/apache/druid/segment/serde/FloatGenericColumnPartSerde.java +++ b/processing/src/main/java/org/apache/druid/segment/serde/FloatNumericColumnPartSerde.java @@ -27,25 +27,27 @@ import org.apache.druid.segment.column.ColumnConfig; import org.apache.druid.segment.column.ValueType; import org.apache.druid.segment.data.CompressedColumnarFloatsSupplier; +import javax.annotation.Nullable; import java.nio.ByteBuffer; import java.nio.ByteOrder; /** */ -public class FloatGenericColumnPartSerde implements ColumnPartSerde +public class FloatNumericColumnPartSerde implements ColumnPartSerde { @JsonCreator - public static FloatGenericColumnPartSerde createDeserializer( + public static FloatNumericColumnPartSerde createDeserializer( @JsonProperty("byteOrder") ByteOrder byteOrder ) { - return new FloatGenericColumnPartSerde(byteOrder, null); + return new FloatNumericColumnPartSerde(byteOrder, null); } private final ByteOrder byteOrder; + @Nullable private final Serializer serializer; - private FloatGenericColumnPartSerde(ByteOrder byteOrder, Serializer serializer) + private FloatNumericColumnPartSerde(ByteOrder byteOrder, @Nullable Serializer serializer) { this.byteOrder = byteOrder; this.serializer = serializer; @@ -79,12 +81,13 @@ public class FloatGenericColumnPartSerde implements ColumnPartSerde return this; } - public FloatGenericColumnPartSerde build() + public FloatNumericColumnPartSerde build() { - return new FloatGenericColumnPartSerde(byteOrder, delegate); + return new FloatNumericColumnPartSerde(byteOrder, delegate); } } + @Nullable @Override public Serializer getSerializer() { @@ -103,13 +106,13 @@ public class FloatGenericColumnPartSerde implements ColumnPartSerde buffer, byteOrder ); + FloatNumericColumnSupplier columnSupplier = new FloatNumericColumnSupplier( + column, + IndexIO.LEGACY_FACTORY.getBitmapFactory().makeEmptyImmutableBitmap() + ); builder.setType(ValueType.FLOAT) .setHasMultipleValues(false) - .setGenericColumn(new FloatGenericColumnSupplier( - column, - IndexIO.LEGACY_FACTORY.getBitmapFactory() - .makeEmptyImmutableBitmap() - )); + .setNumericColumnSupplier(columnSupplier); } }; } diff --git a/processing/src/main/java/org/apache/druid/segment/serde/FloatGenericColumnPartSerdeV2.java b/processing/src/main/java/org/apache/druid/segment/serde/FloatNumericColumnPartSerdeV2.java similarity index 80% rename from processing/src/main/java/org/apache/druid/segment/serde/FloatGenericColumnPartSerdeV2.java rename to processing/src/main/java/org/apache/druid/segment/serde/FloatNumericColumnPartSerdeV2.java index cabe0dd3719..ccc748a210a 100644 --- a/processing/src/main/java/org/apache/druid/segment/serde/FloatGenericColumnPartSerdeV2.java +++ b/processing/src/main/java/org/apache/druid/segment/serde/FloatNumericColumnPartSerdeV2.java @@ -35,15 +35,15 @@ import java.nio.channels.WritableByteChannel; /** */ -public class FloatGenericColumnPartSerdeV2 implements ColumnPartSerde +public class FloatNumericColumnPartSerdeV2 implements ColumnPartSerde { @JsonCreator - public static FloatGenericColumnPartSerdeV2 createDeserializer( + public static FloatNumericColumnPartSerdeV2 createDeserializer( @JsonProperty("byteOrder") ByteOrder byteOrder, @Nullable @JsonProperty("bitmapSerdeFactory") BitmapSerdeFactory bitmapSerdeFactory ) { - return new FloatGenericColumnPartSerdeV2( + return new FloatNumericColumnPartSerdeV2( byteOrder, bitmapSerdeFactory != null ? bitmapSerdeFactory : new BitmapSerde.LegacyBitmapSerdeFactory(), null @@ -51,13 +51,14 @@ public class FloatGenericColumnPartSerdeV2 implements ColumnPartSerde } private final ByteOrder byteOrder; + @Nullable private Serializer serializer; private final BitmapSerdeFactory bitmapSerdeFactory; - private FloatGenericColumnPartSerdeV2( + private FloatNumericColumnPartSerdeV2( ByteOrder byteOrder, BitmapSerdeFactory bitmapSerdeFactory, - Serializer serializer + @Nullable Serializer serializer ) { this.byteOrder = byteOrder; @@ -106,28 +107,27 @@ public class FloatGenericColumnPartSerdeV2 implements ColumnPartSerde return this; } - public FloatGenericColumnPartSerdeV2 build() + public FloatNumericColumnPartSerdeV2 build() { - return new FloatGenericColumnPartSerdeV2( - byteOrder, bitmapSerdeFactory, - new Serializer() - { - @Override - public long getSerializedSize() throws IOException - { - return delegate.getSerializedSize(); - } + Serializer serializer = new Serializer() + { + @Override + public long getSerializedSize() throws IOException + { + return delegate.getSerializedSize(); + } - @Override - public void writeTo(WritableByteChannel channel, FileSmoosher fileSmoosher) throws IOException - { - delegate.writeTo(channel, fileSmoosher); - } - } - ); + @Override + public void writeTo(WritableByteChannel channel, FileSmoosher fileSmoosher) throws IOException + { + delegate.writeTo(channel, fileSmoosher); + } + }; + return new FloatNumericColumnPartSerdeV2(byteOrder, bitmapSerdeFactory, serializer); } } + @Nullable @Override public Serializer getSerializer() { @@ -153,7 +153,7 @@ public class FloatGenericColumnPartSerdeV2 implements ColumnPartSerde } builder.setType(ValueType.FLOAT) .setHasMultipleValues(false) - .setGenericColumn(new FloatGenericColumnSupplier(column, bitmap)); + .setNumericColumnSupplier(new FloatNumericColumnSupplier(column, bitmap)); }; } } diff --git a/processing/src/main/java/org/apache/druid/segment/serde/FloatGenericColumnSupplier.java b/processing/src/main/java/org/apache/druid/segment/serde/FloatNumericColumnSupplier.java similarity index 88% rename from processing/src/main/java/org/apache/druid/segment/serde/FloatGenericColumnSupplier.java rename to processing/src/main/java/org/apache/druid/segment/serde/FloatNumericColumnSupplier.java index 88dfda41191..4ffaf2d5161 100644 --- a/processing/src/main/java/org/apache/druid/segment/serde/FloatGenericColumnSupplier.java +++ b/processing/src/main/java/org/apache/druid/segment/serde/FloatNumericColumnSupplier.java @@ -22,17 +22,17 @@ package org.apache.druid.segment.serde; import com.google.common.base.Supplier; import org.apache.druid.collections.bitmap.ImmutableBitmap; import org.apache.druid.segment.column.FloatsColumn; -import org.apache.druid.segment.column.GenericColumn; +import org.apache.druid.segment.column.NumericColumn; import org.apache.druid.segment.data.CompressedColumnarFloatsSupplier; /** */ -public class FloatGenericColumnSupplier implements Supplier +public class FloatNumericColumnSupplier implements Supplier { private final CompressedColumnarFloatsSupplier column; private final ImmutableBitmap nullValueBitmap; - public FloatGenericColumnSupplier( + public FloatNumericColumnSupplier( CompressedColumnarFloatsSupplier column, ImmutableBitmap nullValueBitmap ) @@ -42,7 +42,7 @@ public class FloatGenericColumnSupplier implements Supplier } @Override - public GenericColumn get() + public NumericColumn get() { return FloatsColumn.create(column.get(), nullValueBitmap); } diff --git a/processing/src/main/java/org/apache/druid/segment/serde/LargeColumnSupportedComplexColumnSerializer.java b/processing/src/main/java/org/apache/druid/segment/serde/LargeColumnSupportedComplexColumnSerializer.java index 0241c3ecd23..8e4f2c23def 100644 --- a/processing/src/main/java/org/apache/druid/segment/serde/LargeColumnSupportedComplexColumnSerializer.java +++ b/processing/src/main/java/org/apache/druid/segment/serde/LargeColumnSupportedComplexColumnSerializer.java @@ -31,33 +31,38 @@ import org.apache.druid.segment.writeout.SegmentWriteOutMedium; import java.io.IOException; import java.nio.channels.WritableByteChannel; -public class LargeColumnSupportedComplexColumnSerializer implements GenericColumnSerializer +public class LargeColumnSupportedComplexColumnSerializer implements GenericColumnSerializer { @PublicApi - public static LargeColumnSupportedComplexColumnSerializer create( + public static LargeColumnSupportedComplexColumnSerializer create( SegmentWriteOutMedium segmentWriteOutMedium, String filenameBase, ObjectStrategy strategy ) { - return new LargeColumnSupportedComplexColumnSerializer(segmentWriteOutMedium, filenameBase, strategy); + return new LargeColumnSupportedComplexColumnSerializer<>(segmentWriteOutMedium, filenameBase, strategy); } - public static LargeColumnSupportedComplexColumnSerializer createWithColumnSize( + public static LargeColumnSupportedComplexColumnSerializer createWithColumnSize( SegmentWriteOutMedium segmentWriteOutMedium, String filenameBase, ObjectStrategy strategy, int columnSize ) { - return new LargeColumnSupportedComplexColumnSerializer(segmentWriteOutMedium, filenameBase, strategy, columnSize); + return new LargeColumnSupportedComplexColumnSerializer<>( + segmentWriteOutMedium, + filenameBase, + strategy, + columnSize + ); } private final SegmentWriteOutMedium segmentWriteOutMedium; private final String filenameBase; private final ObjectStrategy strategy; private final int columnSize; - private GenericIndexedWriter writer; + private GenericIndexedWriter writer; private LargeColumnSupportedComplexColumnSerializer( SegmentWriteOutMedium segmentWriteOutMedium, @@ -95,7 +100,7 @@ public class LargeColumnSupportedComplexColumnSerializer implements GenericColum } @Override - public void serialize(ColumnValueSelector selector) throws IOException + public void serialize(ColumnValueSelector selector) throws IOException { writer.write(selector.getObject()); } diff --git a/processing/src/main/java/org/apache/druid/segment/serde/LongGenericColumnPartSerde.java b/processing/src/main/java/org/apache/druid/segment/serde/LongNumericColumnPartSerde.java similarity index 79% rename from processing/src/main/java/org/apache/druid/segment/serde/LongGenericColumnPartSerde.java rename to processing/src/main/java/org/apache/druid/segment/serde/LongNumericColumnPartSerde.java index 64b454cc95d..2dda2eb3c00 100644 --- a/processing/src/main/java/org/apache/druid/segment/serde/LongGenericColumnPartSerde.java +++ b/processing/src/main/java/org/apache/druid/segment/serde/LongNumericColumnPartSerde.java @@ -27,25 +27,27 @@ import org.apache.druid.segment.column.ColumnConfig; import org.apache.druid.segment.column.ValueType; import org.apache.druid.segment.data.CompressedColumnarLongsSupplier; +import javax.annotation.Nullable; import java.nio.ByteBuffer; import java.nio.ByteOrder; /** */ -public class LongGenericColumnPartSerde implements ColumnPartSerde +public class LongNumericColumnPartSerde implements ColumnPartSerde { @JsonCreator - public static LongGenericColumnPartSerde createDeserializer( + public static LongNumericColumnPartSerde createDeserializer( @JsonProperty("byteOrder") ByteOrder byteOrder ) { - return new LongGenericColumnPartSerde(byteOrder, null); + return new LongNumericColumnPartSerde(byteOrder, null); } private final ByteOrder byteOrder; + @Nullable private final Serializer serializer; - private LongGenericColumnPartSerde(ByteOrder byteOrder, Serializer serializer) + private LongNumericColumnPartSerde(ByteOrder byteOrder, @Nullable Serializer serializer) { this.byteOrder = byteOrder; this.serializer = serializer; @@ -79,12 +81,13 @@ public class LongGenericColumnPartSerde implements ColumnPartSerde return this; } - public LongGenericColumnPartSerde build() + public LongNumericColumnPartSerde build() { - return new LongGenericColumnPartSerde(byteOrder, delegate); + return new LongNumericColumnPartSerde(byteOrder, delegate); } } + @Nullable @Override public Serializer getSerializer() { @@ -103,13 +106,13 @@ public class LongGenericColumnPartSerde implements ColumnPartSerde buffer, byteOrder ); + LongNumericColumnSupplier columnSupplier = new LongNumericColumnSupplier( + column, + IndexIO.LEGACY_FACTORY.getBitmapFactory().makeEmptyImmutableBitmap() + ); builder.setType(ValueType.LONG) .setHasMultipleValues(false) - .setGenericColumn(new LongGenericColumnSupplier( - column, - IndexIO.LEGACY_FACTORY.getBitmapFactory() - .makeEmptyImmutableBitmap() - )); + .setNumericColumnSupplier(columnSupplier); } }; } diff --git a/processing/src/main/java/org/apache/druid/segment/serde/LongGenericColumnPartSerdeV2.java b/processing/src/main/java/org/apache/druid/segment/serde/LongNumericColumnPartSerdeV2.java similarity index 80% rename from processing/src/main/java/org/apache/druid/segment/serde/LongGenericColumnPartSerdeV2.java rename to processing/src/main/java/org/apache/druid/segment/serde/LongNumericColumnPartSerdeV2.java index f072afd8efa..ad27d81260f 100644 --- a/processing/src/main/java/org/apache/druid/segment/serde/LongGenericColumnPartSerdeV2.java +++ b/processing/src/main/java/org/apache/druid/segment/serde/LongNumericColumnPartSerdeV2.java @@ -35,15 +35,15 @@ import java.nio.channels.WritableByteChannel; /** */ -public class LongGenericColumnPartSerdeV2 implements ColumnPartSerde +public class LongNumericColumnPartSerdeV2 implements ColumnPartSerde { @JsonCreator - public static LongGenericColumnPartSerdeV2 createDeserializer( + public static LongNumericColumnPartSerdeV2 createDeserializer( @JsonProperty("byteOrder") ByteOrder byteOrder, @Nullable @JsonProperty("bitmapSerdeFactory") BitmapSerdeFactory bitmapSerdeFactory ) { - return new LongGenericColumnPartSerdeV2( + return new LongNumericColumnPartSerdeV2( byteOrder, bitmapSerdeFactory != null ? bitmapSerdeFactory : new BitmapSerde.LegacyBitmapSerdeFactory(), null @@ -51,12 +51,14 @@ public class LongGenericColumnPartSerdeV2 implements ColumnPartSerde } private final ByteOrder byteOrder; + @Nullable private Serializer serializer; private final BitmapSerdeFactory bitmapSerdeFactory; - private LongGenericColumnPartSerdeV2( + private LongNumericColumnPartSerdeV2( ByteOrder byteOrder, - BitmapSerdeFactory bitmapSerdeFactory, Serializer serializer + BitmapSerdeFactory bitmapSerdeFactory, + @Nullable Serializer serializer ) { this.byteOrder = byteOrder; @@ -105,28 +107,27 @@ public class LongGenericColumnPartSerdeV2 implements ColumnPartSerde return this; } - public LongGenericColumnPartSerdeV2 build() + public LongNumericColumnPartSerdeV2 build() { - return new LongGenericColumnPartSerdeV2( - byteOrder, bitmapSerdeFactory, - new Serializer() - { - @Override - public long getSerializedSize() throws IOException - { - return delegate.getSerializedSize(); - } + Serializer serializer = new Serializer() + { + @Override + public long getSerializedSize() throws IOException + { + return delegate.getSerializedSize(); + } - @Override - public void writeTo(WritableByteChannel channel, FileSmoosher smoosher) throws IOException - { - delegate.writeTo(channel, smoosher); - } - } - ); + @Override + public void writeTo(WritableByteChannel channel, FileSmoosher smoosher) throws IOException + { + delegate.writeTo(channel, smoosher); + } + }; + return new LongNumericColumnPartSerdeV2(byteOrder, bitmapSerdeFactory, serializer); } } + @Nullable @Override public Serializer getSerializer() { @@ -152,7 +153,7 @@ public class LongGenericColumnPartSerdeV2 implements ColumnPartSerde } builder.setType(ValueType.LONG) .setHasMultipleValues(false) - .setGenericColumn(new LongGenericColumnSupplier(column, bitmap)); + .setNumericColumnSupplier(new LongNumericColumnSupplier(column, bitmap)); }; } } diff --git a/processing/src/main/java/org/apache/druid/segment/serde/LongGenericColumnSupplier.java b/processing/src/main/java/org/apache/druid/segment/serde/LongNumericColumnSupplier.java similarity index 86% rename from processing/src/main/java/org/apache/druid/segment/serde/LongGenericColumnSupplier.java rename to processing/src/main/java/org/apache/druid/segment/serde/LongNumericColumnSupplier.java index 729d2e8bb36..eb0b2f65657 100644 --- a/processing/src/main/java/org/apache/druid/segment/serde/LongGenericColumnSupplier.java +++ b/processing/src/main/java/org/apache/druid/segment/serde/LongNumericColumnSupplier.java @@ -21,25 +21,25 @@ package org.apache.druid.segment.serde; import com.google.common.base.Supplier; import org.apache.druid.collections.bitmap.ImmutableBitmap; -import org.apache.druid.segment.column.GenericColumn; import org.apache.druid.segment.column.LongsColumn; +import org.apache.druid.segment.column.NumericColumn; import org.apache.druid.segment.data.CompressedColumnarLongsSupplier; /** -*/ -public class LongGenericColumnSupplier implements Supplier + */ +public class LongNumericColumnSupplier implements Supplier { private final CompressedColumnarLongsSupplier column; private final ImmutableBitmap nullValueBitmap; - public LongGenericColumnSupplier(CompressedColumnarLongsSupplier column, ImmutableBitmap nullValueBitmap) + public LongNumericColumnSupplier(CompressedColumnarLongsSupplier column, ImmutableBitmap nullValueBitmap) { this.column = column; this.nullValueBitmap = nullValueBitmap; } @Override - public GenericColumn get() + public NumericColumn get() { return LongsColumn.create(column.get(), nullValueBitmap); } diff --git a/processing/src/main/java/org/apache/druid/segment/transform/ExpressionTransform.java b/processing/src/main/java/org/apache/druid/segment/transform/ExpressionTransform.java index a9b562c0238..2e0bc67ad17 100644 --- a/processing/src/main/java/org/apache/druid/segment/transform/ExpressionTransform.java +++ b/processing/src/main/java/org/apache/druid/segment/transform/ExpressionTransform.java @@ -27,7 +27,7 @@ import org.apache.druid.data.input.Row; import org.apache.druid.math.expr.Expr; import org.apache.druid.math.expr.ExprMacroTable; import org.apache.druid.math.expr.Parser; -import org.apache.druid.segment.column.Column; +import org.apache.druid.segment.column.ColumnHolder; import java.util.Objects; @@ -87,7 +87,7 @@ public class ExpressionTransform implements Transform private static Object getValueFromRow(final Row row, final String column) { - if (column.equals(Column.TIME_COLUMN_NAME)) { + if (column.equals(ColumnHolder.TIME_COLUMN_NAME)) { return row.getTimestampFromEpoch(); } else { return row.getRaw(column); diff --git a/processing/src/main/java/org/apache/druid/segment/transform/Transformer.java b/processing/src/main/java/org/apache/druid/segment/transform/Transformer.java index 9501fbc483a..a80eae85f1f 100644 --- a/processing/src/main/java/org/apache/druid/segment/transform/Transformer.java +++ b/processing/src/main/java/org/apache/druid/segment/transform/Transformer.java @@ -25,7 +25,7 @@ import org.apache.druid.data.input.Rows; import org.apache.druid.java.util.common.DateTimes; import org.apache.druid.query.filter.ValueMatcher; import org.apache.druid.query.groupby.RowBasedColumnSelectorFactory; -import org.apache.druid.segment.column.Column; +import org.apache.druid.segment.column.ColumnHolder; import org.apache.druid.segment.column.ValueType; import org.joda.time.DateTime; @@ -113,9 +113,9 @@ public class Transformer @Override public long getTimestampFromEpoch() { - final RowFunction transform = transforms.get(Column.TIME_COLUMN_NAME); + final RowFunction transform = transforms.get(ColumnHolder.TIME_COLUMN_NAME); if (transform != null) { - return Rows.objectToNumber(Column.TIME_COLUMN_NAME, transform.eval(row)).longValue(); + return Rows.objectToNumber(ColumnHolder.TIME_COLUMN_NAME, transform.eval(row)).longValue(); } else { return row.getTimestampFromEpoch(); } @@ -124,7 +124,7 @@ public class Transformer @Override public DateTime getTimestamp() { - final RowFunction transform = transforms.get(Column.TIME_COLUMN_NAME); + final RowFunction transform = transforms.get(ColumnHolder.TIME_COLUMN_NAME); if (transform != null) { return DateTimes.utc(getTimestampFromEpoch()); } else { diff --git a/processing/src/main/java/org/apache/druid/segment/virtual/ExpressionSelectors.java b/processing/src/main/java/org/apache/druid/segment/virtual/ExpressionSelectors.java index 5e855eab0dd..c82be3bbb90 100644 --- a/processing/src/main/java/org/apache/druid/segment/virtual/ExpressionSelectors.java +++ b/processing/src/main/java/org/apache/druid/segment/virtual/ExpressionSelectors.java @@ -33,6 +33,7 @@ import org.apache.druid.query.expression.ExprUtils; import org.apache.druid.query.extraction.ExtractionFn; import org.apache.druid.query.monomorphicprocessing.RuntimeShapeInspector; import org.apache.druid.segment.BaseObjectColumnValueSelector; +import org.apache.druid.segment.BaseSingleValueDimensionSelector; import org.apache.druid.segment.ColumnSelectorFactory; import org.apache.druid.segment.ColumnValueSelector; import org.apache.druid.segment.ConstantExprEvalSelector; @@ -40,8 +41,8 @@ import org.apache.druid.segment.DimensionSelector; import org.apache.druid.segment.DimensionSelectorUtils; import org.apache.druid.segment.NilColumnValueSelector; import org.apache.druid.segment.NullDimensionSelector; -import org.apache.druid.segment.column.Column; import org.apache.druid.segment.column.ColumnCapabilities; +import org.apache.druid.segment.column.ColumnHolder; import org.apache.druid.segment.column.ValueType; import org.apache.druid.segment.data.IndexedInts; @@ -138,11 +139,11 @@ public class ExpressionSelectors final String column = Iterables.getOnlyElement(columns); final ColumnCapabilities capabilities = columnSelectorFactory.getColumnCapabilities(column); - if (column.equals(Column.TIME_COLUMN_NAME)) { + if (column.equals(ColumnHolder.TIME_COLUMN_NAME)) { // Optimization for expressions that hit the __time column and nothing else. // May be worth applying this optimization to all long columns? return new SingleLongInputCachingExpressionColumnValueSelector( - columnSelectorFactory.makeColumnValueSelector(Column.TIME_COLUMN_NAME), + columnSelectorFactory.makeColumnValueSelector(ColumnHolder.TIME_COLUMN_NAME), expression ); } else if (capabilities != null diff --git a/processing/src/main/java/org/apache/druid/segment/virtual/SingleStringInputCachingExpressionColumnValueSelector.java b/processing/src/main/java/org/apache/druid/segment/virtual/SingleStringInputCachingExpressionColumnValueSelector.java index cef8436efd1..87c5df19d1f 100644 --- a/processing/src/main/java/org/apache/druid/segment/virtual/SingleStringInputCachingExpressionColumnValueSelector.java +++ b/processing/src/main/java/org/apache/druid/segment/virtual/SingleStringInputCachingExpressionColumnValueSelector.java @@ -21,6 +21,7 @@ package org.apache.druid.segment.virtual; import com.google.common.base.Preconditions; import com.google.common.base.Supplier; +import it.unimi.dsi.fastutil.ints.Int2ObjectLinkedOpenHashMap; import org.apache.druid.java.util.common.ISE; import org.apache.druid.math.expr.Expr; import org.apache.druid.math.expr.ExprEval; @@ -29,7 +30,6 @@ import org.apache.druid.query.monomorphicprocessing.RuntimeShapeInspector; import org.apache.druid.segment.ColumnValueSelector; import org.apache.druid.segment.DimensionSelector; import org.apache.druid.segment.data.IndexedInts; -import it.unimi.dsi.fastutil.ints.Int2ObjectLinkedOpenHashMap; import javax.annotation.Nullable; @@ -44,7 +44,9 @@ public class SingleStringInputCachingExpressionColumnValueSelector implements Co private final DimensionSelector selector; private final Expr expression; private final Expr.ObjectBinding bindings; + @Nullable private final ExprEval[] arrayEvalCache; + @Nullable private final LruEvalCache lruEvalCache; public SingleStringInputCachingExpressionColumnValueSelector( diff --git a/processing/src/main/java/org/apache/druid/segment/virtual/package-info.java b/processing/src/main/java/org/apache/druid/segment/virtual/package-info.java new file mode 100644 index 00000000000..2473dcc2715 --- /dev/null +++ b/processing/src/main/java/org/apache/druid/segment/virtual/package-info.java @@ -0,0 +1,23 @@ +/* + * 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. + */ + +@EverythingIsNonnullByDefault +package org.apache.druid.segment.virtual; + +import org.apache.druid.annotations.EverythingIsNonnullByDefault; diff --git a/processing/src/main/java/org/apache/druid/segment/writeout/TmpFileSegmentWriteOutMedium.java b/processing/src/main/java/org/apache/druid/segment/writeout/TmpFileSegmentWriteOutMedium.java index ee3f881e087..5c37ab6b591 100644 --- a/processing/src/main/java/org/apache/druid/segment/writeout/TmpFileSegmentWriteOutMedium.java +++ b/processing/src/main/java/org/apache/druid/segment/writeout/TmpFileSegmentWriteOutMedium.java @@ -19,8 +19,8 @@ package org.apache.druid.segment.writeout; -import org.apache.druid.java.util.common.io.Closer; import org.apache.commons.io.FileUtils; +import org.apache.druid.java.util.common.io.Closer; import java.io.File; import java.io.IOException; diff --git a/processing/src/test/java/org/apache/druid/collections/bitmap/BitmapBenchmark.java b/processing/src/test/java/org/apache/druid/collections/bitmap/BitmapBenchmark.java index 2c34deac7e5..81874b58d3a 100644 --- a/processing/src/test/java/org/apache/druid/collections/bitmap/BitmapBenchmark.java +++ b/processing/src/test/java/org/apache/druid/collections/bitmap/BitmapBenchmark.java @@ -73,7 +73,7 @@ public class BitmapBenchmark conciseCount++; final ByteBuffer buf = ByteBuffer.allocateDirect(bytes.length).put(bytes); buf.rewind(); - return new ImmutableConciseSet(buf); + return new ImmutableConciseSet(buf.asIntBuffer()); } protected static ImmutableRoaringBitmap writeImmutable(MutableRoaringBitmap r, ByteBuffer buf) throws IOException diff --git a/processing/src/test/java/org/apache/druid/collections/bitmap/ConciseBitmapFactoryTest.java b/processing/src/test/java/org/apache/druid/collections/bitmap/ConciseBitmapFactoryTest.java index 02c530f39f0..c172630765a 100644 --- a/processing/src/test/java/org/apache/druid/collections/bitmap/ConciseBitmapFactoryTest.java +++ b/processing/src/test/java/org/apache/druid/collections/bitmap/ConciseBitmapFactoryTest.java @@ -22,9 +22,9 @@ package org.apache.druid.collections.bitmap; import com.google.common.base.Function; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; +import junit.framework.Assert; import org.apache.druid.extendedset.intset.ConciseSet; import org.apache.druid.extendedset.intset.ImmutableConciseSet; -import junit.framework.Assert; import org.junit.Test; import java.util.Arrays; diff --git a/processing/src/test/java/org/apache/druid/collections/bitmap/RangeBitmapBenchmarkTest.java b/processing/src/test/java/org/apache/druid/collections/bitmap/RangeBitmapBenchmarkTest.java index 6f97e4b3795..f84941297f8 100644 --- a/processing/src/test/java/org/apache/druid/collections/bitmap/RangeBitmapBenchmarkTest.java +++ b/processing/src/test/java/org/apache/druid/collections/bitmap/RangeBitmapBenchmarkTest.java @@ -21,10 +21,10 @@ package org.apache.druid.collections.bitmap; import com.carrotsearch.junitbenchmarks.annotation.BenchmarkHistoryChart; import com.carrotsearch.junitbenchmarks.annotation.LabelType; +import org.apache.druid.collections.test.annotation.Benchmark; import org.apache.druid.extendedset.intset.ConciseSet; import org.apache.druid.extendedset.intset.ImmutableConciseSet; import org.apache.druid.java.util.common.StringUtils; -import org.apache.druid.collections.test.annotation.Benchmark; import org.junit.BeforeClass; import org.junit.experimental.categories.Category; import org.roaringbitmap.buffer.MutableRoaringBitmap; diff --git a/processing/src/test/java/org/apache/druid/collections/bitmap/UniformBitmapBenchmarkTest.java b/processing/src/test/java/org/apache/druid/collections/bitmap/UniformBitmapBenchmarkTest.java index d0af420dbc0..74ecdaa32c1 100644 --- a/processing/src/test/java/org/apache/druid/collections/bitmap/UniformBitmapBenchmarkTest.java +++ b/processing/src/test/java/org/apache/druid/collections/bitmap/UniformBitmapBenchmarkTest.java @@ -21,10 +21,10 @@ package org.apache.druid.collections.bitmap; import com.carrotsearch.junitbenchmarks.annotation.BenchmarkHistoryChart; import com.carrotsearch.junitbenchmarks.annotation.LabelType; +import org.apache.druid.collections.test.annotation.Benchmark; import org.apache.druid.extendedset.intset.ConciseSet; import org.apache.druid.extendedset.intset.ImmutableConciseSet; import org.apache.druid.java.util.common.StringUtils; -import org.apache.druid.collections.test.annotation.Benchmark; import org.junit.BeforeClass; import org.junit.experimental.categories.Category; import org.roaringbitmap.buffer.MutableRoaringBitmap; diff --git a/processing/src/test/java/org/apache/druid/collections/bitmap/WrappedBitSetBitmapBitSetTest.java b/processing/src/test/java/org/apache/druid/collections/bitmap/WrappedBitSetBitmapBitSetTest.java index 974dd0baeeb..05e23c0c94c 100644 --- a/processing/src/test/java/org/apache/druid/collections/bitmap/WrappedBitSetBitmapBitSetTest.java +++ b/processing/src/test/java/org/apache/druid/collections/bitmap/WrappedBitSetBitmapBitSetTest.java @@ -20,9 +20,7 @@ package org.apache.druid.collections.bitmap; import com.google.common.collect.Sets; - import org.apache.druid.collections.IntSetTestUtility; - import org.junit.Assert; import org.junit.Test; import org.roaringbitmap.IntIterator; diff --git a/processing/src/test/java/org/apache/druid/collections/spatial/ImmutableRTreeTest.java b/processing/src/test/java/org/apache/druid/collections/spatial/ImmutableRTreeTest.java index 2cc5099efe6..22e482c1a13 100644 --- a/processing/src/test/java/org/apache/druid/collections/spatial/ImmutableRTreeTest.java +++ b/processing/src/test/java/org/apache/druid/collections/spatial/ImmutableRTreeTest.java @@ -24,6 +24,7 @@ import com.google.common.base.Throwables; import com.google.common.collect.Iterables; import com.google.common.collect.Sets; import com.google.common.primitives.Bytes; +import junit.framework.Assert; import org.apache.druid.collections.bitmap.BitmapFactory; import org.apache.druid.collections.bitmap.ConciseBitmapFactory; import org.apache.druid.collections.bitmap.ImmutableBitmap; @@ -34,7 +35,6 @@ import org.apache.druid.collections.spatial.search.RectangularBound; import org.apache.druid.collections.spatial.split.LinearGutmanSplitStrategy; import org.apache.druid.segment.data.GenericIndexed; import org.apache.druid.segment.data.ImmutableRTreeObjectStrategy; -import junit.framework.Assert; import org.junit.Test; import org.roaringbitmap.IntIterator; diff --git a/processing/src/test/java/org/apache/druid/collections/spatial/RTreeTest.java b/processing/src/test/java/org/apache/druid/collections/spatial/RTreeTest.java index 24e47ed96b9..e38087afb95 100644 --- a/processing/src/test/java/org/apache/druid/collections/spatial/RTreeTest.java +++ b/processing/src/test/java/org/apache/druid/collections/spatial/RTreeTest.java @@ -19,11 +19,11 @@ package org.apache.druid.collections.spatial; +import junit.framework.Assert; import org.apache.druid.collections.bitmap.BitmapFactory; import org.apache.druid.collections.bitmap.ConciseBitmapFactory; import org.apache.druid.collections.bitmap.RoaringBitmapFactory; import org.apache.druid.collections.spatial.split.LinearGutmanSplitStrategy; -import junit.framework.Assert; import org.junit.Before; import org.junit.Test; diff --git a/processing/src/test/java/org/apache/druid/collections/spatial/split/LinearGutmanSplitStrategyTest.java b/processing/src/test/java/org/apache/druid/collections/spatial/split/LinearGutmanSplitStrategyTest.java index 232ba8a86cc..5c84463b64b 100644 --- a/processing/src/test/java/org/apache/druid/collections/spatial/split/LinearGutmanSplitStrategyTest.java +++ b/processing/src/test/java/org/apache/druid/collections/spatial/split/LinearGutmanSplitStrategyTest.java @@ -19,13 +19,13 @@ package org.apache.druid.collections.spatial.split; +import junit.framework.Assert; import org.apache.druid.collections.bitmap.BitmapFactory; import org.apache.druid.collections.bitmap.ConciseBitmapFactory; import org.apache.druid.collections.bitmap.RoaringBitmapFactory; import org.apache.druid.collections.spatial.Node; import org.apache.druid.collections.spatial.Point; import org.apache.druid.collections.spatial.RTree; -import junit.framework.Assert; import org.junit.Test; import java.util.Random; diff --git a/processing/src/test/java/org/apache/druid/query/DefaultQueryMetricsTest.java b/processing/src/test/java/org/apache/druid/query/DefaultQueryMetricsTest.java index 16312c6ea57..6f837d90248 100644 --- a/processing/src/test/java/org/apache/druid/query/DefaultQueryMetricsTest.java +++ b/processing/src/test/java/org/apache/druid/query/DefaultQueryMetricsTest.java @@ -20,8 +20,8 @@ package org.apache.druid.query; import com.google.common.collect.ImmutableSet; -import org.apache.druid.java.util.emitter.service.ServiceEmitter; import org.apache.druid.java.util.common.granularity.Granularities; +import org.apache.druid.java.util.emitter.service.ServiceEmitter; import org.apache.druid.query.aggregation.CountAggregatorFactory; import org.apache.druid.query.dimension.DefaultDimensionSpec; import org.apache.druid.query.dimension.ListFilteredDimensionSpec; diff --git a/processing/src/test/java/org/apache/druid/query/DoubleStorageTest.java b/processing/src/test/java/org/apache/druid/query/DoubleStorageTest.java index 5d48bb2afa5..479a5244420 100644 --- a/processing/src/test/java/org/apache/druid/query/DoubleStorageTest.java +++ b/processing/src/test/java/org/apache/druid/query/DoubleStorageTest.java @@ -51,7 +51,7 @@ import org.apache.druid.segment.IndexSpec; import org.apache.druid.segment.QueryableIndex; import org.apache.druid.segment.QueryableIndexSegment; import org.apache.druid.segment.TestHelper; -import org.apache.druid.segment.column.Column; +import org.apache.druid.segment.column.ColumnHolder; import org.apache.druid.segment.column.ValueType; import org.apache.druid.segment.incremental.IncrementalIndex; import org.apache.druid.segment.incremental.IncrementalIndexSchema; @@ -305,8 +305,8 @@ public class DoubleStorageTest private static QueryableIndex buildIndex(String storeDoubleAsFloat) throws IOException { - String oldValue = System.getProperty(Column.DOUBLE_STORAGE_TYPE_PROPERTY); - System.setProperty(Column.DOUBLE_STORAGE_TYPE_PROPERTY, storeDoubleAsFloat); + String oldValue = System.getProperty(ColumnHolder.DOUBLE_STORAGE_TYPE_PROPERTY); + System.setProperty(ColumnHolder.DOUBLE_STORAGE_TYPE_PROPERTY, storeDoubleAsFloat); final IncrementalIndexSchema schema = new IncrementalIndexSchema.Builder() .withMinTimestamp(DateTimes.of("2011-01-13T00:00:00.000Z").getMillis()) .withDimensionsSpec(ROW_PARSER) @@ -331,9 +331,9 @@ public class DoubleStorageTest }); if (oldValue == null) { - System.clearProperty(Column.DOUBLE_STORAGE_TYPE_PROPERTY); + System.clearProperty(ColumnHolder.DOUBLE_STORAGE_TYPE_PROPERTY); } else { - System.setProperty(Column.DOUBLE_STORAGE_TYPE_PROPERTY, oldValue); + System.setProperty(ColumnHolder.DOUBLE_STORAGE_TYPE_PROPERTY, oldValue); } File someTmpFile = File.createTempFile("billy", "yay"); someTmpFile.delete(); diff --git a/processing/src/test/java/org/apache/druid/query/IntervalChunkingQueryRunnerTest.java b/processing/src/test/java/org/apache/druid/query/IntervalChunkingQueryRunnerTest.java index 5a335592b65..0334e063acf 100644 --- a/processing/src/test/java/org/apache/druid/query/IntervalChunkingQueryRunnerTest.java +++ b/processing/src/test/java/org/apache/druid/query/IntervalChunkingQueryRunnerTest.java @@ -20,8 +20,8 @@ package org.apache.druid.query; import com.google.common.collect.ImmutableMap; -import org.apache.druid.java.util.emitter.service.ServiceEmitter; import org.apache.druid.java.util.common.guava.Sequences; +import org.apache.druid.java.util.emitter.service.ServiceEmitter; import org.apache.druid.query.Druids.TimeseriesQueryBuilder; import org.apache.druid.query.aggregation.CountAggregatorFactory; import org.easymock.EasyMock; diff --git a/processing/src/test/java/org/apache/druid/query/MultiValuedDimensionTest.java b/processing/src/test/java/org/apache/druid/query/MultiValuedDimensionTest.java index afe1a2f6fca..ba4fe7e8e0c 100644 --- a/processing/src/test/java/org/apache/druid/query/MultiValuedDimensionTest.java +++ b/processing/src/test/java/org/apache/druid/query/MultiValuedDimensionTest.java @@ -25,6 +25,7 @@ import com.google.common.collect.ImmutableSet; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.io.Files; +import org.apache.commons.io.FileUtils; import org.apache.druid.collections.CloseableStupidPool; import org.apache.druid.data.input.Row; import org.apache.druid.data.input.impl.CSVParseSpec; @@ -60,7 +61,6 @@ import org.apache.druid.segment.incremental.IncrementalIndex; import org.apache.druid.segment.writeout.OffHeapMemorySegmentWriteOutMediumFactory; import org.apache.druid.segment.writeout.SegmentWriteOutMediumFactory; import org.apache.druid.segment.writeout.TmpFileSegmentWriteOutMediumFactory; -import org.apache.commons.io.FileUtils; import org.junit.After; import org.junit.Before; import org.junit.Test; diff --git a/processing/src/test/java/org/apache/druid/query/UnionQueryRunnerTest.java b/processing/src/test/java/org/apache/druid/query/UnionQueryRunnerTest.java index ea0b48d2671..cbe458d87fd 100644 --- a/processing/src/test/java/org/apache/druid/query/UnionQueryRunnerTest.java +++ b/processing/src/test/java/org/apache/druid/query/UnionQueryRunnerTest.java @@ -21,9 +21,9 @@ package org.apache.druid.query; import com.google.common.collect.Iterables; import com.google.common.collect.Maps; +import junit.framework.Assert; import org.apache.druid.java.util.common.guava.Sequence; import org.apache.druid.java.util.common.guava.Sequences; -import junit.framework.Assert; import org.junit.Test; import java.util.Arrays; diff --git a/processing/src/test/java/org/apache/druid/query/aggregation/FilteredAggregatorTest.java b/processing/src/test/java/org/apache/druid/query/aggregation/FilteredAggregatorTest.java index fd27033c6de..53eafd9f22a 100644 --- a/processing/src/test/java/org/apache/druid/query/aggregation/FilteredAggregatorTest.java +++ b/processing/src/test/java/org/apache/druid/query/aggregation/FilteredAggregatorTest.java @@ -39,6 +39,7 @@ import org.apache.druid.query.filter.ValueMatcher; import org.apache.druid.query.monomorphicprocessing.RuntimeShapeInspector; import org.apache.druid.query.ordering.StringComparators; import org.apache.druid.query.search.ContainsSearchQuerySpec; +import org.apache.druid.segment.AbstractDimensionSelector; import org.apache.druid.segment.ColumnSelectorFactory; import org.apache.druid.segment.ColumnValueSelector; import org.apache.druid.segment.DimensionSelector; @@ -95,7 +96,7 @@ public class FilteredAggregatorTest if ("dim".equals(dimensionName)) { return dimensionSpec.decorate( - new DimensionSelector() + new AbstractDimensionSelector() { @Override public IndexedInts getRow() @@ -167,13 +168,6 @@ public class FilteredAggregatorTest }; } - @Nullable - @Override - public Object getObject() - { - return defaultGetObject(); - } - @Override public Class classOfObject() { diff --git a/processing/src/test/java/org/apache/druid/query/aggregation/cardinality/CardinalityAggregatorTest.java b/processing/src/test/java/org/apache/druid/query/aggregation/cardinality/CardinalityAggregatorTest.java index 37d016a3608..01703dfb49d 100644 --- a/processing/src/test/java/org/apache/druid/query/aggregation/cardinality/CardinalityAggregatorTest.java +++ b/processing/src/test/java/org/apache/druid/query/aggregation/cardinality/CardinalityAggregatorTest.java @@ -45,6 +45,7 @@ import org.apache.druid.query.extraction.JavaScriptExtractionFn; import org.apache.druid.query.extraction.RegexDimExtractionFn; import org.apache.druid.query.filter.ValueMatcher; import org.apache.druid.query.monomorphicprocessing.RuntimeShapeInspector; +import org.apache.druid.segment.AbstractDimensionSelector; import org.apache.druid.segment.DimensionSelector; import org.apache.druid.segment.DimensionSelectorUtils; import org.apache.druid.segment.IdLookup; @@ -60,7 +61,7 @@ import java.util.Map; public class CardinalityAggregatorTest { - public static class TestDimensionSelector implements DimensionSelector + public static class TestDimensionSelector extends AbstractDimensionSelector { private final List column; private final Map ids; @@ -194,13 +195,6 @@ public class CardinalityAggregatorTest }; } - @Nullable - @Override - public Object getObject() - { - return defaultGetObject(); - } - @Override public Class classOfObject() { diff --git a/processing/src/test/java/org/apache/druid/query/aggregation/first/DoubleFirstAggregationTest.java b/processing/src/test/java/org/apache/druid/query/aggregation/first/DoubleFirstAggregationTest.java index 13d976b28dd..19ceaa5b4e6 100644 --- a/processing/src/test/java/org/apache/druid/query/aggregation/first/DoubleFirstAggregationTest.java +++ b/processing/src/test/java/org/apache/druid/query/aggregation/first/DoubleFirstAggregationTest.java @@ -29,7 +29,7 @@ import org.apache.druid.query.aggregation.TestDoubleColumnSelectorImpl; import org.apache.druid.query.aggregation.TestLongColumnSelector; import org.apache.druid.query.aggregation.TestObjectColumnSelector; import org.apache.druid.segment.ColumnSelectorFactory; -import org.apache.druid.segment.column.Column; +import org.apache.druid.segment.column.ColumnHolder; import org.easymock.EasyMock; import org.junit.Assert; import org.junit.Before; @@ -64,7 +64,7 @@ public class DoubleFirstAggregationTest valueSelector = new TestDoubleColumnSelectorImpl(doubleValues); objectSelector = new TestObjectColumnSelector<>(pairs); colSelectorFactory = EasyMock.createMock(ColumnSelectorFactory.class); - EasyMock.expect(colSelectorFactory.makeColumnValueSelector(Column.TIME_COLUMN_NAME)).andReturn(timeSelector); + EasyMock.expect(colSelectorFactory.makeColumnValueSelector(ColumnHolder.TIME_COLUMN_NAME)).andReturn(timeSelector); EasyMock.expect(colSelectorFactory.makeColumnValueSelector("nilly")).andReturn(valueSelector); EasyMock.expect(colSelectorFactory.makeColumnValueSelector("billy")).andReturn(objectSelector); EasyMock.replay(colSelectorFactory); diff --git a/processing/src/test/java/org/apache/druid/query/aggregation/first/FloatFirstAggregationTest.java b/processing/src/test/java/org/apache/druid/query/aggregation/first/FloatFirstAggregationTest.java index db7962871a7..1e9721d8319 100644 --- a/processing/src/test/java/org/apache/druid/query/aggregation/first/FloatFirstAggregationTest.java +++ b/processing/src/test/java/org/apache/druid/query/aggregation/first/FloatFirstAggregationTest.java @@ -29,7 +29,7 @@ import org.apache.druid.query.aggregation.TestFloatColumnSelector; import org.apache.druid.query.aggregation.TestLongColumnSelector; import org.apache.druid.query.aggregation.TestObjectColumnSelector; import org.apache.druid.segment.ColumnSelectorFactory; -import org.apache.druid.segment.column.Column; +import org.apache.druid.segment.column.ColumnHolder; import org.easymock.EasyMock; import org.junit.Assert; import org.junit.Before; @@ -64,7 +64,7 @@ public class FloatFirstAggregationTest valueSelector = new TestFloatColumnSelector(floats); objectSelector = new TestObjectColumnSelector<>(pairs); colSelectorFactory = EasyMock.createMock(ColumnSelectorFactory.class); - EasyMock.expect(colSelectorFactory.makeColumnValueSelector(Column.TIME_COLUMN_NAME)).andReturn(timeSelector); + EasyMock.expect(colSelectorFactory.makeColumnValueSelector(ColumnHolder.TIME_COLUMN_NAME)).andReturn(timeSelector); EasyMock.expect(colSelectorFactory.makeColumnValueSelector("nilly")).andReturn(valueSelector); EasyMock.expect(colSelectorFactory.makeColumnValueSelector("billy")).andReturn(objectSelector); EasyMock.replay(colSelectorFactory); diff --git a/processing/src/test/java/org/apache/druid/query/aggregation/first/LongFirstAggregationTest.java b/processing/src/test/java/org/apache/druid/query/aggregation/first/LongFirstAggregationTest.java index f75493607df..4f3df593f13 100644 --- a/processing/src/test/java/org/apache/druid/query/aggregation/first/LongFirstAggregationTest.java +++ b/processing/src/test/java/org/apache/druid/query/aggregation/first/LongFirstAggregationTest.java @@ -28,7 +28,7 @@ import org.apache.druid.query.aggregation.BufferAggregator; import org.apache.druid.query.aggregation.TestLongColumnSelector; import org.apache.druid.query.aggregation.TestObjectColumnSelector; import org.apache.druid.segment.ColumnSelectorFactory; -import org.apache.druid.segment.column.Column; +import org.apache.druid.segment.column.ColumnHolder; import org.easymock.EasyMock; import org.junit.Assert; import org.junit.Before; @@ -63,7 +63,7 @@ public class LongFirstAggregationTest valueSelector = new TestLongColumnSelector(longValues); objectSelector = new TestObjectColumnSelector<>(pairs); colSelectorFactory = EasyMock.createMock(ColumnSelectorFactory.class); - EasyMock.expect(colSelectorFactory.makeColumnValueSelector(Column.TIME_COLUMN_NAME)).andReturn(timeSelector); + EasyMock.expect(colSelectorFactory.makeColumnValueSelector(ColumnHolder.TIME_COLUMN_NAME)).andReturn(timeSelector); EasyMock.expect(colSelectorFactory.makeColumnValueSelector("nilly")).andReturn(valueSelector); EasyMock.expect(colSelectorFactory.makeColumnValueSelector("billy")).andReturn(objectSelector); EasyMock.replay(colSelectorFactory); diff --git a/processing/src/test/java/org/apache/druid/query/aggregation/first/StringFirstAggregationTest.java b/processing/src/test/java/org/apache/druid/query/aggregation/first/StringFirstAggregationTest.java index 1540ce88d8e..c4ae2671bd8 100644 --- a/processing/src/test/java/org/apache/druid/query/aggregation/first/StringFirstAggregationTest.java +++ b/processing/src/test/java/org/apache/druid/query/aggregation/first/StringFirstAggregationTest.java @@ -28,7 +28,7 @@ import org.apache.druid.query.aggregation.SerializablePairLongString; import org.apache.druid.query.aggregation.TestLongColumnSelector; import org.apache.druid.query.aggregation.TestObjectColumnSelector; import org.apache.druid.segment.ColumnSelectorFactory; -import org.apache.druid.segment.column.Column; +import org.apache.druid.segment.column.ColumnHolder; import org.easymock.EasyMock; import org.junit.Assert; import org.junit.Before; @@ -65,7 +65,7 @@ public class StringFirstAggregationTest valueSelector = new TestObjectColumnSelector<>(strings); objectSelector = new TestObjectColumnSelector<>(pairs); colSelectorFactory = EasyMock.createMock(ColumnSelectorFactory.class); - EasyMock.expect(colSelectorFactory.makeColumnValueSelector(Column.TIME_COLUMN_NAME)).andReturn(timeSelector); + EasyMock.expect(colSelectorFactory.makeColumnValueSelector(ColumnHolder.TIME_COLUMN_NAME)).andReturn(timeSelector); EasyMock.expect(colSelectorFactory.makeColumnValueSelector("nilly")).andReturn(valueSelector); EasyMock.expect(colSelectorFactory.makeColumnValueSelector("billy")).andReturn(objectSelector); EasyMock.replay(colSelectorFactory); diff --git a/processing/src/test/java/org/apache/druid/query/aggregation/hyperloglog/HyperUniquesAggregatorFactoryTest.java b/processing/src/test/java/org/apache/druid/query/aggregation/hyperloglog/HyperUniquesAggregatorFactoryTest.java index af76c99df70..0813fd2825b 100644 --- a/processing/src/test/java/org/apache/druid/query/aggregation/hyperloglog/HyperUniquesAggregatorFactoryTest.java +++ b/processing/src/test/java/org/apache/druid/query/aggregation/hyperloglog/HyperUniquesAggregatorFactoryTest.java @@ -22,8 +22,8 @@ package org.apache.druid.query.aggregation.hyperloglog; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.hash.HashFunction; import com.google.common.hash.Hashing; -import org.apache.druid.hll.HLLCV0; import org.apache.druid.hll.HyperLogLogCollector; +import org.apache.druid.hll.VersionZeroHyperLogLogCollector; import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.query.aggregation.AggregatorFactory; import org.apache.druid.segment.TestHelper; @@ -47,7 +47,7 @@ public class HyperUniquesAggregatorFactoryTest public void testDeserializeV0() { Object v0 = aggregatorFactory.deserialize(V0_BASE64); - Assert.assertEquals("deserialized value is HLLCV0", HLLCV0.class, v0.getClass()); + Assert.assertEquals("deserialized value is VersionZeroHyperLogLogCollector", VersionZeroHyperLogLogCollector.class, v0.getClass()); } @Test diff --git a/processing/src/test/java/org/apache/druid/query/aggregation/last/DoubleLastAggregationTest.java b/processing/src/test/java/org/apache/druid/query/aggregation/last/DoubleLastAggregationTest.java index 450d7eeb778..21d6cada819 100644 --- a/processing/src/test/java/org/apache/druid/query/aggregation/last/DoubleLastAggregationTest.java +++ b/processing/src/test/java/org/apache/druid/query/aggregation/last/DoubleLastAggregationTest.java @@ -29,7 +29,7 @@ import org.apache.druid.query.aggregation.TestDoubleColumnSelectorImpl; import org.apache.druid.query.aggregation.TestLongColumnSelector; import org.apache.druid.query.aggregation.TestObjectColumnSelector; import org.apache.druid.segment.ColumnSelectorFactory; -import org.apache.druid.segment.column.Column; +import org.apache.druid.segment.column.ColumnHolder; import org.easymock.EasyMock; import org.junit.Assert; import org.junit.Before; @@ -64,7 +64,7 @@ public class DoubleLastAggregationTest valueSelector = new TestDoubleColumnSelectorImpl(doubles); objectSelector = new TestObjectColumnSelector<>(pairs); colSelectorFactory = EasyMock.createMock(ColumnSelectorFactory.class); - EasyMock.expect(colSelectorFactory.makeColumnValueSelector(Column.TIME_COLUMN_NAME)).andReturn(timeSelector); + EasyMock.expect(colSelectorFactory.makeColumnValueSelector(ColumnHolder.TIME_COLUMN_NAME)).andReturn(timeSelector); EasyMock.expect(colSelectorFactory.makeColumnValueSelector("nilly")).andReturn(valueSelector); EasyMock.expect(colSelectorFactory.makeColumnValueSelector("billy")).andReturn(objectSelector); EasyMock.replay(colSelectorFactory); diff --git a/processing/src/test/java/org/apache/druid/query/aggregation/last/FloatLastAggregationTest.java b/processing/src/test/java/org/apache/druid/query/aggregation/last/FloatLastAggregationTest.java index 1d7a42ec8a9..f094ecf24e6 100644 --- a/processing/src/test/java/org/apache/druid/query/aggregation/last/FloatLastAggregationTest.java +++ b/processing/src/test/java/org/apache/druid/query/aggregation/last/FloatLastAggregationTest.java @@ -29,7 +29,7 @@ import org.apache.druid.query.aggregation.TestFloatColumnSelector; import org.apache.druid.query.aggregation.TestLongColumnSelector; import org.apache.druid.query.aggregation.TestObjectColumnSelector; import org.apache.druid.segment.ColumnSelectorFactory; -import org.apache.druid.segment.column.Column; +import org.apache.druid.segment.column.ColumnHolder; import org.easymock.EasyMock; import org.junit.Assert; import org.junit.Before; @@ -64,7 +64,7 @@ public class FloatLastAggregationTest valueSelector = new TestFloatColumnSelector(floats); objectSelector = new TestObjectColumnSelector<>(pairs); colSelectorFactory = EasyMock.createMock(ColumnSelectorFactory.class); - EasyMock.expect(colSelectorFactory.makeColumnValueSelector(Column.TIME_COLUMN_NAME)).andReturn(timeSelector); + EasyMock.expect(colSelectorFactory.makeColumnValueSelector(ColumnHolder.TIME_COLUMN_NAME)).andReturn(timeSelector); EasyMock.expect(colSelectorFactory.makeColumnValueSelector("nilly")).andReturn(valueSelector); EasyMock.expect(colSelectorFactory.makeColumnValueSelector("billy")).andReturn(objectSelector); EasyMock.replay(colSelectorFactory); diff --git a/processing/src/test/java/org/apache/druid/query/aggregation/last/LongLastAggregationTest.java b/processing/src/test/java/org/apache/druid/query/aggregation/last/LongLastAggregationTest.java index 63fdec7e179..1324bee261d 100644 --- a/processing/src/test/java/org/apache/druid/query/aggregation/last/LongLastAggregationTest.java +++ b/processing/src/test/java/org/apache/druid/query/aggregation/last/LongLastAggregationTest.java @@ -28,7 +28,7 @@ import org.apache.druid.query.aggregation.BufferAggregator; import org.apache.druid.query.aggregation.TestLongColumnSelector; import org.apache.druid.query.aggregation.TestObjectColumnSelector; import org.apache.druid.segment.ColumnSelectorFactory; -import org.apache.druid.segment.column.Column; +import org.apache.druid.segment.column.ColumnHolder; import org.easymock.EasyMock; import org.junit.Assert; import org.junit.Before; @@ -63,7 +63,7 @@ public class LongLastAggregationTest valueSelector = new TestLongColumnSelector(longValues); objectSelector = new TestObjectColumnSelector<>(pairs); colSelectorFactory = EasyMock.createMock(ColumnSelectorFactory.class); - EasyMock.expect(colSelectorFactory.makeColumnValueSelector(Column.TIME_COLUMN_NAME)).andReturn(timeSelector); + EasyMock.expect(colSelectorFactory.makeColumnValueSelector(ColumnHolder.TIME_COLUMN_NAME)).andReturn(timeSelector); EasyMock.expect(colSelectorFactory.makeColumnValueSelector("nilly")).andReturn(valueSelector); EasyMock.expect(colSelectorFactory.makeColumnValueSelector("billy")).andReturn(objectSelector); EasyMock.replay(colSelectorFactory); diff --git a/processing/src/test/java/org/apache/druid/query/aggregation/last/StringLastAggregationTest.java b/processing/src/test/java/org/apache/druid/query/aggregation/last/StringLastAggregationTest.java index 99d7e0de2b3..2e22f9cfcf7 100644 --- a/processing/src/test/java/org/apache/druid/query/aggregation/last/StringLastAggregationTest.java +++ b/processing/src/test/java/org/apache/druid/query/aggregation/last/StringLastAggregationTest.java @@ -28,7 +28,7 @@ import org.apache.druid.query.aggregation.SerializablePairLongString; import org.apache.druid.query.aggregation.TestLongColumnSelector; import org.apache.druid.query.aggregation.TestObjectColumnSelector; import org.apache.druid.segment.ColumnSelectorFactory; -import org.apache.druid.segment.column.Column; +import org.apache.druid.segment.column.ColumnHolder; import org.easymock.EasyMock; import org.junit.Assert; import org.junit.Before; @@ -65,7 +65,7 @@ public class StringLastAggregationTest valueSelector = new TestObjectColumnSelector<>(strings); objectSelector = new TestObjectColumnSelector<>(pairs); colSelectorFactory = EasyMock.createMock(ColumnSelectorFactory.class); - EasyMock.expect(colSelectorFactory.makeColumnValueSelector(Column.TIME_COLUMN_NAME)).andReturn(timeSelector); + EasyMock.expect(colSelectorFactory.makeColumnValueSelector(ColumnHolder.TIME_COLUMN_NAME)).andReturn(timeSelector); EasyMock.expect(colSelectorFactory.makeColumnValueSelector("nilly")).andReturn(valueSelector); EasyMock.expect(colSelectorFactory.makeColumnValueSelector("billy")).andReturn(objectSelector); EasyMock.replay(colSelectorFactory); diff --git a/processing/src/test/java/org/apache/druid/query/dimension/TestDimensionSelector.java b/processing/src/test/java/org/apache/druid/query/dimension/TestDimensionSelector.java index 4bd192a1adc..1a70662e8ab 100644 --- a/processing/src/test/java/org/apache/druid/query/dimension/TestDimensionSelector.java +++ b/processing/src/test/java/org/apache/druid/query/dimension/TestDimensionSelector.java @@ -22,11 +22,11 @@ package org.apache.druid.query.dimension; import com.google.common.base.Predicate; import org.apache.druid.query.filter.ValueMatcher; import org.apache.druid.query.monomorphicprocessing.RuntimeShapeInspector; -import org.apache.druid.segment.DimensionSelector; +import org.apache.druid.segment.AbstractDimensionSelector; import org.apache.druid.segment.DimensionSelectorUtils; import org.apache.druid.segment.IdLookup; -import org.apache.druid.segment.data.IndexedInts; import org.apache.druid.segment.data.ArrayBasedIndexedInts; +import org.apache.druid.segment.data.IndexedInts; import javax.annotation.Nullable; @@ -35,7 +35,7 @@ import javax.annotation.Nullable; * encoding 0 -> a, 1 -> b, ... * row -> [c,e,g] */ -class TestDimensionSelector implements DimensionSelector +class TestDimensionSelector extends AbstractDimensionSelector { public static final TestDimensionSelector instance = new TestDimensionSelector(); @@ -94,13 +94,6 @@ class TestDimensionSelector implements DimensionSelector }; } - @Nullable - @Override - public Object getObject() - { - return defaultGetObject(); - } - @Override public Class classOfObject() { diff --git a/processing/src/test/java/org/apache/druid/query/filter/GetDimensionRangeSetTest.java b/processing/src/test/java/org/apache/druid/query/filter/GetDimensionRangeSetTest.java index d51bf5374a6..63e672fa63f 100644 --- a/processing/src/test/java/org/apache/druid/query/filter/GetDimensionRangeSetTest.java +++ b/processing/src/test/java/org/apache/druid/query/filter/GetDimensionRangeSetTest.java @@ -29,7 +29,7 @@ import org.apache.druid.js.JavaScriptConfig; import org.apache.druid.query.extraction.IdentityExtractionFn; import org.apache.druid.query.ordering.StringComparators; import org.apache.druid.query.search.ContainsSearchQuerySpec; -import org.apache.druid.segment.column.Column; +import org.apache.druid.segment.column.ColumnHolder; import org.junit.Assert; import org.junit.Test; @@ -66,7 +66,7 @@ public class GetDimensionRangeSetTest private final DimFilter other3 = new SearchQueryDimFilter("dim", new ContainsSearchQuerySpec("a", true), null); private final DimFilter interval1 = new IntervalDimFilter( - Column.TIME_COLUMN_NAME, + ColumnHolder.TIME_COLUMN_NAME, Arrays.asList( Intervals.of("1970-01-01T00:00:00.001Z/1970-01-01T00:00:00.004Z"), Intervals.of("1975-01-01T00:00:00.001Z/1980-01-01T00:00:00.004Z") @@ -115,7 +115,7 @@ public class GetDimensionRangeSetTest Assert.assertNull(other2.getDimensionRangeSet("someOtherDim")); Assert.assertNull(other3.getDimensionRangeSet("dim")); - Assert.assertNull(interval1.getDimensionRangeSet(Column.TIME_COLUMN_NAME)); + Assert.assertNull(interval1.getDimensionRangeSet(ColumnHolder.TIME_COLUMN_NAME)); Assert.assertNull(interval2.getDimensionRangeSet("dim1")); } diff --git a/processing/src/test/java/org/apache/druid/query/filter/IntervalDimFilterTest.java b/processing/src/test/java/org/apache/druid/query/filter/IntervalDimFilterTest.java index 8a1903b05ee..75271449b71 100644 --- a/processing/src/test/java/org/apache/druid/query/filter/IntervalDimFilterTest.java +++ b/processing/src/test/java/org/apache/druid/query/filter/IntervalDimFilterTest.java @@ -27,7 +27,7 @@ import org.apache.druid.guice.GuiceInjectors; import org.apache.druid.guice.annotations.Json; import org.apache.druid.java.util.common.Intervals; import org.apache.druid.query.extraction.RegexDimExtractionFn; -import org.apache.druid.segment.column.Column; +import org.apache.druid.segment.column.ColumnHolder; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -50,7 +50,7 @@ public class IntervalDimFilterTest public void testSerde() throws IOException { DimFilter intervalFilter = new IntervalDimFilter( - Column.TIME_COLUMN_NAME, + ColumnHolder.TIME_COLUMN_NAME, Arrays.asList( Intervals.of("1970-01-01T00:00:00.001Z/1970-01-01T00:00:00.004Z"), Intervals.of("1975-01-01T00:00:00.001Z/1980-01-01T00:00:00.004Z") @@ -62,7 +62,7 @@ public class IntervalDimFilterTest Assert.assertEquals(intervalFilter, actualFilter); intervalFilter = new IntervalDimFilter( - Column.TIME_COLUMN_NAME, + ColumnHolder.TIME_COLUMN_NAME, Arrays.asList( Intervals.of("1970-01-01T00:00:00.001Z/1970-01-01T00:00:00.004Z"), Intervals.of("1975-01-01T00:00:00.001Z/1980-01-01T00:00:00.004Z") @@ -79,7 +79,7 @@ public class IntervalDimFilterTest public void testGetCacheKey() { DimFilter intervalFilter1 = new IntervalDimFilter( - Column.TIME_COLUMN_NAME, + ColumnHolder.TIME_COLUMN_NAME, Arrays.asList( Intervals.of("1970-01-01T00:00:00.001Z/1970-01-01T00:00:00.004Z"), Intervals.of("1975-01-01T00:00:00.001Z/1980-01-01T00:00:00.004Z") @@ -88,7 +88,7 @@ public class IntervalDimFilterTest ); DimFilter intervalFilter2 = new IntervalDimFilter( - Column.TIME_COLUMN_NAME, + ColumnHolder.TIME_COLUMN_NAME, Arrays.asList( Intervals.of("1970-01-01T00:00:00.001Z/1970-01-01T00:00:00.004Z"), Intervals.of("1976-01-01T00:00:00.001Z/1980-01-01T00:00:00.004Z") @@ -99,7 +99,7 @@ public class IntervalDimFilterTest RegexDimExtractionFn regexFn = new RegexDimExtractionFn(".*", false, null); DimFilter intervalFilter3 = new IntervalDimFilter( - Column.TIME_COLUMN_NAME, + ColumnHolder.TIME_COLUMN_NAME, Arrays.asList( Intervals.of("1970-01-01T00:00:00.001Z/1970-01-01T00:00:00.004Z"), Intervals.of("1975-01-01T00:00:00.001Z/1980-01-01T00:00:00.004Z") @@ -107,7 +107,7 @@ public class IntervalDimFilterTest regexFn ); DimFilter intervalFilter4 = new IntervalDimFilter( - Column.TIME_COLUMN_NAME, + ColumnHolder.TIME_COLUMN_NAME, Arrays.asList( Intervals.of("1970-01-01T00:00:00.001Z/1970-01-01T00:00:00.004Z"), Intervals.of("1976-01-01T00:00:00.001Z/1980-01-01T00:00:00.004Z") @@ -123,7 +123,7 @@ public class IntervalDimFilterTest RegexDimExtractionFn regexFn = new RegexDimExtractionFn(".*", false, null); DimFilter intervalFilter1 = new IntervalDimFilter( - Column.TIME_COLUMN_NAME, + ColumnHolder.TIME_COLUMN_NAME, Arrays.asList( Intervals.of("1970-01-01T00:00:00.001Z/1970-01-01T00:00:00.004Z"), Intervals.of("1975-01-01T00:00:00.001Z/1980-01-01T00:00:00.004Z") @@ -132,7 +132,7 @@ public class IntervalDimFilterTest ); DimFilter intervalFilter2 = new IntervalDimFilter( - Column.TIME_COLUMN_NAME, + ColumnHolder.TIME_COLUMN_NAME, Arrays.asList( Intervals.of("1970-01-01T00:00:00.001Z/1970-01-01T00:00:00.004Z"), Intervals.of("1975-01-01T00:00:00.001Z/1980-01-01T00:00:00.004Z") @@ -141,7 +141,7 @@ public class IntervalDimFilterTest ); DimFilter intervalFilter3 = new IntervalDimFilter( - Column.TIME_COLUMN_NAME, + ColumnHolder.TIME_COLUMN_NAME, Arrays.asList( Intervals.of("1970-01-01T00:00:00.001Z/1970-01-01T00:00:00.004Z"), Intervals.of("1977-01-01T00:00:00.001Z/1980-01-01T00:00:00.004Z") @@ -153,7 +153,7 @@ public class IntervalDimFilterTest Assert.assertNotEquals(intervalFilter1.hashCode(), intervalFilter3.hashCode()); DimFilter intervalFilter4 = new IntervalDimFilter( - Column.TIME_COLUMN_NAME, + ColumnHolder.TIME_COLUMN_NAME, Arrays.asList( Intervals.of("1970-01-01T00:00:00.001Z/1970-01-01T00:00:00.004Z"), Intervals.of("1975-01-01T00:00:00.001Z/1977-01-01T00:00:00.004Z"), @@ -181,7 +181,7 @@ public class IntervalDimFilterTest RegexDimExtractionFn regexFn = new RegexDimExtractionFn(".*", false, null); DimFilter intervalFilter1 = new IntervalDimFilter( - Column.TIME_COLUMN_NAME, + ColumnHolder.TIME_COLUMN_NAME, Arrays.asList( Intervals.of("1970-01-01T00:00:00.001Z/1970-01-01T00:00:00.004Z"), Intervals.of("1975-01-01T00:00:00.001Z/1980-01-01T00:00:00.004Z") @@ -190,7 +190,7 @@ public class IntervalDimFilterTest ); DimFilter intervalFilter2 = new IntervalDimFilter( - Column.TIME_COLUMN_NAME, + ColumnHolder.TIME_COLUMN_NAME, Arrays.asList( Intervals.of("1970-01-01T00:00:00.001Z/1970-01-01T00:00:00.004Z"), Intervals.of("1975-01-01T00:00:00.001Z/1980-01-01T00:00:00.004Z") @@ -199,7 +199,7 @@ public class IntervalDimFilterTest ); DimFilter intervalFilter3 = new IntervalDimFilter( - Column.TIME_COLUMN_NAME, + ColumnHolder.TIME_COLUMN_NAME, Arrays.asList( Intervals.of("1970-01-01T00:00:00.001Z/1970-01-01T00:00:00.004Z"), Intervals.of("1977-01-01T00:00:00.001Z/1980-01-01T00:00:00.004Z") @@ -211,7 +211,7 @@ public class IntervalDimFilterTest Assert.assertNotEquals(intervalFilter1, intervalFilter3); DimFilter intervalFilter4 = new IntervalDimFilter( - Column.TIME_COLUMN_NAME, + ColumnHolder.TIME_COLUMN_NAME, Arrays.asList( Intervals.of("1970-01-01T00:00:00.001Z/1970-01-01T00:00:00.004Z"), Intervals.of("1975-01-01T00:00:00.001Z/1977-01-01T00:00:00.004Z"), @@ -236,13 +236,13 @@ public class IntervalDimFilterTest public void testGetRequiredColumns() { DimFilter intervalFilter = new IntervalDimFilter( - Column.TIME_COLUMN_NAME, + ColumnHolder.TIME_COLUMN_NAME, Arrays.asList( Intervals.of("1970-01-01T00:00:00.001Z/1970-01-01T00:00:00.004Z"), Intervals.of("1975-01-01T00:00:00.001Z/1980-01-01T00:00:00.004Z") ), null ); - Assert.assertEquals(intervalFilter.getRequiredColumns(), Sets.newHashSet(Column.TIME_COLUMN_NAME)); + Assert.assertEquals(intervalFilter.getRequiredColumns(), Sets.newHashSet(ColumnHolder.TIME_COLUMN_NAME)); } } diff --git a/processing/src/test/java/org/apache/druid/query/groupby/GroupByLimitPushDownMultiNodeMergeTest.java b/processing/src/test/java/org/apache/druid/query/groupby/GroupByLimitPushDownMultiNodeMergeTest.java index 8e615ae0f97..a409a12360a 100644 --- a/processing/src/test/java/org/apache/druid/query/groupby/GroupByLimitPushDownMultiNodeMergeTest.java +++ b/processing/src/test/java/org/apache/druid/query/groupby/GroupByLimitPushDownMultiNodeMergeTest.java @@ -79,8 +79,8 @@ import org.apache.druid.segment.IndexSpec; import org.apache.druid.segment.QueryableIndex; import org.apache.druid.segment.QueryableIndexSegment; import org.apache.druid.segment.Segment; -import org.apache.druid.segment.column.Column; import org.apache.druid.segment.column.ColumnConfig; +import org.apache.druid.segment.column.ColumnHolder; import org.apache.druid.segment.column.ValueType; import org.apache.druid.segment.incremental.IncrementalIndex; import org.apache.druid.segment.incremental.IncrementalIndexSchema; @@ -640,7 +640,7 @@ public class GroupByLimitPushDownMultiNodeMergeTest .setDimensions( new DefaultDimensionSpec("dimA", "dimA"), new ExtractionDimensionSpec( - Column.TIME_COLUMN_NAME, + ColumnHolder.TIME_COLUMN_NAME, "hour", ValueType.LONG, new TimeFormatExtractionFn( diff --git a/processing/src/test/java/org/apache/druid/query/groupby/GroupByQueryRunnerTest.java b/processing/src/test/java/org/apache/druid/query/groupby/GroupByQueryRunnerTest.java index 7697506dd7d..20a8efd3982 100644 --- a/processing/src/test/java/org/apache/druid/query/groupby/GroupByQueryRunnerTest.java +++ b/processing/src/test/java/org/apache/druid/query/groupby/GroupByQueryRunnerTest.java @@ -121,7 +121,7 @@ import org.apache.druid.query.ordering.StringComparators; import org.apache.druid.query.search.ContainsSearchQuerySpec; import org.apache.druid.query.spec.MultipleIntervalSegmentSpec; import org.apache.druid.segment.TestHelper; -import org.apache.druid.segment.column.Column; +import org.apache.druid.segment.column.ColumnHolder; import org.apache.druid.segment.column.ValueType; import org.apache.druid.segment.virtual.ExpressionVirtualColumn; import org.joda.time.DateTime; @@ -4324,11 +4324,15 @@ public class GroupByQueryRunnerTest .builder() .setDataSource(QueryRunnerTestHelper.dataSource) .setQuerySegmentSpec(QueryRunnerTestHelper.fullOnInterval) - .setDimensions(new DefaultDimensionSpec("market", "market"), new ExtractionDimensionSpec( - Column.TIME_COLUMN_NAME, - Column.TIME_COLUMN_NAME, - new TimeFormatExtractionFn("EEEE", null, null, null, false) - )).setAggregatorSpecs(QueryRunnerTestHelper.rowsCount, QueryRunnerTestHelper.indexDoubleSum) + .setDimensions( + new DefaultDimensionSpec("market", "market"), + new ExtractionDimensionSpec( + ColumnHolder.TIME_COLUMN_NAME, + ColumnHolder.TIME_COLUMN_NAME, + new TimeFormatExtractionFn("EEEE", null, null, null, false) + ) + ) + .setAggregatorSpecs(QueryRunnerTestHelper.rowsCount, QueryRunnerTestHelper.indexDoubleSum) .setPostAggregatorSpecs(Collections.singletonList(QueryRunnerTestHelper.addRowsIndexConstant)) .setGranularity(QueryRunnerTestHelper.allGran) .setDimFilter( @@ -5100,8 +5104,8 @@ public class GroupByQueryRunnerTest .setGranularity(QueryRunnerTestHelper.dayGran) .build(); - final DimFilter fridayFilter = new SelectorDimFilter(Column.TIME_COLUMN_NAME, "Friday", new TimeFormatExtractionFn("EEEE", null, null, null, false)); - final DimFilter firstDaysFilter = new InDimFilter(Column.TIME_COLUMN_NAME, ImmutableList.of("1", "2", "3"), new TimeFormatExtractionFn("d", null, null, null, false)); + final DimFilter fridayFilter = new SelectorDimFilter(ColumnHolder.TIME_COLUMN_NAME, "Friday", new TimeFormatExtractionFn("EEEE", null, null, null, false)); + final DimFilter firstDaysFilter = new InDimFilter(ColumnHolder.TIME_COLUMN_NAME, ImmutableList.of("1", "2", "3"), new TimeFormatExtractionFn("d", null, null, null, false)); final GroupByQuery query = GroupByQuery .builder() .setDataSource(subquery) @@ -5810,11 +5814,15 @@ public class GroupByQueryRunnerTest .builder() .setDataSource(QueryRunnerTestHelper.dataSource) .setQuerySegmentSpec(QueryRunnerTestHelper.fullOnInterval) - .setDimensions(new DefaultDimensionSpec("market", "market"), new ExtractionDimensionSpec( - Column.TIME_COLUMN_NAME, - "dayOfWeek", - new TimeFormatExtractionFn("EEEE", null, null, null, false) - )).setAggregatorSpecs(QueryRunnerTestHelper.rowsCount, QueryRunnerTestHelper.indexDoubleSum) + .setDimensions( + new DefaultDimensionSpec("market", "market"), + new ExtractionDimensionSpec( + ColumnHolder.TIME_COLUMN_NAME, + "dayOfWeek", + new TimeFormatExtractionFn("EEEE", null, null, null, false) + ) + ) + .setAggregatorSpecs(QueryRunnerTestHelper.rowsCount, QueryRunnerTestHelper.indexDoubleSum) .setPostAggregatorSpecs(Collections.singletonList(QueryRunnerTestHelper.addRowsIndexConstant)) .setGranularity(QueryRunnerTestHelper.allGran) .setDimFilter( @@ -6055,16 +6063,17 @@ public class GroupByQueryRunnerTest .builder() .setDataSource(QueryRunnerTestHelper.dataSource) .setQuerySegmentSpec(QueryRunnerTestHelper.fullOnInterval) - .setDimensions(new DefaultDimensionSpec("market", "market"), new ExtractionDimensionSpec( - Column.TIME_COLUMN_NAME, - "dayOfWeek", - new CascadeExtractionFn( - new ExtractionFn[]{ - new TimeFormatExtractionFn("EEEE", null, null, null, false), - nullWednesdays, - } + .setDimensions( + new DefaultDimensionSpec("market", "market"), + new ExtractionDimensionSpec( + ColumnHolder.TIME_COLUMN_NAME, + "dayOfWeek", + new CascadeExtractionFn( + new ExtractionFn[]{new TimeFormatExtractionFn("EEEE", null, null, null, false), nullWednesdays} + ) ) - )).setAggregatorSpecs(QueryRunnerTestHelper.rowsCount, QueryRunnerTestHelper.indexDoubleSum) + ) + .setAggregatorSpecs(QueryRunnerTestHelper.rowsCount, QueryRunnerTestHelper.indexDoubleSum) .setPostAggregatorSpecs(Collections.singletonList(QueryRunnerTestHelper.addRowsIndexConstant)) .setGranularity(QueryRunnerTestHelper.allGran) .setDimFilter( @@ -6838,22 +6847,15 @@ public class GroupByQueryRunnerTest lookupExtractionFn = new LookupExtractionFn(mapLookupExtractor, false, "EMPTY", true, true); } - GroupByQuery query = GroupByQuery.builder() - .setDataSource(QueryRunnerTestHelper.dataSource) - .setQuerySegmentSpec(QueryRunnerTestHelper.firstToThird) - .setDimensions(new DefaultDimensionSpec("null_column", "alias")) - .setAggregatorSpecs(QueryRunnerTestHelper.rowsCount, - new LongSumAggregatorFactory("idx", "index")) - .setGranularity(QueryRunnerTestHelper.dayGran) - .setDimFilter( - new ExtractionDimFilter( - "null_column", - "EMPTY", - lookupExtractionFn, - null - ) - ) - .build(); + GroupByQuery query = GroupByQuery + .builder() + .setDataSource(QueryRunnerTestHelper.dataSource) + .setQuerySegmentSpec(QueryRunnerTestHelper.firstToThird) + .setDimensions(new DefaultDimensionSpec("null_column", "alias")) + .setAggregatorSpecs(QueryRunnerTestHelper.rowsCount, new LongSumAggregatorFactory("idx", "index")) + .setGranularity(QueryRunnerTestHelper.dayGran) + .setDimFilter(new ExtractionDimFilter("null_column", "EMPTY", lookupExtractionFn, null)) + .build(); List expectedResults = Arrays .asList( GroupByQueryRunnerTestHelper.createExpectedRow("2011-04-01", "alias", null, "rows", 13L, "idx", 6619L), @@ -7646,7 +7648,7 @@ public class GroupByQueryRunnerTest .setDimensions( new DefaultDimensionSpec("qualityLong", "ql_alias"), new DefaultDimensionSpec("qualityFloat", "qf_alias"), - new DefaultDimensionSpec(Column.TIME_COLUMN_NAME, "time_alias") + new DefaultDimensionSpec(ColumnHolder.TIME_COLUMN_NAME, "time_alias") ) .setDimFilter(new SelectorDimFilter("quality", "entertainment", null)) .setAggregatorSpecs(QueryRunnerTestHelper.rowsCount, new LongSumAggregatorFactory("idx", "index")) @@ -8135,12 +8137,15 @@ public class GroupByQueryRunnerTest .builder() .setDataSource(QueryRunnerTestHelper.dataSource) .setQuerySegmentSpec(QueryRunnerTestHelper.firstToThird) - .setDimensions(new DefaultDimensionSpec("quality", "alias"), new ExtractionDimensionSpec( - Column.TIME_COLUMN_NAME, - "time_day", - ValueType.LONG, - new TimeFormatExtractionFn(null, null, null, Granularities.DAY, true) - )) + .setDimensions( + new DefaultDimensionSpec("quality", "alias"), + new ExtractionDimensionSpec( + ColumnHolder.TIME_COLUMN_NAME, + "time_day", + ValueType.LONG, + new TimeFormatExtractionFn(null, null, null, Granularities.DAY, true) + ) + ) .setDimFilter(new SelectorDimFilter("quality", "technology", null)) .setAggregatorSpecs(QueryRunnerTestHelper.rowsCount) .setGranularity(QueryRunnerTestHelper.dayGran) diff --git a/processing/src/test/java/org/apache/druid/query/groupby/GroupByQueryRunnerTestHelper.java b/processing/src/test/java/org/apache/druid/query/groupby/GroupByQueryRunnerTestHelper.java index 5a448a404c1..bef65e7cb6d 100644 --- a/processing/src/test/java/org/apache/druid/query/groupby/GroupByQueryRunnerTestHelper.java +++ b/processing/src/test/java/org/apache/druid/query/groupby/GroupByQueryRunnerTestHelper.java @@ -32,7 +32,7 @@ import org.apache.druid.query.QueryPlus; import org.apache.druid.query.QueryRunner; import org.apache.druid.query.QueryRunnerFactory; import org.apache.druid.query.QueryToolChest; -import org.apache.druid.segment.column.Column; +import org.apache.druid.segment.column.ColumnHolder; import org.joda.time.DateTime; import org.joda.time.chrono.ISOChronology; @@ -76,7 +76,7 @@ public class GroupByQueryRunnerTestHelper public static List createExpectedRows(String[] columnNames, Object[]... values) { - int timeIndex = Arrays.asList(columnNames).indexOf(Column.TIME_COLUMN_NAME); + int timeIndex = Arrays.asList(columnNames).indexOf(ColumnHolder.TIME_COLUMN_NAME); Preconditions.checkArgument(timeIndex >= 0); List expected = Lists.newArrayList(); diff --git a/processing/src/test/java/org/apache/druid/query/scan/MultiSegmentScanQueryTest.java b/processing/src/test/java/org/apache/druid/query/scan/MultiSegmentScanQueryTest.java index 36cfe3e1e77..4d1df19392c 100644 --- a/processing/src/test/java/org/apache/druid/query/scan/MultiSegmentScanQueryTest.java +++ b/processing/src/test/java/org/apache/druid/query/scan/MultiSegmentScanQueryTest.java @@ -23,6 +23,8 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; import com.google.common.io.CharSource; import com.google.common.util.concurrent.MoreExecutors; +import org.apache.commons.io.IOUtils; +import org.apache.commons.lang.StringUtils; import org.apache.druid.java.util.common.DateTimes; import org.apache.druid.java.util.common.granularity.Granularities; import org.apache.druid.java.util.common.guava.MergeSequence; @@ -42,8 +44,6 @@ import org.apache.druid.segment.incremental.IncrementalIndex; import org.apache.druid.segment.incremental.IncrementalIndexSchema; import org.apache.druid.timeline.DataSegment; import org.apache.druid.timeline.partition.NoneShardSpec; -import org.apache.commons.io.IOUtils; -import org.apache.commons.lang.StringUtils; import org.joda.time.Interval; import org.junit.AfterClass; import org.junit.Assert; diff --git a/processing/src/test/java/org/apache/druid/query/scan/ScanQueryRunnerTest.java b/processing/src/test/java/org/apache/druid/query/scan/ScanQueryRunnerTest.java index 5fb8457780f..5943bba7ae0 100644 --- a/processing/src/test/java/org/apache/druid/query/scan/ScanQueryRunnerTest.java +++ b/processing/src/test/java/org/apache/druid/query/scan/ScanQueryRunnerTest.java @@ -45,7 +45,7 @@ import org.apache.druid.query.lookup.LookupExtractionFn; import org.apache.druid.query.spec.LegacySegmentSpec; import org.apache.druid.query.spec.QuerySegmentSpec; import org.apache.druid.segment.VirtualColumn; -import org.apache.druid.segment.column.Column; +import org.apache.druid.segment.column.ColumnHolder; import org.apache.druid.segment.column.ValueType; import org.apache.druid.segment.virtual.ExpressionVirtualColumn; import org.joda.time.DateTime; @@ -235,7 +235,7 @@ public class ScanQueryRunnerTest { ScanQuery query = newTestQuery() .intervals(I_0112_0114) - .columns(Column.TIME_COLUMN_NAME, QueryRunnerTestHelper.marketDimension, QueryRunnerTestHelper.indexMetric) + .columns(ColumnHolder.TIME_COLUMN_NAME, QueryRunnerTestHelper.marketDimension, QueryRunnerTestHelper.indexMetric) .build(); HashMap context = new HashMap(); @@ -629,7 +629,7 @@ public class ScanQueryRunnerTest private String getTimestampName() { - return legacy ? "timestamp" : Column.TIME_COLUMN_NAME; + return legacy ? "timestamp" : ColumnHolder.TIME_COLUMN_NAME; } private List toExpected( diff --git a/processing/src/test/java/org/apache/druid/query/search/SearchQueryRunnerTest.java b/processing/src/test/java/org/apache/druid/query/search/SearchQueryRunnerTest.java index dfc2e8a8525..b4e9127e038 100644 --- a/processing/src/test/java/org/apache/druid/query/search/SearchQueryRunnerTest.java +++ b/processing/src/test/java/org/apache/druid/query/search/SearchQueryRunnerTest.java @@ -54,7 +54,7 @@ import org.apache.druid.query.spec.MultipleIntervalSegmentSpec; import org.apache.druid.segment.QueryableIndexSegment; import org.apache.druid.segment.TestHelper; import org.apache.druid.segment.TestIndex; -import org.apache.druid.segment.column.Column; +import org.apache.druid.segment.column.ColumnHolder; import org.apache.druid.segment.column.ValueType; import org.apache.druid.segment.incremental.IncrementalIndex; import org.apache.druid.segment.incremental.IncrementalIndexSchema; @@ -597,7 +597,7 @@ public class SearchQueryRunnerTest .intervals(QueryRunnerTestHelper.fullOnInterval) .query("Friday") .dimensions(new ExtractionDimensionSpec( - Column.TIME_COLUMN_NAME, + ColumnHolder.TIME_COLUMN_NAME, "__time2", new TimeFormatExtractionFn( "EEEE", @@ -621,7 +621,7 @@ public class SearchQueryRunnerTest SearchQuery searchQuery = Druids.newSearchQueryBuilder() .dimensions( new DefaultDimensionSpec( - Column.TIME_COLUMN_NAME, Column.TIME_COLUMN_NAME, + ColumnHolder.TIME_COLUMN_NAME, ColumnHolder.TIME_COLUMN_NAME, ValueType.LONG ) ) @@ -632,7 +632,7 @@ public class SearchQueryRunnerTest .build(); List expectedHits = new ArrayList<>(); - expectedHits.add(new SearchHit(Column.TIME_COLUMN_NAME, "1297123200000", 13)); + expectedHits.add(new SearchHit(ColumnHolder.TIME_COLUMN_NAME, "1297123200000", 13)); checkSearchQuery(searchQuery, expectedHits); } @@ -645,7 +645,7 @@ public class SearchQueryRunnerTest SearchQuery searchQuery = Druids.newSearchQueryBuilder() .dimensions( new ExtractionDimensionSpec( - Column.TIME_COLUMN_NAME, Column.TIME_COLUMN_NAME, + ColumnHolder.TIME_COLUMN_NAME, ColumnHolder.TIME_COLUMN_NAME, jsExtractionFn ) ) @@ -656,7 +656,7 @@ public class SearchQueryRunnerTest .build(); List expectedHits = new ArrayList<>(); - expectedHits.add(new SearchHit(Column.TIME_COLUMN_NAME, "super-1297123200000", 13)); + expectedHits.add(new SearchHit(ColumnHolder.TIME_COLUMN_NAME, "super-1297123200000", 13)); checkSearchQuery(searchQuery, expectedHits); } diff --git a/processing/src/test/java/org/apache/druid/query/select/MultiSegmentSelectQueryTest.java b/processing/src/test/java/org/apache/druid/query/select/MultiSegmentSelectQueryTest.java index 66722a0eb9d..54ff86733a3 100644 --- a/processing/src/test/java/org/apache/druid/query/select/MultiSegmentSelectQueryTest.java +++ b/processing/src/test/java/org/apache/druid/query/select/MultiSegmentSelectQueryTest.java @@ -25,6 +25,8 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; import com.google.common.io.CharSource; +import org.apache.commons.io.IOUtils; +import org.apache.commons.lang.StringUtils; import org.apache.druid.jackson.DefaultObjectMapper; import org.apache.druid.java.util.common.DateTimes; import org.apache.druid.java.util.common.Intervals; @@ -50,8 +52,6 @@ import org.apache.druid.timeline.TimelineObjectHolder; import org.apache.druid.timeline.VersionedIntervalTimeline; import org.apache.druid.timeline.partition.NoneShardSpec; import org.apache.druid.timeline.partition.SingleElementPartitionChunk; -import org.apache.commons.io.IOUtils; -import org.apache.commons.lang.StringUtils; import org.joda.time.Interval; import org.junit.AfterClass; import org.junit.Assert; diff --git a/processing/src/test/java/org/apache/druid/query/select/SelectQueryRunnerTest.java b/processing/src/test/java/org/apache/druid/query/select/SelectQueryRunnerTest.java index 0574b656b66..edd93b7cb35 100644 --- a/processing/src/test/java/org/apache/druid/query/select/SelectQueryRunnerTest.java +++ b/processing/src/test/java/org/apache/druid/query/select/SelectQueryRunnerTest.java @@ -53,7 +53,7 @@ import org.apache.druid.query.lookup.LookupExtractionFn; import org.apache.druid.query.ordering.StringComparators; import org.apache.druid.query.spec.LegacySegmentSpec; import org.apache.druid.query.spec.QuerySegmentSpec; -import org.apache.druid.segment.column.Column; +import org.apache.druid.segment.column.ColumnHolder; import org.apache.druid.segment.column.ValueType; import org.apache.druid.segment.virtual.ExpressionVirtualColumn; import org.joda.time.DateTime; @@ -688,12 +688,12 @@ public class SelectQueryRunnerTest { List dimSpecs = Arrays.asList( new DefaultDimensionSpec(QueryRunnerTestHelper.indexMetric, "floatIndex", ValueType.FLOAT), - new DefaultDimensionSpec(Column.TIME_COLUMN_NAME, "longTime", ValueType.LONG) + new DefaultDimensionSpec(ColumnHolder.TIME_COLUMN_NAME, "longTime", ValueType.LONG) ); SelectQuery query = newTestQuery() .dimensionSpecs(dimSpecs) - .metrics(Arrays.asList(Column.TIME_COLUMN_NAME, "index")) + .metrics(Arrays.asList(ColumnHolder.TIME_COLUMN_NAME, "index")) .intervals(I_0112_0114) .build(); @@ -716,7 +716,7 @@ public class SelectQueryRunnerTest .put("longTime", 1294790400000L) .put("floatIndex", 100.0f) .put(QueryRunnerTestHelper.indexMetric, 100.000000F) - .put(Column.TIME_COLUMN_NAME, 1294790400000L) + .put(ColumnHolder.TIME_COLUMN_NAME, 1294790400000L) .build() ), new EventHolder( @@ -727,7 +727,7 @@ public class SelectQueryRunnerTest .put("longTime", 1294790400000L) .put("floatIndex", 100.0f) .put(QueryRunnerTestHelper.indexMetric, 100.000000F) - .put(Column.TIME_COLUMN_NAME, 1294790400000L) + .put(ColumnHolder.TIME_COLUMN_NAME, 1294790400000L) .build() ), new EventHolder( @@ -738,7 +738,7 @@ public class SelectQueryRunnerTest .put("longTime", 1294790400000L) .put("floatIndex", 100.0f) .put(QueryRunnerTestHelper.indexMetric, 100.000000F) - .put(Column.TIME_COLUMN_NAME, 1294790400000L) + .put(ColumnHolder.TIME_COLUMN_NAME, 1294790400000L) .build() ) ) @@ -762,7 +762,7 @@ public class SelectQueryRunnerTest .put("longTime", 1294876800000L) .put("floatIndex", 1564.6177f) .put(QueryRunnerTestHelper.indexMetric, 1564.6177f) - .put(Column.TIME_COLUMN_NAME, 1294876800000L) + .put(ColumnHolder.TIME_COLUMN_NAME, 1294876800000L) .build() ), new EventHolder( @@ -773,7 +773,7 @@ public class SelectQueryRunnerTest .put("longTime", 1294876800000L) .put("floatIndex", 826.0602f) .put(QueryRunnerTestHelper.indexMetric, 826.0602f) - .put(Column.TIME_COLUMN_NAME, 1294876800000L) + .put(ColumnHolder.TIME_COLUMN_NAME, 1294876800000L) .build() ), new EventHolder( @@ -784,7 +784,7 @@ public class SelectQueryRunnerTest .put("longTime", 1294876800000L) .put("floatIndex", 1689.0128f) .put(QueryRunnerTestHelper.indexMetric, 1689.0128f) - .put(Column.TIME_COLUMN_NAME, 1294876800000L) + .put(ColumnHolder.TIME_COLUMN_NAME, 1294876800000L) .build() ) ) @@ -803,12 +803,12 @@ public class SelectQueryRunnerTest List dimSpecs = Arrays.asList( new ExtractionDimensionSpec(QueryRunnerTestHelper.indexMetric, "floatIndex", jsExtractionFn), - new ExtractionDimensionSpec(Column.TIME_COLUMN_NAME, "longTime", jsExtractionFn) + new ExtractionDimensionSpec(ColumnHolder.TIME_COLUMN_NAME, "longTime", jsExtractionFn) ); SelectQuery query = newTestQuery() .dimensionSpecs(dimSpecs) - .metrics(Arrays.asList(Column.TIME_COLUMN_NAME, "index")) + .metrics(Arrays.asList(ColumnHolder.TIME_COLUMN_NAME, "index")) .intervals(I_0112_0114) .build(); @@ -831,7 +831,7 @@ public class SelectQueryRunnerTest .put("longTime", "super-1294790400000") .put("floatIndex", "super-100") .put(QueryRunnerTestHelper.indexMetric, 100.000000F) - .put(Column.TIME_COLUMN_NAME, 1294790400000L) + .put(ColumnHolder.TIME_COLUMN_NAME, 1294790400000L) .build() ), new EventHolder( @@ -842,7 +842,7 @@ public class SelectQueryRunnerTest .put("longTime", "super-1294790400000") .put("floatIndex", "super-100") .put(QueryRunnerTestHelper.indexMetric, 100.000000F) - .put(Column.TIME_COLUMN_NAME, 1294790400000L) + .put(ColumnHolder.TIME_COLUMN_NAME, 1294790400000L) .build() ), new EventHolder( @@ -853,7 +853,7 @@ public class SelectQueryRunnerTest .put("longTime", "super-1294790400000") .put("floatIndex", "super-100") .put(QueryRunnerTestHelper.indexMetric, 100.000000F) - .put(Column.TIME_COLUMN_NAME, 1294790400000L) + .put(ColumnHolder.TIME_COLUMN_NAME, 1294790400000L) .build() ) ) @@ -877,7 +877,7 @@ public class SelectQueryRunnerTest .put("longTime", "super-1294876800000") .put("floatIndex", "super-1564.617729") .put(QueryRunnerTestHelper.indexMetric, 1564.6177f) - .put(Column.TIME_COLUMN_NAME, 1294876800000L) + .put(ColumnHolder.TIME_COLUMN_NAME, 1294876800000L) .build() ), new EventHolder( @@ -888,7 +888,7 @@ public class SelectQueryRunnerTest .put("longTime", "super-1294876800000") .put("floatIndex", "super-826.060182") .put(QueryRunnerTestHelper.indexMetric, 826.0602f) - .put(Column.TIME_COLUMN_NAME, 1294876800000L) + .put(ColumnHolder.TIME_COLUMN_NAME, 1294876800000L) .build() ), new EventHolder( @@ -899,7 +899,7 @@ public class SelectQueryRunnerTest .put("longTime", "super-1294876800000") .put("floatIndex", "super-1689.012875") .put(QueryRunnerTestHelper.indexMetric, 1689.0128f) - .put(Column.TIME_COLUMN_NAME, 1294876800000L) + .put(ColumnHolder.TIME_COLUMN_NAME, 1294876800000L) .build() ) ) diff --git a/processing/src/test/java/org/apache/druid/query/timeboundary/TimeBoundaryQueryRunnerTest.java b/processing/src/test/java/org/apache/druid/query/timeboundary/TimeBoundaryQueryRunnerTest.java index 16d30acf513..5c266e135b5 100644 --- a/processing/src/test/java/org/apache/druid/query/timeboundary/TimeBoundaryQueryRunnerTest.java +++ b/processing/src/test/java/org/apache/druid/query/timeboundary/TimeBoundaryQueryRunnerTest.java @@ -23,6 +23,7 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.io.CharSource; +import org.apache.commons.lang.StringUtils; import org.apache.druid.java.util.common.DateTimes; import org.apache.druid.java.util.common.Intervals; import org.apache.druid.java.util.common.granularity.Granularities; @@ -44,7 +45,6 @@ import org.apache.druid.timeline.TimelineObjectHolder; import org.apache.druid.timeline.VersionedIntervalTimeline; import org.apache.druid.timeline.partition.NoneShardSpec; import org.apache.druid.timeline.partition.SingleElementPartitionChunk; -import org.apache.commons.lang.StringUtils; import org.joda.time.DateTime; import org.joda.time.Interval; import org.junit.Assert; diff --git a/processing/src/test/java/org/apache/druid/query/topn/DefaultTopNQueryMetricsTest.java b/processing/src/test/java/org/apache/druid/query/topn/DefaultTopNQueryMetricsTest.java index 23abdb63df5..a9fdda77b89 100644 --- a/processing/src/test/java/org/apache/druid/query/topn/DefaultTopNQueryMetricsTest.java +++ b/processing/src/test/java/org/apache/druid/query/topn/DefaultTopNQueryMetricsTest.java @@ -20,8 +20,8 @@ package org.apache.druid.query.topn; import com.google.common.collect.ImmutableSet; -import org.apache.druid.java.util.emitter.service.ServiceEmitter; import org.apache.druid.java.util.common.granularity.Granularities; +import org.apache.druid.java.util.emitter.service.ServiceEmitter; import org.apache.druid.query.CachingEmitter; import org.apache.druid.query.DefaultQueryMetricsTest; import org.apache.druid.query.DruidMetrics; diff --git a/processing/src/test/java/org/apache/druid/query/topn/PerSegmentQueryOptimizeTest.java b/processing/src/test/java/org/apache/druid/query/topn/PerSegmentQueryOptimizeTest.java index 2d2204f2299..38ec24d89df 100644 --- a/processing/src/test/java/org/apache/druid/query/topn/PerSegmentQueryOptimizeTest.java +++ b/processing/src/test/java/org/apache/druid/query/topn/PerSegmentQueryOptimizeTest.java @@ -27,7 +27,7 @@ import org.apache.druid.query.aggregation.FilteredAggregatorFactory; import org.apache.druid.query.aggregation.LongSumAggregatorFactory; import org.apache.druid.query.aggregation.SuppressedAggregatorFactory; import org.apache.druid.query.filter.IntervalDimFilter; -import org.apache.druid.segment.column.Column; +import org.apache.druid.segment.column.ColumnHolder; import org.joda.time.Interval; import org.junit.Assert; import org.junit.Test; @@ -44,7 +44,7 @@ public class PerSegmentQueryOptimizeTest FilteredAggregatorFactory aggregatorFactory = new FilteredAggregatorFactory( longSumAggregatorFactory, new IntervalDimFilter( - Column.TIME_COLUMN_NAME, + ColumnHolder.TIME_COLUMN_NAME, Collections.singletonList(Intervals.utc(1000, 2000)), null ) @@ -65,7 +65,7 @@ public class PerSegmentQueryOptimizeTest AggregatorFactory expectedPartialFilteredAgg = new FilteredAggregatorFactory( longSumAggregatorFactory, new IntervalDimFilter( - Column.TIME_COLUMN_NAME, + ColumnHolder.TIME_COLUMN_NAME, Collections.singletonList(Intervals.utc(1500, 2000)), null ) diff --git a/processing/src/test/java/org/apache/druid/query/topn/TopNQueryRunnerTest.java b/processing/src/test/java/org/apache/druid/query/topn/TopNQueryRunnerTest.java index d805065b1a7..be47ae5156a 100644 --- a/processing/src/test/java/org/apache/druid/query/topn/TopNQueryRunnerTest.java +++ b/processing/src/test/java/org/apache/druid/query/topn/TopNQueryRunnerTest.java @@ -88,7 +88,7 @@ import org.apache.druid.query.lookup.LookupExtractionFn; import org.apache.druid.query.ordering.StringComparators; import org.apache.druid.query.spec.MultipleIntervalSegmentSpec; import org.apache.druid.segment.TestHelper; -import org.apache.druid.segment.column.Column; +import org.apache.druid.segment.column.ColumnHolder; import org.apache.druid.segment.column.ValueType; import org.apache.druid.segment.virtual.ExpressionVirtualColumn; import org.junit.AfterClass; @@ -3853,7 +3853,7 @@ public class TopNQueryRunnerTest .granularity(QueryRunnerTestHelper.allGran) .dimension( new ExtractionDimensionSpec( - Column.TIME_COLUMN_NAME, + ColumnHolder.TIME_COLUMN_NAME, "dayOfWeek", new TimeFormatExtractionFn("EEEE", null, null, null, false) ) @@ -5067,7 +5067,7 @@ public class TopNQueryRunnerTest TopNQuery query = new TopNQueryBuilder() .dataSource(QueryRunnerTestHelper.dataSource) .granularity(QueryRunnerTestHelper.allGran) - .dimension(new DefaultDimensionSpec(Column.TIME_COLUMN_NAME, "time_alias", ValueType.LONG)) + .dimension(new DefaultDimensionSpec(ColumnHolder.TIME_COLUMN_NAME, "time_alias", ValueType.LONG)) .metric("maxIndex") .threshold(4) .intervals(QueryRunnerTestHelper.fullOnInterval) @@ -5274,7 +5274,7 @@ public class TopNQueryRunnerTest TopNQuery query = new TopNQueryBuilder() .dataSource(QueryRunnerTestHelper.dataSource) .granularity(QueryRunnerTestHelper.allGran) - .dimension(new ExtractionDimensionSpec(Column.TIME_COLUMN_NAME, "time_alias", jsExtractionFn)) + .dimension(new ExtractionDimensionSpec(ColumnHolder.TIME_COLUMN_NAME, "time_alias", jsExtractionFn)) .metric("maxIndex") .threshold(4) .intervals(QueryRunnerTestHelper.fullOnInterval) @@ -5749,7 +5749,7 @@ public class TopNQueryRunnerTest .dataSource(QueryRunnerTestHelper.dataSource) .granularity(QueryRunnerTestHelper.allGran) .filters(new BoundDimFilter( - Column.TIME_COLUMN_NAME, + ColumnHolder.TIME_COLUMN_NAME, "0", String.valueOf(Long.MAX_VALUE), true, diff --git a/processing/src/test/java/org/apache/druid/segment/ConciseBitmapIndexMergerV9Test.java b/processing/src/test/java/org/apache/druid/segment/ConciseBitmapIndexMergerV9Test.java index e0dc642f423..9bad930b200 100644 --- a/processing/src/test/java/org/apache/druid/segment/ConciseBitmapIndexMergerV9Test.java +++ b/processing/src/test/java/org/apache/druid/segment/ConciseBitmapIndexMergerV9Test.java @@ -19,10 +19,10 @@ package org.apache.druid.segment; -import org.apache.druid.segment.writeout.SegmentWriteOutMediumFactory; import org.apache.druid.segment.data.CompressionFactory.LongEncodingStrategy; import org.apache.druid.segment.data.CompressionStrategy; import org.apache.druid.segment.data.ConciseBitmapSerdeFactory; +import org.apache.druid.segment.writeout.SegmentWriteOutMediumFactory; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; diff --git a/processing/src/test/java/org/apache/druid/segment/DictionaryMergeIteratorTest.java b/processing/src/test/java/org/apache/druid/segment/DictionaryMergeIteratorTest.java index fce6c858f9a..c4bf8361b54 100644 --- a/processing/src/test/java/org/apache/druid/segment/DictionaryMergeIteratorTest.java +++ b/processing/src/test/java/org/apache/druid/segment/DictionaryMergeIteratorTest.java @@ -20,8 +20,8 @@ package org.apache.druid.segment; import com.google.common.collect.Iterators; -import org.apache.druid.segment.data.ArrayIndexed; import org.apache.druid.segment.data.Indexed; +import org.apache.druid.segment.data.ListIndexed; import org.junit.Assert; import org.junit.Test; @@ -39,11 +39,11 @@ public class DictionaryMergeIteratorTest String[] s3 = {"a", "d", "f"}; // 0 3 5 String[] s4 = {"a", "b", "c"}; String[] s5 = {"a", "b", "c", "d", "e", "f"}; - Indexed i1 = new ArrayIndexed(s1, String.class); - Indexed i2 = new ArrayIndexed(s2, String.class); - Indexed i3 = new ArrayIndexed(s3, String.class); - Indexed i4 = new ArrayIndexed(s4, String.class); - Indexed i5 = new ArrayIndexed(s5, String.class); + Indexed i1 = new ListIndexed(s1); + Indexed i2 = new ListIndexed(s2); + Indexed i3 = new ListIndexed(s3); + Indexed i4 = new ListIndexed(s4); + Indexed i5 = new ListIndexed(s5); IndexMerger.DictionaryMergeIterator iterator = new IndexMerger.DictionaryMergeIterator(new Indexed[]{i1, i2, i3, i4, i5}, false); diff --git a/processing/src/test/java/org/apache/druid/segment/EmptyIndexTest.java b/processing/src/test/java/org/apache/druid/segment/EmptyIndexTest.java index d63d3a382b2..4f9f8bc7acd 100644 --- a/processing/src/test/java/org/apache/druid/segment/EmptyIndexTest.java +++ b/processing/src/test/java/org/apache/druid/segment/EmptyIndexTest.java @@ -21,16 +21,16 @@ package org.apache.druid.segment; import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; +import org.apache.commons.io.FileUtils; import org.apache.druid.collections.bitmap.ConciseBitmapFactory; import org.apache.druid.java.util.common.Intervals; import org.apache.druid.query.aggregation.AggregatorFactory; -import org.apache.druid.segment.column.Column; +import org.apache.druid.segment.column.ColumnHolder; import org.apache.druid.segment.incremental.IncrementalIndex; import org.apache.druid.segment.incremental.IncrementalIndexAdapter; import org.apache.druid.segment.writeout.OffHeapMemorySegmentWriteOutMediumFactory; import org.apache.druid.segment.writeout.SegmentWriteOutMediumFactory; import org.apache.druid.segment.writeout.TmpFileSegmentWriteOutMediumFactory; -import org.apache.commons.io.FileUtils; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; @@ -98,7 +98,7 @@ public class EmptyIndexTest Assert.assertEquals( "getReadOnlyTimestamps", 0, - emptyQueryableIndex.getColumn(Column.TIME_COLUMN_NAME).getLength() + emptyQueryableIndex.getColumnHolder(ColumnHolder.TIME_COLUMN_NAME).getLength() ); } finally { diff --git a/processing/src/test/java/org/apache/druid/segment/IndexMergerNullHandlingTest.java b/processing/src/test/java/org/apache/druid/segment/IndexMergerNullHandlingTest.java index 8db4364e0b6..61dc753e778 100644 --- a/processing/src/test/java/org/apache/druid/segment/IndexMergerNullHandlingTest.java +++ b/processing/src/test/java/org/apache/druid/segment/IndexMergerNullHandlingTest.java @@ -30,7 +30,7 @@ import org.apache.druid.java.util.common.ISE; import org.apache.druid.java.util.common.guava.Comparators; import org.apache.druid.query.aggregation.AggregatorFactory; import org.apache.druid.segment.column.BitmapIndex; -import org.apache.druid.segment.column.Column; +import org.apache.druid.segment.column.ColumnHolder; import org.apache.druid.segment.column.DictionaryEncodedColumn; import org.apache.druid.segment.data.IncrementalIndexTest; import org.apache.druid.segment.incremental.IncrementalIndex; @@ -117,13 +117,13 @@ public class IndexMergerNullHandlingTest final File tempDir = temporaryFolder.newFolder(); try (QueryableIndex index = indexIO.loadIndex(indexMerger.persist(toPersist, tempDir, indexSpec, null))) { - final Column column = index.getColumn("d"); + final ColumnHolder columnHolder = index.getColumnHolder("d"); if (subsetList.stream().allMatch(nullFlavors::contains)) { // all null -> should be missing - Assert.assertNull(subsetList.toString(), column); + Assert.assertNull(subsetList.toString(), columnHolder); } else { - Assert.assertNotNull(subsetList.toString(), column); + Assert.assertNotNull(subsetList.toString(), columnHolder); // The column has multiple values if there are any lists with > 1 element in the input set. final boolean hasMultipleValues = subsetList.stream() @@ -141,7 +141,8 @@ public class IndexMergerNullHandlingTest } } - try (final DictionaryEncodedColumn dictionaryColumn = column.getDictionaryEncoding()) { + try (final DictionaryEncodedColumn dictionaryColumn = + (DictionaryEncodedColumn) columnHolder.getColumn()) { // Verify unique values against the dictionary. Assert.assertEquals( subsetList.toString(), @@ -174,7 +175,7 @@ public class IndexMergerNullHandlingTest ); // Verify that the bitmap index for null is correct. - final BitmapIndex bitmapIndex = column.getBitmapIndex(); + final BitmapIndex bitmapIndex = columnHolder.getBitmapIndex(); // Read through the column to find all the rows that should match null. final List expectedNullRows = new ArrayList<>(); diff --git a/processing/src/test/java/org/apache/druid/segment/IndexMergerTestBase.java b/processing/src/test/java/org/apache/druid/segment/IndexMergerTestBase.java index f29035e6bb9..d19af352d40 100644 --- a/processing/src/test/java/org/apache/druid/segment/IndexMergerTestBase.java +++ b/processing/src/test/java/org/apache/druid/segment/IndexMergerTestBase.java @@ -26,6 +26,7 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Lists; import com.google.common.collect.Sets; +import it.unimi.dsi.fastutil.ints.IntIterator; import org.apache.druid.collections.bitmap.RoaringBitmapFactory; import org.apache.druid.common.config.NullHandling; import org.apache.druid.data.input.InputRow; @@ -44,10 +45,10 @@ import org.apache.druid.java.util.common.io.smoosh.SmooshedFileMapper; import org.apache.druid.query.aggregation.AggregatorFactory; import org.apache.druid.query.aggregation.CountAggregatorFactory; import org.apache.druid.query.aggregation.LongSumAggregatorFactory; -import org.apache.druid.segment.column.Column; import org.apache.druid.segment.column.ColumnCapabilitiesImpl; +import org.apache.druid.segment.column.ColumnHolder; import org.apache.druid.segment.column.DictionaryEncodedColumn; -import org.apache.druid.segment.column.SimpleDictionaryEncodedColumn; +import org.apache.druid.segment.column.StringDictionaryEncodedColumn; import org.apache.druid.segment.data.BitmapSerdeFactory; import org.apache.druid.segment.data.BitmapValues; import org.apache.druid.segment.data.CompressionFactory; @@ -58,7 +59,6 @@ import org.apache.druid.segment.incremental.IncrementalIndex; import org.apache.druid.segment.incremental.IncrementalIndexAdapter; import org.apache.druid.segment.incremental.IncrementalIndexSchema; import org.apache.druid.segment.writeout.SegmentWriteOutMediumFactory; -import it.unimi.dsi.fastutil.ints.IntIterator; import org.joda.time.Interval; import org.junit.Assert; import org.junit.Rule; @@ -168,7 +168,7 @@ public class IndexMergerTestBase indexIO.loadIndex(indexMerger.persist(toPersist, tempDir, indexSpec, null)) ); - Assert.assertEquals(2, index.getColumn(Column.TIME_COLUMN_NAME).getLength()); + Assert.assertEquals(2, index.getColumnHolder(ColumnHolder.TIME_COLUMN_NAME).getLength()); Assert.assertEquals(Arrays.asList("dim1", "dim2"), Lists.newArrayList(index.getAvailableDimensions())); Assert.assertEquals(3, index.getColumnNames().size()); @@ -209,7 +209,7 @@ public class IndexMergerTestBase indexIO.loadIndex(indexMerger.persist(toPersist, tempDir, indexSpec, null)) ); - Assert.assertEquals(2, index.getColumn(Column.TIME_COLUMN_NAME).getLength()); + Assert.assertEquals(2, index.getColumnHolder(ColumnHolder.TIME_COLUMN_NAME).getLength()); Assert.assertEquals(Arrays.asList("dim1", "dim2"), Lists.newArrayList(index.getAvailableDimensions())); Assert.assertEquals(3, index.getColumnNames().size()); assertDimCompression(index, indexSpec.getDimensionCompression()); @@ -245,7 +245,7 @@ public class IndexMergerTestBase indexIO.loadIndex(indexMerger.persist(toPersist, tempDir, indexSpec, null)) ); - Assert.assertEquals(2, index.getColumn(Column.TIME_COLUMN_NAME).getLength()); + Assert.assertEquals(2, index.getColumnHolder(ColumnHolder.TIME_COLUMN_NAME).getLength()); Assert.assertEquals(Arrays.asList("dim1", "dim2"), Lists.newArrayList(index.getAvailableDimensions())); Assert.assertEquals(3, index.getColumnNames().size()); @@ -299,7 +299,7 @@ public class IndexMergerTestBase indexIO.loadIndex(indexMerger.persist(toPersist1, tempDir1, indexSpec, null)) ); - Assert.assertEquals(2, index1.getColumn(Column.TIME_COLUMN_NAME).getLength()); + Assert.assertEquals(2, index1.getColumnHolder(ColumnHolder.TIME_COLUMN_NAME).getLength()); Assert.assertEquals(Arrays.asList("dim1", "dim2"), Lists.newArrayList(index1.getAvailableDimensions())); Assert.assertEquals(3, index1.getColumnNames().size()); @@ -307,7 +307,7 @@ public class IndexMergerTestBase indexIO.loadIndex(indexMerger.persist(toPersist2, tempDir2, indexSpec, null)) ); - Assert.assertEquals(2, index2.getColumn(Column.TIME_COLUMN_NAME).getLength()); + Assert.assertEquals(2, index2.getColumnHolder(ColumnHolder.TIME_COLUMN_NAME).getLength()); Assert.assertEquals(Arrays.asList("dim1", "dim2"), Lists.newArrayList(index2.getAvailableDimensions())); Assert.assertEquals(3, index2.getColumnNames().size()); @@ -327,7 +327,7 @@ public class IndexMergerTestBase ) ); - Assert.assertEquals(3, merged.getColumn(Column.TIME_COLUMN_NAME).getLength()); + Assert.assertEquals(3, merged.getColumnHolder(ColumnHolder.TIME_COLUMN_NAME).getLength()); Assert.assertEquals(Arrays.asList("dim1", "dim2"), Lists.newArrayList(merged.getAvailableDimensions())); Assert.assertEquals(3, merged.getColumnNames().size()); assertDimCompression(index2, indexSpec.getDimensionCompression()); @@ -392,13 +392,13 @@ public class IndexMergerTestBase ) ); - Assert.assertEquals(1, index1.getColumn(Column.TIME_COLUMN_NAME).getLength()); + Assert.assertEquals(1, index1.getColumnHolder(ColumnHolder.TIME_COLUMN_NAME).getLength()); Assert.assertEquals(ImmutableList.of("dim2"), ImmutableList.copyOf(index1.getAvailableDimensions())); - Assert.assertEquals(1, index2.getColumn(Column.TIME_COLUMN_NAME).getLength()); + Assert.assertEquals(1, index2.getColumnHolder(ColumnHolder.TIME_COLUMN_NAME).getLength()); Assert.assertEquals(ImmutableList.of("dim2"), ImmutableList.copyOf(index2.getAvailableDimensions())); - Assert.assertEquals(2, merged.getColumn(Column.TIME_COLUMN_NAME).getLength()); + Assert.assertEquals(2, merged.getColumnHolder(ColumnHolder.TIME_COLUMN_NAME).getLength()); Assert.assertEquals(ImmutableList.of("dim2"), ImmutableList.copyOf(merged.getAvailableDimensions())); assertDimCompression(index1, indexSpec.getDimensionCompression()); @@ -431,7 +431,7 @@ public class IndexMergerTestBase indexIO.validateTwoSegments(incrementalAdapter, queryableAdapter); - Assert.assertEquals(2, index1.getColumn(Column.TIME_COLUMN_NAME).getLength()); + Assert.assertEquals(2, index1.getColumnHolder(ColumnHolder.TIME_COLUMN_NAME).getLength()); Assert.assertEquals(Arrays.asList("dim1", "dim2"), Lists.newArrayList(index1.getAvailableDimensions())); Assert.assertEquals(3, index1.getColumnNames().size()); @@ -449,7 +449,7 @@ public class IndexMergerTestBase ) ); - Assert.assertEquals(2, merged.getColumn(Column.TIME_COLUMN_NAME).getLength()); + Assert.assertEquals(2, merged.getColumnHolder(ColumnHolder.TIME_COLUMN_NAME).getLength()); Assert.assertEquals(Arrays.asList("dim1", "dim2"), Lists.newArrayList(merged.getAvailableDimensions())); Assert.assertEquals(3, merged.getColumnNames().size()); @@ -482,7 +482,7 @@ public class IndexMergerTestBase indexIO.validateTwoSegments(incrementalAdapter, queryableAdapter); - Assert.assertEquals(2, index1.getColumn(Column.TIME_COLUMN_NAME).getLength()); + Assert.assertEquals(2, index1.getColumnHolder(ColumnHolder.TIME_COLUMN_NAME).getLength()); Assert.assertEquals(Arrays.asList("dim1", "dim2"), Lists.newArrayList(index1.getAvailableDimensions())); Assert.assertEquals(3, index1.getColumnNames().size()); @@ -505,7 +505,7 @@ public class IndexMergerTestBase ) ); - Assert.assertEquals(2, merged.getColumn(Column.TIME_COLUMN_NAME).getLength()); + Assert.assertEquals(2, merged.getColumnHolder(ColumnHolder.TIME_COLUMN_NAME).getLength()); Assert.assertEquals(Arrays.asList("dim1", "dim2"), Lists.newArrayList(merged.getAvailableDimensions())); Assert.assertEquals(3, merged.getColumnNames().size()); @@ -545,7 +545,7 @@ public class IndexMergerTestBase indexIO.validateTwoSegments(incrementalAdapter, queryableAdapter); - Assert.assertEquals(2, index1.getColumn(Column.TIME_COLUMN_NAME).getLength()); + Assert.assertEquals(2, index1.getColumnHolder(ColumnHolder.TIME_COLUMN_NAME).getLength()); Assert.assertEquals(Arrays.asList("dim1", "dim2"), Lists.newArrayList(index1.getAvailableDimensions())); Assert.assertEquals(3, index1.getColumnNames().size()); @@ -576,7 +576,7 @@ public class IndexMergerTestBase ) ); - Assert.assertEquals(2, merged.getColumn(Column.TIME_COLUMN_NAME).getLength()); + Assert.assertEquals(2, merged.getColumnHolder(ColumnHolder.TIME_COLUMN_NAME).getLength()); Assert.assertEquals(Arrays.asList("dim1", "dim2"), Lists.newArrayList(merged.getAvailableDimensions())); Assert.assertEquals(3, merged.getColumnNames().size()); @@ -619,7 +619,7 @@ public class IndexMergerTestBase indexIO.validateTwoSegments(incrementalAdapter, queryableAdapter); - Assert.assertEquals(2, index1.getColumn(Column.TIME_COLUMN_NAME).getLength()); + Assert.assertEquals(2, index1.getColumnHolder(ColumnHolder.TIME_COLUMN_NAME).getLength()); Assert.assertEquals(Arrays.asList("dim1", "dim2"), Lists.newArrayList(index1.getAvailableDimensions())); Assert.assertEquals(4, index1.getColumnNames().size()); @@ -628,7 +628,7 @@ public class IndexMergerTestBase indexIO.loadIndex(indexMerger.convert(tempDir1, convertDir, indexSpec)) ); - Assert.assertEquals(2, converted.getColumn(Column.TIME_COLUMN_NAME).getLength()); + Assert.assertEquals(2, converted.getColumnHolder(ColumnHolder.TIME_COLUMN_NAME).getLength()); Assert.assertEquals(Arrays.asList("dim1", "dim2"), Lists.newArrayList(converted.getAvailableDimensions())); Assert.assertEquals(4, converted.getColumnNames().size()); @@ -677,7 +677,7 @@ public class IndexMergerTestBase indexIO.validateTwoSegments(incrementalAdapter, queryableAdapter); - Assert.assertEquals(2, index1.getColumn(Column.TIME_COLUMN_NAME).getLength()); + Assert.assertEquals(2, index1.getColumnHolder(ColumnHolder.TIME_COLUMN_NAME).getLength()); Assert.assertEquals(Arrays.asList("dim1", "dim2"), Lists.newArrayList(index1.getAvailableDimensions())); Assert.assertEquals(4, index1.getColumnNames().size()); @@ -699,7 +699,7 @@ public class IndexMergerTestBase indexIO.loadIndex(indexMerger.convert(tempDir1, convertDir, newSpec)) ); - Assert.assertEquals(2, converted.getColumn(Column.TIME_COLUMN_NAME).getLength()); + Assert.assertEquals(2, converted.getColumnHolder(ColumnHolder.TIME_COLUMN_NAME).getLength()); Assert.assertEquals(Arrays.asList("dim1", "dim2"), Lists.newArrayList(converted.getAvailableDimensions())); Assert.assertEquals(4, converted.getColumnNames().size()); @@ -722,15 +722,15 @@ public class IndexMergerTestBase return; } - DictionaryEncodedColumn encodedColumn = index.getColumn("dim2").getDictionaryEncoding(); + DictionaryEncodedColumn encodedColumn = (DictionaryEncodedColumn) index.getColumnHolder("dim2").getColumn(); Object obj; if (encodedColumn.hasMultipleValues()) { - Field field = SimpleDictionaryEncodedColumn.class.getDeclaredField("multiValueColumn"); + Field field = StringDictionaryEncodedColumn.class.getDeclaredField("multiValueColumn"); field.setAccessible(true); obj = field.get(encodedColumn); } else { - Field field = SimpleDictionaryEncodedColumn.class.getDeclaredField("column"); + Field field = StringDictionaryEncodedColumn.class.getDeclaredField("column"); field.setAccessible(true); obj = field.get(encodedColumn); @@ -2070,7 +2070,7 @@ public class IndexMergerTestBase adapter = new QueryableIndexIndexableAdapter(index); rowList = RowIteratorHelper.toList(adapter.getRows()); - Assert.assertEquals(2, index.getColumn(Column.TIME_COLUMN_NAME).getLength()); + Assert.assertEquals(2, index.getColumnHolder(ColumnHolder.TIME_COLUMN_NAME).getLength()); Assert.assertEquals(Arrays.asList("dim1", "dim2"), Lists.newArrayList(index.getAvailableDimensions())); Assert.assertEquals(3, index.getColumnNames().size()); @@ -2102,7 +2102,7 @@ public class IndexMergerTestBase schema = makeDimensionSchemas(Arrays.asList("dim1", "dim2"), MultiValueHandling.SORTED_SET); index = persistAndLoad(schema, rows); - Assert.assertEquals(1, index.getColumn(Column.TIME_COLUMN_NAME).getLength()); + Assert.assertEquals(1, index.getColumnHolder(ColumnHolder.TIME_COLUMN_NAME).getLength()); Assert.assertEquals(Arrays.asList("dim1", "dim2"), Lists.newArrayList(index.getAvailableDimensions())); Assert.assertEquals(3, index.getColumnNames().size()); @@ -2133,7 +2133,7 @@ public class IndexMergerTestBase schema = makeDimensionSchemas(Arrays.asList("dim1", "dim2"), MultiValueHandling.ARRAY); index = persistAndLoad(schema, rows); - Assert.assertEquals(2, index.getColumn(Column.TIME_COLUMN_NAME).getLength()); + Assert.assertEquals(2, index.getColumnHolder(ColumnHolder.TIME_COLUMN_NAME).getLength()); Assert.assertEquals(Arrays.asList("dim1", "dim2"), Lists.newArrayList(index.getAvailableDimensions())); Assert.assertEquals(3, index.getColumnNames().size()); @@ -2190,7 +2190,7 @@ public class IndexMergerTestBase ) ); - Assert.assertEquals(3, index.getColumn(Column.TIME_COLUMN_NAME).getLength()); + Assert.assertEquals(3, index.getColumnHolder(ColumnHolder.TIME_COLUMN_NAME).getLength()); Assert.assertEquals( Arrays.asList("dim1", "dim2"), Lists.newArrayList(index.getAvailableDimensions()) diff --git a/processing/src/test/java/org/apache/druid/segment/IndexMergerV9CompatibilityTest.java b/processing/src/test/java/org/apache/druid/segment/IndexMergerV9CompatibilityTest.java index bb5118d9c4d..c25fd76ef7d 100644 --- a/processing/src/test/java/org/apache/druid/segment/IndexMergerV9CompatibilityTest.java +++ b/processing/src/test/java/org/apache/druid/segment/IndexMergerV9CompatibilityTest.java @@ -23,6 +23,7 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.io.ByteSource; import com.google.common.io.Files; +import org.apache.commons.io.FileUtils; import org.apache.druid.data.input.InputRow; import org.apache.druid.data.input.MapBasedInputRow; import org.apache.druid.java.util.common.DateTimes; @@ -37,7 +38,6 @@ import org.apache.druid.segment.incremental.IncrementalIndexSchema; import org.apache.druid.segment.writeout.OffHeapMemorySegmentWriteOutMediumFactory; import org.apache.druid.segment.writeout.SegmentWriteOutMediumFactory; import org.apache.druid.segment.writeout.TmpFileSegmentWriteOutMediumFactory; -import org.apache.commons.io.FileUtils; import org.junit.After; import org.junit.Assert; import org.junit.Before; diff --git a/processing/src/test/java/org/apache/druid/segment/IndexMergerV9WithSpatialIndexTest.java b/processing/src/test/java/org/apache/druid/segment/IndexMergerV9WithSpatialIndexTest.java index dfc2dd7b7b2..18b93087282 100644 --- a/processing/src/test/java/org/apache/druid/segment/IndexMergerV9WithSpatialIndexTest.java +++ b/processing/src/test/java/org/apache/druid/segment/IndexMergerV9WithSpatialIndexTest.java @@ -23,6 +23,7 @@ import com.google.common.base.Throwables; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; import com.google.common.collect.Maps; +import org.apache.commons.io.FileUtils; import org.apache.druid.collections.spatial.search.RadiusBound; import org.apache.druid.collections.spatial.search.RectangularBound; import org.apache.druid.data.input.MapBasedInputRow; @@ -31,7 +32,6 @@ import org.apache.druid.data.input.impl.SpatialDimensionSchema; import org.apache.druid.java.util.common.DateTimes; import org.apache.druid.java.util.common.Intervals; import org.apache.druid.java.util.common.granularity.Granularities; -import org.apache.druid.segment.writeout.SegmentWriteOutMediumFactory; import org.apache.druid.query.Druids; import org.apache.druid.query.FinalizeResultsQueryRunner; import org.apache.druid.query.QueryPlus; @@ -49,7 +49,7 @@ import org.apache.druid.query.timeseries.TimeseriesQueryRunnerFactory; import org.apache.druid.query.timeseries.TimeseriesResultValue; import org.apache.druid.segment.incremental.IncrementalIndex; import org.apache.druid.segment.incremental.IncrementalIndexSchema; -import org.apache.commons.io.FileUtils; +import org.apache.druid.segment.writeout.SegmentWriteOutMediumFactory; import org.joda.time.Interval; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/processing/src/test/java/org/apache/druid/segment/MergeIntIteratorTest.java b/processing/src/test/java/org/apache/druid/segment/MergeIntIteratorTest.java index 5a6cefcf7c3..9f532fef4e0 100644 --- a/processing/src/test/java/org/apache/druid/segment/MergeIntIteratorTest.java +++ b/processing/src/test/java/org/apache/druid/segment/MergeIntIteratorTest.java @@ -34,9 +34,9 @@ import java.util.List; import java.util.NoSuchElementException; import java.util.concurrent.ThreadLocalRandom; -import static org.apache.druid.segment.IntIteratorUtils.mergeAscending; import static it.unimi.dsi.fastutil.ints.IntIterators.EMPTY_ITERATOR; import static java.lang.Integer.MAX_VALUE; +import static org.apache.druid.segment.IntIteratorUtils.mergeAscending; import static org.junit.Assert.assertFalse; import static org.junit.Assert.fail; diff --git a/processing/src/test/java/org/apache/druid/segment/QueryableIndexIndexableAdapterTest.java b/processing/src/test/java/org/apache/druid/segment/QueryableIndexIndexableAdapterTest.java index ccb107080da..6b9117c3cb3 100644 --- a/processing/src/test/java/org/apache/druid/segment/QueryableIndexIndexableAdapterTest.java +++ b/processing/src/test/java/org/apache/druid/segment/QueryableIndexIndexableAdapterTest.java @@ -21,6 +21,7 @@ package org.apache.druid.segment; import com.google.common.collect.ImmutableList; import org.apache.druid.segment.data.BitmapValues; +import org.apache.druid.segment.data.CloseableIndexed; import org.apache.druid.segment.data.CompressionFactory; import org.apache.druid.segment.data.CompressionStrategy; import org.apache.druid.segment.data.ConciseBitmapSerdeFactory; @@ -96,9 +97,11 @@ public class QueryableIndexIndexableAdapterTest String dimension = "dim1"; @SuppressWarnings("UnusedAssignment") //null is added to all dimensions with value BitmapValues bitmapValues = adapter.getBitmapValues(dimension, 0); - for (int i = 0; i < adapter.getDimValueLookup(dimension).size(); i++) { - bitmapValues = adapter.getBitmapValues(dimension, i); - Assert.assertEquals(1, bitmapValues.size()); + try (CloseableIndexed dimValueLookup = adapter.getDimValueLookup(dimension)) { + for (int i = 0; i < dimValueLookup.size(); i++) { + bitmapValues = adapter.getBitmapValues(dimension, i); + Assert.assertEquals(1, bitmapValues.size()); + } } } } diff --git a/processing/src/test/java/org/apache/druid/segment/RoaringBitmapIndexMergerV9Test.java b/processing/src/test/java/org/apache/druid/segment/RoaringBitmapIndexMergerV9Test.java index 0b88e979093..16298beb6df 100644 --- a/processing/src/test/java/org/apache/druid/segment/RoaringBitmapIndexMergerV9Test.java +++ b/processing/src/test/java/org/apache/druid/segment/RoaringBitmapIndexMergerV9Test.java @@ -19,10 +19,10 @@ package org.apache.druid.segment; -import org.apache.druid.segment.writeout.SegmentWriteOutMediumFactory; import org.apache.druid.segment.data.CompressionFactory.LongEncodingStrategy; import org.apache.druid.segment.data.CompressionStrategy; import org.apache.druid.segment.data.RoaringBitmapSerdeFactory; +import org.apache.druid.segment.writeout.SegmentWriteOutMediumFactory; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; diff --git a/processing/src/test/java/org/apache/druid/segment/data/CompressedColumnarIntsSerializerTest.java b/processing/src/test/java/org/apache/druid/segment/data/CompressedColumnarIntsSerializerTest.java index 9920907abcd..17a7cb19816 100644 --- a/processing/src/test/java/org/apache/druid/segment/data/CompressedColumnarIntsSerializerTest.java +++ b/processing/src/test/java/org/apache/druid/segment/data/CompressedColumnarIntsSerializerTest.java @@ -22,6 +22,8 @@ package org.apache.druid.segment.data; import com.google.common.base.Function; import com.google.common.collect.Iterables; import com.google.common.collect.Sets; +import it.unimi.dsi.fastutil.ints.IntArrayList; +import org.apache.commons.io.IOUtils; import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.java.util.common.guava.CloseQuietly; import org.apache.druid.java.util.common.io.smoosh.FileSmoosher; @@ -31,8 +33,6 @@ import org.apache.druid.java.util.common.io.smoosh.SmooshedWriter; import org.apache.druid.segment.writeout.OffHeapMemorySegmentWriteOutMedium; import org.apache.druid.segment.writeout.SegmentWriteOutMedium; import org.apache.druid.segment.writeout.WriteOutBytes; -import it.unimi.dsi.fastutil.ints.IntArrayList; -import org.apache.commons.io.IOUtils; import org.junit.After; import org.junit.Before; import org.junit.Rule; diff --git a/processing/src/test/java/org/apache/druid/segment/data/CompressedColumnarIntsSupplierTest.java b/processing/src/test/java/org/apache/druid/segment/data/CompressedColumnarIntsSupplierTest.java index 63d3bd31795..a857eb4256c 100644 --- a/processing/src/test/java/org/apache/druid/segment/data/CompressedColumnarIntsSupplierTest.java +++ b/processing/src/test/java/org/apache/druid/segment/data/CompressedColumnarIntsSupplierTest.java @@ -20,11 +20,11 @@ package org.apache.druid.segment.data; import com.google.common.primitives.Longs; +import it.unimi.dsi.fastutil.ints.IntArrays; import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.java.util.common.guava.CloseQuietly; import org.apache.druid.java.util.common.io.Closer; import org.apache.druid.segment.CompressedPools; -import it.unimi.dsi.fastutil.ints.IntArrays; import org.junit.After; import org.junit.Assert; import org.junit.Before; diff --git a/processing/src/test/java/org/apache/druid/segment/data/CompressedFloatsSerdeTest.java b/processing/src/test/java/org/apache/druid/segment/data/CompressedFloatsSerdeTest.java index ef82fcc6d38..7d7bd6f851e 100644 --- a/processing/src/test/java/org/apache/druid/segment/data/CompressedFloatsSerdeTest.java +++ b/processing/src/test/java/org/apache/druid/segment/data/CompressedFloatsSerdeTest.java @@ -21,10 +21,10 @@ package org.apache.druid.segment.data; import com.google.common.base.Supplier; import com.google.common.primitives.Floats; +import it.unimi.dsi.fastutil.ints.IntArrays; import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.java.util.common.guava.CloseQuietly; import org.apache.druid.segment.writeout.OffHeapMemorySegmentWriteOutMedium; -import it.unimi.dsi.fastutil.ints.IntArrays; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/processing/src/test/java/org/apache/druid/segment/data/CompressedLongsSerdeTest.java b/processing/src/test/java/org/apache/druid/segment/data/CompressedLongsSerdeTest.java index 6ba5b7ebb29..0f65d6515b8 100644 --- a/processing/src/test/java/org/apache/druid/segment/data/CompressedLongsSerdeTest.java +++ b/processing/src/test/java/org/apache/druid/segment/data/CompressedLongsSerdeTest.java @@ -21,10 +21,10 @@ package org.apache.druid.segment.data; import com.google.common.base.Supplier; import com.google.common.primitives.Longs; +import it.unimi.dsi.fastutil.ints.IntArrays; import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.java.util.common.guava.CloseQuietly; import org.apache.druid.segment.writeout.OffHeapMemorySegmentWriteOutMedium; -import it.unimi.dsi.fastutil.ints.IntArrays; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/processing/src/test/java/org/apache/druid/segment/data/CompressedVSizeColumnarIntsSerializerTest.java b/processing/src/test/java/org/apache/druid/segment/data/CompressedVSizeColumnarIntsSerializerTest.java index b89ae961bb6..65cda7220a7 100644 --- a/processing/src/test/java/org/apache/druid/segment/data/CompressedVSizeColumnarIntsSerializerTest.java +++ b/processing/src/test/java/org/apache/druid/segment/data/CompressedVSizeColumnarIntsSerializerTest.java @@ -23,6 +23,8 @@ import com.google.common.base.Function; import com.google.common.collect.Iterables; import com.google.common.collect.Sets; import com.google.common.primitives.Ints; +import it.unimi.dsi.fastutil.ints.IntArrayList; +import org.apache.commons.io.IOUtils; import org.apache.druid.java.util.common.guava.CloseQuietly; import org.apache.druid.java.util.common.io.smoosh.FileSmoosher; import org.apache.druid.java.util.common.io.smoosh.Smoosh; @@ -31,8 +33,6 @@ import org.apache.druid.java.util.common.io.smoosh.SmooshedWriter; import org.apache.druid.segment.writeout.OffHeapMemorySegmentWriteOutMedium; import org.apache.druid.segment.writeout.SegmentWriteOutMedium; import org.apache.druid.segment.writeout.WriteOutBytes; -import it.unimi.dsi.fastutil.ints.IntArrayList; -import org.apache.commons.io.IOUtils; import org.junit.After; import org.junit.Before; import org.junit.Rule; diff --git a/processing/src/test/java/org/apache/druid/segment/data/CompressedVSizeColumnarIntsSupplierTest.java b/processing/src/test/java/org/apache/druid/segment/data/CompressedVSizeColumnarIntsSupplierTest.java index 38ae7ff981e..3ba3a67f5f7 100644 --- a/processing/src/test/java/org/apache/druid/segment/data/CompressedVSizeColumnarIntsSupplierTest.java +++ b/processing/src/test/java/org/apache/druid/segment/data/CompressedVSizeColumnarIntsSupplierTest.java @@ -24,12 +24,12 @@ import com.google.common.collect.Iterables; import com.google.common.collect.Sets; import com.google.common.primitives.Ints; import com.google.common.primitives.Longs; +import it.unimi.dsi.fastutil.ints.IntArrayList; +import it.unimi.dsi.fastutil.ints.IntArrays; import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.java.util.common.guava.CloseQuietly; import org.apache.druid.java.util.common.io.Closer; import org.apache.druid.segment.CompressedPools; -import it.unimi.dsi.fastutil.ints.IntArrayList; -import it.unimi.dsi.fastutil.ints.IntArrays; import org.junit.After; import org.junit.Assert; import org.junit.Before; diff --git a/processing/src/test/java/org/apache/druid/segment/data/V3CompressedVSizeColumnarMultiIntsSerializerTest.java b/processing/src/test/java/org/apache/druid/segment/data/V3CompressedVSizeColumnarMultiIntsSerializerTest.java index 8234131243f..feff69533ff 100644 --- a/processing/src/test/java/org/apache/druid/segment/data/V3CompressedVSizeColumnarMultiIntsSerializerTest.java +++ b/processing/src/test/java/org/apache/druid/segment/data/V3CompressedVSizeColumnarMultiIntsSerializerTest.java @@ -24,6 +24,7 @@ import com.google.common.collect.Iterables; import com.google.common.collect.Ordering; import com.google.common.collect.Sets; import com.google.common.primitives.Ints; +import org.apache.commons.io.IOUtils; import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.java.util.common.guava.CloseQuietly; import org.apache.druid.java.util.common.io.smoosh.FileSmoosher; @@ -33,7 +34,6 @@ import org.apache.druid.java.util.common.io.smoosh.SmooshedWriter; import org.apache.druid.segment.writeout.OffHeapMemorySegmentWriteOutMedium; import org.apache.druid.segment.writeout.SegmentWriteOutMedium; import org.apache.druid.segment.writeout.WriteOutBytes; -import org.apache.commons.io.IOUtils; import org.junit.Before; import org.junit.Rule; import org.junit.Test; diff --git a/processing/src/test/java/org/apache/druid/segment/data/VSizeColumnarIntsSerializerTest.java b/processing/src/test/java/org/apache/druid/segment/data/VSizeColumnarIntsSerializerTest.java index 8456448ca69..29d7cb6f2a0 100644 --- a/processing/src/test/java/org/apache/druid/segment/data/VSizeColumnarIntsSerializerTest.java +++ b/processing/src/test/java/org/apache/druid/segment/data/VSizeColumnarIntsSerializerTest.java @@ -20,10 +20,10 @@ package org.apache.druid.segment.data; import com.google.common.primitives.Ints; +import org.apache.commons.io.IOUtils; import org.apache.druid.segment.writeout.OffHeapMemorySegmentWriteOutMedium; import org.apache.druid.segment.writeout.SegmentWriteOutMedium; import org.apache.druid.segment.writeout.WriteOutBytes; -import org.apache.commons.io.IOUtils; import org.junit.After; import org.junit.Before; import org.junit.Test; diff --git a/processing/src/test/java/org/apache/druid/segment/filter/BaseFilterTest.java b/processing/src/test/java/org/apache/druid/segment/filter/BaseFilterTest.java index 7fc66b42f82..313f729f98a 100644 --- a/processing/src/test/java/org/apache/druid/segment/filter/BaseFilterTest.java +++ b/processing/src/test/java/org/apache/druid/segment/filter/BaseFilterTest.java @@ -180,62 +180,20 @@ public abstract class BaseFilterTest ); final Map>> finishers = ImmutableMap.of( - "incremental", new Function>() - { - @Override - public Pair apply(IndexBuilder input) - { - final IncrementalIndex index = input.buildIncrementalIndex(); - return Pair.of( - new IncrementalIndexStorageAdapter(index), - new Closeable() - { - @Override - public void close() - { - index.close(); - } - } - ); - } + "incremental", + input -> { + final IncrementalIndex index = input.buildIncrementalIndex(); + return Pair.of(new IncrementalIndexStorageAdapter(index), index); }, - "mmapped", new Function>() - { - @Override - public Pair apply(IndexBuilder input) - { - final QueryableIndex index = input.buildMMappedIndex(); - return Pair.of( - new QueryableIndexStorageAdapter(index), - new Closeable() - { - @Override - public void close() - { - index.close(); - } - } - ); - } + "mmapped", + input -> { + final QueryableIndex index = input.buildMMappedIndex(); + return Pair.of(new QueryableIndexStorageAdapter(index), index); }, - "mmappedMerged", new Function>() - { - @Override - public Pair apply(IndexBuilder input) - { - final QueryableIndex index = input.buildMMappedMergedIndex(); - return Pair.of( - new QueryableIndexStorageAdapter(index), - new Closeable() - { - @Override - public void close() - { - index.close(); - } - } - ); - } + "mmappedMerged", + input -> { + final QueryableIndex index = input.buildMMappedMergedIndex(); + return Pair.of(new QueryableIndexStorageAdapter(index), index); } ); diff --git a/processing/src/test/java/org/apache/druid/segment/filter/ExpressionFilterTest.java b/processing/src/test/java/org/apache/druid/segment/filter/ExpressionFilterTest.java index 6759fd0b17f..8abc51c35a2 100644 --- a/processing/src/test/java/org/apache/druid/segment/filter/ExpressionFilterTest.java +++ b/processing/src/test/java/org/apache/druid/segment/filter/ExpressionFilterTest.java @@ -22,8 +22,8 @@ package org.apache.druid.segment.filter; import com.google.common.base.Function; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; -import org.apache.druid.common.config.NullHandling; import com.google.common.collect.Sets; +import org.apache.druid.common.config.NullHandling; import org.apache.druid.data.input.InputRow; import org.apache.druid.data.input.impl.DimensionsSpec; import org.apache.druid.data.input.impl.FloatDimensionSchema; diff --git a/processing/src/test/java/org/apache/druid/segment/filter/ExtractionDimFilterTest.java b/processing/src/test/java/org/apache/druid/segment/filter/ExtractionDimFilterTest.java index 6a89e4cdeec..50d123f85b4 100644 --- a/processing/src/test/java/org/apache/druid/segment/filter/ExtractionDimFilterTest.java +++ b/processing/src/test/java/org/apache/druid/segment/filter/ExtractionDimFilterTest.java @@ -34,12 +34,14 @@ import org.apache.druid.query.filter.DimFilters; import org.apache.druid.query.filter.ExtractionDimFilter; import org.apache.druid.query.filter.Filter; import org.apache.druid.query.filter.SelectorDimFilter; +import org.apache.druid.query.monomorphicprocessing.RuntimeShapeInspector; import org.apache.druid.segment.column.BitmapIndex; -import org.apache.druid.segment.data.ArrayIndexed; import org.apache.druid.segment.data.BitmapSerdeFactory; +import org.apache.druid.segment.data.CloseableIndexed; import org.apache.druid.segment.data.ConciseBitmapSerdeFactory; import org.apache.druid.segment.data.GenericIndexed; import org.apache.druid.segment.data.Indexed; +import org.apache.druid.segment.data.ListIndexed; import org.apache.druid.segment.data.RoaringBitmapSerdeFactory; import org.apache.druid.segment.serde.BitmapIndexColumnPartSupplier; import org.junit.Assert; @@ -47,7 +49,9 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; +import javax.annotation.Nullable; import java.util.Collections; +import java.util.Iterator; import java.util.Map; /** @@ -91,10 +95,54 @@ public class ExtractionDimFilterTest private final BitmapIndexSelector BITMAP_INDEX_SELECTOR = new BitmapIndexSelector() { @Override - public Indexed getDimensionValues(String dimension) + public CloseableIndexed getDimensionValues(String dimension) { final String[] vals = DIM_VALS.get(dimension); - return vals == null ? null : new ArrayIndexed(vals, String.class); + if (vals == null) { + return null; + } else { + Indexed indexed = new ListIndexed<>(vals); + return new CloseableIndexed() + { + + @Override + public int size() + { + return indexed.size(); + } + + @Nullable + @Override + public String get(int index) + { + return indexed.get(index); + } + + @Override + public int indexOf(@Nullable String value) + { + return indexed.indexOf(value); + } + + @Override + public void inspectRuntimeShape(RuntimeShapeInspector inspector) + { + inspector.visit("indexed", indexed); + } + + @Override + public void close() + { + // close nothing + } + + @Override + public Iterator iterator() + { + return indexed.iterator(); + } + }; + } } @Override diff --git a/processing/src/test/java/org/apache/druid/segment/filter/FiltersTest.java b/processing/src/test/java/org/apache/druid/segment/filter/FiltersTest.java index b6c53fce9c9..3d27f4d6c5f 100644 --- a/processing/src/test/java/org/apache/druid/segment/filter/FiltersTest.java +++ b/processing/src/test/java/org/apache/druid/segment/filter/FiltersTest.java @@ -20,13 +20,13 @@ package org.apache.druid.segment.filter; import com.google.common.collect.Lists; +import it.unimi.dsi.fastutil.ints.IntIterators; import org.apache.druid.collections.bitmap.BitmapFactory; import org.apache.druid.collections.bitmap.ConciseBitmapFactory; import org.apache.druid.collections.bitmap.ImmutableBitmap; import org.apache.druid.collections.bitmap.MutableBitmap; import org.apache.druid.segment.IntIteratorUtils; import org.apache.druid.segment.column.BitmapIndex; -import it.unimi.dsi.fastutil.ints.IntIterators; import org.junit.Test; import java.util.List; diff --git a/processing/src/test/java/org/apache/druid/segment/filter/SpatialFilterBonusTest.java b/processing/src/test/java/org/apache/druid/segment/filter/SpatialFilterBonusTest.java index 120ad1e7c11..af76178c0e5 100644 --- a/processing/src/test/java/org/apache/druid/segment/filter/SpatialFilterBonusTest.java +++ b/processing/src/test/java/org/apache/druid/segment/filter/SpatialFilterBonusTest.java @@ -32,7 +32,6 @@ import org.apache.druid.java.util.common.DateTimes; import org.apache.druid.java.util.common.Intervals; import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.java.util.common.granularity.Granularities; -import org.apache.druid.segment.writeout.SegmentWriteOutMediumFactory; import org.apache.druid.query.Druids; import org.apache.druid.query.FinalizeResultsQueryRunner; import org.apache.druid.query.QueryPlus; @@ -59,6 +58,7 @@ import org.apache.druid.segment.Segment; import org.apache.druid.segment.TestHelper; import org.apache.druid.segment.incremental.IncrementalIndex; import org.apache.druid.segment.incremental.IncrementalIndexSchema; +import org.apache.druid.segment.writeout.SegmentWriteOutMediumFactory; import org.joda.time.Interval; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/processing/src/test/java/org/apache/druid/segment/filter/SpatialFilterTest.java b/processing/src/test/java/org/apache/druid/segment/filter/SpatialFilterTest.java index 143d3851f00..59688540bc0 100644 --- a/processing/src/test/java/org/apache/druid/segment/filter/SpatialFilterTest.java +++ b/processing/src/test/java/org/apache/druid/segment/filter/SpatialFilterTest.java @@ -31,7 +31,6 @@ import org.apache.druid.data.input.impl.SpatialDimensionSchema; import org.apache.druid.java.util.common.DateTimes; import org.apache.druid.java.util.common.Intervals; import org.apache.druid.java.util.common.granularity.Granularities; -import org.apache.druid.segment.writeout.OffHeapMemorySegmentWriteOutMediumFactory; import org.apache.druid.query.Druids; import org.apache.druid.query.FinalizeResultsQueryRunner; import org.apache.druid.query.QueryPlus; @@ -57,6 +56,7 @@ import org.apache.druid.segment.Segment; import org.apache.druid.segment.TestHelper; import org.apache.druid.segment.incremental.IncrementalIndex; import org.apache.druid.segment.incremental.IncrementalIndexSchema; +import org.apache.druid.segment.writeout.OffHeapMemorySegmentWriteOutMediumFactory; import org.joda.time.Interval; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/processing/src/test/java/org/apache/druid/segment/filter/TimeFilteringTest.java b/processing/src/test/java/org/apache/druid/segment/filter/TimeFilteringTest.java index d493b841ddc..417256a0501 100644 --- a/processing/src/test/java/org/apache/druid/segment/filter/TimeFilteringTest.java +++ b/processing/src/test/java/org/apache/druid/segment/filter/TimeFilteringTest.java @@ -49,7 +49,7 @@ import org.apache.druid.query.ordering.StringComparators; import org.apache.druid.query.search.ContainsSearchQuerySpec; import org.apache.druid.segment.IndexBuilder; import org.apache.druid.segment.StorageAdapter; -import org.apache.druid.segment.column.Column; +import org.apache.druid.segment.column.ColumnHolder; import org.junit.AfterClass; import org.junit.Test; import org.junit.runner.RunWith; @@ -109,25 +109,25 @@ public class TimeFilteringTest extends BaseFilterTest public void testTimeFilterAsLong() { assertFilterMatches( - new SelectorDimFilter(Column.TIME_COLUMN_NAME, "0", null), + new SelectorDimFilter(ColumnHolder.TIME_COLUMN_NAME, "0", null), ImmutableList.of("0") ); assertFilterMatches( - new SelectorDimFilter(Column.TIME_COLUMN_NAME, "9000", null), + new SelectorDimFilter(ColumnHolder.TIME_COLUMN_NAME, "9000", null), ImmutableList.of() ); assertFilterMatches( - new BoundDimFilter(Column.TIME_COLUMN_NAME, "0", "4", false, false, null, null, StringComparators.NUMERIC), + new BoundDimFilter(ColumnHolder.TIME_COLUMN_NAME, "0", "4", false, false, null, null, StringComparators.NUMERIC), ImmutableList.of("0", "1", "2", "3", "4") ); assertFilterMatches( - new BoundDimFilter(Column.TIME_COLUMN_NAME, "0", "4", true, true, null, null, StringComparators.NUMERIC), + new BoundDimFilter(ColumnHolder.TIME_COLUMN_NAME, "0", "4", true, true, null, null, StringComparators.NUMERIC), ImmutableList.of("1", "2", "3") ); assertFilterMatches( - new InDimFilter(Column.TIME_COLUMN_NAME, Arrays.asList("2", "4", "8"), null), + new InDimFilter(ColumnHolder.TIME_COLUMN_NAME, Arrays.asList("2", "4", "8"), null), ImmutableList.of("2", "4") ); @@ -137,23 +137,23 @@ public class TimeFilteringTest extends BaseFilterTest infilterValues.add(String.valueOf(i * 2)); } assertFilterMatches( - new InDimFilter(Column.TIME_COLUMN_NAME, infilterValues, null), + new InDimFilter(ColumnHolder.TIME_COLUMN_NAME, infilterValues, null), ImmutableList.of("0", "2", "4") ); String jsFn = "function(x) { return(x === 3 || x === 5) }"; assertFilterMatches( - new JavaScriptDimFilter(Column.TIME_COLUMN_NAME, jsFn, null, JavaScriptConfig.getEnabledInstance()), + new JavaScriptDimFilter(ColumnHolder.TIME_COLUMN_NAME, jsFn, null, JavaScriptConfig.getEnabledInstance()), ImmutableList.of("3", "5") ); assertFilterMatches( - new RegexDimFilter(Column.TIME_COLUMN_NAME, "4", null), + new RegexDimFilter(ColumnHolder.TIME_COLUMN_NAME, "4", null), ImmutableList.of("4") ); assertFilterMatches( - new SearchQueryDimFilter(Column.TIME_COLUMN_NAME, new ContainsSearchQuerySpec("2", true), null), + new SearchQueryDimFilter(ColumnHolder.TIME_COLUMN_NAME, new ContainsSearchQuerySpec("2", true), null), ImmutableList.of("2") ); } @@ -172,25 +172,25 @@ public class TimeFilteringTest extends BaseFilterTest LookupExtractionFn exfn = new LookupExtractionFn(mapExtractor, false, "UNKNOWN", false, true); assertFilterMatches( - new SelectorDimFilter(Column.TIME_COLUMN_NAME, "Monday", exfn), + new SelectorDimFilter(ColumnHolder.TIME_COLUMN_NAME, "Monday", exfn), ImmutableList.of("0") ); assertFilterMatches( - new SelectorDimFilter(Column.TIME_COLUMN_NAME, "Notaday", exfn), + new SelectorDimFilter(ColumnHolder.TIME_COLUMN_NAME, "Notaday", exfn), ImmutableList.of() ); assertFilterMatches( - new BoundDimFilter(Column.TIME_COLUMN_NAME, "Fridax", "Fridaz", false, false, null, exfn, StringComparators.ALPHANUMERIC), + new BoundDimFilter(ColumnHolder.TIME_COLUMN_NAME, "Fridax", "Fridaz", false, false, null, exfn, StringComparators.ALPHANUMERIC), ImmutableList.of("4") ); assertFilterMatches( - new BoundDimFilter(Column.TIME_COLUMN_NAME, "Friday", "Friday", true, true, null, exfn, StringComparators.ALPHANUMERIC), + new BoundDimFilter(ColumnHolder.TIME_COLUMN_NAME, "Friday", "Friday", true, true, null, exfn, StringComparators.ALPHANUMERIC), ImmutableList.of() ); assertFilterMatches( - new InDimFilter(Column.TIME_COLUMN_NAME, Arrays.asList("Caturday", "Saturday", "Tuesday"), exfn), + new InDimFilter(ColumnHolder.TIME_COLUMN_NAME, Arrays.asList("Caturday", "Saturday", "Tuesday"), exfn), ImmutableList.of("1", "5") ); @@ -201,23 +201,23 @@ public class TimeFilteringTest extends BaseFilterTest "Hello", "World", "1", "2", "3", "4", "5", "6", "7" ); assertFilterMatches( - new InDimFilter(Column.TIME_COLUMN_NAME, bigList, exfn), + new InDimFilter(ColumnHolder.TIME_COLUMN_NAME, bigList, exfn), ImmutableList.of("1", "5") ); String jsFn = "function(x) { return(x === 'Wednesday' || x === 'Thursday') }"; assertFilterMatches( - new JavaScriptDimFilter(Column.TIME_COLUMN_NAME, jsFn, exfn, JavaScriptConfig.getEnabledInstance()), + new JavaScriptDimFilter(ColumnHolder.TIME_COLUMN_NAME, jsFn, exfn, JavaScriptConfig.getEnabledInstance()), ImmutableList.of("2", "3") ); assertFilterMatches( - new RegexDimFilter(Column.TIME_COLUMN_NAME, ".*day", exfn), + new RegexDimFilter(ColumnHolder.TIME_COLUMN_NAME, ".*day", exfn), ImmutableList.of("0", "1", "2", "3", "4", "5") ); assertFilterMatches( - new SearchQueryDimFilter(Column.TIME_COLUMN_NAME, new ContainsSearchQuerySpec("s", true), exfn), + new SearchQueryDimFilter(ColumnHolder.TIME_COLUMN_NAME, new ContainsSearchQuerySpec("s", true), exfn), ImmutableList.of("1", "2", "3") ); } @@ -233,7 +233,7 @@ public class TimeFilteringTest extends BaseFilterTest false ); assertFilterMatches( - new SelectorDimFilter(Column.TIME_COLUMN_NAME, "Wednesday", exfn), + new SelectorDimFilter(ColumnHolder.TIME_COLUMN_NAME, "Wednesday", exfn), ImmutableList.of("0", "1", "2", "3", "4", "5") ); } @@ -243,7 +243,7 @@ public class TimeFilteringTest extends BaseFilterTest { assertFilterMatches( new IntervalDimFilter( - Column.TIME_COLUMN_NAME, + ColumnHolder.TIME_COLUMN_NAME, Collections.singletonList(Intervals.of("1970-01-01T00:00:00.001Z/1970-01-01T00:00:00.005Z")), null ), @@ -252,7 +252,7 @@ public class TimeFilteringTest extends BaseFilterTest assertFilterMatches( new IntervalDimFilter( - Column.TIME_COLUMN_NAME, + ColumnHolder.TIME_COLUMN_NAME, Arrays.asList( Intervals.of("1970-01-01T00:00:00.000Z/1970-01-01T00:00:00.003Z"), Intervals.of("1970-01-01T00:00:00.004Z/1970-01-01T00:00:00.006Z") @@ -264,7 +264,7 @@ public class TimeFilteringTest extends BaseFilterTest assertFilterMatches( new IntervalDimFilter( - Column.TIME_COLUMN_NAME, + ColumnHolder.TIME_COLUMN_NAME, Arrays.asList( Intervals.of("1970-01-01T00:00:00.000Z/1970-01-01T00:00:00.001Z"), Intervals.of("1970-01-01T00:00:00.003Z/1970-01-01T00:00:00.006Z"), @@ -280,7 +280,7 @@ public class TimeFilteringTest extends BaseFilterTest ExtractionFn exFn = new JavaScriptExtractionFn(timeBoosterJsFn, true, JavaScriptConfig.getEnabledInstance()); assertFilterMatches( new IntervalDimFilter( - Column.TIME_COLUMN_NAME, + ColumnHolder.TIME_COLUMN_NAME, Collections.singletonList(Intervals.of("1970-01-01T02:00:00.001Z/1970-01-01T02:00:00.005Z")), exFn ), diff --git a/processing/src/test/java/org/apache/druid/segment/incremental/IncrementalIndexAdapterTest.java b/processing/src/test/java/org/apache/druid/segment/incremental/IncrementalIndexAdapterTest.java index e74efd6db6c..11182c7140f 100644 --- a/processing/src/test/java/org/apache/druid/segment/incremental/IncrementalIndexAdapterTest.java +++ b/processing/src/test/java/org/apache/druid/segment/incremental/IncrementalIndexAdapterTest.java @@ -24,6 +24,7 @@ import org.apache.druid.segment.IndexSpec; import org.apache.druid.segment.IndexableAdapter; import org.apache.druid.segment.RowIterator; import org.apache.druid.segment.data.BitmapValues; +import org.apache.druid.segment.data.CloseableIndexed; import org.apache.druid.segment.data.CompressionFactory; import org.apache.druid.segment.data.CompressionStrategy; import org.apache.druid.segment.data.ConciseBitmapSerdeFactory; @@ -56,9 +57,11 @@ public class IncrementalIndexAdapterTest INDEX_SPEC.getBitmapSerdeFactory().getBitmapFactory() ); String dimension = "dim1"; - for (int i = 0; i < adapter.getDimValueLookup(dimension).size(); i++) { - BitmapValues bitmapValues = adapter.getBitmapValues(dimension, i); - Assert.assertEquals(1, bitmapValues.size()); + try (CloseableIndexed dimValueLookup = adapter.getDimValueLookup(dimension)) { + for (int i = 0; i < dimValueLookup.size(); i++) { + BitmapValues bitmapValues = adapter.getBitmapValues(dimension, i); + Assert.assertEquals(1, bitmapValues.size()); + } } } diff --git a/processing/src/test/java/org/apache/druid/segment/serde/HyperUniquesSerdeForTest.java b/processing/src/test/java/org/apache/druid/segment/serde/HyperUniquesSerdeForTest.java index 02cef87f179..da141e560f0 100644 --- a/processing/src/test/java/org/apache/druid/segment/serde/HyperUniquesSerdeForTest.java +++ b/processing/src/test/java/org/apache/druid/segment/serde/HyperUniquesSerdeForTest.java @@ -19,32 +19,25 @@ package org.apache.druid.segment.serde; -import com.google.common.collect.Ordering; import com.google.common.hash.HashFunction; -import org.apache.druid.java.util.common.StringUtils; +import it.unimi.dsi.fastutil.bytes.ByteArrays; import org.apache.druid.data.input.InputRow; import org.apache.druid.hll.HyperLogLogCollector; -import org.apache.druid.segment.writeout.SegmentWriteOutMedium; +import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.segment.GenericColumnSerializer; import org.apache.druid.segment.column.ColumnBuilder; import org.apache.druid.segment.data.GenericIndexed; import org.apache.druid.segment.data.ObjectStrategy; +import org.apache.druid.segment.writeout.SegmentWriteOutMedium; import java.nio.ByteBuffer; +import java.util.Comparator; import java.util.List; public class HyperUniquesSerdeForTest extends ComplexMetricSerde { - private static Ordering comparator = new Ordering() - { - @Override - public int compare( - HyperLogLogCollector arg1, HyperLogLogCollector arg2 - ) - { - return arg1.toByteBuffer().compareTo(arg2.toByteBuffer()); - } - }.nullsFirst(); + private static Comparator comparator = + Comparator.nullsFirst(Comparator.comparing(HyperLogLogCollector::toByteBuffer)); private final HashFunction hashFn; @@ -109,7 +102,7 @@ public class HyperUniquesSerdeForTest extends ComplexMetricSerde column = GenericIndexed.read(byteBuffer, getObjectStrategy(), columnBuilder.getFileMapper()); } - columnBuilder.setComplexColumn(new ComplexColumnPartSupplier(getTypeName(), column)); + columnBuilder.setComplexColumnSupplier(new ComplexColumnPartSupplier(getTypeName(), column)); } @Override @@ -135,7 +128,7 @@ public class HyperUniquesSerdeForTest extends ComplexMetricSerde public byte[] toBytes(HyperLogLogCollector collector) { if (collector == null) { - return new byte[]{}; + return ByteArrays.EMPTY_ARRAY; } ByteBuffer val = collector.toByteBuffer(); byte[] retVal = new byte[val.remaining()]; diff --git a/processing/src/test/java/org/apache/druid/segment/serde/LargeColumnSupportedComplexColumnSerializerTest.java b/processing/src/test/java/org/apache/druid/segment/serde/LargeColumnSupportedComplexColumnSerializerTest.java index ccf716d8bb5..b3b45ffc703 100644 --- a/processing/src/test/java/org/apache/druid/segment/serde/LargeColumnSupportedComplexColumnSerializerTest.java +++ b/processing/src/test/java/org/apache/druid/segment/serde/LargeColumnSupportedComplexColumnSerializerTest.java @@ -28,8 +28,8 @@ import org.apache.druid.java.util.common.io.smoosh.SmooshedFileMapper; import org.apache.druid.java.util.common.io.smoosh.SmooshedWriter; import org.apache.druid.query.monomorphicprocessing.RuntimeShapeInspector; import org.apache.druid.segment.ObjectColumnSelector; -import org.apache.druid.segment.column.Column; import org.apache.druid.segment.column.ColumnBuilder; +import org.apache.druid.segment.column.ColumnHolder; import org.apache.druid.segment.column.ComplexColumn; import org.apache.druid.segment.column.ValueType; import org.apache.druid.segment.writeout.OffHeapMemorySegmentWriteOutMedium; @@ -119,8 +119,8 @@ public class LargeColumnSupportedComplexColumnSerializerTest .setFileMapper(mapper); serde.deserializeColumn(mapper.mapFile("test"), builder); - Column column = builder.build(); - ComplexColumn complexColumn = column.getComplexColumn(); + ColumnHolder columnHolder = builder.build(); + ComplexColumn complexColumn = (ComplexColumn) columnHolder.getColumn(); HyperLogLogCollector collector = HyperLogLogCollector.makeLatestCollector(); for (int i = 0; i < aCase; i++) { diff --git a/processing/src/test/java/org/apache/druid/segment/virtual/ExpressionColumnValueSelectorTest.java b/processing/src/test/java/org/apache/druid/segment/virtual/ExpressionColumnValueSelectorTest.java index 65d86051ad0..ae95dbe3b0e 100644 --- a/processing/src/test/java/org/apache/druid/segment/virtual/ExpressionColumnValueSelectorTest.java +++ b/processing/src/test/java/org/apache/druid/segment/virtual/ExpressionColumnValueSelectorTest.java @@ -22,6 +22,7 @@ package org.apache.druid.segment.virtual; import com.google.common.base.Supplier; import org.apache.druid.common.guava.SettableSupplier; import org.apache.druid.query.monomorphicprocessing.RuntimeShapeInspector; +import org.apache.druid.segment.BaseSingleValueDimensionSelector; import org.apache.druid.segment.ColumnValueSelector; import org.apache.druid.segment.DimensionSelector; import org.apache.druid.segment.TestObjectColumnSelector; diff --git a/processing/src/test/java/org/apache/druid/segment/writeout/WriteOutBytesTest.java b/processing/src/test/java/org/apache/druid/segment/writeout/WriteOutBytesTest.java index cc05ab8fd05..0104b54026c 100644 --- a/processing/src/test/java/org/apache/druid/segment/writeout/WriteOutBytesTest.java +++ b/processing/src/test/java/org/apache/druid/segment/writeout/WriteOutBytesTest.java @@ -21,8 +21,8 @@ package org.apache.druid.segment.writeout; import com.google.common.io.Files; import com.google.common.primitives.Ints; -import org.apache.druid.java.util.common.StringUtils; import org.apache.commons.io.IOUtils; +import org.apache.druid.java.util.common.StringUtils; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/server/src/main/java/org/apache/druid/client/AbstractCuratorServerInventoryView.java b/server/src/main/java/org/apache/druid/client/AbstractCuratorServerInventoryView.java index dfb1ac3876c..9e46e9c9ed2 100644 --- a/server/src/main/java/org/apache/druid/client/AbstractCuratorServerInventoryView.java +++ b/server/src/main/java/org/apache/druid/client/AbstractCuratorServerInventoryView.java @@ -23,6 +23,7 @@ import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.base.Function; import com.google.common.base.Throwables; +import org.apache.curator.framework.CuratorFramework; import org.apache.druid.curator.inventory.CuratorInventoryManager; import org.apache.druid.curator.inventory.CuratorInventoryManagerStrategy; import org.apache.druid.curator.inventory.InventoryManagerConfig; @@ -32,7 +33,6 @@ import org.apache.druid.java.util.common.lifecycle.LifecycleStart; import org.apache.druid.java.util.common.lifecycle.LifecycleStop; import org.apache.druid.java.util.emitter.EmittingLogger; import org.apache.druid.timeline.DataSegment; -import org.apache.curator.framework.CuratorFramework; import java.io.IOException; import java.util.Collection; diff --git a/server/src/main/java/org/apache/druid/client/BatchServerInventoryView.java b/server/src/main/java/org/apache/druid/client/BatchServerInventoryView.java index 8160ff7d851..f8b1ef160c1 100644 --- a/server/src/main/java/org/apache/druid/client/BatchServerInventoryView.java +++ b/server/src/main/java/org/apache/druid/client/BatchServerInventoryView.java @@ -28,14 +28,14 @@ import com.google.common.base.Predicates; import com.google.common.collect.Iterables; import com.google.common.collect.Sets; import com.google.inject.Inject; -import org.apache.druid.java.util.emitter.EmittingLogger; +import org.apache.curator.framework.CuratorFramework; import org.apache.druid.guice.ManageLifecycle; import org.apache.druid.java.util.common.ISE; import org.apache.druid.java.util.common.Pair; +import org.apache.druid.java.util.emitter.EmittingLogger; import org.apache.druid.server.coordination.DruidServerMetadata; import org.apache.druid.server.initialization.ZkPathsConfig; import org.apache.druid.timeline.DataSegment; -import org.apache.curator.framework.CuratorFramework; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; diff --git a/server/src/main/java/org/apache/druid/client/BatchServerInventoryViewProvider.java b/server/src/main/java/org/apache/druid/client/BatchServerInventoryViewProvider.java index fff49a7f33e..1686a2f7790 100644 --- a/server/src/main/java/org/apache/druid/client/BatchServerInventoryViewProvider.java +++ b/server/src/main/java/org/apache/druid/client/BatchServerInventoryViewProvider.java @@ -22,9 +22,8 @@ package org.apache.druid.client; import com.fasterxml.jackson.annotation.JacksonInject; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.base.Predicates; - -import org.apache.druid.server.initialization.ZkPathsConfig; import org.apache.curator.framework.CuratorFramework; +import org.apache.druid.server.initialization.ZkPathsConfig; import javax.validation.constraints.NotNull; diff --git a/server/src/main/java/org/apache/druid/client/FilteredBatchServerInventoryViewProvider.java b/server/src/main/java/org/apache/druid/client/FilteredBatchServerInventoryViewProvider.java index bc4127e4a5a..d8df8d17a94 100644 --- a/server/src/main/java/org/apache/druid/client/FilteredBatchServerInventoryViewProvider.java +++ b/server/src/main/java/org/apache/druid/client/FilteredBatchServerInventoryViewProvider.java @@ -22,9 +22,8 @@ package org.apache.druid.client; import com.fasterxml.jackson.annotation.JacksonInject; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.base.Predicates; - -import org.apache.druid.server.initialization.ZkPathsConfig; import org.apache.curator.framework.CuratorFramework; +import org.apache.druid.server.initialization.ZkPathsConfig; import javax.validation.constraints.NotNull; diff --git a/server/src/main/java/org/apache/druid/client/FilteredHttpServerInventoryViewProvider.java b/server/src/main/java/org/apache/druid/client/FilteredHttpServerInventoryViewProvider.java index daa1d9a0346..4b9d4393cdd 100644 --- a/server/src/main/java/org/apache/druid/client/FilteredHttpServerInventoryViewProvider.java +++ b/server/src/main/java/org/apache/druid/client/FilteredHttpServerInventoryViewProvider.java @@ -22,10 +22,10 @@ package org.apache.druid.client; import com.fasterxml.jackson.annotation.JacksonInject; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.base.Predicates; -import org.apache.druid.java.util.http.client.HttpClient; import org.apache.druid.discovery.DruidNodeDiscoveryProvider; import org.apache.druid.guice.annotations.EscalatedClient; import org.apache.druid.guice.annotations.Smile; +import org.apache.druid.java.util.http.client.HttpClient; import javax.validation.constraints.NotNull; diff --git a/server/src/main/java/org/apache/druid/client/FilteredServerInventoryView.java b/server/src/main/java/org/apache/druid/client/FilteredServerInventoryView.java index a03b6920c44..ff7476ded03 100644 --- a/server/src/main/java/org/apache/druid/client/FilteredServerInventoryView.java +++ b/server/src/main/java/org/apache/druid/client/FilteredServerInventoryView.java @@ -20,7 +20,6 @@ package org.apache.druid.client; import com.google.common.base.Predicate; - import org.apache.druid.java.util.common.Pair; import org.apache.druid.server.coordination.DruidServerMetadata; import org.apache.druid.timeline.DataSegment; diff --git a/server/src/main/java/org/apache/druid/client/FilteredSingleServerInventoryViewProvider.java b/server/src/main/java/org/apache/druid/client/FilteredSingleServerInventoryViewProvider.java index 402e31539c7..4ae88a5040c 100644 --- a/server/src/main/java/org/apache/druid/client/FilteredSingleServerInventoryViewProvider.java +++ b/server/src/main/java/org/apache/druid/client/FilteredSingleServerInventoryViewProvider.java @@ -22,9 +22,8 @@ package org.apache.druid.client; import com.fasterxml.jackson.annotation.JacksonInject; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.base.Predicates; - -import org.apache.druid.server.initialization.ZkPathsConfig; import org.apache.curator.framework.CuratorFramework; +import org.apache.druid.server.initialization.ZkPathsConfig; import javax.validation.constraints.NotNull; diff --git a/server/src/main/java/org/apache/druid/client/HttpServerInventoryViewProvider.java b/server/src/main/java/org/apache/druid/client/HttpServerInventoryViewProvider.java index cad81471028..931129270fc 100644 --- a/server/src/main/java/org/apache/druid/client/HttpServerInventoryViewProvider.java +++ b/server/src/main/java/org/apache/druid/client/HttpServerInventoryViewProvider.java @@ -22,10 +22,10 @@ package org.apache.druid.client; import com.fasterxml.jackson.annotation.JacksonInject; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.base.Predicates; -import org.apache.druid.java.util.http.client.HttpClient; import org.apache.druid.discovery.DruidNodeDiscoveryProvider; import org.apache.druid.guice.annotations.EscalatedClient; import org.apache.druid.guice.annotations.Smile; +import org.apache.druid.java.util.http.client.HttpClient; import javax.validation.constraints.NotNull; diff --git a/server/src/main/java/org/apache/druid/client/ResultLevelCacheUtil.java b/server/src/main/java/org/apache/druid/client/ResultLevelCacheUtil.java index 95883080c1d..86e454c5fb7 100644 --- a/server/src/main/java/org/apache/druid/client/ResultLevelCacheUtil.java +++ b/server/src/main/java/org/apache/druid/client/ResultLevelCacheUtil.java @@ -21,8 +21,8 @@ package org.apache.druid.client; import org.apache.druid.client.cache.Cache; import org.apache.druid.client.cache.CacheConfig; -import org.apache.druid.java.util.common.logger.Logger; import org.apache.druid.java.util.common.StringUtils; +import org.apache.druid.java.util.common.logger.Logger; import org.apache.druid.query.CacheStrategy; import org.apache.druid.query.Query; import org.apache.druid.query.QueryContexts; diff --git a/server/src/main/java/org/apache/druid/client/SingleServerInventoryProvider.java b/server/src/main/java/org/apache/druid/client/SingleServerInventoryProvider.java index c72c2ecff73..3e2ad48a335 100644 --- a/server/src/main/java/org/apache/druid/client/SingleServerInventoryProvider.java +++ b/server/src/main/java/org/apache/druid/client/SingleServerInventoryProvider.java @@ -22,9 +22,8 @@ package org.apache.druid.client; import com.fasterxml.jackson.annotation.JacksonInject; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.base.Predicates; - -import org.apache.druid.server.initialization.ZkPathsConfig; import org.apache.curator.framework.CuratorFramework; +import org.apache.druid.server.initialization.ZkPathsConfig; import javax.validation.constraints.NotNull; diff --git a/server/src/main/java/org/apache/druid/client/SingleServerInventoryView.java b/server/src/main/java/org/apache/druid/client/SingleServerInventoryView.java index 8a467e58751..8645ddf0a8e 100644 --- a/server/src/main/java/org/apache/druid/client/SingleServerInventoryView.java +++ b/server/src/main/java/org/apache/druid/client/SingleServerInventoryView.java @@ -25,13 +25,13 @@ import com.google.common.base.Preconditions; import com.google.common.base.Predicate; import com.google.common.base.Predicates; import com.google.inject.Inject; -import org.apache.druid.java.util.emitter.EmittingLogger; +import org.apache.curator.framework.CuratorFramework; import org.apache.druid.guice.ManageLifecycle; import org.apache.druid.java.util.common.Pair; +import org.apache.druid.java.util.emitter.EmittingLogger; import org.apache.druid.server.coordination.DruidServerMetadata; import org.apache.druid.server.initialization.ZkPathsConfig; import org.apache.druid.timeline.DataSegment; -import org.apache.curator.framework.CuratorFramework; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; diff --git a/server/src/main/java/org/apache/druid/client/cache/CacheExecutorFactory.java b/server/src/main/java/org/apache/druid/client/cache/CacheExecutorFactory.java index fd1212c5c22..95fb66a71bd 100644 --- a/server/src/main/java/org/apache/druid/client/cache/CacheExecutorFactory.java +++ b/server/src/main/java/org/apache/druid/client/cache/CacheExecutorFactory.java @@ -20,8 +20,8 @@ package org.apache.druid.client.cache; import com.fasterxml.jackson.annotation.JsonCreator; -import org.apache.druid.java.util.common.concurrent.Execs; import org.apache.druid.java.util.common.StringUtils; +import org.apache.druid.java.util.common.concurrent.Execs; import java.util.concurrent.Executor; import java.util.concurrent.ForkJoinPool; diff --git a/server/src/main/java/org/apache/druid/client/cache/CaffeineCache.java b/server/src/main/java/org/apache/druid/client/cache/CaffeineCache.java index 9682ca1cee2..ec18cd2d7ab 100644 --- a/server/src/main/java/org/apache/druid/client/cache/CaffeineCache.java +++ b/server/src/main/java/org/apache/druid/client/cache/CaffeineCache.java @@ -25,12 +25,12 @@ import com.github.benmanes.caffeine.cache.stats.CacheStats; import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Maps; -import org.apache.druid.java.util.common.logger.Logger; -import org.apache.druid.java.util.emitter.service.ServiceEmitter; -import org.apache.druid.java.util.emitter.service.ServiceMetricEvent; import net.jpountz.lz4.LZ4Compressor; import net.jpountz.lz4.LZ4Factory; import net.jpountz.lz4.LZ4FastDecompressor; +import org.apache.druid.java.util.common.logger.Logger; +import org.apache.druid.java.util.emitter.service.ServiceEmitter; +import org.apache.druid.java.util.emitter.service.ServiceMetricEvent; import java.nio.ByteBuffer; import java.util.Map; diff --git a/server/src/main/java/org/apache/druid/client/cache/CaffeineCacheConfig.java b/server/src/main/java/org/apache/druid/client/cache/CaffeineCacheConfig.java index 44a552505c0..e828a62ab2e 100644 --- a/server/src/main/java/org/apache/druid/client/cache/CaffeineCacheConfig.java +++ b/server/src/main/java/org/apache/druid/client/cache/CaffeineCacheConfig.java @@ -20,6 +20,7 @@ package org.apache.druid.client.cache; import com.fasterxml.jackson.annotation.JsonProperty; + import java.util.concurrent.Executor; public class CaffeineCacheConfig diff --git a/server/src/main/java/org/apache/druid/client/cache/MemcacheClientPool.java b/server/src/main/java/org/apache/druid/client/cache/MemcacheClientPool.java index 66b34eebafa..fad65784163 100644 --- a/server/src/main/java/org/apache/druid/client/cache/MemcacheClientPool.java +++ b/server/src/main/java/org/apache/druid/client/cache/MemcacheClientPool.java @@ -22,9 +22,9 @@ package org.apache.druid.client.cache; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Preconditions; import com.google.common.base.Supplier; +import net.spy.memcached.MemcachedClientIF; import org.apache.druid.collections.ResourceHolder; import org.apache.druid.java.util.common.logger.Logger; -import net.spy.memcached.MemcachedClientIF; import sun.misc.Cleaner; import java.util.concurrent.atomic.AtomicInteger; diff --git a/server/src/main/java/org/apache/druid/client/cache/MemcachedCache.java b/server/src/main/java/org/apache/druid/client/cache/MemcachedCache.java index 053c2970571..a3fd26caf07 100644 --- a/server/src/main/java/org/apache/druid/client/cache/MemcachedCache.java +++ b/server/src/main/java/org/apache/druid/client/cache/MemcachedCache.java @@ -30,13 +30,6 @@ import com.google.common.collect.ImmutableSet; import com.google.common.collect.Maps; import com.google.common.hash.HashFunction; import com.google.common.hash.Hashing; -import org.apache.druid.collections.ResourceHolder; -import org.apache.druid.collections.StupidResourceHolder; -import org.apache.druid.java.util.common.StringUtils; -import org.apache.druid.java.util.common.logger.Logger; -import org.apache.druid.java.util.emitter.service.ServiceEmitter; -import org.apache.druid.java.util.emitter.service.ServiceMetricEvent; -import org.apache.druid.java.util.metrics.AbstractMonitor; import net.spy.memcached.AddrUtil; import net.spy.memcached.ConnectionFactory; import net.spy.memcached.ConnectionFactoryBuilder; @@ -50,6 +43,13 @@ import net.spy.memcached.metrics.MetricType; import net.spy.memcached.ops.LinkedOperationQueueFactory; import net.spy.memcached.ops.OperationQueueFactory; import org.apache.commons.codec.digest.DigestUtils; +import org.apache.druid.collections.ResourceHolder; +import org.apache.druid.collections.StupidResourceHolder; +import org.apache.druid.java.util.common.StringUtils; +import org.apache.druid.java.util.common.logger.Logger; +import org.apache.druid.java.util.emitter.service.ServiceEmitter; +import org.apache.druid.java.util.emitter.service.ServiceMetricEvent; +import org.apache.druid.java.util.metrics.AbstractMonitor; import javax.annotation.Nullable; import java.io.IOException; diff --git a/server/src/main/java/org/apache/druid/client/coordinator/CoordinatorClient.java b/server/src/main/java/org/apache/druid/client/coordinator/CoordinatorClient.java index c278dba05c0..0450af4b8f3 100644 --- a/server/src/main/java/org/apache/druid/client/coordinator/CoordinatorClient.java +++ b/server/src/main/java/org/apache/druid/client/coordinator/CoordinatorClient.java @@ -23,11 +23,11 @@ import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.base.Throwables; import com.google.inject.Inject; -import org.apache.druid.java.util.http.client.response.FullResponseHolder; import org.apache.druid.client.ImmutableSegmentLoadInfo; import org.apache.druid.discovery.DruidLeaderClient; import org.apache.druid.java.util.common.ISE; import org.apache.druid.java.util.common.StringUtils; +import org.apache.druid.java.util.http.client.response.FullResponseHolder; import org.jboss.netty.handler.codec.http.HttpMethod; import org.jboss.netty.handler.codec.http.HttpResponseStatus; import org.joda.time.Interval; diff --git a/server/src/main/java/org/apache/druid/client/selector/AbstractTierSelectorStrategy.java b/server/src/main/java/org/apache/druid/client/selector/AbstractTierSelectorStrategy.java index 80cc4f73e18..43991af6fbc 100644 --- a/server/src/main/java/org/apache/druid/client/selector/AbstractTierSelectorStrategy.java +++ b/server/src/main/java/org/apache/druid/client/selector/AbstractTierSelectorStrategy.java @@ -20,8 +20,8 @@ package org.apache.druid.client.selector; import com.google.common.collect.Iterables; -import org.apache.druid.timeline.DataSegment; import it.unimi.dsi.fastutil.ints.Int2ObjectRBTreeMap; +import org.apache.druid.timeline.DataSegment; import javax.annotation.Nullable; import java.util.ArrayList; diff --git a/server/src/main/java/org/apache/druid/client/selector/ServerSelector.java b/server/src/main/java/org/apache/druid/client/selector/ServerSelector.java index 0d9deb17b27..5e0ce0cd212 100644 --- a/server/src/main/java/org/apache/druid/client/selector/ServerSelector.java +++ b/server/src/main/java/org/apache/druid/client/selector/ServerSelector.java @@ -19,13 +19,13 @@ package org.apache.druid.client.selector; +import it.unimi.dsi.fastutil.ints.Int2ObjectRBTreeMap; import org.apache.druid.server.coordination.DruidServerMetadata; import org.apache.druid.server.coordination.ServerType; import org.apache.druid.timeline.DataSegment; -import it.unimi.dsi.fastutil.ints.Int2ObjectRBTreeMap; -import java.util.ArrayList; import javax.annotation.Nullable; +import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; import java.util.List; diff --git a/server/src/main/java/org/apache/druid/client/selector/TierSelectorStrategy.java b/server/src/main/java/org/apache/druid/client/selector/TierSelectorStrategy.java index 5393d2bea94..69987f89f42 100644 --- a/server/src/main/java/org/apache/druid/client/selector/TierSelectorStrategy.java +++ b/server/src/main/java/org/apache/druid/client/selector/TierSelectorStrategy.java @@ -21,8 +21,8 @@ package org.apache.druid.client.selector; import com.fasterxml.jackson.annotation.JsonSubTypes; import com.fasterxml.jackson.annotation.JsonTypeInfo; -import org.apache.druid.timeline.DataSegment; import it.unimi.dsi.fastutil.ints.Int2ObjectRBTreeMap; +import org.apache.druid.timeline.DataSegment; import javax.annotation.Nullable; import java.util.Comparator; diff --git a/server/src/main/java/org/apache/druid/curator/CuratorConfig.java b/server/src/main/java/org/apache/druid/curator/CuratorConfig.java index f3fac4229e4..d07b9d9f18f 100644 --- a/server/src/main/java/org/apache/druid/curator/CuratorConfig.java +++ b/server/src/main/java/org/apache/druid/curator/CuratorConfig.java @@ -19,14 +19,13 @@ package org.apache.druid.curator; -import javax.validation.constraints.Min; - import com.fasterxml.jackson.annotation.JsonProperty; import com.google.common.base.Preconditions; - import org.apache.druid.metadata.DefaultPasswordProvider; import org.apache.druid.metadata.PasswordProvider; +import javax.validation.constraints.Min; + /** */ public class CuratorConfig diff --git a/server/src/main/java/org/apache/druid/curator/CuratorModule.java b/server/src/main/java/org/apache/druid/curator/CuratorModule.java index f6b0ab19685..115a20eb0dc 100644 --- a/server/src/main/java/org/apache/druid/curator/CuratorModule.java +++ b/server/src/main/java/org/apache/druid/curator/CuratorModule.java @@ -19,9 +19,9 @@ package org.apache.druid.curator; -import java.nio.charset.StandardCharsets; -import java.util.List; - +import com.google.inject.Binder; +import com.google.inject.Module; +import com.google.inject.Provides; import org.apache.curator.ensemble.EnsembleProvider; import org.apache.curator.ensemble.exhibitor.DefaultExhibitorRestClient; import org.apache.curator.ensemble.exhibitor.ExhibitorEnsembleProvider; @@ -34,18 +34,16 @@ import org.apache.curator.framework.api.ACLProvider; import org.apache.curator.framework.imps.DefaultACLProvider; import org.apache.curator.retry.BoundedExponentialBackoffRetry; import org.apache.curator.shaded.com.google.common.base.Strings; -import org.apache.zookeeper.ZooDefs; -import org.apache.zookeeper.data.ACL; - -import com.google.inject.Binder; -import com.google.inject.Module; -import com.google.inject.Provides; - import org.apache.druid.guice.JsonConfigProvider; import org.apache.druid.guice.LazySingleton; import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.java.util.common.lifecycle.Lifecycle; import org.apache.druid.java.util.common.logger.Logger; +import org.apache.zookeeper.ZooDefs; +import org.apache.zookeeper.data.ACL; + +import java.nio.charset.StandardCharsets; +import java.util.List; /** */ diff --git a/server/src/main/java/org/apache/druid/curator/CuratorUtils.java b/server/src/main/java/org/apache/druid/curator/CuratorUtils.java index 1ae6eceb4af..b89a645b9b2 100644 --- a/server/src/main/java/org/apache/druid/curator/CuratorUtils.java +++ b/server/src/main/java/org/apache/druid/curator/CuratorUtils.java @@ -20,11 +20,10 @@ package org.apache.druid.curator; import org.apache.curator.framework.CuratorFramework; -import org.apache.zookeeper.CreateMode; -import org.apache.zookeeper.KeeperException; - import org.apache.druid.java.util.common.IAE; import org.apache.druid.java.util.common.logger.Logger; +import org.apache.zookeeper.CreateMode; +import org.apache.zookeeper.KeeperException; public class CuratorUtils { diff --git a/server/src/main/java/org/apache/druid/curator/ExhibitorConfig.java b/server/src/main/java/org/apache/druid/curator/ExhibitorConfig.java index 0a29bd72a44..df6640a1011 100644 --- a/server/src/main/java/org/apache/druid/curator/ExhibitorConfig.java +++ b/server/src/main/java/org/apache/druid/curator/ExhibitorConfig.java @@ -21,11 +21,10 @@ package org.apache.druid.curator; import com.fasterxml.jackson.annotation.JsonProperty; -import java.util.ArrayList; -import java.util.List; - import javax.validation.constraints.Max; import javax.validation.constraints.Min; +import java.util.ArrayList; +import java.util.List; /** */ diff --git a/server/src/main/java/org/apache/druid/curator/announcement/Announcer.java b/server/src/main/java/org/apache/druid/curator/announcement/Announcer.java index 32ea8f7f03c..976b40097ac 100644 --- a/server/src/main/java/org/apache/druid/curator/announcement/Announcer.java +++ b/server/src/main/java/org/apache/druid/curator/announcement/Announcer.java @@ -23,14 +23,6 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Throwables; import com.google.common.collect.Lists; import com.google.common.collect.Sets; -import org.apache.druid.curator.cache.PathChildrenCacheFactory; -import org.apache.druid.java.util.common.IAE; -import org.apache.druid.java.util.common.ISE; -import org.apache.druid.java.util.common.guava.CloseQuietly; -import org.apache.druid.java.util.common.io.Closer; -import org.apache.druid.java.util.common.lifecycle.LifecycleStart; -import org.apache.druid.java.util.common.lifecycle.LifecycleStop; -import org.apache.druid.java.util.common.logger.Logger; import org.apache.curator.framework.CuratorFramework; import org.apache.curator.framework.api.transaction.CuratorTransaction; import org.apache.curator.framework.api.transaction.CuratorTransactionFinal; @@ -39,6 +31,14 @@ import org.apache.curator.framework.recipes.cache.PathChildrenCache; import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent; import org.apache.curator.framework.recipes.cache.PathChildrenCacheListener; import org.apache.curator.utils.ZKPaths; +import org.apache.druid.curator.cache.PathChildrenCacheFactory; +import org.apache.druid.java.util.common.IAE; +import org.apache.druid.java.util.common.ISE; +import org.apache.druid.java.util.common.guava.CloseQuietly; +import org.apache.druid.java.util.common.io.Closer; +import org.apache.druid.java.util.common.lifecycle.LifecycleStart; +import org.apache.druid.java.util.common.lifecycle.LifecycleStop; +import org.apache.druid.java.util.common.logger.Logger; import org.apache.zookeeper.CreateMode; import org.apache.zookeeper.KeeperException; import org.apache.zookeeper.data.Stat; diff --git a/server/src/main/java/org/apache/druid/curator/discovery/CuratorDruidLeaderSelector.java b/server/src/main/java/org/apache/druid/curator/discovery/CuratorDruidLeaderSelector.java index 32d18a1663d..517c1e80135 100644 --- a/server/src/main/java/org/apache/druid/curator/discovery/CuratorDruidLeaderSelector.java +++ b/server/src/main/java/org/apache/druid/curator/discovery/CuratorDruidLeaderSelector.java @@ -21,6 +21,10 @@ package org.apache.druid.curator.discovery; import com.google.common.base.Preconditions; import com.google.common.base.Throwables; +import org.apache.curator.framework.CuratorFramework; +import org.apache.curator.framework.recipes.leader.LeaderLatch; +import org.apache.curator.framework.recipes.leader.LeaderLatchListener; +import org.apache.curator.framework.recipes.leader.Participant; import org.apache.druid.concurrent.LifecycleLock; import org.apache.druid.discovery.DruidLeaderSelector; import org.apache.druid.guice.annotations.Self; @@ -30,10 +34,6 @@ import org.apache.druid.java.util.common.concurrent.Execs; import org.apache.druid.java.util.common.guava.CloseQuietly; import org.apache.druid.java.util.emitter.EmittingLogger; import org.apache.druid.server.DruidNode; -import org.apache.curator.framework.CuratorFramework; -import org.apache.curator.framework.recipes.leader.LeaderLatch; -import org.apache.curator.framework.recipes.leader.LeaderLatchListener; -import org.apache.curator.framework.recipes.leader.Participant; import javax.annotation.Nullable; import java.util.concurrent.ExecutorService; diff --git a/server/src/main/java/org/apache/druid/curator/discovery/CuratorDruidNodeAnnouncer.java b/server/src/main/java/org/apache/druid/curator/discovery/CuratorDruidNodeAnnouncer.java index 26adb758559..70102fd67dc 100644 --- a/server/src/main/java/org/apache/druid/curator/discovery/CuratorDruidNodeAnnouncer.java +++ b/server/src/main/java/org/apache/druid/curator/discovery/CuratorDruidNodeAnnouncer.java @@ -23,13 +23,13 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.base.Throwables; import com.google.inject.Inject; +import org.apache.curator.utils.ZKPaths; import org.apache.druid.curator.announcement.Announcer; import org.apache.druid.discovery.DiscoveryDruidNode; import org.apache.druid.discovery.DruidNodeAnnouncer; import org.apache.druid.guice.annotations.Json; import org.apache.druid.java.util.common.logger.Logger; import org.apache.druid.server.initialization.ZkPathsConfig; -import org.apache.curator.utils.ZKPaths; /** */ diff --git a/server/src/main/java/org/apache/druid/curator/discovery/CuratorDruidNodeDiscoveryProvider.java b/server/src/main/java/org/apache/druid/curator/discovery/CuratorDruidNodeDiscoveryProvider.java index a90a64e68bd..212d27d9f99 100644 --- a/server/src/main/java/org/apache/druid/curator/discovery/CuratorDruidNodeDiscoveryProvider.java +++ b/server/src/main/java/org/apache/druid/curator/discovery/CuratorDruidNodeDiscoveryProvider.java @@ -24,6 +24,10 @@ import com.google.common.base.Preconditions; import com.google.common.base.Throwables; import com.google.common.collect.ImmutableList; import com.google.inject.Inject; +import org.apache.curator.framework.CuratorFramework; +import org.apache.curator.framework.recipes.cache.PathChildrenCache; +import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent; +import org.apache.curator.utils.ZKPaths; import org.apache.druid.concurrent.LifecycleLock; import org.apache.druid.discovery.DiscoveryDruidNode; import org.apache.druid.discovery.DruidNodeDiscovery; @@ -37,10 +41,6 @@ import org.apache.druid.java.util.common.lifecycle.LifecycleStart; import org.apache.druid.java.util.common.lifecycle.LifecycleStop; import org.apache.druid.java.util.common.logger.Logger; import org.apache.druid.server.initialization.ZkPathsConfig; -import org.apache.curator.framework.CuratorFramework; -import org.apache.curator.framework.recipes.cache.PathChildrenCache; -import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent; -import org.apache.curator.utils.ZKPaths; import java.util.ArrayList; import java.util.Collection; diff --git a/server/src/main/java/org/apache/druid/curator/discovery/CuratorServiceAnnouncer.java b/server/src/main/java/org/apache/druid/curator/discovery/CuratorServiceAnnouncer.java index 96a6fbbf6cd..99bbd3d10cb 100644 --- a/server/src/main/java/org/apache/druid/curator/discovery/CuratorServiceAnnouncer.java +++ b/server/src/main/java/org/apache/druid/curator/discovery/CuratorServiceAnnouncer.java @@ -22,10 +22,10 @@ package org.apache.druid.curator.discovery; import com.google.common.base.Throwables; import com.google.common.collect.Maps; import com.google.inject.Inject; -import org.apache.druid.java.util.emitter.EmittingLogger; -import org.apache.druid.server.DruidNode; import org.apache.curator.x.discovery.ServiceDiscovery; import org.apache.curator.x.discovery.ServiceInstance; +import org.apache.druid.java.util.emitter.EmittingLogger; +import org.apache.druid.server.DruidNode; import java.util.Map; diff --git a/server/src/main/java/org/apache/druid/curator/discovery/DiscoveryModule.java b/server/src/main/java/org/apache/druid/curator/discovery/DiscoveryModule.java index 766429f2255..fd93c480983 100644 --- a/server/src/main/java/org/apache/druid/curator/discovery/DiscoveryModule.java +++ b/server/src/main/java/org/apache/druid/curator/discovery/DiscoveryModule.java @@ -32,6 +32,20 @@ import com.google.inject.Provides; import com.google.inject.TypeLiteral; import com.google.inject.name.Named; import com.google.inject.name.Names; +import org.apache.curator.framework.CuratorFramework; +import org.apache.curator.utils.CloseableExecutorService; +import org.apache.curator.utils.ZKPaths; +import org.apache.curator.x.discovery.DownInstancePolicy; +import org.apache.curator.x.discovery.InstanceFilter; +import org.apache.curator.x.discovery.ProviderStrategy; +import org.apache.curator.x.discovery.ServiceCache; +import org.apache.curator.x.discovery.ServiceCacheBuilder; +import org.apache.curator.x.discovery.ServiceDiscovery; +import org.apache.curator.x.discovery.ServiceDiscoveryBuilder; +import org.apache.curator.x.discovery.ServiceInstance; +import org.apache.curator.x.discovery.ServiceProvider; +import org.apache.curator.x.discovery.ServiceProviderBuilder; +import org.apache.curator.x.discovery.details.ServiceCacheListener; import org.apache.druid.client.coordinator.Coordinator; import org.apache.druid.client.indexing.IndexingService; import org.apache.druid.discovery.DruidLeaderSelector; @@ -48,20 +62,6 @@ import org.apache.druid.java.util.common.lifecycle.Lifecycle; import org.apache.druid.server.DruidNode; import org.apache.druid.server.initialization.CuratorDiscoveryConfig; import org.apache.druid.server.initialization.ZkPathsConfig; -import org.apache.curator.framework.CuratorFramework; -import org.apache.curator.utils.CloseableExecutorService; -import org.apache.curator.utils.ZKPaths; -import org.apache.curator.x.discovery.DownInstancePolicy; -import org.apache.curator.x.discovery.InstanceFilter; -import org.apache.curator.x.discovery.ProviderStrategy; -import org.apache.curator.x.discovery.ServiceCache; -import org.apache.curator.x.discovery.ServiceCacheBuilder; -import org.apache.curator.x.discovery.ServiceDiscovery; -import org.apache.curator.x.discovery.ServiceDiscoveryBuilder; -import org.apache.curator.x.discovery.ServiceInstance; -import org.apache.curator.x.discovery.ServiceProvider; -import org.apache.curator.x.discovery.ServiceProviderBuilder; -import org.apache.curator.x.discovery.details.ServiceCacheListener; import java.lang.annotation.Annotation; import java.util.Collection; diff --git a/server/src/main/java/org/apache/druid/curator/discovery/ServerDiscoverySelector.java b/server/src/main/java/org/apache/druid/curator/discovery/ServerDiscoverySelector.java index a47d257d24c..d51402d6ab9 100644 --- a/server/src/main/java/org/apache/druid/curator/discovery/ServerDiscoverySelector.java +++ b/server/src/main/java/org/apache/druid/curator/discovery/ServerDiscoverySelector.java @@ -23,13 +23,13 @@ import com.google.common.base.Function; import com.google.common.base.Preconditions; import com.google.common.collect.Collections2; import com.google.common.net.HostAndPort; +import org.apache.curator.x.discovery.ServiceInstance; +import org.apache.curator.x.discovery.ServiceProvider; import org.apache.druid.client.selector.DiscoverySelector; import org.apache.druid.client.selector.Server; import org.apache.druid.java.util.common.lifecycle.LifecycleStart; import org.apache.druid.java.util.common.lifecycle.LifecycleStop; import org.apache.druid.java.util.common.logger.Logger; -import org.apache.curator.x.discovery.ServiceInstance; -import org.apache.curator.x.discovery.ServiceProvider; import javax.annotation.Nullable; import java.io.IOException; diff --git a/server/src/main/java/org/apache/druid/curator/inventory/CuratorInventoryManager.java b/server/src/main/java/org/apache/druid/curator/inventory/CuratorInventoryManager.java index 38a49d5ee5a..ee3ca05ea8c 100644 --- a/server/src/main/java/org/apache/druid/curator/inventory/CuratorInventoryManager.java +++ b/server/src/main/java/org/apache/druid/curator/inventory/CuratorInventoryManager.java @@ -20,18 +20,18 @@ package org.apache.druid.curator.inventory; import com.google.common.collect.Sets; -import org.apache.druid.curator.cache.PathChildrenCacheFactory; -import org.apache.druid.java.util.common.StringUtils; -import org.apache.druid.java.util.common.io.Closer; -import org.apache.druid.java.util.common.lifecycle.LifecycleStart; -import org.apache.druid.java.util.common.lifecycle.LifecycleStop; -import org.apache.druid.java.util.common.logger.Logger; import org.apache.curator.framework.CuratorFramework; import org.apache.curator.framework.recipes.cache.ChildData; import org.apache.curator.framework.recipes.cache.PathChildrenCache; import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent; import org.apache.curator.framework.recipes.cache.PathChildrenCacheListener; import org.apache.curator.utils.ZKPaths; +import org.apache.druid.curator.cache.PathChildrenCacheFactory; +import org.apache.druid.java.util.common.StringUtils; +import org.apache.druid.java.util.common.io.Closer; +import org.apache.druid.java.util.common.lifecycle.LifecycleStart; +import org.apache.druid.java.util.common.lifecycle.LifecycleStop; +import org.apache.druid.java.util.common.logger.Logger; import java.io.IOException; import java.util.Collection; diff --git a/server/src/main/java/org/apache/druid/guice/AnnouncerModule.java b/server/src/main/java/org/apache/druid/guice/AnnouncerModule.java index d8f469ac0d4..bb58e694d31 100644 --- a/server/src/main/java/org/apache/druid/guice/AnnouncerModule.java +++ b/server/src/main/java/org/apache/druid/guice/AnnouncerModule.java @@ -22,15 +22,15 @@ package org.apache.druid.guice; import com.google.inject.Binder; import com.google.inject.Module; import com.google.inject.Provides; -import org.apache.druid.java.util.common.concurrent.Execs; +import org.apache.curator.framework.CuratorFramework; import org.apache.druid.curator.announcement.Announcer; +import org.apache.druid.java.util.common.concurrent.Execs; import org.apache.druid.server.coordination.BatchDataSegmentAnnouncer; import org.apache.druid.server.coordination.CuratorDataSegmentServerAnnouncer; import org.apache.druid.server.coordination.DataSegmentAnnouncer; import org.apache.druid.server.coordination.DataSegmentAnnouncerProvider; import org.apache.druid.server.coordination.DataSegmentServerAnnouncer; import org.apache.druid.server.initialization.BatchDataSegmentAnnouncerConfig; -import org.apache.curator.framework.CuratorFramework; /** */ diff --git a/server/src/main/java/org/apache/druid/guice/CoordinatorDiscoveryModule.java b/server/src/main/java/org/apache/druid/guice/CoordinatorDiscoveryModule.java index 46ff781f876..3440b545e26 100644 --- a/server/src/main/java/org/apache/druid/guice/CoordinatorDiscoveryModule.java +++ b/server/src/main/java/org/apache/druid/guice/CoordinatorDiscoveryModule.java @@ -22,7 +22,6 @@ package org.apache.druid.guice; import com.google.inject.Binder; import com.google.inject.Module; import com.google.inject.Provides; -import org.apache.druid.java.util.http.client.HttpClient; import org.apache.druid.client.coordinator.Coordinator; import org.apache.druid.client.coordinator.CoordinatorSelectorConfig; import org.apache.druid.curator.discovery.ServerDiscoveryFactory; @@ -30,6 +29,7 @@ import org.apache.druid.curator.discovery.ServerDiscoverySelector; import org.apache.druid.discovery.DruidLeaderClient; import org.apache.druid.discovery.DruidNodeDiscoveryProvider; import org.apache.druid.guice.annotations.EscalatedGlobal; +import org.apache.druid.java.util.http.client.HttpClient; /** */ diff --git a/server/src/main/java/org/apache/druid/guice/IndexingServiceDiscoveryModule.java b/server/src/main/java/org/apache/druid/guice/IndexingServiceDiscoveryModule.java index bbb694386da..4348b5b8027 100644 --- a/server/src/main/java/org/apache/druid/guice/IndexingServiceDiscoveryModule.java +++ b/server/src/main/java/org/apache/druid/guice/IndexingServiceDiscoveryModule.java @@ -22,7 +22,6 @@ package org.apache.druid.guice; import com.google.inject.Binder; import com.google.inject.Module; import com.google.inject.Provides; -import org.apache.druid.java.util.http.client.HttpClient; import org.apache.druid.client.indexing.IndexingService; import org.apache.druid.client.indexing.IndexingServiceSelectorConfig; import org.apache.druid.curator.discovery.ServerDiscoveryFactory; @@ -30,6 +29,7 @@ import org.apache.druid.curator.discovery.ServerDiscoverySelector; import org.apache.druid.discovery.DruidLeaderClient; import org.apache.druid.discovery.DruidNodeDiscoveryProvider; import org.apache.druid.guice.annotations.EscalatedGlobal; +import org.apache.druid.java.util.http.client.HttpClient; /** */ diff --git a/server/src/main/java/org/apache/druid/guice/QueryRunnerFactoryModule.java b/server/src/main/java/org/apache/druid/guice/QueryRunnerFactoryModule.java index 2175a418a88..b1842823d2d 100644 --- a/server/src/main/java/org/apache/druid/guice/QueryRunnerFactoryModule.java +++ b/server/src/main/java/org/apache/druid/guice/QueryRunnerFactoryModule.java @@ -34,8 +34,8 @@ import org.apache.druid.query.metadata.SegmentMetadataQueryRunnerFactory; import org.apache.druid.query.metadata.metadata.SegmentMetadataQuery; import org.apache.druid.query.scan.ScanQuery; import org.apache.druid.query.scan.ScanQueryRunnerFactory; -import org.apache.druid.query.search.SearchQueryRunnerFactory; import org.apache.druid.query.search.SearchQuery; +import org.apache.druid.query.search.SearchQueryRunnerFactory; import org.apache.druid.query.select.SelectQuery; import org.apache.druid.query.select.SelectQueryRunnerFactory; import org.apache.druid.query.timeboundary.TimeBoundaryQuery; diff --git a/server/src/main/java/org/apache/druid/guice/QueryToolChestModule.java b/server/src/main/java/org/apache/druid/guice/QueryToolChestModule.java index b21e982217a..e05dcb48e0e 100644 --- a/server/src/main/java/org/apache/druid/guice/QueryToolChestModule.java +++ b/server/src/main/java/org/apache/druid/guice/QueryToolChestModule.java @@ -43,11 +43,11 @@ import org.apache.druid.query.metadata.metadata.SegmentMetadataQuery; import org.apache.druid.query.scan.ScanQuery; import org.apache.druid.query.scan.ScanQueryConfig; import org.apache.druid.query.scan.ScanQueryQueryToolChest; -import org.apache.druid.query.search.SearchQueryQueryToolChest; import org.apache.druid.query.search.DefaultSearchQueryMetricsFactory; import org.apache.druid.query.search.SearchQuery; import org.apache.druid.query.search.SearchQueryConfig; import org.apache.druid.query.search.SearchQueryMetricsFactory; +import org.apache.druid.query.search.SearchQueryQueryToolChest; import org.apache.druid.query.select.DefaultSelectQueryMetricsFactory; import org.apache.druid.query.select.SelectQuery; import org.apache.druid.query.select.SelectQueryConfig; diff --git a/server/src/main/java/org/apache/druid/initialization/Initialization.java b/server/src/main/java/org/apache/druid/initialization/Initialization.java index 5ab04ea1bf0..9d8c1019e9b 100644 --- a/server/src/main/java/org/apache/druid/initialization/Initialization.java +++ b/server/src/main/java/org/apache/druid/initialization/Initialization.java @@ -30,6 +30,7 @@ import com.google.inject.Injector; import com.google.inject.Key; import com.google.inject.Module; import com.google.inject.util.Modules; +import org.apache.commons.io.FileUtils; import org.apache.druid.curator.CuratorModule; import org.apache.druid.curator.discovery.DiscoveryModule; import org.apache.druid.guice.AWSModule; @@ -69,7 +70,6 @@ import org.apache.druid.server.initialization.AuthenticatorMapperModule; import org.apache.druid.server.initialization.AuthorizerMapperModule; import org.apache.druid.server.initialization.jetty.JettyServerModule; import org.apache.druid.server.metrics.MetricsModule; -import org.apache.commons.io.FileUtils; import org.eclipse.aether.artifact.DefaultArtifact; import java.io.File; diff --git a/server/src/main/java/org/apache/druid/initialization/Log4jShutterDownerModule.java b/server/src/main/java/org/apache/druid/initialization/Log4jShutterDownerModule.java index a5ca8d83583..ee13f9bdd3c 100644 --- a/server/src/main/java/org/apache/druid/initialization/Log4jShutterDownerModule.java +++ b/server/src/main/java/org/apache/druid/initialization/Log4jShutterDownerModule.java @@ -24,13 +24,11 @@ import com.google.inject.Key; import com.google.inject.Module; import com.google.inject.Provides; import com.google.inject.name.Names; - import org.apache.druid.common.config.Log4jShutdown; import org.apache.druid.guice.ManageLifecycle; import org.apache.druid.java.util.common.lifecycle.LifecycleStart; import org.apache.druid.java.util.common.lifecycle.LifecycleStop; import org.apache.druid.java.util.common.logger.Logger; - import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.core.impl.Log4jContextFactory; import org.apache.logging.log4j.core.util.ShutdownCallbackRegistry; diff --git a/server/src/main/java/org/apache/druid/metadata/SQLFirehoseDatabaseConnector.java b/server/src/main/java/org/apache/druid/metadata/SQLFirehoseDatabaseConnector.java index 0fecee0c891..59860265cbe 100644 --- a/server/src/main/java/org/apache/druid/metadata/SQLFirehoseDatabaseConnector.java +++ b/server/src/main/java/org/apache/druid/metadata/SQLFirehoseDatabaseConnector.java @@ -20,8 +20,8 @@ package org.apache.druid.metadata; import com.fasterxml.jackson.annotation.JsonTypeInfo; import com.google.common.base.Predicate; -import org.apache.druid.java.util.common.RetryUtils; import org.apache.commons.dbcp2.BasicDataSource; +import org.apache.druid.java.util.common.RetryUtils; import org.skife.jdbi.v2.DBI; import org.skife.jdbi.v2.exceptions.DBIException; import org.skife.jdbi.v2.exceptions.UnableToExecuteStatementException; diff --git a/server/src/main/java/org/apache/druid/metadata/storage/derby/DerbyConnector.java b/server/src/main/java/org/apache/druid/metadata/storage/derby/DerbyConnector.java index 9a4eece4b4b..8899ddc4adc 100644 --- a/server/src/main/java/org/apache/druid/metadata/storage/derby/DerbyConnector.java +++ b/server/src/main/java/org/apache/druid/metadata/storage/derby/DerbyConnector.java @@ -21,6 +21,7 @@ package org.apache.druid.metadata.storage.derby; import com.google.common.base.Supplier; import com.google.inject.Inject; +import org.apache.commons.dbcp2.BasicDataSource; import org.apache.druid.guice.ManageLifecycle; import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.java.util.common.lifecycle.LifecycleStart; @@ -30,7 +31,6 @@ import org.apache.druid.metadata.MetadataStorage; import org.apache.druid.metadata.MetadataStorageConnectorConfig; import org.apache.druid.metadata.MetadataStorageTablesConfig; import org.apache.druid.metadata.SQLMetadataConnector; -import org.apache.commons.dbcp2.BasicDataSource; import org.skife.jdbi.v2.DBI; import org.skife.jdbi.v2.Handle; diff --git a/server/src/main/java/org/apache/druid/metadata/storage/derby/DerbyMetadataStorage.java b/server/src/main/java/org/apache/druid/metadata/storage/derby/DerbyMetadataStorage.java index deab616b4c1..3cb0639f365 100644 --- a/server/src/main/java/org/apache/druid/metadata/storage/derby/DerbyMetadataStorage.java +++ b/server/src/main/java/org/apache/druid/metadata/storage/derby/DerbyMetadataStorage.java @@ -21,10 +21,10 @@ package org.apache.druid.metadata.storage.derby; import com.google.common.base.Throwables; import com.google.inject.Inject; +import org.apache.derby.drda.NetworkServerControl; import org.apache.druid.java.util.common.logger.Logger; import org.apache.druid.metadata.MetadataStorage; import org.apache.druid.metadata.MetadataStorageConnectorConfig; -import org.apache.derby.drda.NetworkServerControl; import java.net.InetAddress; diff --git a/server/src/main/java/org/apache/druid/offheap/OffheapBufferGenerator.java b/server/src/main/java/org/apache/druid/offheap/OffheapBufferGenerator.java index 687d50f5fe5..7ffbb1e7a00 100644 --- a/server/src/main/java/org/apache/druid/offheap/OffheapBufferGenerator.java +++ b/server/src/main/java/org/apache/druid/offheap/OffheapBufferGenerator.java @@ -20,7 +20,6 @@ package org.apache.druid.offheap; import com.google.common.base.Supplier; - import org.apache.druid.java.util.common.logger.Logger; import java.nio.ByteBuffer; diff --git a/server/src/main/java/org/apache/druid/query/ResultLevelCachingQueryRunner.java b/server/src/main/java/org/apache/druid/query/ResultLevelCachingQueryRunner.java index e5b31a31c8b..494df57f6b5 100644 --- a/server/src/main/java/org/apache/druid/query/ResultLevelCachingQueryRunner.java +++ b/server/src/main/java/org/apache/druid/query/ResultLevelCachingQueryRunner.java @@ -36,7 +36,6 @@ import org.apache.druid.java.util.common.guava.Sequences; import org.apache.druid.java.util.common.logger.Logger; import org.apache.druid.server.QueryResource; - import javax.annotation.Nullable; import java.io.ByteArrayOutputStream; import java.io.IOException; diff --git a/server/src/main/java/org/apache/druid/query/lookup/LookupModule.java b/server/src/main/java/org/apache/druid/query/lookup/LookupModule.java index b08ffb9dff4..318abb9ab2d 100644 --- a/server/src/main/java/org/apache/druid/query/lookup/LookupModule.java +++ b/server/src/main/java/org/apache/druid/query/lookup/LookupModule.java @@ -34,6 +34,7 @@ import com.google.inject.Binder; import com.google.inject.Inject; import com.google.inject.Provides; import com.sun.jersey.spi.container.ResourceFilters; +import org.apache.curator.utils.ZKPaths; import org.apache.druid.common.utils.ServletResourceUtils; import org.apache.druid.curator.announcement.Announcer; import org.apache.druid.discovery.LookupNodeService; @@ -62,7 +63,6 @@ import org.apache.druid.server.listener.resource.AbstractListenerHandler; import org.apache.druid.server.listener.resource.ListenerResource; import org.apache.druid.server.lookup.cache.LookupCoordinatorManager; import org.apache.druid.server.metrics.DataSourceTaskIdHolder; -import org.apache.curator.utils.ZKPaths; import javax.ws.rs.Path; import javax.ws.rs.core.Response; diff --git a/server/src/main/java/org/apache/druid/query/lookup/LookupReferencesManager.java b/server/src/main/java/org/apache/druid/query/lookup/LookupReferencesManager.java index 05f802d1a2c..8d97cbee253 100644 --- a/server/src/main/java/org/apache/druid/query/lookup/LookupReferencesManager.java +++ b/server/src/main/java/org/apache/druid/query/lookup/LookupReferencesManager.java @@ -28,6 +28,7 @@ import com.google.common.base.Strings; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.inject.Inject; +import org.apache.commons.lang.mutable.MutableBoolean; import org.apache.druid.client.coordinator.Coordinator; import org.apache.druid.concurrent.LifecycleLock; import org.apache.druid.discovery.DruidLeaderClient; @@ -43,7 +44,6 @@ import org.apache.druid.java.util.common.lifecycle.LifecycleStart; import org.apache.druid.java.util.common.lifecycle.LifecycleStop; import org.apache.druid.java.util.emitter.EmittingLogger; import org.apache.druid.java.util.http.client.response.FullResponseHolder; -import org.apache.commons.lang.mutable.MutableBoolean; import org.jboss.netty.handler.codec.http.HttpMethod; import org.jboss.netty.handler.codec.http.HttpResponseStatus; diff --git a/server/src/main/java/org/apache/druid/segment/indexing/granularity/GranularitySpec.java b/server/src/main/java/org/apache/druid/segment/indexing/granularity/GranularitySpec.java index 800f768b8cc..9272f6961e4 100644 --- a/server/src/main/java/org/apache/druid/segment/indexing/granularity/GranularitySpec.java +++ b/server/src/main/java/org/apache/druid/segment/indexing/granularity/GranularitySpec.java @@ -22,9 +22,7 @@ package org.apache.druid.segment.indexing.granularity; import com.fasterxml.jackson.annotation.JsonSubTypes; import com.fasterxml.jackson.annotation.JsonTypeInfo; import com.google.common.base.Optional; - import org.apache.druid.java.util.common.granularity.Granularity; - import org.joda.time.DateTime; import org.joda.time.Interval; diff --git a/server/src/main/java/org/apache/druid/segment/loading/LocalDataSegmentFinder.java b/server/src/main/java/org/apache/druid/segment/loading/LocalDataSegmentFinder.java index cec200342c5..830275750f3 100644 --- a/server/src/main/java/org/apache/druid/segment/loading/LocalDataSegmentFinder.java +++ b/server/src/main/java/org/apache/druid/segment/loading/LocalDataSegmentFinder.java @@ -21,11 +21,11 @@ package org.apache.druid.segment.loading; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.inject.Inject; +import org.apache.commons.io.FileUtils; import org.apache.druid.guice.LocalDataStorageDruidModule; import org.apache.druid.java.util.common.Pair; import org.apache.druid.java.util.common.logger.Logger; import org.apache.druid.timeline.DataSegment; -import org.apache.commons.io.FileUtils; import java.io.File; import java.io.IOException; diff --git a/server/src/main/java/org/apache/druid/segment/loading/LocalDataSegmentKiller.java b/server/src/main/java/org/apache/druid/segment/loading/LocalDataSegmentKiller.java index 77d02e0a7ef..1f30c574288 100644 --- a/server/src/main/java/org/apache/druid/segment/loading/LocalDataSegmentKiller.java +++ b/server/src/main/java/org/apache/druid/segment/loading/LocalDataSegmentKiller.java @@ -20,10 +20,10 @@ package org.apache.druid.segment.loading; import com.google.inject.Inject; +import org.apache.commons.io.FileUtils; import org.apache.druid.java.util.common.MapUtils; import org.apache.druid.java.util.common.logger.Logger; import org.apache.druid.timeline.DataSegment; -import org.apache.commons.io.FileUtils; import java.io.File; import java.io.IOException; diff --git a/server/src/main/java/org/apache/druid/segment/loading/LocalDataSegmentPusher.java b/server/src/main/java/org/apache/druid/segment/loading/LocalDataSegmentPusher.java index b81baa2e4c7..68913504a8a 100644 --- a/server/src/main/java/org/apache/druid/segment/loading/LocalDataSegmentPusher.java +++ b/server/src/main/java/org/apache/druid/segment/loading/LocalDataSegmentPusher.java @@ -22,12 +22,12 @@ package org.apache.druid.segment.loading; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.collect.ImmutableMap; import com.google.inject.Inject; +import org.apache.commons.io.FileUtils; import org.apache.druid.java.util.common.CompressionUtils; import org.apache.druid.java.util.common.IOE; import org.apache.druid.java.util.common.logger.Logger; import org.apache.druid.segment.SegmentUtils; import org.apache.druid.timeline.DataSegment; -import org.apache.commons.io.FileUtils; import java.io.File; import java.io.IOException; diff --git a/server/src/main/java/org/apache/druid/segment/loading/OmniDataSegmentArchiver.java b/server/src/main/java/org/apache/druid/segment/loading/OmniDataSegmentArchiver.java index 664204b2db3..0d72bedc282 100644 --- a/server/src/main/java/org/apache/druid/segment/loading/OmniDataSegmentArchiver.java +++ b/server/src/main/java/org/apache/druid/segment/loading/OmniDataSegmentArchiver.java @@ -20,7 +20,6 @@ package org.apache.druid.segment.loading; import com.google.inject.Inject; - import org.apache.druid.java.util.common.MapUtils; import org.apache.druid.timeline.DataSegment; diff --git a/server/src/main/java/org/apache/druid/segment/loading/OmniDataSegmentMover.java b/server/src/main/java/org/apache/druid/segment/loading/OmniDataSegmentMover.java index 6aa61653860..f85d575cb65 100644 --- a/server/src/main/java/org/apache/druid/segment/loading/OmniDataSegmentMover.java +++ b/server/src/main/java/org/apache/druid/segment/loading/OmniDataSegmentMover.java @@ -20,7 +20,6 @@ package org.apache.druid.segment.loading; import com.google.inject.Inject; - import org.apache.druid.java.util.common.MapUtils; import org.apache.druid.timeline.DataSegment; diff --git a/server/src/main/java/org/apache/druid/segment/loading/SegmentLoaderLocalCacheManager.java b/server/src/main/java/org/apache/druid/segment/loading/SegmentLoaderLocalCacheManager.java index eebf631e7c8..3957fda4db6 100644 --- a/server/src/main/java/org/apache/druid/segment/loading/SegmentLoaderLocalCacheManager.java +++ b/server/src/main/java/org/apache/druid/segment/loading/SegmentLoaderLocalCacheManager.java @@ -23,12 +23,12 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.collect.Lists; import com.google.common.primitives.Longs; import com.google.inject.Inject; +import org.apache.commons.io.FileUtils; import org.apache.druid.guice.annotations.Json; import org.apache.druid.java.util.emitter.EmittingLogger; import org.apache.druid.segment.IndexIO; import org.apache.druid.segment.Segment; import org.apache.druid.timeline.DataSegment; -import org.apache.commons.io.FileUtils; import java.io.File; import java.io.IOException; diff --git a/server/src/main/java/org/apache/druid/segment/realtime/appenderator/AppenderatorConfig.java b/server/src/main/java/org/apache/druid/segment/realtime/appenderator/AppenderatorConfig.java index f09726ab60e..cefc421bc38 100644 --- a/server/src/main/java/org/apache/druid/segment/realtime/appenderator/AppenderatorConfig.java +++ b/server/src/main/java/org/apache/druid/segment/realtime/appenderator/AppenderatorConfig.java @@ -19,8 +19,8 @@ package org.apache.druid.segment.realtime.appenderator; -import org.apache.druid.segment.writeout.SegmentWriteOutMediumFactory; import org.apache.druid.segment.IndexSpec; +import org.apache.druid.segment.writeout.SegmentWriteOutMediumFactory; import org.joda.time.Period; import javax.annotation.Nullable; diff --git a/server/src/main/java/org/apache/druid/segment/realtime/appenderator/AppenderatorFactory.java b/server/src/main/java/org/apache/druid/segment/realtime/appenderator/AppenderatorFactory.java index ac73aa0fa70..4b8698490e9 100644 --- a/server/src/main/java/org/apache/druid/segment/realtime/appenderator/AppenderatorFactory.java +++ b/server/src/main/java/org/apache/druid/segment/realtime/appenderator/AppenderatorFactory.java @@ -21,7 +21,6 @@ package org.apache.druid.segment.realtime.appenderator; import com.fasterxml.jackson.annotation.JsonSubTypes; import com.fasterxml.jackson.annotation.JsonTypeInfo; - import org.apache.druid.segment.indexing.DataSchema; import org.apache.druid.segment.indexing.RealtimeTuningConfig; import org.apache.druid.segment.realtime.FireDepartmentMetrics; diff --git a/server/src/main/java/org/apache/druid/segment/realtime/appenderator/AppenderatorImpl.java b/server/src/main/java/org/apache/druid/segment/realtime/appenderator/AppenderatorImpl.java index 808c8ff1dfb..38530084a7f 100644 --- a/server/src/main/java/org/apache/druid/segment/realtime/appenderator/AppenderatorImpl.java +++ b/server/src/main/java/org/apache/druid/segment/realtime/appenderator/AppenderatorImpl.java @@ -38,6 +38,7 @@ import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListeningExecutorService; import com.google.common.util.concurrent.MoreExecutors; +import org.apache.commons.io.FileUtils; import org.apache.druid.client.cache.Cache; import org.apache.druid.client.cache.CacheConfig; import org.apache.druid.client.cache.CachePopulatorStats; @@ -77,7 +78,6 @@ import org.apache.druid.segment.realtime.plumber.Sink; import org.apache.druid.server.coordination.DataSegmentAnnouncer; import org.apache.druid.timeline.DataSegment; import org.apache.druid.timeline.VersionedIntervalTimeline; -import org.apache.commons.io.FileUtils; import org.joda.time.Interval; import javax.annotation.Nullable; diff --git a/server/src/main/java/org/apache/druid/segment/realtime/appenderator/AppenderatorPlumberSchool.java b/server/src/main/java/org/apache/druid/segment/realtime/appenderator/AppenderatorPlumberSchool.java index 00ce61751dc..99adff0a1ba 100644 --- a/server/src/main/java/org/apache/druid/segment/realtime/appenderator/AppenderatorPlumberSchool.java +++ b/server/src/main/java/org/apache/druid/segment/realtime/appenderator/AppenderatorPlumberSchool.java @@ -22,7 +22,6 @@ package org.apache.druid.segment.realtime.appenderator; import com.fasterxml.jackson.annotation.JacksonInject; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; - import org.apache.druid.segment.indexing.DataSchema; import org.apache.druid.segment.indexing.RealtimeTuningConfig; import org.apache.druid.segment.realtime.FireDepartmentMetrics; diff --git a/server/src/main/java/org/apache/druid/segment/realtime/firehose/IngestSegmentFirehose.java b/server/src/main/java/org/apache/druid/segment/realtime/firehose/IngestSegmentFirehose.java index f74a2cf12b6..e39111c65be 100644 --- a/server/src/main/java/org/apache/druid/segment/realtime/firehose/IngestSegmentFirehose.java +++ b/server/src/main/java/org/apache/druid/segment/realtime/firehose/IngestSegmentFirehose.java @@ -39,7 +39,7 @@ import org.apache.druid.segment.BaseObjectColumnValueSelector; import org.apache.druid.segment.Cursor; import org.apache.druid.segment.DimensionSelector; import org.apache.druid.segment.VirtualColumns; -import org.apache.druid.segment.column.Column; +import org.apache.druid.segment.column.ColumnHolder; import org.apache.druid.segment.data.IndexedInts; import org.apache.druid.segment.filter.Filters; import org.apache.druid.segment.transform.TransformSpec; @@ -92,7 +92,7 @@ public class IngestSegmentFirehose implements Firehose public Sequence apply(final Cursor cursor) { final BaseLongColumnValueSelector timestampColumnSelector = - cursor.getColumnSelectorFactory().makeColumnValueSelector(Column.TIME_COLUMN_NAME); + cursor.getColumnSelectorFactory().makeColumnValueSelector(ColumnHolder.TIME_COLUMN_NAME); final Map dimSelectors = Maps.newHashMap(); for (String dim : dims) { diff --git a/server/src/main/java/org/apache/druid/segment/realtime/firehose/LocalFirehoseFactory.java b/server/src/main/java/org/apache/druid/segment/realtime/firehose/LocalFirehoseFactory.java index 2613da1d963..e5b6b1f42cb 100644 --- a/server/src/main/java/org/apache/druid/segment/realtime/firehose/LocalFirehoseFactory.java +++ b/server/src/main/java/org/apache/druid/segment/realtime/firehose/LocalFirehoseFactory.java @@ -22,15 +22,15 @@ package org.apache.druid.segment.realtime.firehose; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.google.common.base.Preconditions; +import org.apache.commons.io.FileUtils; +import org.apache.commons.io.filefilter.TrueFileFilter; +import org.apache.commons.io.filefilter.WildcardFileFilter; import org.apache.druid.data.input.FiniteFirehoseFactory; import org.apache.druid.data.input.InputSplit; import org.apache.druid.data.input.impl.AbstractTextFilesFirehoseFactory; import org.apache.druid.data.input.impl.StringInputRowParser; import org.apache.druid.java.util.common.CompressionUtils; import org.apache.druid.java.util.emitter.EmittingLogger; -import org.apache.commons.io.FileUtils; -import org.apache.commons.io.filefilter.TrueFileFilter; -import org.apache.commons.io.filefilter.WildcardFileFilter; import java.io.File; import java.io.IOException; diff --git a/server/src/main/java/org/apache/druid/segment/realtime/firehose/PredicateFirehose.java b/server/src/main/java/org/apache/druid/segment/realtime/firehose/PredicateFirehose.java index fa00a57547a..b8c6b85581b 100644 --- a/server/src/main/java/org/apache/druid/segment/realtime/firehose/PredicateFirehose.java +++ b/server/src/main/java/org/apache/druid/segment/realtime/firehose/PredicateFirehose.java @@ -20,7 +20,6 @@ package org.apache.druid.segment.realtime.firehose; import com.google.common.base.Predicate; - import org.apache.druid.data.input.Firehose; import org.apache.druid.data.input.InputRow; import org.apache.druid.java.util.common.logger.Logger; diff --git a/server/src/main/java/org/apache/druid/segment/realtime/firehose/SqlFirehoseFactory.java b/server/src/main/java/org/apache/druid/segment/realtime/firehose/SqlFirehoseFactory.java index 74f28f61e90..fc380aa9924 100644 --- a/server/src/main/java/org/apache/druid/segment/realtime/firehose/SqlFirehoseFactory.java +++ b/server/src/main/java/org/apache/druid/segment/realtime/firehose/SqlFirehoseFactory.java @@ -23,7 +23,6 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.ObjectMapper; - import com.google.common.base.Preconditions; import org.apache.druid.data.input.impl.prefetch.PrefetchSqlFirehoseFactory; import org.apache.druid.guice.annotations.Smile; @@ -35,7 +34,6 @@ import org.skife.jdbi.v2.exceptions.CallbackFailedException; import org.skife.jdbi.v2.exceptions.ResultSetException; import org.skife.jdbi.v2.exceptions.StatementException; - import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; diff --git a/server/src/main/java/org/apache/druid/segment/realtime/firehose/TimedShutoffFirehoseFactory.java b/server/src/main/java/org/apache/druid/segment/realtime/firehose/TimedShutoffFirehoseFactory.java index 47ec280c545..d37265b6b85 100644 --- a/server/src/main/java/org/apache/druid/segment/realtime/firehose/TimedShutoffFirehoseFactory.java +++ b/server/src/main/java/org/apache/druid/segment/realtime/firehose/TimedShutoffFirehoseFactory.java @@ -21,12 +21,12 @@ package org.apache.druid.segment.realtime.firehose; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; -import org.apache.druid.java.util.emitter.EmittingLogger; -import org.apache.druid.java.util.common.concurrent.Execs; import org.apache.druid.data.input.Firehose; import org.apache.druid.data.input.FirehoseFactory; import org.apache.druid.data.input.InputRow; import org.apache.druid.data.input.impl.InputRowParser; +import org.apache.druid.java.util.common.concurrent.Execs; +import org.apache.druid.java.util.emitter.EmittingLogger; import org.joda.time.DateTime; import javax.annotation.Nullable; diff --git a/server/src/main/java/org/apache/druid/segment/realtime/plumber/CoordinatorBasedSegmentHandoffNotifier.java b/server/src/main/java/org/apache/druid/segment/realtime/plumber/CoordinatorBasedSegmentHandoffNotifier.java index 4b6a5182dc9..c84bd9467ee 100644 --- a/server/src/main/java/org/apache/druid/segment/realtime/plumber/CoordinatorBasedSegmentHandoffNotifier.java +++ b/server/src/main/java/org/apache/druid/segment/realtime/plumber/CoordinatorBasedSegmentHandoffNotifier.java @@ -23,8 +23,8 @@ import com.google.common.base.Predicate; import com.google.common.collect.Iterables; import org.apache.druid.client.ImmutableSegmentLoadInfo; import org.apache.druid.client.coordinator.CoordinatorClient; -import org.apache.druid.java.util.common.concurrent.Execs; import org.apache.druid.java.util.common.Pair; +import org.apache.druid.java.util.common.concurrent.Execs; import org.apache.druid.java.util.common.logger.Logger; import org.apache.druid.query.SegmentDescriptor; import org.apache.druid.server.coordination.DruidServerMetadata; diff --git a/server/src/main/java/org/apache/druid/segment/realtime/plumber/RealtimePlumber.java b/server/src/main/java/org/apache/druid/segment/realtime/plumber/RealtimePlumber.java index 5d9e6222e20..e8dfd217c6d 100644 --- a/server/src/main/java/org/apache/druid/segment/realtime/plumber/RealtimePlumber.java +++ b/server/src/main/java/org/apache/druid/segment/realtime/plumber/RealtimePlumber.java @@ -30,6 +30,7 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.primitives.Ints; +import org.apache.commons.io.FileUtils; import org.apache.druid.client.cache.Cache; import org.apache.druid.client.cache.CacheConfig; import org.apache.druid.client.cache.CachePopulatorStats; @@ -76,7 +77,6 @@ import org.apache.druid.server.coordination.DataSegmentAnnouncer; import org.apache.druid.timeline.DataSegment; import org.apache.druid.timeline.VersionedIntervalTimeline; import org.apache.druid.timeline.partition.SingleElementPartitionChunk; -import org.apache.commons.io.FileUtils; import org.joda.time.DateTime; import org.joda.time.Duration; import org.joda.time.Interval; diff --git a/server/src/main/java/org/apache/druid/segment/realtime/plumber/Sink.java b/server/src/main/java/org/apache/druid/segment/realtime/plumber/Sink.java index c11d25ddff1..90aced3ffe7 100644 --- a/server/src/main/java/org/apache/druid/segment/realtime/plumber/Sink.java +++ b/server/src/main/java/org/apache/druid/segment/realtime/plumber/Sink.java @@ -364,7 +364,7 @@ public class Sink implements Iterable QueryableIndex oldIndex = segment.asQueryableIndex(); for (String dim : oldIndex.getAvailableDimensions()) { dimOrder.add(dim); - oldCapabilities.put(dim, (ColumnCapabilitiesImpl) oldIndex.getColumn(dim).getCapabilities()); + oldCapabilities.put(dim, (ColumnCapabilitiesImpl) oldIndex.getColumnHolder(dim).getCapabilities()); } } finally { diff --git a/server/src/main/java/org/apache/druid/server/ClientQuerySegmentWalker.java b/server/src/main/java/org/apache/druid/server/ClientQuerySegmentWalker.java index 74cf310a2b3..2d98d2d187b 100644 --- a/server/src/main/java/org/apache/druid/server/ClientQuerySegmentWalker.java +++ b/server/src/main/java/org/apache/druid/server/ClientQuerySegmentWalker.java @@ -22,10 +22,10 @@ package org.apache.druid.server; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.inject.Inject; -import org.apache.druid.java.util.emitter.service.ServiceEmitter; import org.apache.druid.client.CachingClusteredClient; import org.apache.druid.client.cache.Cache; import org.apache.druid.client.cache.CacheConfig; +import org.apache.druid.java.util.emitter.service.ServiceEmitter; import org.apache.druid.query.FluentQueryRunnerBuilder; import org.apache.druid.query.PostProcessingOperator; import org.apache.druid.query.Query; diff --git a/server/src/main/java/org/apache/druid/server/QueryLifecycleFactory.java b/server/src/main/java/org/apache/druid/server/QueryLifecycleFactory.java index 59d3c6ec617..cae225cdd8c 100644 --- a/server/src/main/java/org/apache/druid/server/QueryLifecycleFactory.java +++ b/server/src/main/java/org/apache/druid/server/QueryLifecycleFactory.java @@ -20,8 +20,8 @@ package org.apache.druid.server; import com.google.inject.Inject; -import org.apache.druid.java.util.emitter.service.ServiceEmitter; import org.apache.druid.guice.LazySingleton; +import org.apache.druid.java.util.emitter.service.ServiceEmitter; import org.apache.druid.query.GenericQueryMetricsFactory; import org.apache.druid.query.QuerySegmentWalker; import org.apache.druid.query.QueryToolChestWarehouse; diff --git a/server/src/main/java/org/apache/druid/server/SetAndVerifyContextQueryRunner.java b/server/src/main/java/org/apache/druid/server/SetAndVerifyContextQueryRunner.java index 3952911a8ae..0bddccc810c 100644 --- a/server/src/main/java/org/apache/druid/server/SetAndVerifyContextQueryRunner.java +++ b/server/src/main/java/org/apache/druid/server/SetAndVerifyContextQueryRunner.java @@ -19,14 +19,14 @@ package org.apache.druid.server; +import com.google.common.collect.ImmutableMap; +import org.apache.druid.client.DirectDruidClient; import org.apache.druid.java.util.common.guava.Sequence; import org.apache.druid.query.Query; import org.apache.druid.query.QueryContexts; import org.apache.druid.query.QueryPlus; import org.apache.druid.query.QueryRunner; import org.apache.druid.server.initialization.ServerConfig; -import org.apache.druid.client.DirectDruidClient; -import com.google.common.collect.ImmutableMap; import java.util.Map; diff --git a/server/src/main/java/org/apache/druid/server/coordination/BatchDataSegmentAnnouncer.java b/server/src/main/java/org/apache/druid/server/coordination/BatchDataSegmentAnnouncer.java index 462183d4a09..ffbf75f963b 100644 --- a/server/src/main/java/org/apache/druid/server/coordination/BatchDataSegmentAnnouncer.java +++ b/server/src/main/java/org/apache/druid/server/coordination/BatchDataSegmentAnnouncer.java @@ -29,6 +29,7 @@ import com.google.common.collect.Sets; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.SettableFuture; import com.google.inject.Inject; +import org.apache.curator.utils.ZKPaths; import org.apache.druid.common.utils.UUIDUtils; import org.apache.druid.curator.announcement.Announcer; import org.apache.druid.java.util.common.DateTimes; @@ -38,7 +39,6 @@ import org.apache.druid.java.util.common.logger.Logger; import org.apache.druid.server.initialization.BatchDataSegmentAnnouncerConfig; import org.apache.druid.server.initialization.ZkPathsConfig; import org.apache.druid.timeline.DataSegment; -import org.apache.curator.utils.ZKPaths; import javax.annotation.Nullable; import java.io.IOException; diff --git a/server/src/main/java/org/apache/druid/server/coordination/CuratorDataSegmentServerAnnouncer.java b/server/src/main/java/org/apache/druid/server/coordination/CuratorDataSegmentServerAnnouncer.java index e87f86164b8..909f0c330e1 100644 --- a/server/src/main/java/org/apache/druid/server/coordination/CuratorDataSegmentServerAnnouncer.java +++ b/server/src/main/java/org/apache/druid/server/coordination/CuratorDataSegmentServerAnnouncer.java @@ -23,10 +23,10 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.base.Throwables; import com.google.inject.Inject; +import org.apache.curator.utils.ZKPaths; import org.apache.druid.curator.announcement.Announcer; import org.apache.druid.java.util.common.logger.Logger; import org.apache.druid.server.initialization.ZkPathsConfig; -import org.apache.curator.utils.ZKPaths; /** * {@link DataSegmentServerAnnouncer} is deprecated. diff --git a/server/src/main/java/org/apache/druid/server/coordination/SegmentLoadDropHandler.java b/server/src/main/java/org/apache/druid/server/coordination/SegmentLoadDropHandler.java index 9388bbc24f9..a740652a993 100644 --- a/server/src/main/java/org/apache/druid/server/coordination/SegmentLoadDropHandler.java +++ b/server/src/main/java/org/apache/druid/server/coordination/SegmentLoadDropHandler.java @@ -35,12 +35,12 @@ import com.google.common.util.concurrent.AbstractFuture; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.SettableFuture; import com.google.inject.Inject; -import org.apache.druid.java.util.emitter.EmittingLogger; import org.apache.druid.guice.ManageLifecycle; import org.apache.druid.java.util.common.ISE; import org.apache.druid.java.util.common.concurrent.Execs; import org.apache.druid.java.util.common.lifecycle.LifecycleStart; import org.apache.druid.java.util.common.lifecycle.LifecycleStop; +import org.apache.druid.java.util.emitter.EmittingLogger; import org.apache.druid.segment.loading.SegmentLoaderConfig; import org.apache.druid.segment.loading.SegmentLoadingException; import org.apache.druid.server.SegmentManager; diff --git a/server/src/main/java/org/apache/druid/server/coordination/ZkCoordinator.java b/server/src/main/java/org/apache/druid/server/coordination/ZkCoordinator.java index 96925bcd62f..d55c8d84b88 100644 --- a/server/src/main/java/org/apache/druid/server/coordination/ZkCoordinator.java +++ b/server/src/main/java/org/apache/druid/server/coordination/ZkCoordinator.java @@ -22,17 +22,17 @@ package org.apache.druid.server.coordination; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.base.Throwables; import com.google.inject.Inject; -import org.apache.druid.java.util.emitter.EmittingLogger; -import org.apache.druid.java.util.common.concurrent.Execs; -import org.apache.druid.java.util.common.lifecycle.LifecycleStart; -import org.apache.druid.java.util.common.lifecycle.LifecycleStop; -import org.apache.druid.server.initialization.ZkPathsConfig; import org.apache.curator.framework.CuratorFramework; import org.apache.curator.framework.recipes.cache.ChildData; import org.apache.curator.framework.recipes.cache.PathChildrenCache; import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent; import org.apache.curator.framework.recipes.cache.PathChildrenCacheListener; import org.apache.curator.utils.ZKPaths; +import org.apache.druid.java.util.common.concurrent.Execs; +import org.apache.druid.java.util.common.lifecycle.LifecycleStart; +import org.apache.druid.java.util.common.lifecycle.LifecycleStop; +import org.apache.druid.java.util.emitter.EmittingLogger; +import org.apache.druid.server.initialization.ZkPathsConfig; import java.io.IOException; diff --git a/server/src/main/java/org/apache/druid/server/coordinator/CachingCostBalancerStrategyFactory.java b/server/src/main/java/org/apache/druid/server/coordinator/CachingCostBalancerStrategyFactory.java index 20c8921b79c..a6261db080b 100644 --- a/server/src/main/java/org/apache/druid/server/coordinator/CachingCostBalancerStrategyFactory.java +++ b/server/src/main/java/org/apache/druid/server/coordinator/CachingCostBalancerStrategyFactory.java @@ -22,13 +22,13 @@ package org.apache.druid.server.coordinator; import com.fasterxml.jackson.annotation.JacksonInject; import com.fasterxml.jackson.annotation.JsonCreator; import com.google.common.util.concurrent.ListeningExecutorService; -import org.apache.druid.java.util.emitter.EmittingLogger; import org.apache.druid.client.ServerInventoryView; import org.apache.druid.client.ServerView; import org.apache.druid.java.util.common.concurrent.Execs; import org.apache.druid.java.util.common.lifecycle.Lifecycle; import org.apache.druid.java.util.common.lifecycle.LifecycleStart; import org.apache.druid.java.util.common.lifecycle.LifecycleStop; +import org.apache.druid.java.util.emitter.EmittingLogger; import org.apache.druid.server.coordination.DruidServerMetadata; import org.apache.druid.server.coordinator.cost.ClusterCostCache; import org.apache.druid.timeline.DataSegment; diff --git a/server/src/main/java/org/apache/druid/server/coordinator/CostBalancerStrategy.java b/server/src/main/java/org/apache/druid/server/coordinator/CostBalancerStrategy.java index f7f7420c256..7ce949e37b2 100644 --- a/server/src/main/java/org/apache/druid/server/coordinator/CostBalancerStrategy.java +++ b/server/src/main/java/org/apache/druid/server/coordinator/CostBalancerStrategy.java @@ -25,10 +25,10 @@ import com.google.common.collect.Lists; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListeningExecutorService; +import org.apache.commons.math3.util.FastMath; import org.apache.druid.java.util.common.Pair; import org.apache.druid.java.util.emitter.EmittingLogger; import org.apache.druid.timeline.DataSegment; -import org.apache.commons.math3.util.FastMath; import org.joda.time.Interval; import java.util.ArrayList; diff --git a/server/src/main/java/org/apache/druid/server/coordinator/CuratorLoadQueuePeon.java b/server/src/main/java/org/apache/druid/server/coordinator/CuratorLoadQueuePeon.java index 25df3586ff2..31edb69eb36 100644 --- a/server/src/main/java/org/apache/druid/server/coordinator/CuratorLoadQueuePeon.java +++ b/server/src/main/java/org/apache/druid/server/coordinator/CuratorLoadQueuePeon.java @@ -22,6 +22,9 @@ package org.apache.druid.server.coordinator; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.collect.Lists; +import org.apache.curator.framework.CuratorFramework; +import org.apache.curator.framework.api.CuratorWatcher; +import org.apache.curator.utils.ZKPaths; import org.apache.druid.java.util.common.ISE; import org.apache.druid.java.util.common.concurrent.ScheduledExecutors; import org.apache.druid.java.util.emitter.EmittingLogger; @@ -30,9 +33,6 @@ import org.apache.druid.server.coordination.SegmentChangeRequestDrop; import org.apache.druid.server.coordination.SegmentChangeRequestLoad; import org.apache.druid.server.coordination.SegmentChangeRequestNoop; import org.apache.druid.timeline.DataSegment; -import org.apache.curator.framework.CuratorFramework; -import org.apache.curator.framework.api.CuratorWatcher; -import org.apache.curator.utils.ZKPaths; import org.apache.zookeeper.CreateMode; import org.apache.zookeeper.data.Stat; diff --git a/server/src/main/java/org/apache/druid/server/coordinator/DruidCoordinatorRuntimeParams.java b/server/src/main/java/org/apache/druid/server/coordinator/DruidCoordinatorRuntimeParams.java index 69eea863bfc..8ad0b4d7e33 100644 --- a/server/src/main/java/org/apache/druid/server/coordinator/DruidCoordinatorRuntimeParams.java +++ b/server/src/main/java/org/apache/druid/server/coordinator/DruidCoordinatorRuntimeParams.java @@ -21,9 +21,9 @@ package org.apache.druid.server.coordinator; import com.google.common.collect.Maps; import com.google.common.collect.Sets; -import org.apache.druid.java.util.emitter.service.ServiceEmitter; import org.apache.druid.client.ImmutableDruidDataSource; import org.apache.druid.java.util.common.DateTimes; +import org.apache.druid.java.util.emitter.service.ServiceEmitter; import org.apache.druid.metadata.MetadataRuleManager; import org.apache.druid.timeline.DataSegment; import org.apache.druid.timeline.VersionedIntervalTimeline; diff --git a/server/src/main/java/org/apache/druid/server/coordinator/LoadQueueTaskMaster.java b/server/src/main/java/org/apache/druid/server/coordinator/LoadQueueTaskMaster.java index 7b4b9857d3e..30263094a3d 100644 --- a/server/src/main/java/org/apache/druid/server/coordinator/LoadQueueTaskMaster.java +++ b/server/src/main/java/org/apache/druid/server/coordinator/LoadQueueTaskMaster.java @@ -20,11 +20,11 @@ package org.apache.druid.server.coordinator; import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.curator.framework.CuratorFramework; +import org.apache.curator.utils.ZKPaths; import org.apache.druid.client.ImmutableDruidServer; import org.apache.druid.java.util.http.client.HttpClient; import org.apache.druid.server.initialization.ZkPathsConfig; -import org.apache.curator.framework.CuratorFramework; -import org.apache.curator.utils.ZKPaths; import java.util.concurrent.ExecutorService; import java.util.concurrent.ScheduledExecutorService; diff --git a/server/src/main/java/org/apache/druid/server/coordinator/ReplicationThrottler.java b/server/src/main/java/org/apache/druid/server/coordinator/ReplicationThrottler.java index 8935f093f46..f407d18a91c 100644 --- a/server/src/main/java/org/apache/druid/server/coordinator/ReplicationThrottler.java +++ b/server/src/main/java/org/apache/druid/server/coordinator/ReplicationThrottler.java @@ -21,8 +21,8 @@ package org.apache.druid.server.coordinator; import com.google.common.collect.Lists; import com.google.common.collect.Maps; -import org.apache.druid.java.util.emitter.EmittingLogger; import org.apache.druid.java.util.common.StringUtils; +import org.apache.druid.java.util.emitter.EmittingLogger; import java.util.List; import java.util.Map; diff --git a/server/src/main/java/org/apache/druid/server/coordinator/cost/SegmentsCostCache.java b/server/src/main/java/org/apache/druid/server/coordinator/cost/SegmentsCostCache.java index dd66a535f20..43ded1ee495 100644 --- a/server/src/main/java/org/apache/druid/server/coordinator/cost/SegmentsCostCache.java +++ b/server/src/main/java/org/apache/druid/server/coordinator/cost/SegmentsCostCache.java @@ -21,13 +21,13 @@ package org.apache.druid.server.coordinator.cost; import com.google.common.base.Preconditions; import com.google.common.collect.Ordering; +import org.apache.commons.math3.util.FastMath; import org.apache.druid.java.util.common.ISE; import org.apache.druid.java.util.common.Intervals; import org.apache.druid.java.util.common.granularity.DurationGranularity; import org.apache.druid.java.util.common.guava.Comparators; import org.apache.druid.server.coordinator.CostBalancerStrategy; import org.apache.druid.timeline.DataSegment; -import org.apache.commons.math3.util.FastMath; import org.joda.time.Interval; import java.util.ArrayList; diff --git a/server/src/main/java/org/apache/druid/server/coordinator/helper/CompactionSegmentIterator.java b/server/src/main/java/org/apache/druid/server/coordinator/helper/CompactionSegmentIterator.java index 19a2e5a624d..d3216dc1636 100644 --- a/server/src/main/java/org/apache/druid/server/coordinator/helper/CompactionSegmentIterator.java +++ b/server/src/main/java/org/apache/druid/server/coordinator/helper/CompactionSegmentIterator.java @@ -19,8 +19,8 @@ package org.apache.druid.server.coordinator.helper; -import org.apache.druid.timeline.DataSegment; import it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap; +import org.apache.druid.timeline.DataSegment; import java.util.Iterator; import java.util.List; diff --git a/server/src/main/java/org/apache/druid/server/coordinator/helper/DruidCoordinatorLogger.java b/server/src/main/java/org/apache/druid/server/coordinator/helper/DruidCoordinatorLogger.java index f56a3d7489a..d2af99ccb41 100644 --- a/server/src/main/java/org/apache/druid/server/coordinator/helper/DruidCoordinatorLogger.java +++ b/server/src/main/java/org/apache/druid/server/coordinator/helper/DruidCoordinatorLogger.java @@ -19,10 +19,11 @@ package org.apache.druid.server.coordinator.helper; -import org.apache.druid.java.util.emitter.service.ServiceEmitter; -import org.apache.druid.java.util.emitter.service.ServiceMetricEvent; +import it.unimi.dsi.fastutil.objects.Object2LongMap; import org.apache.druid.client.ImmutableDruidServer; import org.apache.druid.java.util.common.logger.Logger; +import org.apache.druid.java.util.emitter.service.ServiceEmitter; +import org.apache.druid.java.util.emitter.service.ServiceMetricEvent; import org.apache.druid.query.DruidMetrics; import org.apache.druid.server.coordinator.CoordinatorStats; import org.apache.druid.server.coordinator.DruidCluster; @@ -32,7 +33,6 @@ import org.apache.druid.server.coordinator.LoadQueuePeon; import org.apache.druid.server.coordinator.ServerHolder; import org.apache.druid.timeline.DataSegment; import org.apache.druid.timeline.partition.PartitionChunk; -import it.unimi.dsi.fastutil.objects.Object2LongMap; import java.util.List; import java.util.stream.Collectors; diff --git a/server/src/main/java/org/apache/druid/server/coordinator/helper/DruidCoordinatorSegmentCompactor.java b/server/src/main/java/org/apache/druid/server/coordinator/helper/DruidCoordinatorSegmentCompactor.java index 20943b875d3..71547e82f52 100644 --- a/server/src/main/java/org/apache/druid/server/coordinator/helper/DruidCoordinatorSegmentCompactor.java +++ b/server/src/main/java/org/apache/druid/server/coordinator/helper/DruidCoordinatorSegmentCompactor.java @@ -20,6 +20,7 @@ package org.apache.druid.server.coordinator.helper; import com.google.inject.Inject; +import it.unimi.dsi.fastutil.objects.Object2LongMap; import org.apache.druid.client.indexing.IndexingServiceClient; import org.apache.druid.indexer.TaskStatusPlus; import org.apache.druid.java.util.common.ISE; @@ -30,7 +31,6 @@ import org.apache.druid.server.coordinator.DataSourceCompactionConfig; import org.apache.druid.server.coordinator.DruidCoordinatorRuntimeParams; import org.apache.druid.timeline.DataSegment; import org.apache.druid.timeline.VersionedIntervalTimeline; -import it.unimi.dsi.fastutil.objects.Object2LongMap; import javax.annotation.Nullable; import java.util.ArrayList; diff --git a/server/src/main/java/org/apache/druid/server/coordinator/helper/DruidCoordinatorSegmentKiller.java b/server/src/main/java/org/apache/druid/server/coordinator/helper/DruidCoordinatorSegmentKiller.java index 7030e3e6dda..b9272b97e5d 100644 --- a/server/src/main/java/org/apache/druid/server/coordinator/helper/DruidCoordinatorSegmentKiller.java +++ b/server/src/main/java/org/apache/druid/server/coordinator/helper/DruidCoordinatorSegmentKiller.java @@ -22,7 +22,6 @@ package org.apache.druid.server.coordinator.helper; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Preconditions; import com.google.inject.Inject; - import org.apache.druid.client.indexing.IndexingServiceClient; import org.apache.druid.java.util.common.DateTimes; import org.apache.druid.java.util.common.JodaUtils; diff --git a/server/src/main/java/org/apache/druid/server/coordinator/helper/DruidCoordinatorSegmentMerger.java b/server/src/main/java/org/apache/druid/server/coordinator/helper/DruidCoordinatorSegmentMerger.java index 7486dcea22e..87e44ee87df 100644 --- a/server/src/main/java/org/apache/druid/server/coordinator/helper/DruidCoordinatorSegmentMerger.java +++ b/server/src/main/java/org/apache/druid/server/coordinator/helper/DruidCoordinatorSegmentMerger.java @@ -29,7 +29,6 @@ import com.google.common.collect.Maps; import com.google.common.collect.Multiset; import com.google.common.collect.Ordering; import com.google.inject.Inject; -import org.apache.druid.java.util.emitter.service.ServiceMetricEvent; import org.apache.druid.client.indexing.IndexingServiceClient; import org.apache.druid.common.config.JacksonConfigManager; import org.apache.druid.java.util.common.DateTimes; @@ -37,6 +36,7 @@ import org.apache.druid.java.util.common.ISE; import org.apache.druid.java.util.common.Pair; import org.apache.druid.java.util.common.guava.FunctionalIterable; import org.apache.druid.java.util.common.logger.Logger; +import org.apache.druid.java.util.emitter.service.ServiceMetricEvent; import org.apache.druid.server.coordinator.CoordinatorStats; import org.apache.druid.server.coordinator.DatasourceWhitelist; import org.apache.druid.server.coordinator.DruidCoordinatorRuntimeParams; diff --git a/server/src/main/java/org/apache/druid/server/coordinator/helper/NewestSegmentFirstIterator.java b/server/src/main/java/org/apache/druid/server/coordinator/helper/NewestSegmentFirstIterator.java index e5a19c5e381..1f9a84db873 100644 --- a/server/src/main/java/org/apache/druid/server/coordinator/helper/NewestSegmentFirstIterator.java +++ b/server/src/main/java/org/apache/druid/server/coordinator/helper/NewestSegmentFirstIterator.java @@ -23,6 +23,7 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; +import it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap; import org.apache.druid.java.util.common.ISE; import org.apache.druid.java.util.common.Intervals; import org.apache.druid.java.util.common.Pair; @@ -33,7 +34,6 @@ import org.apache.druid.timeline.DataSegment; import org.apache.druid.timeline.TimelineObjectHolder; import org.apache.druid.timeline.VersionedIntervalTimeline; import org.apache.druid.timeline.partition.PartitionChunk; -import it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap; import org.joda.time.DateTime; import org.joda.time.Interval; import org.joda.time.Period; diff --git a/server/src/main/java/org/apache/druid/server/coordinator/rules/IntervalLoadRule.java b/server/src/main/java/org/apache/druid/server/coordinator/rules/IntervalLoadRule.java index b5f553a60e6..2e944bf2854 100644 --- a/server/src/main/java/org/apache/druid/server/coordinator/rules/IntervalLoadRule.java +++ b/server/src/main/java/org/apache/druid/server/coordinator/rules/IntervalLoadRule.java @@ -22,7 +22,6 @@ package org.apache.druid.server.coordinator.rules; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.google.common.collect.ImmutableMap; - import org.apache.druid.client.DruidServer; import org.apache.druid.java.util.common.logger.Logger; import org.apache.druid.timeline.DataSegment; diff --git a/server/src/main/java/org/apache/druid/server/coordinator/rules/LoadRule.java b/server/src/main/java/org/apache/druid/server/coordinator/rules/LoadRule.java index e455e939ae9..086982b7e2f 100644 --- a/server/src/main/java/org/apache/druid/server/coordinator/rules/LoadRule.java +++ b/server/src/main/java/org/apache/druid/server/coordinator/rules/LoadRule.java @@ -19,6 +19,8 @@ package org.apache.druid.server.coordinator.rules; +import it.unimi.dsi.fastutil.objects.Object2IntMap; +import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; import org.apache.druid.java.util.common.IAE; import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.java.util.emitter.EmittingLogger; @@ -30,8 +32,6 @@ import org.apache.druid.server.coordinator.DruidCoordinatorRuntimeParams; import org.apache.druid.server.coordinator.ReplicationThrottler; import org.apache.druid.server.coordinator.ServerHolder; import org.apache.druid.timeline.DataSegment; -import it.unimi.dsi.fastutil.objects.Object2IntMap; -import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; import javax.annotation.Nullable; import java.util.Collections; diff --git a/server/src/main/java/org/apache/druid/server/coordinator/rules/PeriodLoadRule.java b/server/src/main/java/org/apache/druid/server/coordinator/rules/PeriodLoadRule.java index 2fe36cc14fc..4d36ef0ef57 100644 --- a/server/src/main/java/org/apache/druid/server/coordinator/rules/PeriodLoadRule.java +++ b/server/src/main/java/org/apache/druid/server/coordinator/rules/PeriodLoadRule.java @@ -22,7 +22,6 @@ package org.apache.druid.server.coordinator.rules; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.google.common.collect.ImmutableMap; - import org.apache.druid.client.DruidServer; import org.apache.druid.java.util.common.logger.Logger; import org.apache.druid.timeline.DataSegment; diff --git a/server/src/main/java/org/apache/druid/server/emitter/ComposingEmitterModule.java b/server/src/main/java/org/apache/druid/server/emitter/ComposingEmitterModule.java index 0d672871997..27a35fd68df 100644 --- a/server/src/main/java/org/apache/druid/server/emitter/ComposingEmitterModule.java +++ b/server/src/main/java/org/apache/druid/server/emitter/ComposingEmitterModule.java @@ -28,12 +28,12 @@ import com.google.inject.Key; import com.google.inject.Provides; import com.google.inject.name.Named; import com.google.inject.name.Names; -import org.apache.druid.java.util.emitter.core.ComposingEmitter; -import org.apache.druid.java.util.emitter.core.Emitter; import org.apache.druid.guice.JsonConfigProvider; import org.apache.druid.guice.ManageLifecycle; import org.apache.druid.initialization.DruidModule; import org.apache.druid.java.util.common.logger.Logger; +import org.apache.druid.java.util.emitter.core.ComposingEmitter; +import org.apache.druid.java.util.emitter.core.Emitter; import java.util.Collections; import java.util.List; diff --git a/server/src/main/java/org/apache/druid/server/emitter/HttpEmitterModule.java b/server/src/main/java/org/apache/druid/server/emitter/HttpEmitterModule.java index 35170140f51..851bcedd842 100644 --- a/server/src/main/java/org/apache/druid/server/emitter/HttpEmitterModule.java +++ b/server/src/main/java/org/apache/druid/server/emitter/HttpEmitterModule.java @@ -26,19 +26,19 @@ import com.google.inject.Module; import com.google.inject.Provides; import com.google.inject.name.Named; import com.google.inject.util.Providers; +import io.netty.handler.ssl.ClientAuth; +import io.netty.handler.ssl.JdkSslContext; +import io.netty.util.HashedWheelTimer; +import org.apache.druid.guice.JsonConfigProvider; import org.apache.druid.guice.LazySingleton; +import org.apache.druid.guice.ManageLifecycle; +import org.apache.druid.java.util.common.concurrent.Execs; +import org.apache.druid.java.util.common.lifecycle.Lifecycle; import org.apache.druid.java.util.common.logger.Logger; import org.apache.druid.java.util.emitter.core.Emitter; import org.apache.druid.java.util.emitter.core.HttpEmitterConfig; import org.apache.druid.java.util.emitter.core.HttpPostEmitter; -import org.apache.druid.guice.JsonConfigProvider; -import org.apache.druid.guice.ManageLifecycle; -import org.apache.druid.java.util.common.concurrent.Execs; -import org.apache.druid.java.util.common.lifecycle.Lifecycle; import org.apache.druid.server.security.TLSUtils; -import io.netty.handler.ssl.ClientAuth; -import io.netty.handler.ssl.JdkSslContext; -import io.netty.util.HashedWheelTimer; import org.asynchttpclient.AsyncHttpClient; import org.asynchttpclient.DefaultAsyncHttpClient; import org.asynchttpclient.DefaultAsyncHttpClientConfig; diff --git a/server/src/main/java/org/apache/druid/server/emitter/HttpEmitterSSLClientConfig.java b/server/src/main/java/org/apache/druid/server/emitter/HttpEmitterSSLClientConfig.java index ec318489526..bbf7a14140c 100644 --- a/server/src/main/java/org/apache/druid/server/emitter/HttpEmitterSSLClientConfig.java +++ b/server/src/main/java/org/apache/druid/server/emitter/HttpEmitterSSLClientConfig.java @@ -20,7 +20,6 @@ package org.apache.druid.server.emitter; import com.fasterxml.jackson.annotation.JsonProperty; - import org.apache.druid.metadata.PasswordProvider; /** diff --git a/server/src/main/java/org/apache/druid/server/emitter/LogEmitterModule.java b/server/src/main/java/org/apache/druid/server/emitter/LogEmitterModule.java index f27e270a650..d5ae0b0926c 100644 --- a/server/src/main/java/org/apache/druid/server/emitter/LogEmitterModule.java +++ b/server/src/main/java/org/apache/druid/server/emitter/LogEmitterModule.java @@ -25,11 +25,11 @@ import com.google.inject.Binder; import com.google.inject.Module; import com.google.inject.Provides; import com.google.inject.name.Named; +import org.apache.druid.guice.JsonConfigProvider; +import org.apache.druid.guice.ManageLifecycle; import org.apache.druid.java.util.emitter.core.Emitter; import org.apache.druid.java.util.emitter.core.LoggingEmitter; import org.apache.druid.java.util.emitter.core.LoggingEmitterConfig; -import org.apache.druid.guice.JsonConfigProvider; -import org.apache.druid.guice.ManageLifecycle; /** */ diff --git a/server/src/main/java/org/apache/druid/server/emitter/NoopEmitterModule.java b/server/src/main/java/org/apache/druid/server/emitter/NoopEmitterModule.java index 6e5332f1889..6c0e7f2e0df 100644 --- a/server/src/main/java/org/apache/druid/server/emitter/NoopEmitterModule.java +++ b/server/src/main/java/org/apache/druid/server/emitter/NoopEmitterModule.java @@ -23,9 +23,9 @@ import com.google.inject.Binder; import com.google.inject.Module; import com.google.inject.Provides; import com.google.inject.name.Named; +import org.apache.druid.guice.ManageLifecycle; import org.apache.druid.java.util.emitter.core.Emitter; import org.apache.druid.java.util.emitter.core.NoopEmitter; -import org.apache.druid.guice.ManageLifecycle; /** */ diff --git a/server/src/main/java/org/apache/druid/server/emitter/ParametrizedUriEmitterModule.java b/server/src/main/java/org/apache/druid/server/emitter/ParametrizedUriEmitterModule.java index 2debcd36038..ab1195569f4 100644 --- a/server/src/main/java/org/apache/druid/server/emitter/ParametrizedUriEmitterModule.java +++ b/server/src/main/java/org/apache/druid/server/emitter/ParametrizedUriEmitterModule.java @@ -25,13 +25,13 @@ import com.google.inject.Binder; import com.google.inject.Module; import com.google.inject.Provides; import com.google.inject.name.Named; +import org.apache.druid.guice.JsonConfigProvider; +import org.apache.druid.guice.ManageLifecycle; +import org.apache.druid.java.util.common.lifecycle.Lifecycle; import org.apache.druid.java.util.common.logger.Logger; import org.apache.druid.java.util.emitter.core.Emitter; import org.apache.druid.java.util.emitter.core.ParametrizedUriEmitter; import org.apache.druid.java.util.emitter.core.ParametrizedUriEmitterConfig; -import org.apache.druid.guice.JsonConfigProvider; -import org.apache.druid.guice.ManageLifecycle; -import org.apache.druid.java.util.common.lifecycle.Lifecycle; import javax.annotation.Nullable; import javax.net.ssl.SSLContext; diff --git a/server/src/main/java/org/apache/druid/server/http/security/ConfigResourceFilter.java b/server/src/main/java/org/apache/druid/server/http/security/ConfigResourceFilter.java index 2a7d32c1f50..9ebe98d4c7a 100644 --- a/server/src/main/java/org/apache/druid/server/http/security/ConfigResourceFilter.java +++ b/server/src/main/java/org/apache/druid/server/http/security/ConfigResourceFilter.java @@ -22,8 +22,8 @@ package org.apache.druid.server.http.security; import com.google.inject.Inject; import com.sun.jersey.spi.container.ContainerRequest; import org.apache.druid.server.security.Access; -import org.apache.druid.server.security.AuthorizerMapper; import org.apache.druid.server.security.AuthorizationUtils; +import org.apache.druid.server.security.AuthorizerMapper; import org.apache.druid.server.security.ForbiddenException; import org.apache.druid.server.security.Resource; import org.apache.druid.server.security.ResourceAction; diff --git a/server/src/main/java/org/apache/druid/server/http/security/DatasourceResourceFilter.java b/server/src/main/java/org/apache/druid/server/http/security/DatasourceResourceFilter.java index a76905dba41..6f62f94d3a2 100644 --- a/server/src/main/java/org/apache/druid/server/http/security/DatasourceResourceFilter.java +++ b/server/src/main/java/org/apache/druid/server/http/security/DatasourceResourceFilter.java @@ -26,8 +26,8 @@ import com.google.common.collect.Iterables; import com.google.inject.Inject; import com.sun.jersey.spi.container.ContainerRequest; import org.apache.druid.server.security.Access; -import org.apache.druid.server.security.AuthorizerMapper; import org.apache.druid.server.security.AuthorizationUtils; +import org.apache.druid.server.security.AuthorizerMapper; import org.apache.druid.server.security.ForbiddenException; import org.apache.druid.server.security.Resource; import org.apache.druid.server.security.ResourceAction; diff --git a/server/src/main/java/org/apache/druid/server/http/security/RulesResourceFilter.java b/server/src/main/java/org/apache/druid/server/http/security/RulesResourceFilter.java index 0e1fee100ae..d59aa20de11 100644 --- a/server/src/main/java/org/apache/druid/server/http/security/RulesResourceFilter.java +++ b/server/src/main/java/org/apache/druid/server/http/security/RulesResourceFilter.java @@ -26,8 +26,8 @@ import com.google.common.collect.Iterables; import com.google.inject.Inject; import com.sun.jersey.spi.container.ContainerRequest; import org.apache.druid.server.security.Access; -import org.apache.druid.server.security.AuthorizerMapper; import org.apache.druid.server.security.AuthorizationUtils; +import org.apache.druid.server.security.AuthorizerMapper; import org.apache.druid.server.security.ForbiddenException; import org.apache.druid.server.security.Resource; import org.apache.druid.server.security.ResourceAction; diff --git a/server/src/main/java/org/apache/druid/server/http/security/StateResourceFilter.java b/server/src/main/java/org/apache/druid/server/http/security/StateResourceFilter.java index 7e230302c25..cd97b5289ae 100644 --- a/server/src/main/java/org/apache/druid/server/http/security/StateResourceFilter.java +++ b/server/src/main/java/org/apache/druid/server/http/security/StateResourceFilter.java @@ -22,8 +22,8 @@ package org.apache.druid.server.http.security; import com.google.inject.Inject; import com.sun.jersey.spi.container.ContainerRequest; import org.apache.druid.server.security.Access; -import org.apache.druid.server.security.AuthorizerMapper; import org.apache.druid.server.security.AuthorizationUtils; +import org.apache.druid.server.security.AuthorizerMapper; import org.apache.druid.server.security.ForbiddenException; import org.apache.druid.server.security.Resource; import org.apache.druid.server.security.ResourceAction; diff --git a/server/src/main/java/org/apache/druid/server/initialization/AuthenticatorMapperModule.java b/server/src/main/java/org/apache/druid/server/initialization/AuthenticatorMapperModule.java index dfbbbecfa99..21c2e675fc5 100644 --- a/server/src/main/java/org/apache/druid/server/initialization/AuthenticatorMapperModule.java +++ b/server/src/main/java/org/apache/druid/server/initialization/AuthenticatorMapperModule.java @@ -35,10 +35,10 @@ import org.apache.druid.java.util.common.IAE; import org.apache.druid.java.util.common.ISE; import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.java.util.common.logger.Logger; +import org.apache.druid.server.security.AllowAllAuthenticator; import org.apache.druid.server.security.AuthConfig; import org.apache.druid.server.security.Authenticator; import org.apache.druid.server.security.AuthenticatorMapper; -import org.apache.druid.server.security.AllowAllAuthenticator; import java.util.Collections; import java.util.HashSet; diff --git a/server/src/main/java/org/apache/druid/server/initialization/jetty/JettyRequestLog.java b/server/src/main/java/org/apache/druid/server/initialization/jetty/JettyRequestLog.java index 7eece1e9766..a786e8c76ac 100644 --- a/server/src/main/java/org/apache/druid/server/initialization/jetty/JettyRequestLog.java +++ b/server/src/main/java/org/apache/druid/server/initialization/jetty/JettyRequestLog.java @@ -19,13 +19,12 @@ package org.apache.druid.server.initialization.jetty; +import org.apache.druid.java.util.common.logger.Logger; import org.eclipse.jetty.server.Request; import org.eclipse.jetty.server.RequestLog; import org.eclipse.jetty.server.Response; import org.eclipse.jetty.util.component.AbstractLifeCycle; -import org.apache.druid.java.util.common.logger.Logger; - public class JettyRequestLog extends AbstractLifeCycle implements RequestLog { diff --git a/server/src/main/java/org/apache/druid/server/listener/announcer/ListenerResourceAnnouncer.java b/server/src/main/java/org/apache/druid/server/listener/announcer/ListenerResourceAnnouncer.java index 526d40f09d9..b083f97dc70 100644 --- a/server/src/main/java/org/apache/druid/server/listener/announcer/ListenerResourceAnnouncer.java +++ b/server/src/main/java/org/apache/druid/server/listener/announcer/ListenerResourceAnnouncer.java @@ -20,12 +20,12 @@ package org.apache.druid.server.listener.announcer; import com.google.common.base.Throwables; +import org.apache.curator.utils.ZKPaths; import org.apache.druid.curator.announcement.Announcer; import org.apache.druid.java.util.common.lifecycle.LifecycleStart; import org.apache.druid.java.util.common.lifecycle.LifecycleStop; import org.apache.druid.java.util.common.logger.Logger; import org.apache.druid.server.http.HostAndPortWithScheme; -import org.apache.curator.utils.ZKPaths; import java.nio.ByteBuffer; diff --git a/server/src/main/java/org/apache/druid/server/listener/announcer/ListeningAnnouncerConfig.java b/server/src/main/java/org/apache/druid/server/listener/announcer/ListeningAnnouncerConfig.java index 8134b5cac44..4f81c406ddb 100644 --- a/server/src/main/java/org/apache/druid/server/listener/announcer/ListeningAnnouncerConfig.java +++ b/server/src/main/java/org/apache/druid/server/listener/announcer/ListeningAnnouncerConfig.java @@ -23,9 +23,9 @@ import com.fasterxml.jackson.annotation.JacksonInject; import com.fasterxml.jackson.annotation.JsonProperty; import com.google.common.base.Preconditions; import com.google.inject.Inject; +import org.apache.curator.utils.ZKPaths; import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.server.initialization.ZkPathsConfig; -import org.apache.curator.utils.ZKPaths; /** * Even though we provide the mechanism to get zk paths here, we do NOT handle announcing and unannouncing in this module. diff --git a/server/src/main/java/org/apache/druid/server/listener/resource/ListenerResource.java b/server/src/main/java/org/apache/druid/server/listener/resource/ListenerResource.java index fb28b027714..7e28f08caca 100644 --- a/server/src/main/java/org/apache/druid/server/listener/resource/ListenerResource.java +++ b/server/src/main/java/org/apache/druid/server/listener/resource/ListenerResource.java @@ -23,7 +23,6 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.jaxrs.smile.SmileMediaTypes; import com.google.common.base.Preconditions; import com.google.common.base.Strings; - import org.apache.druid.common.utils.ServletResourceUtils; import org.apache.druid.guice.annotations.Json; import org.apache.druid.guice.annotations.Smile; diff --git a/server/src/main/java/org/apache/druid/server/log/EmittingRequestLoggerProvider.java b/server/src/main/java/org/apache/druid/server/log/EmittingRequestLoggerProvider.java index d575db06aee..9e5a7214526 100644 --- a/server/src/main/java/org/apache/druid/server/log/EmittingRequestLoggerProvider.java +++ b/server/src/main/java/org/apache/druid/server/log/EmittingRequestLoggerProvider.java @@ -24,8 +24,8 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonTypeName; import com.google.inject.Inject; import com.google.inject.Injector; -import org.apache.druid.java.util.emitter.service.ServiceEmitter; import org.apache.druid.java.util.common.logger.Logger; +import org.apache.druid.java.util.emitter.service.ServiceEmitter; import javax.validation.constraints.NotNull; diff --git a/server/src/main/java/org/apache/druid/server/log/FileRequestLoggerProvider.java b/server/src/main/java/org/apache/druid/server/log/FileRequestLoggerProvider.java index 20e73c3612a..f3d500d6985 100644 --- a/server/src/main/java/org/apache/druid/server/log/FileRequestLoggerProvider.java +++ b/server/src/main/java/org/apache/druid/server/log/FileRequestLoggerProvider.java @@ -23,7 +23,6 @@ import com.fasterxml.jackson.annotation.JacksonInject; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.databind.ObjectMapper; - import org.apache.druid.guice.annotations.Json; import org.apache.druid.java.util.common.concurrent.ScheduledExecutorFactory; import org.apache.druid.java.util.common.logger.Logger; diff --git a/server/src/main/java/org/apache/druid/server/log/LoggingRequestLogger.java b/server/src/main/java/org/apache/druid/server/log/LoggingRequestLogger.java index 47b220b5bc7..59896064665 100644 --- a/server/src/main/java/org/apache/druid/server/log/LoggingRequestLogger.java +++ b/server/src/main/java/org/apache/druid/server/log/LoggingRequestLogger.java @@ -21,7 +21,6 @@ package org.apache.druid.server.log; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.collect.ImmutableList; - import org.apache.druid.java.util.common.logger.Logger; import org.apache.druid.query.Query; import org.apache.druid.server.RequestLogLine; diff --git a/server/src/main/java/org/apache/druid/server/metrics/EventReceiverFirehoseRegister.java b/server/src/main/java/org/apache/druid/server/metrics/EventReceiverFirehoseRegister.java index 64902708873..66a022992e7 100644 --- a/server/src/main/java/org/apache/druid/server/metrics/EventReceiverFirehoseRegister.java +++ b/server/src/main/java/org/apache/druid/server/metrics/EventReceiverFirehoseRegister.java @@ -19,13 +19,13 @@ package org.apache.druid.server.metrics; +import org.apache.druid.java.util.common.ISE; +import org.apache.druid.java.util.common.logger.Logger; + import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; -import org.apache.druid.java.util.common.ISE; -import org.apache.druid.java.util.common.logger.Logger; - public class EventReceiverFirehoseRegister { diff --git a/server/src/main/java/org/apache/druid/server/metrics/HistoricalMetricsMonitor.java b/server/src/main/java/org/apache/druid/server/metrics/HistoricalMetricsMonitor.java index 893c2e91839..30083cbc091 100644 --- a/server/src/main/java/org/apache/druid/server/metrics/HistoricalMetricsMonitor.java +++ b/server/src/main/java/org/apache/druid/server/metrics/HistoricalMetricsMonitor.java @@ -20,16 +20,16 @@ package org.apache.druid.server.metrics; import com.google.inject.Inject; +import it.unimi.dsi.fastutil.objects.Object2LongMap; +import it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap; +import org.apache.druid.client.DruidServerConfig; import org.apache.druid.java.util.emitter.service.ServiceEmitter; import org.apache.druid.java.util.emitter.service.ServiceMetricEvent; import org.apache.druid.java.util.metrics.AbstractMonitor; -import org.apache.druid.client.DruidServerConfig; import org.apache.druid.query.DruidMetrics; import org.apache.druid.server.SegmentManager; import org.apache.druid.server.coordination.SegmentLoadDropHandler; import org.apache.druid.timeline.DataSegment; -import it.unimi.dsi.fastutil.objects.Object2LongMap; -import it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap; import java.util.Map; diff --git a/server/src/main/java/org/apache/druid/server/metrics/MetricsModule.java b/server/src/main/java/org/apache/druid/server/metrics/MetricsModule.java index 7e3a25a535c..c91ad3daf7a 100644 --- a/server/src/main/java/org/apache/druid/server/metrics/MetricsModule.java +++ b/server/src/main/java/org/apache/druid/server/metrics/MetricsModule.java @@ -28,6 +28,12 @@ import com.google.inject.Key; import com.google.inject.Module; import com.google.inject.Provides; import com.google.inject.name.Names; +import org.apache.druid.guice.DruidBinders; +import org.apache.druid.guice.JsonConfigProvider; +import org.apache.druid.guice.LazySingleton; +import org.apache.druid.guice.ManageLifecycle; +import org.apache.druid.java.util.common.concurrent.Execs; +import org.apache.druid.java.util.common.logger.Logger; import org.apache.druid.java.util.emitter.service.ServiceEmitter; import org.apache.druid.java.util.metrics.JvmCpuMonitor; import org.apache.druid.java.util.metrics.JvmMonitor; @@ -35,15 +41,10 @@ import org.apache.druid.java.util.metrics.JvmThreadsMonitor; import org.apache.druid.java.util.metrics.Monitor; import org.apache.druid.java.util.metrics.MonitorScheduler; import org.apache.druid.java.util.metrics.SysMonitor; -import org.apache.druid.guice.DruidBinders; -import org.apache.druid.guice.JsonConfigProvider; -import org.apache.druid.guice.LazySingleton; -import org.apache.druid.guice.ManageLifecycle; -import org.apache.druid.java.util.common.concurrent.Execs; -import org.apache.druid.java.util.common.logger.Logger; import org.apache.druid.query.ExecutorServiceMonitor; import java.util.List; +import java.util.Map; import java.util.Set; /** @@ -112,10 +113,11 @@ public class MetricsModule implements Module DataSourceTaskIdHolder dataSourceTaskIdHolder ) { - return new JvmMonitor(MonitorsConfig.mapOfDatasourceAndTaskID( + Map dimensions = MonitorsConfig.mapOfDatasourceAndTaskID( dataSourceTaskIdHolder.getDataSource(), dataSourceTaskIdHolder.getTaskId() - )); + ); + return new JvmMonitor(dimensions); } @Provides @@ -124,22 +126,22 @@ public class MetricsModule implements Module DataSourceTaskIdHolder dataSourceTaskIdHolder ) { - return new JvmCpuMonitor(MonitorsConfig.mapOfDatasourceAndTaskID( + Map dimensions = MonitorsConfig.mapOfDatasourceAndTaskID( dataSourceTaskIdHolder.getDataSource(), dataSourceTaskIdHolder.getTaskId() - )); + ); + return new JvmCpuMonitor(dimensions); } @Provides @ManageLifecycle public JvmThreadsMonitor getJvmThreadsMonitor(DataSourceTaskIdHolder dataSourceTaskIdHolder) { - return new JvmThreadsMonitor( - MonitorsConfig.mapOfDatasourceAndTaskID( - dataSourceTaskIdHolder.getDataSource(), - dataSourceTaskIdHolder.getTaskId() - ) + Map dimensions = MonitorsConfig.mapOfDatasourceAndTaskID( + dataSourceTaskIdHolder.getDataSource(), + dataSourceTaskIdHolder.getTaskId() ); + return new JvmThreadsMonitor(dimensions); } @Provides @@ -148,9 +150,10 @@ public class MetricsModule implements Module DataSourceTaskIdHolder dataSourceTaskIdHolder ) { - return new SysMonitor(MonitorsConfig.mapOfDatasourceAndTaskID( + Map dimensions = MonitorsConfig.mapOfDatasourceAndTaskID( dataSourceTaskIdHolder.getDataSource(), dataSourceTaskIdHolder.getTaskId() - )); + ); + return new SysMonitor(dimensions); } } diff --git a/server/src/main/java/org/apache/druid/server/metrics/MonitorsConfig.java b/server/src/main/java/org/apache/druid/server/metrics/MonitorsConfig.java index ef0cdc1f421..4381895b0bc 100644 --- a/server/src/main/java/org/apache/druid/server/metrics/MonitorsConfig.java +++ b/server/src/main/java/org/apache/druid/server/metrics/MonitorsConfig.java @@ -78,10 +78,7 @@ public class MonitorsConfig '}'; } - public static Map mapOfDatasourceAndTaskID( - final String datasource, - final String taskId - ) + public static Map mapOfDatasourceAndTaskID(final String datasource, final String taskId) { final ImmutableMap.Builder builder = ImmutableMap.builder(); if (datasource != null) { diff --git a/server/src/main/java/org/apache/druid/server/router/CoordinatorRuleManager.java b/server/src/main/java/org/apache/druid/server/router/CoordinatorRuleManager.java index 1c6af5f4aeb..e865112133b 100644 --- a/server/src/main/java/org/apache/druid/server/router/CoordinatorRuleManager.java +++ b/server/src/main/java/org/apache/druid/server/router/CoordinatorRuleManager.java @@ -24,16 +24,16 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.base.Supplier; import com.google.common.collect.Lists; import com.google.inject.Inject; -import org.apache.druid.java.util.http.client.response.FullResponseHolder; -import org.apache.druid.java.util.common.concurrent.Execs; import org.apache.druid.discovery.DruidLeaderClient; import org.apache.druid.guice.ManageLifecycle; import org.apache.druid.guice.annotations.Json; import org.apache.druid.java.util.common.ISE; +import org.apache.druid.java.util.common.concurrent.Execs; import org.apache.druid.java.util.common.concurrent.ScheduledExecutors; import org.apache.druid.java.util.common.lifecycle.LifecycleStart; import org.apache.druid.java.util.common.lifecycle.LifecycleStop; import org.apache.druid.java.util.common.logger.Logger; +import org.apache.druid.java.util.http.client.response.FullResponseHolder; import org.apache.druid.server.coordinator.rules.Rule; import org.jboss.netty.handler.codec.http.HttpMethod; import org.jboss.netty.handler.codec.http.HttpResponseStatus; diff --git a/server/src/main/java/org/apache/druid/server/router/TieredBrokerHostSelector.java b/server/src/main/java/org/apache/druid/server/router/TieredBrokerHostSelector.java index 48ec5882206..4b224c89ee7 100644 --- a/server/src/main/java/org/apache/druid/server/router/TieredBrokerHostSelector.java +++ b/server/src/main/java/org/apache/druid/server/router/TieredBrokerHostSelector.java @@ -25,7 +25,6 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; import com.google.common.collect.Maps; import com.google.inject.Inject; -import org.apache.druid.java.util.emitter.EmittingLogger; import org.apache.druid.client.selector.Server; import org.apache.druid.discovery.DiscoveryDruidNode; import org.apache.druid.discovery.DruidNodeDiscovery; @@ -34,6 +33,7 @@ import org.apache.druid.java.util.common.DateTimes; import org.apache.druid.java.util.common.Pair; import org.apache.druid.java.util.common.lifecycle.LifecycleStart; import org.apache.druid.java.util.common.lifecycle.LifecycleStop; +import org.apache.druid.java.util.emitter.EmittingLogger; import org.apache.druid.query.Query; import org.apache.druid.server.coordinator.rules.LoadRule; import org.apache.druid.server.coordinator.rules.Rule; diff --git a/server/src/test/java/org/apache/druid/client/BrokerServerViewTest.java b/server/src/test/java/org/apache/druid/client/BrokerServerViewTest.java index 0df2c82a634..b8ed6bf466e 100644 --- a/server/src/test/java/org/apache/druid/client/BrokerServerViewTest.java +++ b/server/src/test/java/org/apache/druid/client/BrokerServerViewTest.java @@ -28,7 +28,6 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; -import org.apache.druid.java.util.http.client.HttpClient; import org.apache.druid.client.selector.HighestPriorityTierSelectorStrategy; import org.apache.druid.client.selector.RandomServerSelectorStrategy; import org.apache.druid.client.selector.ServerSelector; @@ -36,6 +35,7 @@ import org.apache.druid.curator.CuratorTestBase; import org.apache.druid.jackson.DefaultObjectMapper; import org.apache.druid.java.util.common.Intervals; import org.apache.druid.java.util.common.Pair; +import org.apache.druid.java.util.http.client.HttpClient; import org.apache.druid.query.QueryToolChestWarehouse; import org.apache.druid.query.QueryWatcher; import org.apache.druid.query.TableDataSource; diff --git a/server/src/test/java/org/apache/druid/client/CoordinatorServerViewTest.java b/server/src/test/java/org/apache/druid/client/CoordinatorServerViewTest.java index ec67833e504..9d054f375b9 100644 --- a/server/src/test/java/org/apache/druid/client/CoordinatorServerViewTest.java +++ b/server/src/test/java/org/apache/druid/client/CoordinatorServerViewTest.java @@ -26,6 +26,7 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; +import org.apache.curator.utils.ZKPaths; import org.apache.druid.curator.CuratorTestBase; import org.apache.druid.java.util.common.Intervals; import org.apache.druid.java.util.common.Pair; @@ -39,7 +40,6 @@ import org.apache.druid.timeline.TimelineLookup; import org.apache.druid.timeline.TimelineObjectHolder; import org.apache.druid.timeline.partition.NoneShardSpec; import org.apache.druid.timeline.partition.PartitionHolder; -import org.apache.curator.utils.ZKPaths; import org.joda.time.Interval; import org.junit.After; import org.junit.Assert; diff --git a/server/src/test/java/org/apache/druid/client/HttpServerInventoryViewTest.java b/server/src/test/java/org/apache/druid/client/HttpServerInventoryViewTest.java index fbeae25f769..96bc3893b01 100644 --- a/server/src/test/java/org/apache/druid/client/HttpServerInventoryViewTest.java +++ b/server/src/test/java/org/apache/druid/client/HttpServerInventoryViewTest.java @@ -25,22 +25,22 @@ import com.google.common.collect.ImmutableMap; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.MoreExecutors; -import org.apache.druid.java.util.http.client.HttpClient; -import org.apache.druid.java.util.http.client.Request; -import org.apache.druid.java.util.http.client.response.HttpResponseHandler; import org.apache.druid.discovery.DataNodeService; import org.apache.druid.discovery.DiscoveryDruidNode; import org.apache.druid.discovery.DruidNodeDiscovery; import org.apache.druid.discovery.DruidNodeDiscoveryProvider; import org.apache.druid.java.util.common.Intervals; import org.apache.druid.java.util.common.RE; +import org.apache.druid.java.util.http.client.HttpClient; +import org.apache.druid.java.util.http.client.Request; +import org.apache.druid.java.util.http.client.response.HttpResponseHandler; import org.apache.druid.segment.TestHelper; import org.apache.druid.server.DruidNode; +import org.apache.druid.server.coordination.ChangeRequestHistory; +import org.apache.druid.server.coordination.ChangeRequestsSnapshot; import org.apache.druid.server.coordination.DruidServerMetadata; import org.apache.druid.server.coordination.SegmentChangeRequestDrop; -import org.apache.druid.server.coordination.ChangeRequestHistory; import org.apache.druid.server.coordination.SegmentChangeRequestLoad; -import org.apache.druid.server.coordination.ChangeRequestsSnapshot; import org.apache.druid.server.coordination.ServerType; import org.apache.druid.timeline.DataSegment; import org.easymock.EasyMock; diff --git a/server/src/test/java/org/apache/druid/client/cache/BytesBoundedLinkedQueueTest.java b/server/src/test/java/org/apache/druid/client/cache/BytesBoundedLinkedQueueTest.java index 616afb9958a..940160cce3c 100644 --- a/server/src/test/java/org/apache/druid/client/cache/BytesBoundedLinkedQueueTest.java +++ b/server/src/test/java/org/apache/druid/client/cache/BytesBoundedLinkedQueueTest.java @@ -20,11 +20,10 @@ package org.apache.druid.client.cache; +import org.apache.druid.java.util.common.ISE; import org.junit.Assert; import org.junit.Test; -import org.apache.druid.java.util.common.ISE; - import java.util.ArrayList; import java.util.List; import java.util.concurrent.BlockingQueue; diff --git a/server/src/test/java/org/apache/druid/client/cache/MemcachedCacheBenchmark.java b/server/src/test/java/org/apache/druid/client/cache/MemcachedCacheBenchmark.java index e439fe2ff5a..147ae6a488d 100644 --- a/server/src/test/java/org/apache/druid/client/cache/MemcachedCacheBenchmark.java +++ b/server/src/test/java/org/apache/druid/client/cache/MemcachedCacheBenchmark.java @@ -24,8 +24,6 @@ import com.google.caliper.Runner; import com.google.caliper.SimpleBenchmark; import com.google.common.base.Suppliers; import com.google.common.collect.Lists; -import org.apache.druid.collections.StupidResourceHolder; -import org.apache.druid.java.util.common.StringUtils; import net.spy.memcached.AddrUtil; import net.spy.memcached.ConnectionFactoryBuilder; import net.spy.memcached.DefaultHashAlgorithm; @@ -33,6 +31,8 @@ import net.spy.memcached.FailureMode; import net.spy.memcached.MemcachedClient; import net.spy.memcached.MemcachedClientIF; import net.spy.memcached.transcoders.SerializingTranscoder; +import org.apache.druid.collections.StupidResourceHolder; +import org.apache.druid.java.util.common.StringUtils; import java.util.List; import java.util.Map; diff --git a/server/src/test/java/org/apache/druid/client/cache/MemcachedCacheTest.java b/server/src/test/java/org/apache/druid/client/cache/MemcachedCacheTest.java index 89eb3daee9e..31840d0ca61 100644 --- a/server/src/test/java/org/apache/druid/client/cache/MemcachedCacheTest.java +++ b/server/src/test/java/org/apache/druid/client/cache/MemcachedCacheTest.java @@ -30,19 +30,6 @@ import com.google.inject.Inject; import com.google.inject.Injector; import com.google.inject.Module; import com.google.inject.name.Names; -import org.apache.druid.collections.StupidResourceHolder; -import org.apache.druid.guice.GuiceInjectors; -import org.apache.druid.guice.JsonConfigProvider; -import org.apache.druid.guice.ManageLifecycle; -import org.apache.druid.initialization.Initialization; -import org.apache.druid.jackson.DefaultObjectMapper; -import org.apache.druid.java.util.common.StringUtils; -import org.apache.druid.java.util.common.lifecycle.Lifecycle; -import org.apache.druid.java.util.common.logger.Logger; -import org.apache.druid.java.util.emitter.core.Emitter; -import org.apache.druid.java.util.emitter.core.Event; -import org.apache.druid.java.util.emitter.service.ServiceEmitter; -import org.apache.druid.java.util.metrics.AbstractMonitor; import net.spy.memcached.BroadcastOpFactory; import net.spy.memcached.CASResponse; import net.spy.memcached.CASValue; @@ -57,6 +44,19 @@ import net.spy.memcached.internal.OperationFuture; import net.spy.memcached.ops.OperationStatus; import net.spy.memcached.transcoders.SerializingTranscoder; import net.spy.memcached.transcoders.Transcoder; +import org.apache.druid.collections.StupidResourceHolder; +import org.apache.druid.guice.GuiceInjectors; +import org.apache.druid.guice.JsonConfigProvider; +import org.apache.druid.guice.ManageLifecycle; +import org.apache.druid.initialization.Initialization; +import org.apache.druid.jackson.DefaultObjectMapper; +import org.apache.druid.java.util.common.StringUtils; +import org.apache.druid.java.util.common.lifecycle.Lifecycle; +import org.apache.druid.java.util.common.logger.Logger; +import org.apache.druid.java.util.emitter.core.Emitter; +import org.apache.druid.java.util.emitter.core.Event; +import org.apache.druid.java.util.emitter.service.ServiceEmitter; +import org.apache.druid.java.util.metrics.AbstractMonitor; import org.easymock.EasyMock; import org.junit.Assert; import org.junit.Before; diff --git a/server/src/test/java/org/apache/druid/client/client/BatchServerInventoryViewTest.java b/server/src/test/java/org/apache/druid/client/client/BatchServerInventoryViewTest.java index fa2fa440c26..d2ae93adddc 100644 --- a/server/src/test/java/org/apache/druid/client/client/BatchServerInventoryViewTest.java +++ b/server/src/test/java/org/apache/druid/client/client/BatchServerInventoryViewTest.java @@ -30,6 +30,11 @@ import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListeningExecutorService; import com.google.common.util.concurrent.MoreExecutors; +import org.apache.curator.framework.CuratorFramework; +import org.apache.curator.framework.CuratorFrameworkFactory; +import org.apache.curator.retry.ExponentialBackoffRetry; +import org.apache.curator.test.TestingCluster; +import org.apache.curator.test.Timing; import org.apache.druid.client.BatchServerInventoryView; import org.apache.druid.client.DruidServer; import org.apache.druid.client.ServerView; @@ -48,11 +53,6 @@ import org.apache.druid.server.coordination.ServerType; import org.apache.druid.server.initialization.BatchDataSegmentAnnouncerConfig; import org.apache.druid.server.initialization.ZkPathsConfig; import org.apache.druid.timeline.DataSegment; -import org.apache.curator.framework.CuratorFramework; -import org.apache.curator.framework.CuratorFrameworkFactory; -import org.apache.curator.retry.ExponentialBackoffRetry; -import org.apache.curator.test.TestingCluster; -import org.apache.curator.test.Timing; import org.easymock.EasyMock; import org.easymock.IAnswer; import org.easymock.LogicalOperator; diff --git a/server/src/test/java/org/apache/druid/client/client/ImmutableSegmentLoadInfoTest.java b/server/src/test/java/org/apache/druid/client/client/ImmutableSegmentLoadInfoTest.java index 11d95d651d0..4baa33ea235 100644 --- a/server/src/test/java/org/apache/druid/client/client/ImmutableSegmentLoadInfoTest.java +++ b/server/src/test/java/org/apache/druid/client/client/ImmutableSegmentLoadInfoTest.java @@ -21,6 +21,7 @@ package org.apache.druid.client.client; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.collect.Sets; +import junit.framework.Assert; import org.apache.druid.client.ImmutableSegmentLoadInfo; import org.apache.druid.java.util.common.Intervals; import org.apache.druid.segment.TestHelper; @@ -28,7 +29,6 @@ import org.apache.druid.server.coordination.DruidServerMetadata; import org.apache.druid.server.coordination.ServerType; import org.apache.druid.timeline.DataSegment; import org.apache.druid.timeline.partition.NoneShardSpec; -import junit.framework.Assert; import org.junit.Test; import java.io.IOException; diff --git a/server/src/test/java/org/apache/druid/curator/CuratorConfigTest.java b/server/src/test/java/org/apache/druid/curator/CuratorConfigTest.java index 67359db0c1e..55d68330152 100644 --- a/server/src/test/java/org/apache/druid/curator/CuratorConfigTest.java +++ b/server/src/test/java/org/apache/druid/curator/CuratorConfigTest.java @@ -19,11 +19,10 @@ package org.apache.druid.curator; +import org.apache.druid.guice.JsonConfigTesterBase; import org.junit.Assert; import org.junit.Test; -import org.apache.druid.guice.JsonConfigTesterBase; - public class CuratorConfigTest extends JsonConfigTesterBase { @Test diff --git a/server/src/test/java/org/apache/druid/curator/CuratorModuleTest.java b/server/src/test/java/org/apache/druid/curator/CuratorModuleTest.java index e4dddb108ae..de1d5496520 100644 --- a/server/src/test/java/org/apache/druid/curator/CuratorModuleTest.java +++ b/server/src/test/java/org/apache/druid/curator/CuratorModuleTest.java @@ -25,12 +25,12 @@ import com.google.inject.Guice; import com.google.inject.Injector; import com.google.inject.Module; import com.google.inject.util.Modules; -import org.apache.druid.guice.GuiceInjectors; -import org.apache.druid.guice.LifecycleModule; import org.apache.curator.ensemble.EnsembleProvider; import org.apache.curator.ensemble.exhibitor.ExhibitorEnsembleProvider; import org.apache.curator.ensemble.fixed.FixedEnsembleProvider; import org.apache.curator.framework.CuratorFramework; +import org.apache.druid.guice.GuiceInjectors; +import org.apache.druid.guice.LifecycleModule; import org.junit.Assert; import org.junit.Test; diff --git a/server/src/test/java/org/apache/druid/curator/CuratorTestBase.java b/server/src/test/java/org/apache/druid/curator/CuratorTestBase.java index 3775f57768e..bf080871587 100644 --- a/server/src/test/java/org/apache/druid/curator/CuratorTestBase.java +++ b/server/src/test/java/org/apache/druid/curator/CuratorTestBase.java @@ -22,17 +22,17 @@ package org.apache.druid.curator; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.base.Throwables; import com.google.common.collect.ImmutableSet; -import org.apache.druid.client.DruidServer; -import org.apache.druid.common.utils.UUIDUtils; -import org.apache.druid.java.util.common.DateTimes; -import org.apache.druid.server.initialization.ZkPathsConfig; -import org.apache.druid.timeline.DataSegment; import org.apache.curator.framework.CuratorFramework; import org.apache.curator.framework.CuratorFrameworkFactory; import org.apache.curator.retry.RetryOneTime; import org.apache.curator.test.TestingServer; import org.apache.curator.test.Timing; import org.apache.curator.utils.ZKPaths; +import org.apache.druid.client.DruidServer; +import org.apache.druid.common.utils.UUIDUtils; +import org.apache.druid.java.util.common.DateTimes; +import org.apache.druid.server.initialization.ZkPathsConfig; +import org.apache.druid.timeline.DataSegment; import org.apache.zookeeper.CreateMode; import org.apache.zookeeper.KeeperException; diff --git a/server/src/test/java/org/apache/druid/curator/announcement/AnnouncerTest.java b/server/src/test/java/org/apache/druid/curator/announcement/AnnouncerTest.java index 5ca9b29f050..e12d8bc47bb 100644 --- a/server/src/test/java/org/apache/druid/curator/announcement/AnnouncerTest.java +++ b/server/src/test/java/org/apache/druid/curator/announcement/AnnouncerTest.java @@ -20,10 +20,6 @@ package org.apache.druid.curator.announcement; import com.google.common.collect.Sets; -import org.apache.druid.curator.CuratorTestBase; -import org.apache.druid.java.util.common.StringUtils; -import org.apache.druid.java.util.common.concurrent.Execs; -import org.apache.druid.java.util.common.logger.Logger; import org.apache.curator.framework.CuratorFramework; import org.apache.curator.framework.api.CuratorEvent; import org.apache.curator.framework.api.CuratorEventType; @@ -32,6 +28,10 @@ import org.apache.curator.framework.api.transaction.CuratorOp; import org.apache.curator.framework.api.transaction.CuratorTransactionResult; import org.apache.curator.test.KillSession; import org.apache.curator.utils.ZKPaths; +import org.apache.druid.curator.CuratorTestBase; +import org.apache.druid.java.util.common.StringUtils; +import org.apache.druid.java.util.common.concurrent.Execs; +import org.apache.druid.java.util.common.logger.Logger; import org.apache.zookeeper.KeeperException.Code; import org.apache.zookeeper.data.Stat; import org.junit.After; diff --git a/server/src/test/java/org/apache/druid/curator/discovery/CuratorDruidLeaderSelectorTest.java b/server/src/test/java/org/apache/druid/curator/discovery/CuratorDruidLeaderSelectorTest.java index 1828bb6da0c..3c452d3a607 100644 --- a/server/src/test/java/org/apache/druid/curator/discovery/CuratorDruidLeaderSelectorTest.java +++ b/server/src/test/java/org/apache/druid/curator/discovery/CuratorDruidLeaderSelectorTest.java @@ -19,11 +19,11 @@ package org.apache.druid.curator.discovery; -import org.apache.druid.java.util.emitter.EmittingLogger; -import org.apache.druid.java.util.emitter.service.ServiceEmitter; import org.apache.druid.curator.CuratorTestBase; import org.apache.druid.discovery.DruidLeaderSelector; import org.apache.druid.java.util.common.logger.Logger; +import org.apache.druid.java.util.emitter.EmittingLogger; +import org.apache.druid.java.util.emitter.service.ServiceEmitter; import org.apache.druid.server.DruidNode; import org.easymock.EasyMock; import org.junit.After; diff --git a/server/src/test/java/org/apache/druid/curator/discovery/ServerDiscoverySelectorTest.java b/server/src/test/java/org/apache/druid/curator/discovery/ServerDiscoverySelectorTest.java index c6cf6516438..cac1bd00801 100644 --- a/server/src/test/java/org/apache/druid/curator/discovery/ServerDiscoverySelectorTest.java +++ b/server/src/test/java/org/apache/druid/curator/discovery/ServerDiscoverySelectorTest.java @@ -19,10 +19,10 @@ package org.apache.druid.curator.discovery; -import org.apache.druid.client.selector.Server; -import org.apache.druid.java.util.common.StringUtils; import org.apache.curator.x.discovery.ServiceInstance; import org.apache.curator.x.discovery.ServiceProvider; +import org.apache.druid.client.selector.Server; +import org.apache.druid.java.util.common.StringUtils; import org.easymock.EasyMock; import org.junit.Assert; import org.junit.Before; diff --git a/server/src/test/java/org/apache/druid/curator/discovery/ServiceAnnouncerTest.java b/server/src/test/java/org/apache/druid/curator/discovery/ServiceAnnouncerTest.java index bf0a51fd7d8..1aa8e17956f 100644 --- a/server/src/test/java/org/apache/druid/curator/discovery/ServiceAnnouncerTest.java +++ b/server/src/test/java/org/apache/druid/curator/discovery/ServiceAnnouncerTest.java @@ -22,13 +22,11 @@ package org.apache.druid.curator.discovery; import com.google.common.base.Predicate; import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterators; - -import org.apache.druid.curator.CuratorTestBase; -import org.apache.druid.java.util.common.ISE; - import org.apache.curator.x.discovery.ServiceDiscovery; import org.apache.curator.x.discovery.ServiceDiscoveryBuilder; import org.apache.curator.x.discovery.ServiceInstance; +import org.apache.druid.curator.CuratorTestBase; +import org.apache.druid.java.util.common.ISE; import org.junit.After; import org.junit.Assert; import org.junit.Before; diff --git a/server/src/test/java/org/apache/druid/curator/inventory/CuratorInventoryManagerTest.java b/server/src/test/java/org/apache/druid/curator/inventory/CuratorInventoryManagerTest.java index 3bc26dd5a63..d95f861ed6d 100644 --- a/server/src/test/java/org/apache/druid/curator/inventory/CuratorInventoryManagerTest.java +++ b/server/src/test/java/org/apache/druid/curator/inventory/CuratorInventoryManagerTest.java @@ -22,12 +22,12 @@ package org.apache.druid.curator.inventory; import com.google.common.collect.Iterables; import com.google.common.collect.Maps; import com.google.common.primitives.Ints; -import org.apache.druid.curator.CuratorTestBase; -import org.apache.druid.java.util.common.concurrent.Execs; import org.apache.curator.framework.CuratorFramework; import org.apache.curator.framework.api.CuratorEvent; import org.apache.curator.framework.api.CuratorEventType; import org.apache.curator.framework.api.CuratorListener; +import org.apache.druid.curator.CuratorTestBase; +import org.apache.druid.java.util.common.concurrent.Execs; import org.apache.zookeeper.CreateMode; import org.apache.zookeeper.Watcher; import org.junit.After; diff --git a/server/src/test/java/org/apache/druid/guice/JsonConfigTesterBaseTest.java b/server/src/test/java/org/apache/druid/guice/JsonConfigTesterBaseTest.java index abc83dfd111..89cabf8c5f4 100644 --- a/server/src/test/java/org/apache/druid/guice/JsonConfigTesterBaseTest.java +++ b/server/src/test/java/org/apache/druid/guice/JsonConfigTesterBaseTest.java @@ -20,7 +20,6 @@ package org.apache.druid.guice; import com.fasterxml.jackson.annotation.JsonProperty; - import org.junit.Assert; import org.junit.Test; diff --git a/server/src/test/java/org/apache/druid/initialization/ComposingEmitterModuleTest.java b/server/src/test/java/org/apache/druid/initialization/ComposingEmitterModuleTest.java index 50bcf09e7e5..ab0a5eb9119 100644 --- a/server/src/test/java/org/apache/druid/initialization/ComposingEmitterModuleTest.java +++ b/server/src/test/java/org/apache/druid/initialization/ComposingEmitterModuleTest.java @@ -25,9 +25,9 @@ import com.google.inject.Injector; import com.google.inject.Key; import com.google.inject.Module; import com.google.inject.name.Names; -import org.apache.druid.java.util.emitter.core.Emitter; import org.apache.druid.guice.DruidGuiceExtensions; import org.apache.druid.guice.LifecycleModule; +import org.apache.druid.java.util.emitter.core.Emitter; import org.apache.druid.server.emitter.ComposingEmitterConfig; import org.apache.druid.server.emitter.ComposingEmitterModule; import org.easymock.EasyMock; diff --git a/server/src/test/java/org/apache/druid/initialization/ZkPathsConfigTest.java b/server/src/test/java/org/apache/druid/initialization/ZkPathsConfigTest.java index f30a27d378c..aa81645deea 100644 --- a/server/src/test/java/org/apache/druid/initialization/ZkPathsConfigTest.java +++ b/server/src/test/java/org/apache/druid/initialization/ZkPathsConfigTest.java @@ -21,13 +21,13 @@ package org.apache.druid.initialization; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.inject.Key; +import org.apache.curator.utils.ZKPaths; import org.apache.druid.guice.JsonConfigProvider; import org.apache.druid.guice.JsonConfigTesterBase; import org.apache.druid.guice.JsonConfigurator; import org.apache.druid.guice.annotations.Json; import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.server.initialization.ZkPathsConfig; -import org.apache.curator.utils.ZKPaths; import org.junit.Assert; import org.junit.Test; diff --git a/server/src/test/java/org/apache/druid/query/dimension/LookupDimensionSpecTest.java b/server/src/test/java/org/apache/druid/query/dimension/LookupDimensionSpecTest.java index 9412266d565..d1a4fedbabc 100644 --- a/server/src/test/java/org/apache/druid/query/dimension/LookupDimensionSpecTest.java +++ b/server/src/test/java/org/apache/druid/query/dimension/LookupDimensionSpecTest.java @@ -23,6 +23,8 @@ import com.fasterxml.jackson.databind.InjectableValues; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.jsontype.NamedType; import com.google.common.collect.ImmutableMap; +import junitparams.JUnitParamsRunner; +import junitparams.Parameters; import org.apache.druid.common.config.NullHandling; import org.apache.druid.jackson.DefaultObjectMapper; import org.apache.druid.query.extraction.ExtractionFn; @@ -32,8 +34,6 @@ import org.apache.druid.query.lookup.LookupExtractorFactoryContainer; import org.apache.druid.query.lookup.LookupReferencesManager; import org.apache.druid.query.lookup.MapLookupExtractorFactory; import org.apache.druid.segment.TestHelper; -import junitparams.JUnitParamsRunner; -import junitparams.Parameters; import org.easymock.EasyMock; import org.junit.Assert; import org.junit.Test; diff --git a/server/src/test/java/org/apache/druid/query/lookup/LookupReferencesManagerTest.java b/server/src/test/java/org/apache/druid/query/lookup/LookupReferencesManagerTest.java index 80d35171f65..f155895a80e 100644 --- a/server/src/test/java/org/apache/druid/query/lookup/LookupReferencesManagerTest.java +++ b/server/src/test/java/org/apache/druid/query/lookup/LookupReferencesManagerTest.java @@ -21,11 +21,11 @@ package org.apache.druid.query.lookup; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.collect.ImmutableMap; +import org.apache.druid.discovery.DruidLeaderClient; +import org.apache.druid.jackson.DefaultObjectMapper; import org.apache.druid.java.util.emitter.EmittingLogger; import org.apache.druid.java.util.http.client.Request; import org.apache.druid.java.util.http.client.response.FullResponseHolder; -import org.apache.druid.discovery.DruidLeaderClient; -import org.apache.druid.jackson.DefaultObjectMapper; import org.apache.druid.server.metrics.NoopServiceEmitter; import org.easymock.EasyMock; import org.jboss.netty.handler.codec.http.HttpMethod; diff --git a/server/src/test/java/org/apache/druid/segment/loading/LocalDataSegmentFinderTest.java b/server/src/test/java/org/apache/druid/segment/loading/LocalDataSegmentFinderTest.java index 5574bd6581a..a5f1e1846de 100644 --- a/server/src/test/java/org/apache/druid/segment/loading/LocalDataSegmentFinderTest.java +++ b/server/src/test/java/org/apache/druid/segment/loading/LocalDataSegmentFinderTest.java @@ -23,11 +23,11 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.jsontype.NamedType; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; +import org.apache.commons.io.FileUtils; import org.apache.druid.java.util.common.Intervals; import org.apache.druid.segment.TestHelper; import org.apache.druid.timeline.DataSegment; import org.apache.druid.timeline.partition.NumberedShardSpec; -import org.apache.commons.io.FileUtils; import org.junit.Assert; import org.junit.Before; import org.junit.BeforeClass; diff --git a/server/src/test/java/org/apache/druid/segment/loading/LocalDataSegmentPullerTest.java b/server/src/test/java/org/apache/druid/segment/loading/LocalDataSegmentPullerTest.java index f2f85c5b023..7cf959f3b75 100644 --- a/server/src/test/java/org/apache/druid/segment/loading/LocalDataSegmentPullerTest.java +++ b/server/src/test/java/org/apache/druid/segment/loading/LocalDataSegmentPullerTest.java @@ -20,8 +20,8 @@ package org.apache.druid.segment.loading; import com.google.common.io.Files; -import org.apache.druid.java.util.common.CompressionUtils; import org.apache.commons.io.FileUtils; +import org.apache.druid.java.util.common.CompressionUtils; import org.junit.After; import org.junit.Assert; import org.junit.Before; diff --git a/server/src/test/java/org/apache/druid/segment/loading/LocalDataSegmentPusherTest.java b/server/src/test/java/org/apache/druid/segment/loading/LocalDataSegmentPusherTest.java index 4992aa71c3f..9d79c0779c6 100644 --- a/server/src/test/java/org/apache/druid/segment/loading/LocalDataSegmentPusherTest.java +++ b/server/src/test/java/org/apache/druid/segment/loading/LocalDataSegmentPusherTest.java @@ -23,13 +23,13 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.collect.ImmutableList; import com.google.common.io.Files; import com.google.common.primitives.Ints; +import org.apache.commons.io.FileUtils; import org.apache.druid.java.util.common.CompressionUtils; import org.apache.druid.java.util.common.Intervals; import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.segment.TestHelper; import org.apache.druid.timeline.DataSegment; import org.apache.druid.timeline.partition.NoneShardSpec; -import org.apache.commons.io.FileUtils; import org.junit.Assert; import org.junit.Before; import org.junit.Rule; diff --git a/server/src/test/java/org/apache/druid/segment/realtime/firehose/EventReceiverFirehoseTest.java b/server/src/test/java/org/apache/druid/segment/realtime/firehose/EventReceiverFirehoseTest.java index 683c8ce061f..45b45bbeaed 100644 --- a/server/src/test/java/org/apache/druid/segment/realtime/firehose/EventReceiverFirehoseTest.java +++ b/server/src/test/java/org/apache/druid/segment/realtime/firehose/EventReceiverFirehoseTest.java @@ -21,6 +21,7 @@ package org.apache.druid.segment.realtime.firehose; import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; +import org.apache.commons.io.IOUtils; import org.apache.druid.data.input.impl.DimensionsSpec; import org.apache.druid.data.input.impl.JSONParseSpec; import org.apache.druid.data.input.impl.MapInputRowParser; @@ -34,7 +35,6 @@ import org.apache.druid.server.metrics.EventReceiverFirehoseRegister; import org.apache.druid.server.security.AllowAllAuthenticator; import org.apache.druid.server.security.AuthConfig; import org.apache.druid.server.security.AuthTestUtils; -import org.apache.commons.io.IOUtils; import org.easymock.EasyMock; import org.junit.Assert; import org.junit.Before; diff --git a/server/src/test/java/org/apache/druid/segment/realtime/firehose/SqlFirehoseFactoryTest.java b/server/src/test/java/org/apache/druid/segment/realtime/firehose/SqlFirehoseFactoryTest.java index 27f19d02de5..59321b1765c 100644 --- a/server/src/test/java/org/apache/druid/segment/realtime/firehose/SqlFirehoseFactoryTest.java +++ b/server/src/test/java/org/apache/druid/segment/realtime/firehose/SqlFirehoseFactoryTest.java @@ -22,6 +22,8 @@ package org.apache.druid.segment.realtime.firehose; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; +import org.apache.commons.dbcp2.BasicDataSource; +import org.apache.commons.io.FileUtils; import org.apache.druid.data.input.Firehose; import org.apache.druid.data.input.Row; import org.apache.druid.data.input.impl.DimensionsSpec; @@ -33,8 +35,6 @@ import org.apache.druid.metadata.MetadataStorageConnectorConfig; import org.apache.druid.metadata.SQLFirehoseDatabaseConnector; import org.apache.druid.metadata.TestDerbyConnector; import org.apache.druid.segment.TestHelper; -import org.apache.commons.dbcp2.BasicDataSource; -import org.apache.commons.io.FileUtils; import org.junit.AfterClass; import org.junit.Assert; import org.junit.BeforeClass; diff --git a/server/src/test/java/org/apache/druid/segment/realtime/plumber/CoordinatorBasedSegmentHandoffNotifierTest.java b/server/src/test/java/org/apache/druid/segment/realtime/plumber/CoordinatorBasedSegmentHandoffNotifierTest.java index 14d77d261f3..4151ef26dc3 100644 --- a/server/src/test/java/org/apache/druid/segment/realtime/plumber/CoordinatorBasedSegmentHandoffNotifierTest.java +++ b/server/src/test/java/org/apache/druid/segment/realtime/plumber/CoordinatorBasedSegmentHandoffNotifierTest.java @@ -21,6 +21,7 @@ package org.apache.druid.segment.realtime.plumber; import com.google.common.collect.Sets; import com.google.common.util.concurrent.MoreExecutors; +import junit.framework.Assert; import org.apache.druid.client.ImmutableSegmentLoadInfo; import org.apache.druid.client.coordinator.CoordinatorClient; import org.apache.druid.java.util.common.Intervals; @@ -29,7 +30,6 @@ import org.apache.druid.server.coordination.DruidServerMetadata; import org.apache.druid.server.coordination.ServerType; import org.apache.druid.timeline.DataSegment; import org.apache.druid.timeline.partition.NumberedShardSpec; -import junit.framework.Assert; import org.easymock.EasyMock; import org.joda.time.Duration; import org.joda.time.Interval; diff --git a/server/src/test/java/org/apache/druid/segment/realtime/plumber/RealtimePlumberSchoolTest.java b/server/src/test/java/org/apache/druid/segment/realtime/plumber/RealtimePlumberSchoolTest.java index b05dd09c23b..ca26db2ce79 100644 --- a/server/src/test/java/org/apache/druid/segment/realtime/plumber/RealtimePlumberSchoolTest.java +++ b/server/src/test/java/org/apache/druid/segment/realtime/plumber/RealtimePlumberSchoolTest.java @@ -26,6 +26,7 @@ import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.io.Files; import com.google.common.util.concurrent.MoreExecutors; +import org.apache.commons.io.FileUtils; import org.apache.druid.client.cache.CachePopulatorStats; import org.apache.druid.client.cache.MapCache; import org.apache.druid.data.input.Committer; @@ -59,7 +60,6 @@ import org.apache.druid.segment.writeout.OffHeapMemorySegmentWriteOutMediumFacto import org.apache.druid.segment.writeout.SegmentWriteOutMediumFactory; import org.apache.druid.segment.writeout.TmpFileSegmentWriteOutMediumFactory; import org.apache.druid.server.coordination.DataSegmentAnnouncer; -import org.apache.commons.io.FileUtils; import org.easymock.EasyMock; import org.joda.time.DateTime; import org.joda.time.Interval; diff --git a/server/src/test/java/org/apache/druid/server/AsyncManagementForwardingServletTest.java b/server/src/test/java/org/apache/druid/server/AsyncManagementForwardingServletTest.java index a2f4261763d..58ddd5c55f3 100644 --- a/server/src/test/java/org/apache/druid/server/AsyncManagementForwardingServletTest.java +++ b/server/src/test/java/org/apache/druid/server/AsyncManagementForwardingServletTest.java @@ -24,6 +24,7 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.inject.Injector; import com.google.inject.Key; +import org.apache.commons.io.IOUtils; import org.apache.druid.common.utils.SocketUtil; import org.apache.druid.discovery.DruidLeaderSelector; import org.apache.druid.guice.GuiceInjectors; @@ -37,7 +38,6 @@ import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.server.initialization.BaseJettyTest; import org.apache.druid.server.initialization.jetty.JettyServerInitUtils; import org.apache.druid.server.initialization.jetty.JettyServerInitializer; -import org.apache.commons.io.IOUtils; import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.server.Handler; import org.eclipse.jetty.server.Server; diff --git a/server/src/test/java/org/apache/druid/server/QueryResourceTest.java b/server/src/test/java/org/apache/druid/server/QueryResourceTest.java index 383c8aea62b..9e48793f247 100644 --- a/server/src/test/java/org/apache/druid/server/QueryResourceTest.java +++ b/server/src/test/java/org/apache/druid/server/QueryResourceTest.java @@ -25,12 +25,12 @@ import com.google.common.base.Throwables; import com.google.common.collect.ImmutableMap; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.MoreExecutors; -import org.apache.druid.java.util.emitter.EmittingLogger; -import org.apache.druid.java.util.emitter.service.ServiceEmitter; -import org.apache.druid.java.util.common.concurrent.Execs; import org.apache.druid.jackson.DefaultObjectMapper; +import org.apache.druid.java.util.common.concurrent.Execs; import org.apache.druid.java.util.common.guava.Sequence; import org.apache.druid.java.util.common.guava.Sequences; +import org.apache.druid.java.util.emitter.EmittingLogger; +import org.apache.druid.java.util.emitter.service.ServiceEmitter; import org.apache.druid.query.DefaultGenericQueryMetricsFactory; import org.apache.druid.query.MapQueryToolChestWarehouse; import org.apache.druid.query.Query; diff --git a/server/src/test/java/org/apache/druid/server/coordination/ChangeRequestHttpSyncerTest.java b/server/src/test/java/org/apache/druid/server/coordination/ChangeRequestHttpSyncerTest.java index 079552185cb..a362e206e3b 100644 --- a/server/src/test/java/org/apache/druid/server/coordination/ChangeRequestHttpSyncerTest.java +++ b/server/src/test/java/org/apache/druid/server/coordination/ChangeRequestHttpSyncerTest.java @@ -24,11 +24,11 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.collect.ImmutableList; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; +import org.apache.druid.java.util.common.RE; +import org.apache.druid.java.util.common.concurrent.Execs; import org.apache.druid.java.util.http.client.HttpClient; import org.apache.druid.java.util.http.client.Request; import org.apache.druid.java.util.http.client.response.HttpResponseHandler; -import org.apache.druid.java.util.common.RE; -import org.apache.druid.java.util.common.concurrent.Execs; import org.apache.druid.segment.TestHelper; import org.easymock.EasyMock; import org.jboss.netty.buffer.ChannelBuffers; diff --git a/server/src/test/java/org/apache/druid/server/coordination/SegmentChangeRequestLoadTest.java b/server/src/test/java/org/apache/druid/server/coordination/SegmentChangeRequestLoadTest.java index 4461fc0f301..d165e3480f5 100644 --- a/server/src/test/java/org/apache/druid/server/coordination/SegmentChangeRequestLoadTest.java +++ b/server/src/test/java/org/apache/druid/server/coordination/SegmentChangeRequestLoadTest.java @@ -22,8 +22,8 @@ package org.apache.druid.server.coordination; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.collect.ImmutableMap; import org.apache.druid.jackson.DefaultObjectMapper; -import org.apache.druid.java.util.common.jackson.JacksonUtils; import org.apache.druid.java.util.common.Intervals; +import org.apache.druid.java.util.common.jackson.JacksonUtils; import org.apache.druid.segment.IndexIO; import org.apache.druid.timeline.DataSegment; import org.apache.druid.timeline.partition.NoneShardSpec; diff --git a/server/src/test/java/org/apache/druid/server/coordination/ZkCoordinatorTest.java b/server/src/test/java/org/apache/druid/server/coordination/ZkCoordinatorTest.java index d1ee59fd8ef..945e96809e5 100644 --- a/server/src/test/java/org/apache/druid/server/coordination/ZkCoordinatorTest.java +++ b/server/src/test/java/org/apache/druid/server/coordination/ZkCoordinatorTest.java @@ -21,6 +21,7 @@ package org.apache.druid.server.coordination; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.collect.ImmutableMap; +import org.apache.curator.utils.ZKPaths; import org.apache.druid.curator.CuratorTestBase; import org.apache.druid.java.util.common.Intervals; import org.apache.druid.java.util.emitter.EmittingLogger; @@ -32,7 +33,6 @@ import org.apache.druid.server.initialization.ZkPathsConfig; import org.apache.druid.server.metrics.NoopServiceEmitter; import org.apache.druid.timeline.DataSegment; import org.apache.druid.timeline.partition.NoneShardSpec; -import org.apache.curator.utils.ZKPaths; import org.apache.zookeeper.CreateMode; import org.easymock.EasyMock; import org.junit.After; diff --git a/server/src/test/java/org/apache/druid/server/coordination/coordination/BatchDataSegmentAnnouncerTest.java b/server/src/test/java/org/apache/druid/server/coordination/coordination/BatchDataSegmentAnnouncerTest.java index e79b6c7a84b..ecf4c4ccac3 100644 --- a/server/src/test/java/org/apache/druid/server/coordination/coordination/BatchDataSegmentAnnouncerTest.java +++ b/server/src/test/java/org/apache/druid/server/coordination/coordination/BatchDataSegmentAnnouncerTest.java @@ -28,23 +28,23 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; import com.google.common.collect.Sets; import com.google.common.util.concurrent.MoreExecutors; +import org.apache.curator.framework.CuratorFramework; +import org.apache.curator.framework.CuratorFrameworkFactory; +import org.apache.curator.retry.ExponentialBackoffRetry; +import org.apache.curator.test.TestingCluster; import org.apache.druid.curator.PotentiallyGzippedCompressionProvider; import org.apache.druid.curator.announcement.Announcer; import org.apache.druid.java.util.common.DateTimes; import org.apache.druid.segment.TestHelper; import org.apache.druid.server.coordination.BatchDataSegmentAnnouncer; -import org.apache.druid.server.coordination.DataSegmentChangeRequest; -import org.apache.druid.server.coordination.DruidServerMetadata; import org.apache.druid.server.coordination.ChangeRequestHistory; import org.apache.druid.server.coordination.ChangeRequestsSnapshot; +import org.apache.druid.server.coordination.DataSegmentChangeRequest; +import org.apache.druid.server.coordination.DruidServerMetadata; import org.apache.druid.server.coordination.ServerType; import org.apache.druid.server.initialization.BatchDataSegmentAnnouncerConfig; import org.apache.druid.server.initialization.ZkPathsConfig; import org.apache.druid.timeline.DataSegment; -import org.apache.curator.framework.CuratorFramework; -import org.apache.curator.framework.CuratorFrameworkFactory; -import org.apache.curator.retry.ExponentialBackoffRetry; -import org.apache.curator.test.TestingCluster; import org.joda.time.Interval; import org.junit.After; import org.junit.Assert; diff --git a/server/src/test/java/org/apache/druid/server/coordinator/CuratorDruidCoordinatorTest.java b/server/src/test/java/org/apache/druid/server/coordinator/CuratorDruidCoordinatorTest.java index 0e52e668e57..ed1064bd600 100644 --- a/server/src/test/java/org/apache/druid/server/coordinator/CuratorDruidCoordinatorTest.java +++ b/server/src/test/java/org/apache/druid/server/coordinator/CuratorDruidCoordinatorTest.java @@ -25,6 +25,9 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Lists; +import org.apache.curator.framework.recipes.cache.PathChildrenCache; +import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent; +import org.apache.curator.utils.ZKPaths; import org.apache.druid.client.BatchServerInventoryView; import org.apache.druid.client.CoordinatorServerView; import org.apache.druid.client.DruidServer; @@ -47,17 +50,17 @@ import org.apache.druid.server.coordination.ServerType; import org.apache.druid.server.initialization.ZkPathsConfig; import org.apache.druid.server.lookup.cache.LookupCoordinatorManager; import org.apache.druid.server.metrics.NoopServiceEmitter; +import org.apache.druid.testing.DeadlockDetectingTimeout; import org.apache.druid.timeline.DataSegment; import org.apache.druid.timeline.partition.NoneShardSpec; -import org.apache.curator.framework.recipes.cache.PathChildrenCache; -import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent; -import org.apache.curator.utils.ZKPaths; import org.easymock.EasyMock; import org.joda.time.Duration; import org.junit.After; import org.junit.Assert; import org.junit.Before; +import org.junit.Rule; import org.junit.Test; +import org.junit.rules.TestRule; import java.util.List; import java.util.concurrent.ConcurrentHashMap; @@ -65,6 +68,7 @@ import java.util.concurrent.ConcurrentMap; import java.util.concurrent.CountDownLatch; import java.util.concurrent.Executor; import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicReference; import java.util.stream.Collectors; @@ -97,8 +101,13 @@ public class CuratorDruidCoordinatorTest extends CuratorTestBase private BatchServerInventoryView baseView; private CoordinatorServerView serverView; private CountDownLatch segmentViewInitLatch; - private CountDownLatch segmentAddedLatch; - private CountDownLatch segmentRemovedLatch; + /** + * The following two fields are changed during {@link #testMoveSegment()}, the change might not be visible from the + * thread, that runs the callback, registered in {@link #setupView()}. volatile modificator doesn't guarantee + * visibility either, but somewhat increases the chances. + */ + private volatile CountDownLatch segmentAddedLatch; + private volatile CountDownLatch segmentRemovedLatch; private final ObjectMapper jsonMapper; private final ZkPathsConfig zkPathsConfig; @@ -240,7 +249,10 @@ public class CuratorDruidCoordinatorTest extends CuratorTestBase tearDownServerAndCurator(); } - @Test(timeout = 60_000L) + @Rule + public final TestRule timeout = new DeadlockDetectingTimeout(60, TimeUnit.SECONDS); + + @Test public void testMoveSegment() throws Exception { segmentViewInitLatch = new CountDownLatch(1); @@ -429,7 +441,8 @@ public class CuratorDruidCoordinatorTest extends CuratorTestBase public void registerSegmentCallback(Executor exec, final SegmentCallback callback) { super.registerSegmentCallback( - exec, new SegmentCallback() + exec, + new SegmentCallback() { @Override public CallbackAction segmentAdded(DruidServerMetadata server, DataSegment segment) diff --git a/server/src/test/java/org/apache/druid/server/coordinator/DruidCoordinatorTest.java b/server/src/test/java/org/apache/druid/server/coordinator/DruidCoordinatorTest.java index bfe308cbd60..862c4040197 100644 --- a/server/src/test/java/org/apache/druid/server/coordinator/DruidCoordinatorTest.java +++ b/server/src/test/java/org/apache/druid/server/coordinator/DruidCoordinatorTest.java @@ -24,6 +24,12 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Lists; +import it.unimi.dsi.fastutil.objects.Object2LongMap; +import org.apache.curator.framework.CuratorFramework; +import org.apache.curator.framework.recipes.cache.PathChildrenCache; +import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent; +import org.apache.curator.framework.recipes.cache.PathChildrenCacheListener; +import org.apache.curator.utils.ZKPaths; import org.apache.druid.client.DruidDataSource; import org.apache.druid.client.DruidServer; import org.apache.druid.client.ImmutableDruidDataSource; @@ -50,12 +56,6 @@ import org.apache.druid.server.coordinator.rules.Rule; import org.apache.druid.server.initialization.ZkPathsConfig; import org.apache.druid.server.lookup.cache.LookupCoordinatorManager; import org.apache.druid.timeline.DataSegment; -import it.unimi.dsi.fastutil.objects.Object2LongMap; -import org.apache.curator.framework.CuratorFramework; -import org.apache.curator.framework.recipes.cache.PathChildrenCache; -import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent; -import org.apache.curator.framework.recipes.cache.PathChildrenCacheListener; -import org.apache.curator.utils.ZKPaths; import org.easymock.Capture; import org.easymock.EasyMock; import org.joda.time.Duration; diff --git a/server/src/test/java/org/apache/druid/server/coordinator/LoadQueuePeonTest.java b/server/src/test/java/org/apache/druid/server/coordinator/LoadQueuePeonTest.java index 496cd959a93..d47755cc184 100644 --- a/server/src/test/java/org/apache/druid/server/coordinator/LoadQueuePeonTest.java +++ b/server/src/test/java/org/apache/druid/server/coordinator/LoadQueuePeonTest.java @@ -24,6 +24,11 @@ import com.google.common.base.Function; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; +import org.apache.curator.framework.CuratorFramework; +import org.apache.curator.framework.recipes.cache.PathChildrenCache; +import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent; +import org.apache.curator.framework.recipes.cache.PathChildrenCacheListener; +import org.apache.curator.utils.ZKPaths; import org.apache.druid.curator.CuratorTestBase; import org.apache.druid.java.util.common.Intervals; import org.apache.druid.java.util.common.concurrent.Execs; @@ -35,11 +40,6 @@ import org.apache.druid.server.coordination.SegmentChangeRequestDrop; import org.apache.druid.server.coordination.SegmentChangeRequestLoad; import org.apache.druid.timeline.DataSegment; import org.apache.druid.timeline.partition.NoneShardSpec; -import org.apache.curator.framework.CuratorFramework; -import org.apache.curator.framework.recipes.cache.PathChildrenCache; -import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent; -import org.apache.curator.framework.recipes.cache.PathChildrenCacheListener; -import org.apache.curator.utils.ZKPaths; import org.joda.time.Duration; import org.junit.After; import org.junit.Assert; diff --git a/server/src/test/java/org/apache/druid/server/coordinator/rules/ForeverLoadRuleTest.java b/server/src/test/java/org/apache/druid/server/coordinator/rules/ForeverLoadRuleTest.java index 8453fe7e150..c9be7f63ddb 100644 --- a/server/src/test/java/org/apache/druid/server/coordinator/rules/ForeverLoadRuleTest.java +++ b/server/src/test/java/org/apache/druid/server/coordinator/rules/ForeverLoadRuleTest.java @@ -21,11 +21,9 @@ package org.apache.druid.server.coordinator.rules; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.collect.ImmutableMap; - import org.apache.druid.client.DruidServer; import org.apache.druid.jackson.DefaultObjectMapper; import org.apache.druid.java.util.common.IAE; - import org.junit.Assert; import org.junit.Test; diff --git a/server/src/test/java/org/apache/druid/server/emitter/EmitterModuleTest.java b/server/src/test/java/org/apache/druid/server/emitter/EmitterModuleTest.java index 87c4e506a11..0acd0858260 100644 --- a/server/src/test/java/org/apache/druid/server/emitter/EmitterModuleTest.java +++ b/server/src/test/java/org/apache/druid/server/emitter/EmitterModuleTest.java @@ -24,14 +24,14 @@ import com.google.inject.Binder; import com.google.inject.Guice; import com.google.inject.Injector; import com.google.inject.Module; -import org.apache.druid.java.util.emitter.core.Emitter; -import org.apache.druid.java.util.emitter.core.ParametrizedUriEmitter; import org.apache.druid.guice.DruidGuiceExtensions; import org.apache.druid.guice.JsonConfigurator; import org.apache.druid.guice.LazySingleton; import org.apache.druid.guice.LifecycleModule; import org.apache.druid.guice.ServerModule; import org.apache.druid.jackson.JacksonModule; +import org.apache.druid.java.util.emitter.core.Emitter; +import org.apache.druid.java.util.emitter.core.ParametrizedUriEmitter; import org.junit.Assert; import org.junit.Test; diff --git a/server/src/test/java/org/apache/druid/server/http/security/PreResponseAuthorizationCheckFilterTest.java b/server/src/test/java/org/apache/druid/server/http/security/PreResponseAuthorizationCheckFilterTest.java index a821b7bafbc..92b08923c71 100644 --- a/server/src/test/java/org/apache/druid/server/http/security/PreResponseAuthorizationCheckFilterTest.java +++ b/server/src/test/java/org/apache/druid/server/http/security/PreResponseAuthorizationCheckFilterTest.java @@ -19,10 +19,10 @@ package org.apache.druid.server.http.security; -import org.apache.druid.java.util.emitter.EmittingLogger; -import org.apache.druid.java.util.emitter.service.ServiceEmitter; import org.apache.druid.jackson.DefaultObjectMapper; import org.apache.druid.java.util.common.ISE; +import org.apache.druid.java.util.emitter.EmittingLogger; +import org.apache.druid.java.util.emitter.service.ServiceEmitter; import org.apache.druid.server.security.AllowAllAuthenticator; import org.apache.druid.server.security.AuthConfig; import org.apache.druid.server.security.AuthenticationResult; diff --git a/server/src/test/java/org/apache/druid/server/initialization/JettyQosTest.java b/server/src/test/java/org/apache/druid/server/initialization/JettyQosTest.java index 158b4cb4683..4316efb9b03 100644 --- a/server/src/test/java/org/apache/druid/server/initialization/JettyQosTest.java +++ b/server/src/test/java/org/apache/druid/server/initialization/JettyQosTest.java @@ -28,11 +28,6 @@ import com.google.inject.Binder; import com.google.inject.Injector; import com.google.inject.Key; import com.google.inject.Module; -import org.apache.druid.java.util.http.client.HttpClient; -import org.apache.druid.java.util.http.client.Request; -import org.apache.druid.java.util.http.client.response.StatusResponseHandler; -import org.apache.druid.java.util.http.client.response.StatusResponseHolder; -import org.apache.druid.java.util.common.concurrent.Execs; import org.apache.druid.guice.GuiceInjectors; import org.apache.druid.guice.Jerseys; import org.apache.druid.guice.JsonConfigProvider; @@ -40,6 +35,11 @@ import org.apache.druid.guice.LazySingleton; import org.apache.druid.guice.LifecycleModule; import org.apache.druid.guice.annotations.Self; import org.apache.druid.initialization.Initialization; +import org.apache.druid.java.util.common.concurrent.Execs; +import org.apache.druid.java.util.http.client.HttpClient; +import org.apache.druid.java.util.http.client.Request; +import org.apache.druid.java.util.http.client.response.StatusResponseHandler; +import org.apache.druid.java.util.http.client.response.StatusResponseHolder; import org.apache.druid.server.DruidNode; import org.apache.druid.server.initialization.jetty.JettyBindings; import org.apache.druid.server.initialization.jetty.JettyServerInitializer; diff --git a/server/src/test/java/org/apache/druid/server/initialization/JettyTest.java b/server/src/test/java/org/apache/druid/server/initialization/JettyTest.java index 1889870ab1a..00b1f4b0860 100644 --- a/server/src/test/java/org/apache/druid/server/initialization/JettyTest.java +++ b/server/src/test/java/org/apache/druid/server/initialization/JettyTest.java @@ -27,6 +27,7 @@ import com.google.inject.Injector; import com.google.inject.Key; import com.google.inject.Module; import com.google.inject.multibindings.Multibinder; +import org.apache.commons.io.IOUtils; import org.apache.druid.guice.GuiceInjectors; import org.apache.druid.guice.Jerseys; import org.apache.druid.guice.JsonConfigProvider; @@ -43,7 +44,6 @@ import org.apache.druid.server.initialization.jetty.JettyServerInitializer; import org.apache.druid.server.initialization.jetty.ServletFilterHolder; import org.apache.druid.server.security.AuthTestUtils; import org.apache.druid.server.security.AuthorizerMapper; -import org.apache.commons.io.IOUtils; import org.eclipse.jetty.server.Server; import org.jboss.netty.handler.codec.http.HttpMethod; import org.junit.Assert; diff --git a/server/src/test/java/org/apache/druid/server/listener/announcer/ListenerResourceAnnouncerTest.java b/server/src/test/java/org/apache/druid/server/listener/announcer/ListenerResourceAnnouncerTest.java index 9317dfe9b82..96e2a18bde7 100644 --- a/server/src/test/java/org/apache/druid/server/listener/announcer/ListenerResourceAnnouncerTest.java +++ b/server/src/test/java/org/apache/druid/server/listener/announcer/ListenerResourceAnnouncerTest.java @@ -19,6 +19,7 @@ package org.apache.druid.server.listener.announcer; +import org.apache.curator.utils.ZKPaths; import org.apache.druid.curator.CuratorTestBase; import org.apache.druid.curator.announcement.Announcer; import org.apache.druid.java.util.common.StringUtils; @@ -26,7 +27,6 @@ import org.apache.druid.java.util.common.concurrent.Execs; import org.apache.druid.segment.CloserRule; import org.apache.druid.server.http.HostAndPortWithScheme; import org.apache.druid.server.initialization.ZkPathsConfig; -import org.apache.curator.utils.ZKPaths; import org.easymock.EasyMock; import org.junit.After; import org.junit.Assert; diff --git a/server/src/test/java/org/apache/druid/server/metrics/HistoricalMetricsMonitorTest.java b/server/src/test/java/org/apache/druid/server/metrics/HistoricalMetricsMonitorTest.java index 22fb2f2e1fe..8e658faafb9 100644 --- a/server/src/test/java/org/apache/druid/server/metrics/HistoricalMetricsMonitorTest.java +++ b/server/src/test/java/org/apache/druid/server/metrics/HistoricalMetricsMonitorTest.java @@ -23,11 +23,11 @@ import com.google.common.base.Function; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; +import org.apache.druid.client.DruidServerConfig; +import org.apache.druid.java.util.common.Intervals; import org.apache.druid.java.util.emitter.service.ServiceEmitter; import org.apache.druid.java.util.emitter.service.ServiceEventBuilder; import org.apache.druid.java.util.emitter.service.ServiceMetricEvent; -import org.apache.druid.client.DruidServerConfig; -import org.apache.druid.java.util.common.Intervals; import org.apache.druid.server.SegmentManager; import org.apache.druid.server.coordination.SegmentLoadDropHandler; import org.apache.druid.timeline.DataSegment; diff --git a/services/src/main/java/org/apache/druid/cli/CliHadoopIndexer.java b/services/src/main/java/org/apache/druid/cli/CliHadoopIndexer.java index a822a35eeb8..fe256b5380f 100644 --- a/services/src/main/java/org/apache/druid/cli/CliHadoopIndexer.java +++ b/services/src/main/java/org/apache/druid/cli/CliHadoopIndexer.java @@ -22,7 +22,6 @@ package org.apache.druid.cli; import com.google.common.base.Joiner; import com.google.common.collect.Lists; import com.google.inject.Inject; - import io.airlift.airline.Arguments; import io.airlift.airline.Command; import io.airlift.airline.Option; diff --git a/services/src/main/java/org/apache/druid/cli/CliInternalHadoopIndexer.java b/services/src/main/java/org/apache/druid/cli/CliInternalHadoopIndexer.java index cff7e7597cb..188e5add483 100644 --- a/services/src/main/java/org/apache/druid/cli/CliInternalHadoopIndexer.java +++ b/services/src/main/java/org/apache/druid/cli/CliInternalHadoopIndexer.java @@ -28,7 +28,6 @@ import com.google.inject.Injector; import com.google.inject.Module; import com.google.inject.TypeLiteral; import com.google.inject.name.Names; - import io.airlift.airline.Arguments; import io.airlift.airline.Command; import org.apache.druid.guice.LazySingleton; diff --git a/services/src/main/java/org/apache/druid/cli/CliPeon.java b/services/src/main/java/org/apache/druid/cli/CliPeon.java index 41fedc89db2..3ce347c6c5e 100644 --- a/services/src/main/java/org/apache/druid/cli/CliPeon.java +++ b/services/src/main/java/org/apache/druid/cli/CliPeon.java @@ -69,9 +69,9 @@ import org.apache.druid.indexing.common.config.TaskStorageConfig; import org.apache.druid.indexing.common.stats.DropwizardRowIngestionMetersFactory; import org.apache.druid.indexing.common.stats.RowIngestionMetersFactory; import org.apache.druid.indexing.common.task.IndexTaskClientFactory; +import org.apache.druid.indexing.common.task.Task; import org.apache.druid.indexing.common.task.batch.parallel.ParallelIndexTaskClient; import org.apache.druid.indexing.common.task.batch.parallel.ParallelIndexTaskClientFactory; -import org.apache.druid.indexing.common.task.Task; import org.apache.druid.indexing.overlord.HeapMemoryTaskStorage; import org.apache.druid.indexing.overlord.IndexerMetadataStorageCoordinator; import org.apache.druid.indexing.overlord.SingleTaskBackgroundRunner; diff --git a/services/src/main/java/org/apache/druid/cli/DumpSegment.java b/services/src/main/java/org/apache/druid/cli/DumpSegment.java index abe25128640..84b178c6e3a 100644 --- a/services/src/main/java/org/apache/druid/cli/DumpSegment.java +++ b/services/src/main/java/org/apache/druid/cli/DumpSegment.java @@ -65,10 +65,9 @@ import org.apache.druid.query.filter.DimFilter; import org.apache.druid.query.metadata.metadata.ListColumnIncluderator; import org.apache.druid.query.metadata.metadata.SegmentAnalysis; import org.apache.druid.query.metadata.metadata.SegmentMetadataQuery; -import org.apache.druid.query.monomorphicprocessing.RuntimeShapeInspector; import org.apache.druid.query.spec.SpecificSegmentSpec; import org.apache.druid.segment.BaseObjectColumnValueSelector; -import org.apache.druid.segment.ColumnValueSelector; +import org.apache.druid.segment.ColumnSelectorFactory; import org.apache.druid.segment.Cursor; import org.apache.druid.segment.IndexIO; import org.apache.druid.segment.QueryableIndex; @@ -76,8 +75,8 @@ import org.apache.druid.segment.QueryableIndexSegment; import org.apache.druid.segment.QueryableIndexStorageAdapter; import org.apache.druid.segment.VirtualColumns; import org.apache.druid.segment.column.BitmapIndex; -import org.apache.druid.segment.column.Column; import org.apache.druid.segment.column.ColumnConfig; +import org.apache.druid.segment.column.ColumnHolder; import org.apache.druid.segment.data.BitmapSerdeFactory; import org.apache.druid.segment.data.ConciseBitmapSerdeFactory; import org.apache.druid.segment.data.RoaringBitmapSerdeFactory; @@ -87,16 +86,15 @@ import org.joda.time.DateTimeZone; import org.joda.time.chrono.ISOChronology; import org.roaringbitmap.IntIterator; -import javax.annotation.Nullable; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; -import java.util.Arrays; import java.util.EnumSet; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.stream.Collectors; @Command( name = "dump-segment", @@ -275,13 +273,11 @@ public class DumpSegment extends GuiceRunnable @Override public Object apply(Cursor cursor) { - final List selectors = Lists.newArrayList(); - - for (String columnName : columnNames) { - ColumnValueSelector selector = - cursor.getColumnSelectorFactory().makeColumnValueSelector(columnName); - selectors.add(new ListObjectSelector(selector)); - } + ColumnSelectorFactory columnSelectorFactory = cursor.getColumnSelectorFactory(); + final List selectors = columnNames + .stream() + .map(columnSelectorFactory::makeColumnValueSelector) + .collect(Collectors.toList()); while (!cursor.isDone()) { final Map row = Maps.newLinkedHashMap(); @@ -290,7 +286,7 @@ public class DumpSegment extends GuiceRunnable final String columnName = columnNames.get(i); final Object value = selectors.get(i).getObject(); - if (timeISO8601 && columnNames.get(i).equals(Column.TIME_COLUMN_NAME)) { + if (timeISO8601 && columnNames.get(i).equals(ColumnHolder.TIME_COLUMN_NAME)) { row.put(columnName, new DateTime(value, DateTimeZone.UTC).toString()); } else { row.put(columnName, value); @@ -355,8 +351,8 @@ public class DumpSegment extends GuiceRunnable jg.writeStartObject(); for (final String columnName : columnNames) { - final Column column = index.getColumn(columnName); - final BitmapIndex bitmapIndex = column.getBitmapIndex(); + final ColumnHolder columnHolder = index.getColumnHolder(columnName); + final BitmapIndex bitmapIndex = columnHolder.getBitmapIndex(); if (bitmapIndex == null) { jg.writeNullField(columnName); @@ -376,7 +372,10 @@ public class DumpSegment extends GuiceRunnable } jg.writeEndArray(); } else { - jg.writeBinary(bitmapSerdeFactory.getObjectStrategy().toBytes(bitmap)); + byte[] bytes = bitmapSerdeFactory.getObjectStrategy().toBytes(bitmap); + if (bytes != null) { + jg.writeBinary(bytes); + } } } } @@ -404,12 +403,12 @@ public class DumpSegment extends GuiceRunnable // Empty columnNames => include all columns. if (columnNames.isEmpty()) { - columnNames.add(Column.TIME_COLUMN_NAME); + columnNames.add(ColumnHolder.TIME_COLUMN_NAME); Iterables.addAll(columnNames, index.getColumnNames()); } else { // Remove any provided columns that do not exist in this segment. for (String columnName : ImmutableList.copyOf(columnNames)) { - if (index.getColumn(columnName) == null) { + if (index.getColumnHolder(columnName) == null) { columnNames.remove(columnName); } } @@ -482,12 +481,12 @@ public class DumpSegment extends GuiceRunnable private static Sequence executeQuery(final Injector injector, final QueryableIndex index, final Query query) { final QueryRunnerFactoryConglomerate conglomerate = injector.getInstance(QueryRunnerFactoryConglomerate.class); - final QueryRunnerFactory factory = conglomerate.findFactory(query); + final QueryRunnerFactory> factory = conglomerate.findFactory(query); final QueryRunner runner = factory.createRunner(new QueryableIndexSegment("segment", index)); - final Sequence results = factory.getToolchest().mergeResults( - factory.mergeRunners(MoreExecutors.sameThreadExecutor(), ImmutableList.of(runner)) - ).run(QueryPlus.wrap(query), Maps.newHashMap()); - return (Sequence) results; + return factory + .getToolchest() + .mergeResults(factory.mergeRunners(MoreExecutors.sameThreadExecutor(), ImmutableList.of(runner))) + .run(QueryPlus.wrap(query), Maps.newHashMap()); } private static void evaluateSequenceForSideEffects(final Sequence sequence) @@ -495,61 +494,4 @@ public class DumpSegment extends GuiceRunnable sequence.accumulate(null, (accumulated, in) -> null); } - private static class ListObjectSelector implements ColumnValueSelector - { - private final ColumnValueSelector delegate; - - private ListObjectSelector(ColumnValueSelector delegate) - { - this.delegate = delegate; - } - - @Override - public double getDouble() - { - return delegate.getDouble(); - } - - @Override - public float getFloat() - { - return delegate.getFloat(); - } - - @Override - public long getLong() - { - return delegate.getLong(); - } - - @Nullable - @Override - public Object getObject() - { - Object object = delegate.getObject(); - if (object instanceof String[]) { - return Arrays.asList((String[]) object); - } else { - return object; - } - } - - @Override - public Class classOfObject() - { - return Object.class; - } - - @Override - public void inspectRuntimeShape(RuntimeShapeInspector inspector) - { - inspector.visit("delegate", delegate); - } - - @Override - public boolean isNull() - { - return delegate.isNull(); - } - } } diff --git a/services/src/main/java/org/apache/druid/cli/PullDependencies.java b/services/src/main/java/org/apache/druid/cli/PullDependencies.java index e2a9b286595..cc835b076a5 100644 --- a/services/src/main/java/org/apache/druid/cli/PullDependencies.java +++ b/services/src/main/java/org/apache/druid/cli/PullDependencies.java @@ -28,16 +28,16 @@ import com.google.inject.Inject; import io.airlift.airline.Command; import io.airlift.airline.Option; import io.netty.util.SuppressForbidden; -import org.apache.druid.guice.ExtensionsConfig; -import org.apache.druid.indexing.common.config.TaskConfig; -import org.apache.druid.java.util.common.ISE; -import org.apache.druid.java.util.common.StringUtils; -import org.apache.druid.java.util.common.logger.Logger; import io.tesla.aether.Repository; import io.tesla.aether.TeslaAether; import io.tesla.aether.guice.RepositorySystemSessionProvider; import io.tesla.aether.internal.DefaultTeslaAether; import org.apache.commons.io.FileUtils; +import org.apache.druid.guice.ExtensionsConfig; +import org.apache.druid.indexing.common.config.TaskConfig; +import org.apache.druid.java.util.common.ISE; +import org.apache.druid.java.util.common.StringUtils; +import org.apache.druid.java.util.common.logger.Logger; import org.eclipse.aether.RepositorySystemSession; import org.eclipse.aether.artifact.Artifact; import org.eclipse.aether.artifact.DefaultArtifact; diff --git a/services/src/main/java/org/apache/druid/cli/validate/DruidJsonValidator.java b/services/src/main/java/org/apache/druid/cli/validate/DruidJsonValidator.java index 8101b33cdfa..c2264a2c8f4 100644 --- a/services/src/main/java/org/apache/druid/cli/validate/DruidJsonValidator.java +++ b/services/src/main/java/org/apache/druid/cli/validate/DruidJsonValidator.java @@ -33,6 +33,7 @@ import com.google.inject.name.Names; import io.airlift.airline.Command; import io.airlift.airline.Option; import io.netty.util.SuppressForbidden; +import org.apache.commons.io.output.NullWriter; import org.apache.druid.cli.GuiceRunnable; import org.apache.druid.data.input.InputRow; import org.apache.druid.data.input.impl.StringInputRowParser; @@ -51,7 +52,6 @@ import org.apache.druid.initialization.Initialization; import org.apache.druid.java.util.common.UOE; import org.apache.druid.java.util.common.logger.Logger; import org.apache.druid.query.Query; -import org.apache.commons.io.output.NullWriter; import java.io.File; import java.io.IOException; diff --git a/services/src/test/java/org/apache/druid/cli/PullDependenciesTest.java b/services/src/test/java/org/apache/druid/cli/PullDependenciesTest.java index 107158398fa..7a6150a190a 100644 --- a/services/src/test/java/org/apache/druid/cli/PullDependenciesTest.java +++ b/services/src/test/java/org/apache/druid/cli/PullDependenciesTest.java @@ -22,9 +22,9 @@ package org.apache.druid.cli; import com.google.common.base.Throwables; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; +import io.tesla.aether.internal.DefaultTeslaAether; import org.apache.druid.guice.ExtensionsConfig; import org.apache.druid.java.util.common.StringUtils; -import io.tesla.aether.internal.DefaultTeslaAether; import org.eclipse.aether.artifact.Artifact; import org.eclipse.aether.artifact.DefaultArtifact; import org.eclipse.aether.resolution.DependencyRequest; diff --git a/sql/src/main/java/org/apache/druid/sql/avatica/AvaticaMonitor.java b/sql/src/main/java/org/apache/druid/sql/avatica/AvaticaMonitor.java index 830143e088c..369d6a5409e 100644 --- a/sql/src/main/java/org/apache/druid/sql/avatica/AvaticaMonitor.java +++ b/sql/src/main/java/org/apache/druid/sql/avatica/AvaticaMonitor.java @@ -19,16 +19,16 @@ package org.apache.druid.sql.avatica; -import org.apache.druid.java.util.emitter.service.ServiceEmitter; -import org.apache.druid.java.util.emitter.service.ServiceMetricEvent; -import org.apache.druid.java.util.metrics.AbstractMonitor; -import org.apache.druid.java.util.common.logger.Logger; import org.apache.calcite.avatica.metrics.Counter; import org.apache.calcite.avatica.metrics.Gauge; import org.apache.calcite.avatica.metrics.Histogram; import org.apache.calcite.avatica.metrics.Meter; import org.apache.calcite.avatica.metrics.MetricsSystem; import org.apache.calcite.avatica.metrics.Timer; +import org.apache.druid.java.util.common.logger.Logger; +import org.apache.druid.java.util.emitter.service.ServiceEmitter; +import org.apache.druid.java.util.emitter.service.ServiceMetricEvent; +import org.apache.druid.java.util.metrics.AbstractMonitor; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; diff --git a/sql/src/main/java/org/apache/druid/sql/avatica/DruidAvaticaHandler.java b/sql/src/main/java/org/apache/druid/sql/avatica/DruidAvaticaHandler.java index 6bb0ec198ff..1a7877fcaad 100644 --- a/sql/src/main/java/org/apache/druid/sql/avatica/DruidAvaticaHandler.java +++ b/sql/src/main/java/org/apache/druid/sql/avatica/DruidAvaticaHandler.java @@ -20,11 +20,11 @@ package org.apache.druid.sql.avatica; import com.google.inject.Inject; -import org.apache.druid.guice.annotations.Self; -import org.apache.druid.server.DruidNode; import org.apache.calcite.avatica.remote.LocalService; import org.apache.calcite.avatica.remote.Service; import org.apache.calcite.avatica.server.AvaticaJsonHandler; +import org.apache.druid.guice.annotations.Self; +import org.apache.druid.server.DruidNode; import org.eclipse.jetty.server.Request; import javax.servlet.ServletException; diff --git a/sql/src/main/java/org/apache/druid/sql/avatica/DruidMeta.java b/sql/src/main/java/org/apache/druid/sql/avatica/DruidMeta.java index 872e615a198..01cba459e6f 100644 --- a/sql/src/main/java/org/apache/druid/sql/avatica/DruidMeta.java +++ b/sql/src/main/java/org/apache/druid/sql/avatica/DruidMeta.java @@ -30,6 +30,12 @@ import com.google.common.collect.Iterables; import com.google.common.util.concurrent.ThreadFactoryBuilder; import com.google.inject.Inject; import com.google.inject.Injector; +import org.apache.calcite.avatica.MetaImpl; +import org.apache.calcite.avatica.MissingResultsException; +import org.apache.calcite.avatica.NoSuchConnectionException; +import org.apache.calcite.avatica.NoSuchStatementException; +import org.apache.calcite.avatica.QueryState; +import org.apache.calcite.avatica.remote.TypedValue; import org.apache.druid.java.util.common.DateTimes; import org.apache.druid.java.util.common.ISE; import org.apache.druid.java.util.common.StringUtils; @@ -40,12 +46,6 @@ import org.apache.druid.server.security.AuthenticatorMapper; import org.apache.druid.server.security.ForbiddenException; import org.apache.druid.sql.calcite.planner.Calcites; import org.apache.druid.sql.calcite.planner.PlannerFactory; -import org.apache.calcite.avatica.MetaImpl; -import org.apache.calcite.avatica.MissingResultsException; -import org.apache.calcite.avatica.NoSuchConnectionException; -import org.apache.calcite.avatica.NoSuchStatementException; -import org.apache.calcite.avatica.QueryState; -import org.apache.calcite.avatica.remote.TypedValue; import org.joda.time.Interval; import javax.annotation.Nonnull; diff --git a/sql/src/main/java/org/apache/druid/sql/avatica/DruidStatement.java b/sql/src/main/java/org/apache/druid/sql/avatica/DruidStatement.java index 91f0f0bbda7..39b7341e180 100644 --- a/sql/src/main/java/org/apache/druid/sql/avatica/DruidStatement.java +++ b/sql/src/main/java/org/apache/druid/sql/avatica/DruidStatement.java @@ -22,6 +22,10 @@ package org.apache.druid.sql.avatica; import com.google.common.base.Preconditions; import com.google.common.base.Throwables; import com.google.common.collect.ImmutableMap; +import org.apache.calcite.avatica.ColumnMetaData; +import org.apache.calcite.avatica.Meta; +import org.apache.calcite.rel.type.RelDataType; +import org.apache.calcite.rel.type.RelDataTypeField; import org.apache.druid.java.util.common.ISE; import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.java.util.common.concurrent.Execs; @@ -33,10 +37,6 @@ import org.apache.druid.sql.calcite.planner.DruidPlanner; import org.apache.druid.sql.calcite.planner.PlannerFactory; import org.apache.druid.sql.calcite.planner.PlannerResult; import org.apache.druid.sql.calcite.rel.QueryMaker; -import org.apache.calcite.avatica.ColumnMetaData; -import org.apache.calcite.avatica.Meta; -import org.apache.calcite.rel.type.RelDataType; -import org.apache.calcite.rel.type.RelDataTypeField; import javax.annotation.concurrent.GuardedBy; import java.io.Closeable; diff --git a/sql/src/main/java/org/apache/druid/sql/calcite/aggregation/Aggregations.java b/sql/src/main/java/org/apache/druid/sql/calcite/aggregation/Aggregations.java index a8f0619e041..c7181424f69 100644 --- a/sql/src/main/java/org/apache/druid/sql/calcite/aggregation/Aggregations.java +++ b/sql/src/main/java/org/apache/druid/sql/calcite/aggregation/Aggregations.java @@ -19,14 +19,14 @@ package org.apache.druid.sql.calcite.aggregation; +import org.apache.calcite.rel.core.AggregateCall; +import org.apache.calcite.rel.core.Project; +import org.apache.calcite.rex.RexNode; import org.apache.druid.segment.column.ValueType; import org.apache.druid.sql.calcite.expression.DruidExpression; import org.apache.druid.sql.calcite.expression.Expressions; import org.apache.druid.sql.calcite.planner.PlannerContext; import org.apache.druid.sql.calcite.table.RowSignature; -import org.apache.calcite.rel.core.AggregateCall; -import org.apache.calcite.rel.core.Project; -import org.apache.calcite.rex.RexNode; import javax.annotation.Nullable; import java.util.List; diff --git a/sql/src/main/java/org/apache/druid/sql/calcite/aggregation/SqlAggregator.java b/sql/src/main/java/org/apache/druid/sql/calcite/aggregation/SqlAggregator.java index 92a266d57b9..23240c69098 100644 --- a/sql/src/main/java/org/apache/druid/sql/calcite/aggregation/SqlAggregator.java +++ b/sql/src/main/java/org/apache/druid/sql/calcite/aggregation/SqlAggregator.java @@ -19,12 +19,12 @@ package org.apache.druid.sql.calcite.aggregation; -import org.apache.druid.sql.calcite.planner.PlannerContext; -import org.apache.druid.sql.calcite.table.RowSignature; import org.apache.calcite.rel.core.AggregateCall; import org.apache.calcite.rel.core.Project; import org.apache.calcite.rex.RexBuilder; import org.apache.calcite.sql.SqlAggFunction; +import org.apache.druid.sql.calcite.planner.PlannerContext; +import org.apache.druid.sql.calcite.table.RowSignature; import javax.annotation.Nullable; import java.util.List; diff --git a/sql/src/main/java/org/apache/druid/sql/calcite/aggregation/builtin/ApproxCountDistinctSqlAggregator.java b/sql/src/main/java/org/apache/druid/sql/calcite/aggregation/builtin/ApproxCountDistinctSqlAggregator.java index bd03a1b18f1..df9f9e5946a 100644 --- a/sql/src/main/java/org/apache/druid/sql/calcite/aggregation/builtin/ApproxCountDistinctSqlAggregator.java +++ b/sql/src/main/java/org/apache/druid/sql/calcite/aggregation/builtin/ApproxCountDistinctSqlAggregator.java @@ -21,6 +21,17 @@ package org.apache.druid.sql.calcite.aggregation.builtin; import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; +import org.apache.calcite.rel.core.AggregateCall; +import org.apache.calcite.rel.core.Project; +import org.apache.calcite.rex.RexBuilder; +import org.apache.calcite.rex.RexNode; +import org.apache.calcite.sql.SqlAggFunction; +import org.apache.calcite.sql.SqlFunctionCategory; +import org.apache.calcite.sql.SqlKind; +import org.apache.calcite.sql.type.InferTypes; +import org.apache.calcite.sql.type.OperandTypes; +import org.apache.calcite.sql.type.ReturnTypes; +import org.apache.calcite.sql.type.SqlTypeName; import org.apache.druid.java.util.common.ISE; import org.apache.druid.query.aggregation.AggregatorFactory; import org.apache.druid.query.aggregation.cardinality.CardinalityAggregatorFactory; @@ -38,17 +49,6 @@ import org.apache.druid.sql.calcite.expression.Expressions; import org.apache.druid.sql.calcite.planner.Calcites; import org.apache.druid.sql.calcite.planner.PlannerContext; import org.apache.druid.sql.calcite.table.RowSignature; -import org.apache.calcite.rel.core.AggregateCall; -import org.apache.calcite.rel.core.Project; -import org.apache.calcite.rex.RexBuilder; -import org.apache.calcite.rex.RexNode; -import org.apache.calcite.sql.SqlAggFunction; -import org.apache.calcite.sql.SqlFunctionCategory; -import org.apache.calcite.sql.SqlKind; -import org.apache.calcite.sql.type.InferTypes; -import org.apache.calcite.sql.type.OperandTypes; -import org.apache.calcite.sql.type.ReturnTypes; -import org.apache.calcite.sql.type.SqlTypeName; import javax.annotation.Nullable; import java.util.ArrayList; diff --git a/sql/src/main/java/org/apache/druid/sql/calcite/aggregation/builtin/AvgSqlAggregator.java b/sql/src/main/java/org/apache/druid/sql/calcite/aggregation/builtin/AvgSqlAggregator.java index 39bc45a6628..30b7029c9f5 100644 --- a/sql/src/main/java/org/apache/druid/sql/calcite/aggregation/builtin/AvgSqlAggregator.java +++ b/sql/src/main/java/org/apache/druid/sql/calcite/aggregation/builtin/AvgSqlAggregator.java @@ -21,6 +21,12 @@ package org.apache.druid.sql.calcite.aggregation.builtin; import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; +import org.apache.calcite.rel.core.AggregateCall; +import org.apache.calcite.rel.core.Project; +import org.apache.calcite.rex.RexBuilder; +import org.apache.calcite.sql.SqlAggFunction; +import org.apache.calcite.sql.fun.SqlStdOperatorTable; +import org.apache.calcite.sql.type.SqlTypeName; import org.apache.druid.math.expr.ExprMacroTable; import org.apache.druid.query.aggregation.AggregatorFactory; import org.apache.druid.query.aggregation.CountAggregatorFactory; @@ -34,12 +40,6 @@ import org.apache.druid.sql.calcite.expression.DruidExpression; import org.apache.druid.sql.calcite.planner.Calcites; import org.apache.druid.sql.calcite.planner.PlannerContext; import org.apache.druid.sql.calcite.table.RowSignature; -import org.apache.calcite.rel.core.AggregateCall; -import org.apache.calcite.rel.core.Project; -import org.apache.calcite.rex.RexBuilder; -import org.apache.calcite.sql.SqlAggFunction; -import org.apache.calcite.sql.fun.SqlStdOperatorTable; -import org.apache.calcite.sql.type.SqlTypeName; import javax.annotation.Nullable; import java.util.List; diff --git a/sql/src/main/java/org/apache/druid/sql/calcite/aggregation/builtin/CountSqlAggregator.java b/sql/src/main/java/org/apache/druid/sql/calcite/aggregation/builtin/CountSqlAggregator.java index 7ff80fe6b9a..e98ec32a287 100644 --- a/sql/src/main/java/org/apache/druid/sql/calcite/aggregation/builtin/CountSqlAggregator.java +++ b/sql/src/main/java/org/apache/druid/sql/calcite/aggregation/builtin/CountSqlAggregator.java @@ -21,6 +21,12 @@ package org.apache.druid.sql.calcite.aggregation.builtin; import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; +import org.apache.calcite.rel.core.AggregateCall; +import org.apache.calcite.rel.core.Project; +import org.apache.calcite.rex.RexBuilder; +import org.apache.calcite.rex.RexNode; +import org.apache.calcite.sql.SqlAggFunction; +import org.apache.calcite.sql.fun.SqlStdOperatorTable; import org.apache.druid.java.util.common.ISE; import org.apache.druid.query.aggregation.CountAggregatorFactory; import org.apache.druid.query.filter.DimFilter; @@ -31,12 +37,6 @@ import org.apache.druid.sql.calcite.expression.DruidExpression; import org.apache.druid.sql.calcite.expression.Expressions; import org.apache.druid.sql.calcite.planner.PlannerContext; import org.apache.druid.sql.calcite.table.RowSignature; -import org.apache.calcite.rel.core.AggregateCall; -import org.apache.calcite.rel.core.Project; -import org.apache.calcite.rex.RexBuilder; -import org.apache.calcite.rex.RexNode; -import org.apache.calcite.sql.SqlAggFunction; -import org.apache.calcite.sql.fun.SqlStdOperatorTable; import javax.annotation.Nullable; import java.util.List; diff --git a/sql/src/main/java/org/apache/druid/sql/calcite/aggregation/builtin/MaxSqlAggregator.java b/sql/src/main/java/org/apache/druid/sql/calcite/aggregation/builtin/MaxSqlAggregator.java index 8be0555e097..923b0222ef9 100644 --- a/sql/src/main/java/org/apache/druid/sql/calcite/aggregation/builtin/MaxSqlAggregator.java +++ b/sql/src/main/java/org/apache/druid/sql/calcite/aggregation/builtin/MaxSqlAggregator.java @@ -20,6 +20,11 @@ package org.apache.druid.sql.calcite.aggregation.builtin; import com.google.common.collect.Iterables; +import org.apache.calcite.rel.core.AggregateCall; +import org.apache.calcite.rel.core.Project; +import org.apache.calcite.rex.RexBuilder; +import org.apache.calcite.sql.SqlAggFunction; +import org.apache.calcite.sql.fun.SqlStdOperatorTable; import org.apache.druid.java.util.common.ISE; import org.apache.druid.math.expr.ExprMacroTable; import org.apache.druid.query.aggregation.AggregatorFactory; @@ -34,11 +39,6 @@ import org.apache.druid.sql.calcite.expression.DruidExpression; import org.apache.druid.sql.calcite.planner.Calcites; import org.apache.druid.sql.calcite.planner.PlannerContext; import org.apache.druid.sql.calcite.table.RowSignature; -import org.apache.calcite.rel.core.AggregateCall; -import org.apache.calcite.rel.core.Project; -import org.apache.calcite.rex.RexBuilder; -import org.apache.calcite.sql.SqlAggFunction; -import org.apache.calcite.sql.fun.SqlStdOperatorTable; import javax.annotation.Nullable; import java.util.List; diff --git a/sql/src/main/java/org/apache/druid/sql/calcite/aggregation/builtin/MinSqlAggregator.java b/sql/src/main/java/org/apache/druid/sql/calcite/aggregation/builtin/MinSqlAggregator.java index 08ea2686ca4..9e8abe9e5b6 100644 --- a/sql/src/main/java/org/apache/druid/sql/calcite/aggregation/builtin/MinSqlAggregator.java +++ b/sql/src/main/java/org/apache/druid/sql/calcite/aggregation/builtin/MinSqlAggregator.java @@ -20,6 +20,11 @@ package org.apache.druid.sql.calcite.aggregation.builtin; import com.google.common.collect.Iterables; +import org.apache.calcite.rel.core.AggregateCall; +import org.apache.calcite.rel.core.Project; +import org.apache.calcite.rex.RexBuilder; +import org.apache.calcite.sql.SqlAggFunction; +import org.apache.calcite.sql.fun.SqlStdOperatorTable; import org.apache.druid.java.util.common.ISE; import org.apache.druid.math.expr.ExprMacroTable; import org.apache.druid.query.aggregation.AggregatorFactory; @@ -34,11 +39,6 @@ import org.apache.druid.sql.calcite.expression.DruidExpression; import org.apache.druid.sql.calcite.planner.Calcites; import org.apache.druid.sql.calcite.planner.PlannerContext; import org.apache.druid.sql.calcite.table.RowSignature; -import org.apache.calcite.rel.core.AggregateCall; -import org.apache.calcite.rel.core.Project; -import org.apache.calcite.rex.RexBuilder; -import org.apache.calcite.sql.SqlAggFunction; -import org.apache.calcite.sql.fun.SqlStdOperatorTable; import javax.annotation.Nullable; import java.util.List; diff --git a/sql/src/main/java/org/apache/druid/sql/calcite/aggregation/builtin/SumSqlAggregator.java b/sql/src/main/java/org/apache/druid/sql/calcite/aggregation/builtin/SumSqlAggregator.java index be1c73533d2..0d80932e80f 100644 --- a/sql/src/main/java/org/apache/druid/sql/calcite/aggregation/builtin/SumSqlAggregator.java +++ b/sql/src/main/java/org/apache/druid/sql/calcite/aggregation/builtin/SumSqlAggregator.java @@ -20,6 +20,11 @@ package org.apache.druid.sql.calcite.aggregation.builtin; import com.google.common.collect.Iterables; +import org.apache.calcite.rel.core.AggregateCall; +import org.apache.calcite.rel.core.Project; +import org.apache.calcite.rex.RexBuilder; +import org.apache.calcite.sql.SqlAggFunction; +import org.apache.calcite.sql.fun.SqlStdOperatorTable; import org.apache.druid.java.util.common.ISE; import org.apache.druid.math.expr.ExprMacroTable; import org.apache.druid.query.aggregation.AggregatorFactory; @@ -34,11 +39,6 @@ import org.apache.druid.sql.calcite.expression.DruidExpression; import org.apache.druid.sql.calcite.planner.Calcites; import org.apache.druid.sql.calcite.planner.PlannerContext; import org.apache.druid.sql.calcite.table.RowSignature; -import org.apache.calcite.rel.core.AggregateCall; -import org.apache.calcite.rel.core.Project; -import org.apache.calcite.rex.RexBuilder; -import org.apache.calcite.sql.SqlAggFunction; -import org.apache.calcite.sql.fun.SqlStdOperatorTable; import javax.annotation.Nullable; import java.util.List; diff --git a/sql/src/main/java/org/apache/druid/sql/calcite/expression/AliasedOperatorConversion.java b/sql/src/main/java/org/apache/druid/sql/calcite/expression/AliasedOperatorConversion.java index 392ff16c386..4e0717fda8a 100644 --- a/sql/src/main/java/org/apache/druid/sql/calcite/expression/AliasedOperatorConversion.java +++ b/sql/src/main/java/org/apache/druid/sql/calcite/expression/AliasedOperatorConversion.java @@ -19,13 +19,13 @@ package org.apache.druid.sql.calcite.expression; -import org.apache.druid.java.util.common.IAE; -import org.apache.druid.sql.calcite.planner.PlannerContext; -import org.apache.druid.sql.calcite.table.RowSignature; import org.apache.calcite.rex.RexNode; import org.apache.calcite.sql.SqlFunction; import org.apache.calcite.sql.SqlKind; import org.apache.calcite.sql.SqlOperator; +import org.apache.druid.java.util.common.IAE; +import org.apache.druid.sql.calcite.planner.PlannerContext; +import org.apache.druid.sql.calcite.table.RowSignature; public class AliasedOperatorConversion implements SqlOperatorConversion { diff --git a/sql/src/main/java/org/apache/druid/sql/calcite/expression/BinaryOperatorConversion.java b/sql/src/main/java/org/apache/druid/sql/calcite/expression/BinaryOperatorConversion.java index 5c534347398..86c9c02ff51 100644 --- a/sql/src/main/java/org/apache/druid/sql/calcite/expression/BinaryOperatorConversion.java +++ b/sql/src/main/java/org/apache/druid/sql/calcite/expression/BinaryOperatorConversion.java @@ -20,12 +20,12 @@ package org.apache.druid.sql.calcite.expression; import com.google.common.base.Joiner; +import org.apache.calcite.rex.RexNode; +import org.apache.calcite.sql.SqlOperator; import org.apache.druid.java.util.common.ISE; import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.sql.calcite.planner.PlannerContext; import org.apache.druid.sql.calcite.table.RowSignature; -import org.apache.calcite.rex.RexNode; -import org.apache.calcite.sql.SqlOperator; import java.util.stream.Collectors; diff --git a/sql/src/main/java/org/apache/druid/sql/calcite/expression/DirectOperatorConversion.java b/sql/src/main/java/org/apache/druid/sql/calcite/expression/DirectOperatorConversion.java index 4eb00739729..7d214c76bce 100644 --- a/sql/src/main/java/org/apache/druid/sql/calcite/expression/DirectOperatorConversion.java +++ b/sql/src/main/java/org/apache/druid/sql/calcite/expression/DirectOperatorConversion.java @@ -19,10 +19,10 @@ package org.apache.druid.sql.calcite.expression; -import org.apache.druid.sql.calcite.planner.PlannerContext; -import org.apache.druid.sql.calcite.table.RowSignature; import org.apache.calcite.rex.RexNode; import org.apache.calcite.sql.SqlOperator; +import org.apache.druid.sql.calcite.planner.PlannerContext; +import org.apache.druid.sql.calcite.table.RowSignature; public class DirectOperatorConversion implements SqlOperatorConversion { diff --git a/sql/src/main/java/org/apache/druid/sql/calcite/expression/Expressions.java b/sql/src/main/java/org/apache/druid/sql/calcite/expression/Expressions.java index 17579b1c1ce..e8b0ffb9c4f 100644 --- a/sql/src/main/java/org/apache/druid/sql/calcite/expression/Expressions.java +++ b/sql/src/main/java/org/apache/druid/sql/calcite/expression/Expressions.java @@ -52,7 +52,7 @@ import org.apache.druid.query.filter.OrDimFilter; import org.apache.druid.query.filter.SelectorDimFilter; import org.apache.druid.query.ordering.StringComparator; import org.apache.druid.query.ordering.StringComparators; -import org.apache.druid.segment.column.Column; +import org.apache.druid.segment.column.ColumnHolder; import org.apache.druid.segment.column.ValueType; import org.apache.druid.sql.calcite.filtration.BoundRefKey; import org.apache.druid.sql.calcite.filtration.Bounds; @@ -391,7 +391,7 @@ public class Expressions if (queryGranularity != null) { // lhs is FLOOR(__time TO granularity); rhs must be a timestamp final long rhsMillis = Calcites.calciteDateTimeLiteralToJoda(rhs, plannerContext.getTimeZone()).getMillis(); - return buildTimeFloorFilter(Column.TIME_COLUMN_NAME, queryGranularity, flippedKind, rhsMillis); + return buildTimeFloorFilter(ColumnHolder.TIME_COLUMN_NAME, queryGranularity, flippedKind, rhsMillis); } // In the general case, lhs must be translatable to a SimpleExtraction to be simple-filterable. @@ -402,7 +402,7 @@ public class Expressions final String column = lhsExpression.getSimpleExtraction().getColumn(); final ExtractionFn extractionFn = lhsExpression.getSimpleExtraction().getExtractionFn(); - if (column.equals(Column.TIME_COLUMN_NAME) && extractionFn instanceof TimeFormatExtractionFn) { + if (column.equals(ColumnHolder.TIME_COLUMN_NAME) && extractionFn instanceof TimeFormatExtractionFn) { // Check if we can strip the extractionFn and convert the filter to a direct filter on __time. // This allows potential conversion to query-level "intervals" later on, which is ideal for Druid queries. @@ -563,7 +563,7 @@ public class Expressions final Expr arg = expr.getArg(); final Granularity granularity = expr.getGranularity(); - if (Column.TIME_COLUMN_NAME.equals(Parser.getIdentifierIfIdentifier(arg))) { + if (ColumnHolder.TIME_COLUMN_NAME.equals(Parser.getIdentifierIfIdentifier(arg))) { return granularity; } else { return null; diff --git a/sql/src/main/java/org/apache/druid/sql/calcite/expression/OperatorConversions.java b/sql/src/main/java/org/apache/druid/sql/calcite/expression/OperatorConversions.java index be922b2bb3b..21e7a658c66 100644 --- a/sql/src/main/java/org/apache/druid/sql/calcite/expression/OperatorConversions.java +++ b/sql/src/main/java/org/apache/druid/sql/calcite/expression/OperatorConversions.java @@ -20,9 +20,6 @@ package org.apache.druid.sql.calcite.expression; import com.google.common.base.Preconditions; -import org.apache.druid.sql.calcite.planner.Calcites; -import org.apache.druid.sql.calcite.planner.PlannerContext; -import org.apache.druid.sql.calcite.table.RowSignature; import org.apache.calcite.rex.RexCall; import org.apache.calcite.rex.RexNode; import org.apache.calcite.sql.SqlFunction; @@ -33,6 +30,9 @@ import org.apache.calcite.sql.type.ReturnTypes; import org.apache.calcite.sql.type.SqlReturnTypeInference; import org.apache.calcite.sql.type.SqlTypeFamily; import org.apache.calcite.sql.type.SqlTypeName; +import org.apache.druid.sql.calcite.planner.Calcites; +import org.apache.druid.sql.calcite.planner.PlannerContext; +import org.apache.druid.sql.calcite.table.RowSignature; import javax.annotation.Nullable; import java.util.Arrays; diff --git a/sql/src/main/java/org/apache/druid/sql/calcite/expression/SqlOperatorConversion.java b/sql/src/main/java/org/apache/druid/sql/calcite/expression/SqlOperatorConversion.java index bc68b372fd8..da5b8344ea8 100644 --- a/sql/src/main/java/org/apache/druid/sql/calcite/expression/SqlOperatorConversion.java +++ b/sql/src/main/java/org/apache/druid/sql/calcite/expression/SqlOperatorConversion.java @@ -19,10 +19,10 @@ package org.apache.druid.sql.calcite.expression; -import org.apache.druid.sql.calcite.planner.PlannerContext; -import org.apache.druid.sql.calcite.table.RowSignature; import org.apache.calcite.rex.RexNode; import org.apache.calcite.sql.SqlOperator; +import org.apache.druid.sql.calcite.planner.PlannerContext; +import org.apache.druid.sql.calcite.table.RowSignature; public interface SqlOperatorConversion { diff --git a/sql/src/main/java/org/apache/druid/sql/calcite/expression/TimeUnits.java b/sql/src/main/java/org/apache/druid/sql/calcite/expression/TimeUnits.java index c5c5a0c5c12..4b369c56d07 100644 --- a/sql/src/main/java/org/apache/druid/sql/calcite/expression/TimeUnits.java +++ b/sql/src/main/java/org/apache/druid/sql/calcite/expression/TimeUnits.java @@ -20,8 +20,8 @@ package org.apache.druid.sql.calcite.expression; import com.google.common.collect.ImmutableMap; -import org.apache.druid.java.util.common.granularity.PeriodGranularity; import org.apache.calcite.avatica.util.TimeUnitRange; +import org.apache.druid.java.util.common.granularity.PeriodGranularity; import org.joda.time.DateTimeZone; import org.joda.time.Period; diff --git a/sql/src/main/java/org/apache/druid/sql/calcite/expression/UnaryFunctionOperatorConversion.java b/sql/src/main/java/org/apache/druid/sql/calcite/expression/UnaryFunctionOperatorConversion.java index e0df20c0e6f..419a1bf2e53 100644 --- a/sql/src/main/java/org/apache/druid/sql/calcite/expression/UnaryFunctionOperatorConversion.java +++ b/sql/src/main/java/org/apache/druid/sql/calcite/expression/UnaryFunctionOperatorConversion.java @@ -20,11 +20,11 @@ package org.apache.druid.sql.calcite.expression; import com.google.common.collect.Iterables; +import org.apache.calcite.rex.RexNode; +import org.apache.calcite.sql.SqlOperator; import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.sql.calcite.planner.PlannerContext; import org.apache.druid.sql.calcite.table.RowSignature; -import org.apache.calcite.rex.RexNode; -import org.apache.calcite.sql.SqlOperator; public class UnaryFunctionOperatorConversion implements SqlOperatorConversion { diff --git a/sql/src/main/java/org/apache/druid/sql/calcite/expression/UnaryPrefixOperatorConversion.java b/sql/src/main/java/org/apache/druid/sql/calcite/expression/UnaryPrefixOperatorConversion.java index 37c93911465..9bd3961a189 100644 --- a/sql/src/main/java/org/apache/druid/sql/calcite/expression/UnaryPrefixOperatorConversion.java +++ b/sql/src/main/java/org/apache/druid/sql/calcite/expression/UnaryPrefixOperatorConversion.java @@ -20,11 +20,11 @@ package org.apache.druid.sql.calcite.expression; import com.google.common.collect.Iterables; +import org.apache.calcite.rex.RexNode; +import org.apache.calcite.sql.SqlOperator; import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.sql.calcite.planner.PlannerContext; import org.apache.druid.sql.calcite.table.RowSignature; -import org.apache.calcite.rex.RexNode; -import org.apache.calcite.sql.SqlOperator; public class UnaryPrefixOperatorConversion implements SqlOperatorConversion { diff --git a/sql/src/main/java/org/apache/druid/sql/calcite/expression/UnarySuffixOperatorConversion.java b/sql/src/main/java/org/apache/druid/sql/calcite/expression/UnarySuffixOperatorConversion.java index 05e195584c1..64b6deaf2a1 100644 --- a/sql/src/main/java/org/apache/druid/sql/calcite/expression/UnarySuffixOperatorConversion.java +++ b/sql/src/main/java/org/apache/druid/sql/calcite/expression/UnarySuffixOperatorConversion.java @@ -20,11 +20,11 @@ package org.apache.druid.sql.calcite.expression; import com.google.common.collect.Iterables; +import org.apache.calcite.rex.RexNode; +import org.apache.calcite.sql.SqlOperator; import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.sql.calcite.planner.PlannerContext; import org.apache.druid.sql.calcite.table.RowSignature; -import org.apache.calcite.rex.RexNode; -import org.apache.calcite.sql.SqlOperator; public class UnarySuffixOperatorConversion implements SqlOperatorConversion { diff --git a/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/BTrimOperatorConversion.java b/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/BTrimOperatorConversion.java index 6bee9f2b9e2..74098ddc825 100644 --- a/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/BTrimOperatorConversion.java +++ b/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/BTrimOperatorConversion.java @@ -19,11 +19,6 @@ package org.apache.druid.sql.calcite.expression.builtin; -import org.apache.druid.sql.calcite.expression.DruidExpression; -import org.apache.druid.sql.calcite.expression.OperatorConversions; -import org.apache.druid.sql.calcite.expression.SqlOperatorConversion; -import org.apache.druid.sql.calcite.planner.PlannerContext; -import org.apache.druid.sql.calcite.table.RowSignature; import org.apache.calcite.rex.RexNode; import org.apache.calcite.sql.SqlFunction; import org.apache.calcite.sql.SqlFunctionCategory; @@ -31,6 +26,11 @@ import org.apache.calcite.sql.SqlOperator; import org.apache.calcite.sql.fun.SqlTrimFunction; import org.apache.calcite.sql.type.SqlTypeFamily; import org.apache.calcite.sql.type.SqlTypeName; +import org.apache.druid.sql.calcite.expression.DruidExpression; +import org.apache.druid.sql.calcite.expression.OperatorConversions; +import org.apache.druid.sql.calcite.expression.SqlOperatorConversion; +import org.apache.druid.sql.calcite.planner.PlannerContext; +import org.apache.druid.sql.calcite.table.RowSignature; public class BTrimOperatorConversion implements SqlOperatorConversion { diff --git a/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/CastOperatorConversion.java b/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/CastOperatorConversion.java index 3b30fd63c9b..0c2fd9566c2 100644 --- a/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/CastOperatorConversion.java +++ b/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/CastOperatorConversion.java @@ -21,6 +21,11 @@ package org.apache.druid.sql.calcite.expression.builtin; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; +import org.apache.calcite.rex.RexCall; +import org.apache.calcite.rex.RexNode; +import org.apache.calcite.sql.SqlOperator; +import org.apache.calcite.sql.fun.SqlStdOperatorTable; +import org.apache.calcite.sql.type.SqlTypeName; import org.apache.druid.java.util.common.ISE; import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.java.util.common.granularity.PeriodGranularity; @@ -30,11 +35,6 @@ import org.apache.druid.sql.calcite.expression.Expressions; import org.apache.druid.sql.calcite.expression.SqlOperatorConversion; import org.apache.druid.sql.calcite.planner.PlannerContext; import org.apache.druid.sql.calcite.table.RowSignature; -import org.apache.calcite.rex.RexCall; -import org.apache.calcite.rex.RexNode; -import org.apache.calcite.sql.SqlOperator; -import org.apache.calcite.sql.fun.SqlStdOperatorTable; -import org.apache.calcite.sql.type.SqlTypeName; import org.joda.time.Period; import java.util.Map; diff --git a/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/CeilOperatorConversion.java b/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/CeilOperatorConversion.java index 1a7c031559b..3b4985c6d08 100644 --- a/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/CeilOperatorConversion.java +++ b/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/CeilOperatorConversion.java @@ -19,6 +19,12 @@ package org.apache.druid.sql.calcite.expression.builtin; +import org.apache.calcite.avatica.util.TimeUnitRange; +import org.apache.calcite.rex.RexCall; +import org.apache.calcite.rex.RexLiteral; +import org.apache.calcite.rex.RexNode; +import org.apache.calcite.sql.SqlOperator; +import org.apache.calcite.sql.fun.SqlStdOperatorTable; import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.java.util.common.granularity.PeriodGranularity; import org.apache.druid.sql.calcite.expression.DruidExpression; @@ -27,12 +33,6 @@ import org.apache.druid.sql.calcite.expression.SqlOperatorConversion; import org.apache.druid.sql.calcite.expression.TimeUnits; import org.apache.druid.sql.calcite.planner.PlannerContext; import org.apache.druid.sql.calcite.table.RowSignature; -import org.apache.calcite.avatica.util.TimeUnitRange; -import org.apache.calcite.rex.RexCall; -import org.apache.calcite.rex.RexLiteral; -import org.apache.calcite.rex.RexNode; -import org.apache.calcite.sql.SqlOperator; -import org.apache.calcite.sql.fun.SqlStdOperatorTable; import java.util.Arrays; import java.util.stream.Collectors; diff --git a/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/ConcatOperatorConversion.java b/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/ConcatOperatorConversion.java index f559e431e0e..1d49b5092ea 100644 --- a/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/ConcatOperatorConversion.java +++ b/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/ConcatOperatorConversion.java @@ -19,12 +19,6 @@ package org.apache.druid.sql.calcite.expression.builtin; -import org.apache.druid.sql.calcite.expression.DruidExpression; -import org.apache.druid.sql.calcite.expression.OperatorConversions; -import org.apache.druid.sql.calcite.expression.SqlOperatorConversion; -import org.apache.druid.sql.calcite.planner.Calcites; -import org.apache.druid.sql.calcite.planner.PlannerContext; -import org.apache.druid.sql.calcite.table.RowSignature; import org.apache.calcite.rex.RexNode; import org.apache.calcite.sql.SqlFunction; import org.apache.calcite.sql.SqlFunctionCategory; @@ -32,6 +26,12 @@ import org.apache.calcite.sql.SqlKind; import org.apache.calcite.sql.type.OperandTypes; import org.apache.calcite.sql.type.ReturnTypes; import org.apache.calcite.sql.type.SqlTypeName; +import org.apache.druid.sql.calcite.expression.DruidExpression; +import org.apache.druid.sql.calcite.expression.OperatorConversions; +import org.apache.druid.sql.calcite.expression.SqlOperatorConversion; +import org.apache.druid.sql.calcite.planner.Calcites; +import org.apache.druid.sql.calcite.planner.PlannerContext; +import org.apache.druid.sql.calcite.table.RowSignature; public class ConcatOperatorConversion implements SqlOperatorConversion { diff --git a/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/DateTruncOperatorConversion.java b/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/DateTruncOperatorConversion.java index 5e463759e35..bd6add35547 100644 --- a/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/DateTruncOperatorConversion.java +++ b/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/DateTruncOperatorConversion.java @@ -21,6 +21,12 @@ package org.apache.druid.sql.calcite.expression.builtin; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; +import org.apache.calcite.rex.RexNode; +import org.apache.calcite.sql.SqlFunction; +import org.apache.calcite.sql.SqlFunctionCategory; +import org.apache.calcite.sql.SqlOperator; +import org.apache.calcite.sql.type.SqlTypeFamily; +import org.apache.calcite.sql.type.SqlTypeName; import org.apache.druid.java.util.common.IAE; import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.math.expr.Expr; @@ -30,12 +36,6 @@ import org.apache.druid.sql.calcite.expression.OperatorConversions; import org.apache.druid.sql.calcite.expression.SqlOperatorConversion; import org.apache.druid.sql.calcite.planner.PlannerContext; import org.apache.druid.sql.calcite.table.RowSignature; -import org.apache.calcite.rex.RexNode; -import org.apache.calcite.sql.SqlFunction; -import org.apache.calcite.sql.SqlFunctionCategory; -import org.apache.calcite.sql.SqlOperator; -import org.apache.calcite.sql.type.SqlTypeFamily; -import org.apache.calcite.sql.type.SqlTypeName; import org.joda.time.Period; import java.util.Map; diff --git a/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/ExtractOperatorConversion.java b/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/ExtractOperatorConversion.java index 19a5ff63bd8..1d1123fc399 100644 --- a/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/ExtractOperatorConversion.java +++ b/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/ExtractOperatorConversion.java @@ -20,18 +20,18 @@ package org.apache.druid.sql.calcite.expression.builtin; import com.google.common.collect.ImmutableMap; -import org.apache.druid.query.expression.TimestampExtractExprMacro; -import org.apache.druid.sql.calcite.expression.DruidExpression; -import org.apache.druid.sql.calcite.expression.Expressions; -import org.apache.druid.sql.calcite.expression.SqlOperatorConversion; -import org.apache.druid.sql.calcite.planner.PlannerContext; -import org.apache.druid.sql.calcite.table.RowSignature; import org.apache.calcite.avatica.util.TimeUnitRange; import org.apache.calcite.rex.RexCall; import org.apache.calcite.rex.RexLiteral; import org.apache.calcite.rex.RexNode; import org.apache.calcite.sql.SqlFunction; import org.apache.calcite.sql.fun.SqlStdOperatorTable; +import org.apache.druid.query.expression.TimestampExtractExprMacro; +import org.apache.druid.sql.calcite.expression.DruidExpression; +import org.apache.druid.sql.calcite.expression.Expressions; +import org.apache.druid.sql.calcite.expression.SqlOperatorConversion; +import org.apache.druid.sql.calcite.planner.PlannerContext; +import org.apache.druid.sql.calcite.table.RowSignature; import java.util.Map; diff --git a/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/FloorOperatorConversion.java b/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/FloorOperatorConversion.java index 0b2d2b8cda5..fb5daa162eb 100644 --- a/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/FloorOperatorConversion.java +++ b/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/FloorOperatorConversion.java @@ -19,6 +19,12 @@ package org.apache.druid.sql.calcite.expression.builtin; +import org.apache.calcite.avatica.util.TimeUnitRange; +import org.apache.calcite.rex.RexCall; +import org.apache.calcite.rex.RexLiteral; +import org.apache.calcite.rex.RexNode; +import org.apache.calcite.sql.SqlOperator; +import org.apache.calcite.sql.fun.SqlStdOperatorTable; import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.java.util.common.granularity.PeriodGranularity; import org.apache.druid.sql.calcite.expression.DruidExpression; @@ -27,12 +33,6 @@ import org.apache.druid.sql.calcite.expression.SqlOperatorConversion; import org.apache.druid.sql.calcite.expression.TimeUnits; import org.apache.druid.sql.calcite.planner.PlannerContext; import org.apache.druid.sql.calcite.table.RowSignature; -import org.apache.calcite.avatica.util.TimeUnitRange; -import org.apache.calcite.rex.RexCall; -import org.apache.calcite.rex.RexLiteral; -import org.apache.calcite.rex.RexNode; -import org.apache.calcite.sql.SqlOperator; -import org.apache.calcite.sql.fun.SqlStdOperatorTable; public class FloorOperatorConversion implements SqlOperatorConversion { diff --git a/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/LTrimOperatorConversion.java b/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/LTrimOperatorConversion.java index 7653f19241c..4dfe3f62bf3 100644 --- a/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/LTrimOperatorConversion.java +++ b/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/LTrimOperatorConversion.java @@ -19,11 +19,6 @@ package org.apache.druid.sql.calcite.expression.builtin; -import org.apache.druid.sql.calcite.expression.DruidExpression; -import org.apache.druid.sql.calcite.expression.OperatorConversions; -import org.apache.druid.sql.calcite.expression.SqlOperatorConversion; -import org.apache.druid.sql.calcite.planner.PlannerContext; -import org.apache.druid.sql.calcite.table.RowSignature; import org.apache.calcite.rex.RexNode; import org.apache.calcite.sql.SqlFunction; import org.apache.calcite.sql.SqlFunctionCategory; @@ -31,6 +26,11 @@ import org.apache.calcite.sql.SqlOperator; import org.apache.calcite.sql.fun.SqlTrimFunction; import org.apache.calcite.sql.type.SqlTypeFamily; import org.apache.calcite.sql.type.SqlTypeName; +import org.apache.druid.sql.calcite.expression.DruidExpression; +import org.apache.druid.sql.calcite.expression.OperatorConversions; +import org.apache.druid.sql.calcite.expression.SqlOperatorConversion; +import org.apache.druid.sql.calcite.planner.PlannerContext; +import org.apache.druid.sql.calcite.table.RowSignature; public class LTrimOperatorConversion implements SqlOperatorConversion { diff --git a/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/LookupOperatorConversion.java b/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/LookupOperatorConversion.java index 3a6d6858e59..9a990caa21f 100644 --- a/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/LookupOperatorConversion.java +++ b/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/LookupOperatorConversion.java @@ -20,6 +20,11 @@ package org.apache.druid.sql.calcite.expression.builtin; import com.google.inject.Inject; +import org.apache.calcite.rex.RexNode; +import org.apache.calcite.sql.SqlFunction; +import org.apache.calcite.sql.SqlFunctionCategory; +import org.apache.calcite.sql.type.SqlTypeFamily; +import org.apache.calcite.sql.type.SqlTypeName; import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.math.expr.Expr; import org.apache.druid.query.lookup.LookupReferencesManager; @@ -29,11 +34,6 @@ import org.apache.druid.sql.calcite.expression.OperatorConversions; import org.apache.druid.sql.calcite.expression.SqlOperatorConversion; import org.apache.druid.sql.calcite.planner.PlannerContext; import org.apache.druid.sql.calcite.table.RowSignature; -import org.apache.calcite.rex.RexNode; -import org.apache.calcite.sql.SqlFunction; -import org.apache.calcite.sql.SqlFunctionCategory; -import org.apache.calcite.sql.type.SqlTypeFamily; -import org.apache.calcite.sql.type.SqlTypeName; public class LookupOperatorConversion implements SqlOperatorConversion { diff --git a/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/MillisToTimestampOperatorConversion.java b/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/MillisToTimestampOperatorConversion.java index bf67d3044b6..9d28fc212f7 100644 --- a/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/MillisToTimestampOperatorConversion.java +++ b/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/MillisToTimestampOperatorConversion.java @@ -20,12 +20,6 @@ package org.apache.druid.sql.calcite.expression.builtin; import com.google.common.collect.Iterables; -import org.apache.druid.sql.calcite.expression.DruidExpression; -import org.apache.druid.sql.calcite.expression.Expressions; -import org.apache.druid.sql.calcite.expression.OperatorConversions; -import org.apache.druid.sql.calcite.expression.SqlOperatorConversion; -import org.apache.druid.sql.calcite.planner.PlannerContext; -import org.apache.druid.sql.calcite.table.RowSignature; import org.apache.calcite.rex.RexCall; import org.apache.calcite.rex.RexNode; import org.apache.calcite.sql.SqlFunction; @@ -33,6 +27,12 @@ import org.apache.calcite.sql.SqlFunctionCategory; import org.apache.calcite.sql.SqlOperator; import org.apache.calcite.sql.type.SqlTypeFamily; import org.apache.calcite.sql.type.SqlTypeName; +import org.apache.druid.sql.calcite.expression.DruidExpression; +import org.apache.druid.sql.calcite.expression.Expressions; +import org.apache.druid.sql.calcite.expression.OperatorConversions; +import org.apache.druid.sql.calcite.expression.SqlOperatorConversion; +import org.apache.druid.sql.calcite.planner.PlannerContext; +import org.apache.druid.sql.calcite.table.RowSignature; public class MillisToTimestampOperatorConversion implements SqlOperatorConversion { diff --git a/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/RTrimOperatorConversion.java b/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/RTrimOperatorConversion.java index 4fed852458a..0520a080d1a 100644 --- a/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/RTrimOperatorConversion.java +++ b/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/RTrimOperatorConversion.java @@ -19,11 +19,6 @@ package org.apache.druid.sql.calcite.expression.builtin; -import org.apache.druid.sql.calcite.expression.DruidExpression; -import org.apache.druid.sql.calcite.expression.OperatorConversions; -import org.apache.druid.sql.calcite.expression.SqlOperatorConversion; -import org.apache.druid.sql.calcite.planner.PlannerContext; -import org.apache.druid.sql.calcite.table.RowSignature; import org.apache.calcite.rex.RexNode; import org.apache.calcite.sql.SqlFunction; import org.apache.calcite.sql.SqlFunctionCategory; @@ -31,6 +26,11 @@ import org.apache.calcite.sql.SqlOperator; import org.apache.calcite.sql.fun.SqlTrimFunction; import org.apache.calcite.sql.type.SqlTypeFamily; import org.apache.calcite.sql.type.SqlTypeName; +import org.apache.druid.sql.calcite.expression.DruidExpression; +import org.apache.druid.sql.calcite.expression.OperatorConversions; +import org.apache.druid.sql.calcite.expression.SqlOperatorConversion; +import org.apache.druid.sql.calcite.planner.PlannerContext; +import org.apache.druid.sql.calcite.table.RowSignature; public class RTrimOperatorConversion implements SqlOperatorConversion { diff --git a/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/RegexpExtractOperatorConversion.java b/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/RegexpExtractOperatorConversion.java index 22344a7deeb..3959e2234f0 100644 --- a/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/RegexpExtractOperatorConversion.java +++ b/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/RegexpExtractOperatorConversion.java @@ -19,6 +19,11 @@ package org.apache.druid.sql.calcite.expression.builtin; +import org.apache.calcite.rex.RexNode; +import org.apache.calcite.sql.SqlFunction; +import org.apache.calcite.sql.SqlFunctionCategory; +import org.apache.calcite.sql.type.SqlTypeFamily; +import org.apache.calcite.sql.type.SqlTypeName; import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.math.expr.Expr; import org.apache.druid.query.extraction.RegexDimExtractionFn; @@ -27,11 +32,6 @@ import org.apache.druid.sql.calcite.expression.OperatorConversions; import org.apache.druid.sql.calcite.expression.SqlOperatorConversion; import org.apache.druid.sql.calcite.planner.PlannerContext; import org.apache.druid.sql.calcite.table.RowSignature; -import org.apache.calcite.rex.RexNode; -import org.apache.calcite.sql.SqlFunction; -import org.apache.calcite.sql.SqlFunctionCategory; -import org.apache.calcite.sql.type.SqlTypeFamily; -import org.apache.calcite.sql.type.SqlTypeName; public class RegexpExtractOperatorConversion implements SqlOperatorConversion { diff --git a/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/StrposOperatorConversion.java b/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/StrposOperatorConversion.java index 4fc860f08d8..2fd0f09a082 100644 --- a/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/StrposOperatorConversion.java +++ b/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/StrposOperatorConversion.java @@ -19,18 +19,18 @@ package org.apache.druid.sql.calcite.expression.builtin; -import org.apache.druid.java.util.common.StringUtils; -import org.apache.druid.sql.calcite.expression.DruidExpression; -import org.apache.druid.sql.calcite.expression.OperatorConversions; -import org.apache.druid.sql.calcite.expression.SqlOperatorConversion; -import org.apache.druid.sql.calcite.planner.PlannerContext; -import org.apache.druid.sql.calcite.table.RowSignature; import org.apache.calcite.rex.RexNode; import org.apache.calcite.sql.SqlFunction; import org.apache.calcite.sql.SqlFunctionCategory; import org.apache.calcite.sql.SqlOperator; import org.apache.calcite.sql.type.SqlTypeFamily; import org.apache.calcite.sql.type.SqlTypeName; +import org.apache.druid.java.util.common.StringUtils; +import org.apache.druid.sql.calcite.expression.DruidExpression; +import org.apache.druid.sql.calcite.expression.OperatorConversions; +import org.apache.druid.sql.calcite.expression.SqlOperatorConversion; +import org.apache.druid.sql.calcite.planner.PlannerContext; +import org.apache.druid.sql.calcite.table.RowSignature; public class StrposOperatorConversion implements SqlOperatorConversion { diff --git a/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/SubstringOperatorConversion.java b/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/SubstringOperatorConversion.java index dd811828c2f..de1ee2accef 100644 --- a/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/SubstringOperatorConversion.java +++ b/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/SubstringOperatorConversion.java @@ -19,14 +19,6 @@ package org.apache.druid.sql.calcite.expression.builtin; -import org.apache.druid.java.util.common.StringUtils; -import org.apache.druid.query.extraction.SubstringDimExtractionFn; -import org.apache.druid.sql.calcite.expression.DruidExpression; -import org.apache.druid.sql.calcite.expression.Expressions; -import org.apache.druid.sql.calcite.expression.OperatorConversions; -import org.apache.druid.sql.calcite.expression.SqlOperatorConversion; -import org.apache.druid.sql.calcite.planner.PlannerContext; -import org.apache.druid.sql.calcite.table.RowSignature; import org.apache.calcite.rex.RexCall; import org.apache.calcite.rex.RexLiteral; import org.apache.calcite.rex.RexNode; @@ -35,6 +27,14 @@ import org.apache.calcite.sql.SqlFunctionCategory; import org.apache.calcite.sql.SqlOperator; import org.apache.calcite.sql.type.ReturnTypes; import org.apache.calcite.sql.type.SqlTypeFamily; +import org.apache.druid.java.util.common.StringUtils; +import org.apache.druid.query.extraction.SubstringDimExtractionFn; +import org.apache.druid.sql.calcite.expression.DruidExpression; +import org.apache.druid.sql.calcite.expression.Expressions; +import org.apache.druid.sql.calcite.expression.OperatorConversions; +import org.apache.druid.sql.calcite.expression.SqlOperatorConversion; +import org.apache.druid.sql.calcite.planner.PlannerContext; +import org.apache.druid.sql.calcite.table.RowSignature; public class SubstringOperatorConversion implements SqlOperatorConversion { diff --git a/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/TextcatOperatorConversion.java b/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/TextcatOperatorConversion.java index 3d2817a235e..b678558a4b0 100644 --- a/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/TextcatOperatorConversion.java +++ b/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/TextcatOperatorConversion.java @@ -19,16 +19,16 @@ package org.apache.druid.sql.calcite.expression.builtin; -import org.apache.druid.sql.calcite.expression.DruidExpression; -import org.apache.druid.sql.calcite.expression.OperatorConversions; -import org.apache.druid.sql.calcite.expression.SqlOperatorConversion; -import org.apache.druid.sql.calcite.planner.PlannerContext; -import org.apache.druid.sql.calcite.table.RowSignature; import org.apache.calcite.rex.RexNode; import org.apache.calcite.sql.SqlFunction; import org.apache.calcite.sql.SqlFunctionCategory; import org.apache.calcite.sql.type.SqlTypeFamily; import org.apache.calcite.sql.type.SqlTypeName; +import org.apache.druid.sql.calcite.expression.DruidExpression; +import org.apache.druid.sql.calcite.expression.OperatorConversions; +import org.apache.druid.sql.calcite.expression.SqlOperatorConversion; +import org.apache.druid.sql.calcite.planner.PlannerContext; +import org.apache.druid.sql.calcite.table.RowSignature; public class TextcatOperatorConversion implements SqlOperatorConversion { diff --git a/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/TimeArithmeticOperatorConversion.java b/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/TimeArithmeticOperatorConversion.java index 6ac39b04022..9175855ec34 100644 --- a/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/TimeArithmeticOperatorConversion.java +++ b/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/TimeArithmeticOperatorConversion.java @@ -20,6 +20,11 @@ package org.apache.druid.sql.calcite.expression.builtin; import com.google.common.base.Preconditions; +import org.apache.calcite.rex.RexCall; +import org.apache.calcite.rex.RexNode; +import org.apache.calcite.sql.SqlOperator; +import org.apache.calcite.sql.fun.SqlStdOperatorTable; +import org.apache.calcite.sql.type.SqlTypeFamily; import org.apache.druid.java.util.common.IAE; import org.apache.druid.java.util.common.ISE; import org.apache.druid.java.util.common.StringUtils; @@ -28,11 +33,6 @@ import org.apache.druid.sql.calcite.expression.Expressions; import org.apache.druid.sql.calcite.expression.SqlOperatorConversion; import org.apache.druid.sql.calcite.planner.PlannerContext; import org.apache.druid.sql.calcite.table.RowSignature; -import org.apache.calcite.rex.RexCall; -import org.apache.calcite.rex.RexNode; -import org.apache.calcite.sql.SqlOperator; -import org.apache.calcite.sql.fun.SqlStdOperatorTable; -import org.apache.calcite.sql.type.SqlTypeFamily; import java.util.List; diff --git a/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/TimeExtractOperatorConversion.java b/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/TimeExtractOperatorConversion.java index 07e054b538e..5ab5a505a2b 100644 --- a/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/TimeExtractOperatorConversion.java +++ b/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/TimeExtractOperatorConversion.java @@ -20,6 +20,13 @@ package org.apache.druid.sql.calcite.expression.builtin; import com.google.common.collect.ImmutableList; +import org.apache.calcite.rex.RexCall; +import org.apache.calcite.rex.RexLiteral; +import org.apache.calcite.rex.RexNode; +import org.apache.calcite.sql.SqlFunction; +import org.apache.calcite.sql.SqlFunctionCategory; +import org.apache.calcite.sql.type.SqlTypeFamily; +import org.apache.calcite.sql.type.SqlTypeName; import org.apache.druid.java.util.common.DateTimes; import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.query.expression.TimestampExtractExprMacro; @@ -29,13 +36,6 @@ import org.apache.druid.sql.calcite.expression.OperatorConversions; import org.apache.druid.sql.calcite.expression.SqlOperatorConversion; import org.apache.druid.sql.calcite.planner.PlannerContext; import org.apache.druid.sql.calcite.table.RowSignature; -import org.apache.calcite.rex.RexCall; -import org.apache.calcite.rex.RexLiteral; -import org.apache.calcite.rex.RexNode; -import org.apache.calcite.sql.SqlFunction; -import org.apache.calcite.sql.SqlFunctionCategory; -import org.apache.calcite.sql.type.SqlTypeFamily; -import org.apache.calcite.sql.type.SqlTypeName; import org.joda.time.DateTimeZone; public class TimeExtractOperatorConversion implements SqlOperatorConversion diff --git a/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/TimeFloorOperatorConversion.java b/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/TimeFloorOperatorConversion.java index ae98f5ed986..7771e63d7c3 100644 --- a/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/TimeFloorOperatorConversion.java +++ b/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/TimeFloorOperatorConversion.java @@ -21,6 +21,15 @@ package org.apache.druid.sql.calcite.expression.builtin; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; +import org.apache.calcite.rex.RexCall; +import org.apache.calcite.rex.RexLiteral; +import org.apache.calcite.rex.RexNode; +import org.apache.calcite.sql.SqlFunction; +import org.apache.calcite.sql.SqlFunctionCategory; +import org.apache.calcite.sql.SqlKind; +import org.apache.calcite.sql.SqlOperator; +import org.apache.calcite.sql.type.SqlTypeFamily; +import org.apache.calcite.sql.type.SqlTypeName; import org.apache.druid.java.util.common.DateTimes; import org.apache.druid.java.util.common.granularity.PeriodGranularity; import org.apache.druid.math.expr.ExprMacroTable; @@ -32,15 +41,6 @@ import org.apache.druid.sql.calcite.expression.SqlOperatorConversion; import org.apache.druid.sql.calcite.planner.Calcites; import org.apache.druid.sql.calcite.planner.PlannerContext; import org.apache.druid.sql.calcite.table.RowSignature; -import org.apache.calcite.rex.RexCall; -import org.apache.calcite.rex.RexLiteral; -import org.apache.calcite.rex.RexNode; -import org.apache.calcite.sql.SqlFunction; -import org.apache.calcite.sql.SqlFunctionCategory; -import org.apache.calcite.sql.SqlKind; -import org.apache.calcite.sql.SqlOperator; -import org.apache.calcite.sql.type.SqlTypeFamily; -import org.apache.calcite.sql.type.SqlTypeName; import org.joda.time.DateTime; import org.joda.time.DateTimeZone; import org.joda.time.Period; diff --git a/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/TimeFormatOperatorConversion.java b/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/TimeFormatOperatorConversion.java index dbc45226563..0330e24785e 100644 --- a/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/TimeFormatOperatorConversion.java +++ b/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/TimeFormatOperatorConversion.java @@ -20,13 +20,6 @@ package org.apache.druid.sql.calcite.expression.builtin; import com.google.common.collect.ImmutableList; -import org.apache.druid.java.util.common.DateTimes; -import org.apache.druid.sql.calcite.expression.DruidExpression; -import org.apache.druid.sql.calcite.expression.Expressions; -import org.apache.druid.sql.calcite.expression.OperatorConversions; -import org.apache.druid.sql.calcite.expression.SqlOperatorConversion; -import org.apache.druid.sql.calcite.planner.PlannerContext; -import org.apache.druid.sql.calcite.table.RowSignature; import org.apache.calcite.rex.RexCall; import org.apache.calcite.rex.RexLiteral; import org.apache.calcite.rex.RexNode; @@ -35,6 +28,13 @@ import org.apache.calcite.sql.SqlFunctionCategory; import org.apache.calcite.sql.SqlOperator; import org.apache.calcite.sql.type.SqlTypeFamily; import org.apache.calcite.sql.type.SqlTypeName; +import org.apache.druid.java.util.common.DateTimes; +import org.apache.druid.sql.calcite.expression.DruidExpression; +import org.apache.druid.sql.calcite.expression.Expressions; +import org.apache.druid.sql.calcite.expression.OperatorConversions; +import org.apache.druid.sql.calcite.expression.SqlOperatorConversion; +import org.apache.druid.sql.calcite.planner.PlannerContext; +import org.apache.druid.sql.calcite.table.RowSignature; import org.joda.time.DateTimeZone; import java.util.stream.Collectors; diff --git a/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/TimeParseOperatorConversion.java b/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/TimeParseOperatorConversion.java index cbd678a8159..0a8ca2ba952 100644 --- a/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/TimeParseOperatorConversion.java +++ b/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/TimeParseOperatorConversion.java @@ -19,17 +19,17 @@ package org.apache.druid.sql.calcite.expression.builtin; -import org.apache.druid.sql.calcite.expression.DruidExpression; -import org.apache.druid.sql.calcite.expression.OperatorConversions; -import org.apache.druid.sql.calcite.expression.SqlOperatorConversion; -import org.apache.druid.sql.calcite.planner.PlannerContext; -import org.apache.druid.sql.calcite.table.RowSignature; import org.apache.calcite.rex.RexNode; import org.apache.calcite.sql.SqlFunction; import org.apache.calcite.sql.SqlFunctionCategory; import org.apache.calcite.sql.SqlOperator; import org.apache.calcite.sql.type.SqlTypeFamily; import org.apache.calcite.sql.type.SqlTypeName; +import org.apache.druid.sql.calcite.expression.DruidExpression; +import org.apache.druid.sql.calcite.expression.OperatorConversions; +import org.apache.druid.sql.calcite.expression.SqlOperatorConversion; +import org.apache.druid.sql.calcite.planner.PlannerContext; +import org.apache.druid.sql.calcite.table.RowSignature; public class TimeParseOperatorConversion implements SqlOperatorConversion { diff --git a/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/TimeShiftOperatorConversion.java b/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/TimeShiftOperatorConversion.java index 2630c748d03..69539c4f278 100644 --- a/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/TimeShiftOperatorConversion.java +++ b/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/TimeShiftOperatorConversion.java @@ -19,17 +19,17 @@ package org.apache.druid.sql.calcite.expression.builtin; -import org.apache.druid.sql.calcite.expression.DruidExpression; -import org.apache.druid.sql.calcite.expression.OperatorConversions; -import org.apache.druid.sql.calcite.expression.SqlOperatorConversion; -import org.apache.druid.sql.calcite.planner.PlannerContext; -import org.apache.druid.sql.calcite.table.RowSignature; import org.apache.calcite.rex.RexNode; import org.apache.calcite.sql.SqlFunction; import org.apache.calcite.sql.SqlFunctionCategory; import org.apache.calcite.sql.SqlOperator; import org.apache.calcite.sql.type.SqlTypeFamily; import org.apache.calcite.sql.type.SqlTypeName; +import org.apache.druid.sql.calcite.expression.DruidExpression; +import org.apache.druid.sql.calcite.expression.OperatorConversions; +import org.apache.druid.sql.calcite.expression.SqlOperatorConversion; +import org.apache.druid.sql.calcite.planner.PlannerContext; +import org.apache.druid.sql.calcite.table.RowSignature; public class TimeShiftOperatorConversion implements SqlOperatorConversion { diff --git a/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/TimestampToMillisOperatorConversion.java b/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/TimestampToMillisOperatorConversion.java index e59da9ebdc9..5b6fad79cfd 100644 --- a/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/TimestampToMillisOperatorConversion.java +++ b/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/TimestampToMillisOperatorConversion.java @@ -20,12 +20,6 @@ package org.apache.druid.sql.calcite.expression.builtin; import com.google.common.collect.Iterables; -import org.apache.druid.sql.calcite.expression.DruidExpression; -import org.apache.druid.sql.calcite.expression.Expressions; -import org.apache.druid.sql.calcite.expression.OperatorConversions; -import org.apache.druid.sql.calcite.expression.SqlOperatorConversion; -import org.apache.druid.sql.calcite.planner.PlannerContext; -import org.apache.druid.sql.calcite.table.RowSignature; import org.apache.calcite.rex.RexCall; import org.apache.calcite.rex.RexNode; import org.apache.calcite.sql.SqlFunction; @@ -33,6 +27,12 @@ import org.apache.calcite.sql.SqlFunctionCategory; import org.apache.calcite.sql.SqlOperator; import org.apache.calcite.sql.type.SqlTypeFamily; import org.apache.calcite.sql.type.SqlTypeName; +import org.apache.druid.sql.calcite.expression.DruidExpression; +import org.apache.druid.sql.calcite.expression.Expressions; +import org.apache.druid.sql.calcite.expression.OperatorConversions; +import org.apache.druid.sql.calcite.expression.SqlOperatorConversion; +import org.apache.druid.sql.calcite.planner.PlannerContext; +import org.apache.druid.sql.calcite.table.RowSignature; public class TimestampToMillisOperatorConversion implements SqlOperatorConversion { diff --git a/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/TrimOperatorConversion.java b/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/TrimOperatorConversion.java index d7f99beefe5..b35caa8cb80 100644 --- a/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/TrimOperatorConversion.java +++ b/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/TrimOperatorConversion.java @@ -20,17 +20,17 @@ package org.apache.druid.sql.calcite.expression.builtin; import com.google.common.collect.ImmutableList; -import org.apache.druid.sql.calcite.expression.DruidExpression; -import org.apache.druid.sql.calcite.expression.Expressions; -import org.apache.druid.sql.calcite.expression.SqlOperatorConversion; -import org.apache.druid.sql.calcite.planner.PlannerContext; -import org.apache.druid.sql.calcite.table.RowSignature; import org.apache.calcite.rex.RexCall; import org.apache.calcite.rex.RexLiteral; import org.apache.calcite.rex.RexNode; import org.apache.calcite.sql.SqlOperator; import org.apache.calcite.sql.fun.SqlStdOperatorTable; import org.apache.calcite.sql.fun.SqlTrimFunction; +import org.apache.druid.sql.calcite.expression.DruidExpression; +import org.apache.druid.sql.calcite.expression.Expressions; +import org.apache.druid.sql.calcite.expression.SqlOperatorConversion; +import org.apache.druid.sql.calcite.planner.PlannerContext; +import org.apache.druid.sql.calcite.table.RowSignature; import javax.annotation.Nullable; diff --git a/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/TruncateOperatorConversion.java b/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/TruncateOperatorConversion.java index 906bfb2d8f7..4f4b122f0a0 100644 --- a/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/TruncateOperatorConversion.java +++ b/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/TruncateOperatorConversion.java @@ -19,6 +19,11 @@ package org.apache.druid.sql.calcite.expression.builtin; +import org.apache.calcite.rex.RexNode; +import org.apache.calcite.sql.SqlFunction; +import org.apache.calcite.sql.SqlFunctionCategory; +import org.apache.calcite.sql.type.ReturnTypes; +import org.apache.calcite.sql.type.SqlTypeFamily; import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.math.expr.Expr; import org.apache.druid.sql.calcite.expression.DruidExpression; @@ -26,11 +31,6 @@ import org.apache.druid.sql.calcite.expression.OperatorConversions; import org.apache.druid.sql.calcite.expression.SqlOperatorConversion; import org.apache.druid.sql.calcite.planner.PlannerContext; import org.apache.druid.sql.calcite.table.RowSignature; -import org.apache.calcite.rex.RexNode; -import org.apache.calcite.sql.SqlFunction; -import org.apache.calcite.sql.SqlFunctionCategory; -import org.apache.calcite.sql.type.ReturnTypes; -import org.apache.calcite.sql.type.SqlTypeFamily; public class TruncateOperatorConversion implements SqlOperatorConversion { diff --git a/sql/src/main/java/org/apache/druid/sql/calcite/filtration/MoveTimeFiltersToIntervals.java b/sql/src/main/java/org/apache/druid/sql/calcite/filtration/MoveTimeFiltersToIntervals.java index 3916b9676db..6ea3784bcbe 100644 --- a/sql/src/main/java/org/apache/druid/sql/calcite/filtration/MoveTimeFiltersToIntervals.java +++ b/sql/src/main/java/org/apache/druid/sql/calcite/filtration/MoveTimeFiltersToIntervals.java @@ -31,7 +31,7 @@ import org.apache.druid.query.filter.DimFilter; import org.apache.druid.query.filter.NotDimFilter; import org.apache.druid.query.filter.OrDimFilter; import org.apache.druid.query.ordering.StringComparators; -import org.apache.druid.segment.column.Column; +import org.apache.druid.segment.column.ColumnHolder; import java.util.List; @@ -39,7 +39,7 @@ public class MoveTimeFiltersToIntervals implements Function