diff --git a/processing/src/test/java/io/druid/segment/data/CompressedFloatsSerdeTest.java b/processing/src/test/java/io/druid/segment/data/CompressedFloatsSerdeTest.java index a1e681b75d1..bc043a3a905 100644 --- a/processing/src/test/java/io/druid/segment/data/CompressedFloatsSerdeTest.java +++ b/processing/src/test/java/io/druid/segment/data/CompressedFloatsSerdeTest.java @@ -22,8 +22,8 @@ package io.druid.segment.data; import com.google.common.base.Supplier; import com.google.common.io.ByteSink; import com.google.common.primitives.Floats; -import com.google.common.primitives.Ints; import io.druid.java.util.common.guava.CloseQuietly; +import it.unimi.dsi.fastutil.ints.IntArrays; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; @@ -36,9 +36,9 @@ import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.channels.Channels; import java.util.ArrayList; -import java.util.Collections; import java.util.List; import java.util.concurrent.CountDownLatch; +import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; @@ -167,9 +167,10 @@ public class CompressedFloatsSerdeTest indices[i] = i; } - Collections.shuffle(Ints.asList(indices)); - // random access - for (int i = 0; i < indexed.size(); ++i) { + // random access, limited to 1000 elements for large lists (every element would take too long) + IntArrays.shuffle(indices, ThreadLocalRandom.current()); + final int limit = Math.min(indexed.size(), 1000); + for (int i = 0; i < limit; ++i) { int k = indices[i]; Assert.assertEquals(vals[k], indexed.get(k), DELTA); } diff --git a/processing/src/test/java/io/druid/segment/data/CompressedIntsIndexedSupplierTest.java b/processing/src/test/java/io/druid/segment/data/CompressedIntsIndexedSupplierTest.java index 7968fc2b071..e1c2fe945cd 100644 --- a/processing/src/test/java/io/druid/segment/data/CompressedIntsIndexedSupplierTest.java +++ b/processing/src/test/java/io/druid/segment/data/CompressedIntsIndexedSupplierTest.java @@ -23,6 +23,7 @@ import com.google.common.primitives.Ints; import com.google.common.primitives.Longs; import io.druid.java.util.common.guava.CloseQuietly; import io.druid.segment.CompressedPools; +import it.unimi.dsi.fastutil.ints.IntArrays; import org.junit.After; import org.junit.Assert; import org.junit.Before; @@ -34,9 +35,9 @@ import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.IntBuffer; import java.nio.channels.Channels; -import java.util.Collections; import java.util.Random; import java.util.concurrent.CountDownLatch; +import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; @@ -330,9 +331,10 @@ public class CompressedIntsIndexedSupplierTest extends CompressionStrategyTest indices[i] = i; } - Collections.shuffle(Ints.asList(indices)); - // random access - for (int i = 0; i < indexed.size(); ++i) { + // random access, limited to 1000 elements for large lists (every element would take too long) + IntArrays.shuffle(indices, ThreadLocalRandom.current()); + final int limit = Math.min(indexed.size(), 1000); + for (int i = 0; i < limit; ++i) { int k = indices[i]; Assert.assertEquals(vals[k], indexed.get(k), 0.0); } diff --git a/processing/src/test/java/io/druid/segment/data/CompressedLongsSerdeTest.java b/processing/src/test/java/io/druid/segment/data/CompressedLongsSerdeTest.java index 076a0a7fb9e..b8897b01f7d 100644 --- a/processing/src/test/java/io/druid/segment/data/CompressedLongsSerdeTest.java +++ b/processing/src/test/java/io/druid/segment/data/CompressedLongsSerdeTest.java @@ -21,9 +21,9 @@ package io.druid.segment.data; import com.google.common.base.Supplier; import com.google.common.io.ByteSink; -import com.google.common.primitives.Ints; import com.google.common.primitives.Longs; import io.druid.java.util.common.guava.CloseQuietly; +import it.unimi.dsi.fastutil.ints.IntArrays; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; @@ -36,9 +36,9 @@ import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.channels.Channels; import java.util.ArrayList; -import java.util.Collections; import java.util.List; import java.util.concurrent.CountDownLatch; +import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; @@ -189,9 +189,10 @@ public class CompressedLongsSerdeTest indices[i] = i; } - Collections.shuffle(Ints.asList(indices)); - // random access - for (int i = 0; i < indexed.size(); ++i) { + // random access, limited to 1000 elements for large lists (every element would take too long) + IntArrays.shuffle(indices, ThreadLocalRandom.current()); + final int limit = Math.min(indexed.size(), 1000); + for (int i = 0; i < limit; ++i) { int k = indices[i]; Assert.assertEquals(vals[k], indexed.get(k)); } diff --git a/processing/src/test/java/io/druid/segment/data/CompressedVSizeIntsIndexedSupplierTest.java b/processing/src/test/java/io/druid/segment/data/CompressedVSizeIntsIndexedSupplierTest.java index 5080556b46c..128144ab6b0 100644 --- a/processing/src/test/java/io/druid/segment/data/CompressedVSizeIntsIndexedSupplierTest.java +++ b/processing/src/test/java/io/druid/segment/data/CompressedVSizeIntsIndexedSupplierTest.java @@ -26,6 +26,7 @@ import com.google.common.primitives.Ints; import com.google.common.primitives.Longs; import io.druid.java.util.common.guava.CloseQuietly; import io.druid.segment.CompressedPools; +import it.unimi.dsi.fastutil.ints.IntArrays; import org.junit.After; import org.junit.Assert; import org.junit.Before; @@ -38,11 +39,11 @@ import java.io.IOException; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.channels.Channels; -import java.util.Collections; import java.util.List; import java.util.Random; import java.util.Set; import java.util.concurrent.CountDownLatch; +import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; @@ -351,7 +352,7 @@ public class CompressedVSizeIntsIndexedSupplierTest extends CompressionStrategyT { Assert.assertEquals(vals.length, indexed.size()); - // sequential access + // sequential access of every element int[] indices = new int[vals.length]; for (int i = 0; i < indexed.size(); ++i) { final int expected = vals[i]; @@ -360,9 +361,10 @@ public class CompressedVSizeIntsIndexedSupplierTest extends CompressionStrategyT indices[i] = i; } - Collections.shuffle(Ints.asList(indices)); - // random access - for (int i = 0; i < indexed.size(); ++i) { + // random access, limited to 1000 elements for large lists (every element would take too long) + IntArrays.shuffle(indices, ThreadLocalRandom.current()); + final int limit = Math.min(indexed.size(), 1000); + for (int i = 0; i < limit; ++i) { int k = indices[i]; Assert.assertEquals(vals[k], indexed.get(k)); }