Search in sources :

Example 11 with InputRow

use of org.apache.druid.data.input.InputRow in project druid by druid-io.

the class SimpleTestIndex method makeRealtimeIndex.

private static IncrementalIndex makeRealtimeIndex() {
    try {
        List<InputRow> inputRows = Lists.newArrayListWithExpectedSize(NUM_ROWS);
        for (int i = 1; i <= NUM_ROWS; i++) {
            double doubleVal = i + 0.7d;
            String stringVal = String.valueOf(doubleVal);
            inputRows.add(new MapBasedInputRow(DateTime.now(DateTimeZone.UTC), DIMENSIONS, ImmutableMap.of(DOUBLE_COL, doubleVal, SINGLE_VALUE_DOUBLE_AS_STRING_DIM, stringVal, MULTI_VALUE_DOUBLE_AS_STRING_DIM, Lists.newArrayList(stringVal, null, stringVal))));
        }
        return AggregationTestHelper.createIncrementalIndex(inputRows.iterator(), new NoopInputRowParser(null), new AggregatorFactory[] { new CountAggregatorFactory("count"), new DoubleSumAggregatorFactory(DOUBLE_COL, DOUBLE_COL) }, 0, Granularities.NONE, false, 100, false);
    } catch (Exception ex) {
        throw new RuntimeException(ex);
    }
}
Also used : CountAggregatorFactory(org.apache.druid.query.aggregation.CountAggregatorFactory) DoubleSumAggregatorFactory(org.apache.druid.query.aggregation.DoubleSumAggregatorFactory) MapBasedInputRow(org.apache.druid.data.input.MapBasedInputRow) InputRow(org.apache.druid.data.input.InputRow) MapBasedInputRow(org.apache.druid.data.input.MapBasedInputRow) NoopInputRowParser(org.apache.druid.data.input.impl.NoopInputRowParser)

Example 12 with InputRow

use of org.apache.druid.data.input.InputRow in project druid by druid-io.

the class DataGeneratorTest method testZipf.

@Test
public void testZipf() {
    List<GeneratorColumnSchema> schemas = new ArrayList<>();
    RowValueTracker tracker = new RowValueTracker();
    schemas.add(GeneratorColumnSchema.makeZipf("dimA", ValueType.STRING, false, 1, null, 1000, 2000, 1.0));
    schemas.add(GeneratorColumnSchema.makeZipf("dimB", ValueType.FLOAT, false, 1, null, 99990, 99999, 1.0));
    schemas.add(GeneratorColumnSchema.makeEnumeratedZipf("dimC", ValueType.STRING, false, 1, null, Arrays.asList("1-Hello", "2-World", "3-Foo", "4-Bar", "5-BA5EBA11", "6-Rocky", "7-Mango", "8-Contango"), 1.0));
    DataGenerator dataGenerator = new DataGenerator(schemas, 9999, 0, 0, 1000.0);
    for (int i = 0; i < 100; i++) {
        InputRow row = dataGenerator.nextRow();
        // System.out.println("Z-ROW: " + row);
        tracker.addRow(row);
    }
    tracker.printStuff();
}
Also used : ArrayList(java.util.ArrayList) InputRow(org.apache.druid.data.input.InputRow) InitializedNullHandlingTest(org.apache.druid.testing.InitializedNullHandlingTest) Test(org.junit.Test)

Example 13 with InputRow

use of org.apache.druid.data.input.InputRow in project druid by druid-io.

the class DataGeneratorTest method testRoundedNormal.

@Test
public void testRoundedNormal() {
    List<GeneratorColumnSchema> schemas = new ArrayList<>();
    RowValueTracker tracker = new RowValueTracker();
    schemas.add(GeneratorColumnSchema.makeNormal("dimA", ValueType.FLOAT, false, 1, null, 50.0, 1.0, true));
    schemas.add(GeneratorColumnSchema.makeNormal("dimB", ValueType.STRING, false, 1, null, 1000.0, 10.0, true));
    DataGenerator dataGenerator = new DataGenerator(schemas, 9999, 0, 0, 1000.0);
    for (int i = 0; i < 1000000; i++) {
        InputRow row = dataGenerator.nextRow();
        // System.out.println("N-ROW: " + row);
        tracker.addRow(row);
    }
    tracker.printStuff();
}
Also used : ArrayList(java.util.ArrayList) InputRow(org.apache.druid.data.input.InputRow) InitializedNullHandlingTest(org.apache.druid.testing.InitializedNullHandlingTest) Test(org.junit.Test)

Example 14 with InputRow

use of org.apache.druid.data.input.InputRow in project druid by druid-io.

the class DataGeneratorTest method testDiscreteUniform.

@Test
public void testDiscreteUniform() {
    List<GeneratorColumnSchema> schemas = new ArrayList<>();
    RowValueTracker tracker = new RowValueTracker();
    schemas.add(GeneratorColumnSchema.makeDiscreteUniform("dimA", ValueType.STRING, false, 1, null, 10, 20));
    schemas.add(GeneratorColumnSchema.makeEnumeratedDiscreteUniform("dimB", ValueType.STRING, false, 4, null, Arrays.asList("Hello", "World", "Foo", "Bar")));
    schemas.add(GeneratorColumnSchema.makeDiscreteUniform("dimC", ValueType.STRING, false, 1, 0.50, 10, 20));
    schemas.add(GeneratorColumnSchema.makeDiscreteUniform("dimD", ValueType.FLOAT, false, 1, null, 100, 120));
    DataGenerator dataGenerator = new DataGenerator(schemas, 9999, 0, 0, 1000.0);
    for (int i = 0; i < 100; i++) {
        InputRow row = dataGenerator.nextRow();
        // System.out.println("U-ROW: " + row);
        tracker.addRow(row);
    }
    tracker.printStuff();
}
Also used : ArrayList(java.util.ArrayList) InputRow(org.apache.druid.data.input.InputRow) InitializedNullHandlingTest(org.apache.druid.testing.InitializedNullHandlingTest) Test(org.junit.Test)

Example 15 with InputRow

use of org.apache.druid.data.input.InputRow in project druid by druid-io.

the class DataGeneratorTest method testLazyZipf.

@Test
public void testLazyZipf() {
    List<GeneratorColumnSchema> schemas = new ArrayList<>();
    RowValueTracker tracker = new RowValueTracker();
    schemas.add(GeneratorColumnSchema.makeLazyZipf("dimA", ValueType.STRING, false, 1, null, 0, 1220000, 1.0));
    schemas.add(GeneratorColumnSchema.makeLazyZipf("dimB", ValueType.FLOAT, false, 1, null, 99990, 99999, 1.0));
    schemas.add(GeneratorColumnSchema.makeLazyZipf("dimC", ValueType.DOUBLE, false, 1, null, 0, 100000, 1.5));
    schemas.add(GeneratorColumnSchema.makeLazyZipf("dimD", ValueType.LONG, false, 1, null, 0, 100000, 1.5));
    DataGenerator dataGenerator = new DataGenerator(schemas, 9999, 0, 0, 1000.0);
    for (int i = 0; i < 100000; i++) {
        InputRow row = dataGenerator.nextRow();
        System.out.println("Z-ROW: " + row);
        tracker.addRow(row);
    }
    tracker.printStuff();
}
Also used : ArrayList(java.util.ArrayList) InputRow(org.apache.druid.data.input.InputRow) InitializedNullHandlingTest(org.apache.druid.testing.InitializedNullHandlingTest) Test(org.junit.Test)

Aggregations

InputRow (org.apache.druid.data.input.InputRow)266 Test (org.junit.Test)193 MapBasedInputRow (org.apache.druid.data.input.MapBasedInputRow)57 InputEntityReader (org.apache.druid.data.input.InputEntityReader)54 InputRowSchema (org.apache.druid.data.input.InputRowSchema)52 DimensionsSpec (org.apache.druid.data.input.impl.DimensionsSpec)52 TimestampSpec (org.apache.druid.data.input.impl.TimestampSpec)49 ArrayList (java.util.ArrayList)46 List (java.util.List)37 ImmutableList (com.google.common.collect.ImmutableList)33 JSONPathSpec (org.apache.druid.java.util.common.parsers.JSONPathSpec)33 InitializedNullHandlingTest (org.apache.druid.testing.InitializedNullHandlingTest)33 InputRowListPlusRawValues (org.apache.druid.data.input.InputRowListPlusRawValues)29 File (java.io.File)27 HadoopDruidIndexerConfig (org.apache.druid.indexer.HadoopDruidIndexerConfig)27 JSONPathFieldSpec (org.apache.druid.java.util.common.parsers.JSONPathFieldSpec)27 DateTime (org.joda.time.DateTime)24 Map (java.util.Map)23 IOException (java.io.IOException)18 Interval (org.joda.time.Interval)18