Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.junit.Test;

import java.util.Arrays;
import java.util.Collections;

public class CSVParseSpecTest
{
Expand All @@ -41,7 +42,7 @@ public void testColumnMissing() throws Exception
Lists.<SpatialDimensionSchema>newArrayList()
),
",",
Arrays.asList("a"),
Collections.singletonList("a"),
false,
0
);
Expand All @@ -62,7 +63,7 @@ public void testComma() throws Exception
Lists.<SpatialDimensionSchema>newArrayList()
),
",",
Arrays.asList("a"),
Collections.singletonList("a"),
false,
0
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;

public class DelimitedParseSpecTest
{
Expand All @@ -37,10 +38,10 @@ public void testSerde() throws IOException
{
DelimitedParseSpec spec = new DelimitedParseSpec(
new TimestampSpec("abc", "iso", null),
new DimensionsSpec(DimensionsSpec.getDefaultSchemas(Arrays.asList("abc")), null, null),
new DimensionsSpec(DimensionsSpec.getDefaultSchemas(Collections.singletonList("abc")), null, null),
"\u0001",
"\u0002",
Arrays.asList("abc"),
Collections.singletonList("abc"),
false,
0
);
Expand All @@ -51,10 +52,10 @@ public void testSerde() throws IOException
Assert.assertEquals("abc", serde.getTimestampSpec().getTimestampColumn());
Assert.assertEquals("iso", serde.getTimestampSpec().getTimestampFormat());

Assert.assertEquals(Arrays.asList("abc"), serde.getColumns());
Assert.assertEquals(Collections.singletonList("abc"), serde.getColumns());
Assert.assertEquals("\u0001", serde.getDelimiter());
Assert.assertEquals("\u0002", serde.getListDelimiter());
Assert.assertEquals(Arrays.asList("abc"), serde.getDimensionsSpec().getDimensionNames());
Assert.assertEquals(Collections.singletonList("abc"), serde.getDimensionsSpec().getDimensionNames());
}

@Test(expected = IllegalArgumentException.class)
Expand All @@ -73,7 +74,7 @@ public void testColumnMissing() throws Exception
),
",",
" ",
Arrays.asList("a"),
Collections.singletonList("a"),
false,
0
);
Expand All @@ -95,7 +96,7 @@ public void testComma() throws Exception
),
",",
null,
Arrays.asList("a"),
Collections.singletonList("a"),
false,
0
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public static Collection<Object[]> constructorFeeder() throws IOException
final List<Object[]> args = new ArrayList<>();
for (int numSkipHeadRows = 0; numSkipHeadRows < 3; numSkipHeadRows++) {
for (List<String> texts : inputTexts) {
args.add(new Object[] {texts, numSkipHeadRows});
args.add(new Object[] { texts, numSkipHeadRows });
}
}

Expand All @@ -86,26 +86,26 @@ public FileIteratingFirehoseTest(List<String> texts, int numSkipHeaderRows)

this.inputs = texts;
this.expectedResults = inputs.stream()
.map(input -> input.split("\n"))
.flatMap(lines -> {
final List<String> filteredLines = Arrays.asList(lines).stream()
.filter(line -> line.length() > 0)
.map(line -> line.split(",")[1])
.collect(Collectors.toList());
.map(input -> input.split("\n"))
.flatMap(lines -> {
final List<String> filteredLines = Arrays.asList(lines).stream()
.filter(line -> line.length() > 0)
.map(line -> line.split(",")[1])
.collect(Collectors.toList());

final int numRealSkippedRows = Math.min(filteredLines.size(), numSkipHeaderRows);
IntStream.range(0, numRealSkippedRows).forEach(i -> filteredLines.set(i, null));
return filteredLines.stream();
})
.collect(Collectors.toList());
final int numRealSkippedRows = Math.min(filteredLines.size(), numSkipHeaderRows);
IntStream.range(0, numRealSkippedRows).forEach(i -> filteredLines.set(i, null));
return filteredLines.stream();
})
.collect(Collectors.toList());
}

@Test
public void testFirehose() throws Exception
{
final List<LineIterator> lineIterators = inputs.stream()
.map(s -> new LineIterator(new StringReader(s)))
.collect(Collectors.toList());
.map(s -> new LineIterator(new StringReader(s)))
.collect(Collectors.toList());

try (final FileIteratingFirehose firehose = new FileIteratingFirehose(lineIterators.iterator(), parser)) {
final List<String> results = Lists.newArrayList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import com.fasterxml.jackson.databind.InjectableValues;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.ImmutableMap;

import io.druid.TestObjectMapper;
import io.druid.java.util.common.parsers.Parser;
import io.druid.js.JavaScriptConfig;
Expand All @@ -32,7 +31,7 @@
import org.junit.rules.ExpectedException;

import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
import java.util.Map;

/**
Expand All @@ -55,7 +54,7 @@ public void testSerde() throws IOException
);
JavaScriptParseSpec spec = new JavaScriptParseSpec(
new TimestampSpec("abc", "iso", null),
new DimensionsSpec(DimensionsSpec.getDefaultSchemas(Arrays.asList("abc")), null, null),
new DimensionsSpec(DimensionsSpec.getDefaultSchemas(Collections.singletonList("abc")), null, null),
"abc",
JavaScriptConfig.getEnabledInstance()
);
Expand All @@ -67,7 +66,7 @@ public void testSerde() throws IOException
Assert.assertEquals("iso", serde.getTimestampSpec().getTimestampFormat());

Assert.assertEquals("abc", serde.getFunction());
Assert.assertEquals(Arrays.asList("abc"), serde.getDimensionsSpec().getDimensionNames());
Assert.assertEquals(Collections.singletonList("abc"), serde.getDimensionsSpec().getDimensionNames());
}

@Test
Expand All @@ -76,7 +75,7 @@ public void testMakeParser()
final JavaScriptConfig config = JavaScriptConfig.getEnabledInstance();
JavaScriptParseSpec spec = new JavaScriptParseSpec(
new TimestampSpec("abc", "iso", null),
new DimensionsSpec(DimensionsSpec.getDefaultSchemas(Arrays.asList("abc")), null, null),
new DimensionsSpec(DimensionsSpec.getDefaultSchemas(Collections.singletonList("abc")), null, null),
"function(str) { var parts = str.split(\"-\"); return { one: parts[0], two: parts[1] } }",
config
);
Expand All @@ -92,7 +91,7 @@ public void testMakeParserNotAllowed()
final JavaScriptConfig config = new JavaScriptConfig(false);
JavaScriptParseSpec spec = new JavaScriptParseSpec(
new TimestampSpec("abc", "iso", null),
new DimensionsSpec(DimensionsSpec.getDefaultSchemas(Arrays.asList("abc")), null, null),
new DimensionsSpec(DimensionsSpec.getDefaultSchemas(Collections.singletonList("abc")), null, null),
"abc",
config
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.junit.Test;

import java.util.Arrays;
import java.util.Collections;

public class ParseSpecTest
{
Expand Down Expand Up @@ -83,7 +84,7 @@ public void testDimExclusionDuplicate() throws Exception
null
),
new DimensionsSpec(
DimensionsSpec.getDefaultSchemas(Arrays.asList("a")),
DimensionsSpec.getDefaultSchemas(Collections.singletonList("a")),
Lists.newArrayList("B", "B"),
Lists.<SpatialDimensionSchema>newArrayList()
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import org.junit.Test;

import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;

/**
*/
Expand All @@ -38,9 +38,9 @@ public void testSerde() throws IOException
{
RegexParseSpec spec = new RegexParseSpec(
new TimestampSpec("abc", "iso", null),
new DimensionsSpec(DimensionsSpec.getDefaultSchemas(Arrays.asList("abc")), null, null),
new DimensionsSpec(DimensionsSpec.getDefaultSchemas(Collections.singletonList("abc")), null, null),
"\u0001",
Arrays.asList("abc"),
Collections.singletonList("abc"),
"abc"
);
final RegexParseSpec serde = jsonMapper.readValue(
Expand All @@ -52,6 +52,6 @@ public void testSerde() throws IOException

Assert.assertEquals("abc", serde.getPattern());
Assert.assertEquals("\u0001", serde.getListDelimiter());
Assert.assertEquals(Arrays.asList("abc"), serde.getDimensionsSpec().getDimensionNames());
Assert.assertEquals(Collections.singletonList("abc"), serde.getDimensionsSpec().getDimensionNames());
}
}
3 changes: 2 additions & 1 deletion api/src/test/java/io/druid/guice/PolyBindTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.junit.Test;

import java.util.Arrays;
import java.util.Collections;
import java.util.Properties;

/**
Expand All @@ -46,7 +47,7 @@ public void setUp(Module... modules) throws Exception
props = new Properties();
injector = Guice.createInjector(
Iterables.concat(
Arrays.asList(
Collections.singletonList(
new Module()
{
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.TimeUnit;

Expand Down Expand Up @@ -128,7 +129,11 @@ public class FilteredAggregatorBenchmark
private File tmpDir;

private static String JS_FN = "function(str) { return 'super-' + str; }";
private static ExtractionFn JS_EXTRACTION_FN = new JavaScriptExtractionFn(JS_FN, false, JavaScriptConfig.getEnabledInstance());
private static ExtractionFn JS_EXTRACTION_FN = new JavaScriptExtractionFn(
JS_FN,
false,
JavaScriptConfig.getEnabledInstance()
);

static {
JSON_MAPPER = new DefaultObjectMapper();
Expand Down Expand Up @@ -169,10 +174,15 @@ public void setup() throws IOException
filter = new OrDimFilter(
Arrays.asList(
new BoundDimFilter("dimSequential", "-1", "-1", true, true, null, null, StringComparators.ALPHANUMERIC),
new JavaScriptDimFilter("dimSequential", "function(x) { return false }", null, JavaScriptConfig.getEnabledInstance()),
new JavaScriptDimFilter(
"dimSequential",
"function(x) { return false }",
null,
JavaScriptConfig.getEnabledInstance()
),
new RegexDimFilter("dimSequential", "X", null),
new SearchQueryDimFilter("dimSequential", new ContainsSearchQuerySpec("X", false), null),
new InDimFilter("dimSequential", Arrays.asList("X"), null)
new InDimFilter("dimSequential", Collections.singletonList("X"), null)
)
);
filteredMetrics = new AggregatorFactory[1];
Expand Down Expand Up @@ -208,7 +218,7 @@ public void setup() throws IOException
);

BenchmarkSchemaInfo basicSchema = BenchmarkSchemas.SCHEMA_MAP.get("basic");
QuerySegmentSpec intervalSpec = new MultipleIntervalSegmentSpec(Arrays.asList(basicSchema.getDataInterval()));
QuerySegmentSpec intervalSpec = new MultipleIntervalSegmentSpec(Collections.singletonList(basicSchema.getDataInterval()));
List<AggregatorFactory> queryAggs = new ArrayList<>();
queryAggs.add(filteredMetrics[0]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -174,7 +174,7 @@ private void setupQueries()
BenchmarkSchemaInfo basicSchema = BenchmarkSchemas.SCHEMA_MAP.get("basic");

{ // basic.A
QuerySegmentSpec intervalSpec = new MultipleIntervalSegmentSpec(Arrays.asList(basicSchema.getDataInterval()));
QuerySegmentSpec intervalSpec = new MultipleIntervalSegmentSpec(Collections.singletonList(basicSchema.getDataInterval()));
List<AggregatorFactory> queryAggs = new ArrayList<>();
queryAggs.add(new LongSumAggregatorFactory(
"sumLongSequential",
Expand Down Expand Up @@ -240,7 +240,7 @@ private void setupQueries()
}

{ // basic.nested
QuerySegmentSpec intervalSpec = new MultipleIntervalSegmentSpec(Arrays.asList(basicSchema.getDataInterval()));
QuerySegmentSpec intervalSpec = new MultipleIntervalSegmentSpec(Collections.singletonList(basicSchema.getDataInterval()));
List<AggregatorFactory> queryAggs = new ArrayList<>();
queryAggs.add(new LongSumAggregatorFactory(
"sumLongSequential",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -159,7 +159,7 @@ private void setupQueries()
BenchmarkSchemaInfo basicSchema = BenchmarkSchemas.SCHEMA_MAP.get("basic");

{ // basic.A
QuerySegmentSpec intervalSpec = new MultipleIntervalSegmentSpec(Arrays.asList(basicSchema.getDataInterval()));
QuerySegmentSpec intervalSpec = new MultipleIntervalSegmentSpec(Collections.singletonList(basicSchema.getDataInterval()));

List<AggregatorFactory> queryAggs = new ArrayList<>();
queryAggs.add(new LongSumAggregatorFactory("sumLongSequential", "sumLongSequential"));
Expand Down Expand Up @@ -199,7 +199,7 @@ private void setupQueries()
basicQueries.put("float", queryBuilderFloat);
}
{ // basic.numericSort
QuerySegmentSpec intervalSpec = new MultipleIntervalSegmentSpec(Arrays.asList(basicSchema.getDataInterval()));
QuerySegmentSpec intervalSpec = new MultipleIntervalSegmentSpec(Collections.singletonList(basicSchema.getDataInterval()));

List<AggregatorFactory> queryAggs = new ArrayList<>();
queryAggs.add(new LongSumAggregatorFactory("sumLongSequential", "sumLongSequential"));
Expand All @@ -215,7 +215,7 @@ private void setupQueries()
basicQueries.put("numericSort", queryBuilderA);
}
{ // basic.alphanumericSort
QuerySegmentSpec intervalSpec = new MultipleIntervalSegmentSpec(Arrays.asList(basicSchema.getDataInterval()));
QuerySegmentSpec intervalSpec = new MultipleIntervalSegmentSpec(Collections.singletonList(basicSchema.getDataInterval()));

List<AggregatorFactory> queryAggs = new ArrayList<>();
queryAggs.add(new LongSumAggregatorFactory("sumLongSequential", "sumLongSequential"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import org.apache.commons.math3.distribution.EnumeratedDistribution;
import org.apache.commons.math3.util.Pair;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public class SequentialDistribution extends EnumeratedDistribution
Expand All @@ -37,7 +37,7 @@ public class SequentialDistribution extends EnumeratedDistribution
public SequentialDistribution(Integer start, Integer end, List<Object> enumeratedValues)
{
// just pass in some bogus probability mass function, we won't be using it
super(Arrays.asList(new Pair<Object, Double>(null, 1.0)));
super(Collections.singletonList(new Pair<Object, Double>(null, 1.0)));
this.start = start;
this.end = end;
this.enumeratedValues = enumeratedValues;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.TimeUnit;

Expand Down Expand Up @@ -173,7 +174,7 @@ public void readWithFilters(Blackhole blackhole) throws Exception
new JavaScriptDimFilter("dimSequential", "function(x) { return false }", null, JavaScriptConfig.getEnabledInstance()),
new RegexDimFilter("dimSequential", "X", null),
new SearchQueryDimFilter("dimSequential", new ContainsSearchQuerySpec("X", false), null),
new InDimFilter("dimSequential", Arrays.asList("X"), null)
new InDimFilter("dimSequential", Collections.singletonList("X"), null)
)
);

Expand Down
Loading