Search in sources :

Example 31 with DynamicPartitionsSpec

use of org.apache.druid.indexer.partitions.DynamicPartitionsSpec in project druid by druid-io.

the class ITSqlInputSourceTest method testIndexData.

@Test(dataProvider = "resources")
public void testIndexData(List<String> sqlQueries) throws Exception {
    final String indexDatasource = "wikipedia_index_test_" + UUID.randomUUID();
    try (final Closeable ignored1 = unloader(indexDatasource + config.getExtraDatasourceNameSuffix())) {
        final Function<String, String> sqlInputSourcePropsTransform = spec -> {
            try {
                spec = StringUtils.replace(spec, "%%PARTITIONS_SPEC%%", jsonMapper.writeValueAsString(new DynamicPartitionsSpec(null, null)));
                return StringUtils.replace(spec, "%%SQL_QUERY%%", jsonMapper.writeValueAsString(sqlQueries));
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        };
        doIndexTest(indexDatasource, INDEX_TASK, sqlInputSourcePropsTransform, INDEX_QUERIES_RESOURCE, false, true, true, new Pair<>(false, false));
    }
}
Also used : DataProvider(org.testng.annotations.DataProvider) StringUtils(org.apache.druid.java.util.common.StringUtils) DruidTestModuleFactory(org.apache.druid.testing.guice.DruidTestModuleFactory) Test(org.testng.annotations.Test) UUID(java.util.UUID) Function(java.util.function.Function) Guice(org.testng.annotations.Guice) Pair(org.apache.druid.java.util.common.Pair) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) TestNGGroup(org.apache.druid.tests.TestNGGroup) Closeable(java.io.Closeable) DynamicPartitionsSpec(org.apache.druid.indexer.partitions.DynamicPartitionsSpec) DynamicPartitionsSpec(org.apache.druid.indexer.partitions.DynamicPartitionsSpec) Closeable(java.io.Closeable) Test(org.testng.annotations.Test)

Example 32 with DynamicPartitionsSpec

use of org.apache.druid.indexer.partitions.DynamicPartitionsSpec in project druid by druid-io.

the class AbstractS3InputSourceParallelIndexTest method doTest.

void doTest(Pair<String, List> s3InputSource, Pair<Boolean, Boolean> segmentAvailabilityConfirmationPair) throws Exception {
    final String indexDatasource = "wikipedia_index_test_" + UUID.randomUUID();
    try (final Closeable ignored1 = unloader(indexDatasource + config.getExtraDatasourceNameSuffix())) {
        final Function<String, String> s3PropsTransform = spec -> {
            try {
                String inputSourceValue = jsonMapper.writeValueAsString(s3InputSource.rhs);
                inputSourceValue = StringUtils.replace(inputSourceValue, "%%BUCKET%%", config.getCloudBucket());
                inputSourceValue = StringUtils.replace(inputSourceValue, "%%PATH%%", config.getCloudPath());
                spec = StringUtils.replace(spec, "%%INPUT_FORMAT_TYPE%%", InputFormatDetails.JSON.getInputFormatType());
                spec = StringUtils.replace(spec, "%%PARTITIONS_SPEC%%", jsonMapper.writeValueAsString(new DynamicPartitionsSpec(null, null)));
                spec = StringUtils.replace(spec, "%%INPUT_SOURCE_TYPE%%", "s3");
                spec = StringUtils.replace(spec, "%%INPUT_SOURCE_PROPERTY_KEY%%", s3InputSource.lhs);
                return StringUtils.replace(spec, "%%INPUT_SOURCE_PROPERTY_VALUE%%", inputSourceValue);
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        };
        doIndexTest(indexDatasource, INDEX_TASK, s3PropsTransform, INDEX_QUERIES_RESOURCE, false, true, true, segmentAvailabilityConfirmationPair);
    }
}
Also used : List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) DataProvider(org.testng.annotations.DataProvider) ImmutableMap(com.google.common.collect.ImmutableMap) Closeable(java.io.Closeable) DynamicPartitionsSpec(org.apache.druid.indexer.partitions.DynamicPartitionsSpec) StringUtils(org.apache.druid.java.util.common.StringUtils) UUID(java.util.UUID) Function(java.util.function.Function) Pair(org.apache.druid.java.util.common.Pair) DynamicPartitionsSpec(org.apache.druid.indexer.partitions.DynamicPartitionsSpec) Closeable(java.io.Closeable)

Example 33 with DynamicPartitionsSpec

use of org.apache.druid.indexer.partitions.DynamicPartitionsSpec in project druid by druid-io.

the class ITCombiningInputSourceParallelIndexTest method testIndexData.

@Test
public void testIndexData() throws Exception {
    Map inputFormatMap = new ImmutableMap.Builder<String, Object>().put("type", "json").build();
    try (final Closeable ignored1 = unloader(INDEX_DATASOURCE + config.getExtraDatasourceNameSuffix());
        final Closeable ignored2 = unloader(COMBINING_INDEX_DATASOURCE + config.getExtraDatasourceNameSuffix())) {
        final Function<String, String> combiningInputSourceSpecTransform = spec -> {
            try {
                spec = StringUtils.replace(spec, "%%PARTITIONS_SPEC%%", jsonMapper.writeValueAsString(new DynamicPartitionsSpec(null, null)));
                spec = StringUtils.replace(spec, "%%INPUT_SOURCE_FILTER%%", "wikipedia_index_data*");
                spec = StringUtils.replace(spec, "%%INPUT_SOURCE_BASE_DIR%%", "/resources/data/batch_index/json");
                spec = StringUtils.replace(spec, "%%INPUT_FORMAT%%", jsonMapper.writeValueAsString(inputFormatMap));
                spec = StringUtils.replace(spec, "%%APPEND_TO_EXISTING%%", jsonMapper.writeValueAsString(false));
                spec = StringUtils.replace(spec, "%%DROP_EXISTING%%", jsonMapper.writeValueAsString(false));
                spec = StringUtils.replace(spec, "%%FORCE_GUARANTEED_ROLLUP%%", jsonMapper.writeValueAsString(false));
                spec = StringUtils.replace(spec, "%%COMBINING_DATASOURCE%%", INDEX_DATASOURCE + config.getExtraDatasourceNameSuffix());
                return spec;
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        };
        doIndexTest(INDEX_DATASOURCE, INDEX_TASK, combiningInputSourceSpecTransform, INDEX_QUERIES_RESOURCE, false, true, true, new Pair<>(false, false));
        doIndexTest(COMBINING_INDEX_DATASOURCE, COMBINING_INDEX_TASK, combiningInputSourceSpecTransform, COMBINING_QUERIES_RESOURCE, false, true, true, new Pair<>(false, false));
    }
}
Also used : TestNGGroup(org.apache.druid.tests.TestNGGroup) ImmutableMap(com.google.common.collect.ImmutableMap) Closeable(java.io.Closeable) Map(java.util.Map) DynamicPartitionsSpec(org.apache.druid.indexer.partitions.DynamicPartitionsSpec) StringUtils(org.apache.druid.java.util.common.StringUtils) DruidTestModuleFactory(org.apache.druid.testing.guice.DruidTestModuleFactory) Test(org.testng.annotations.Test) Function(java.util.function.Function) Guice(org.testng.annotations.Guice) Pair(org.apache.druid.java.util.common.Pair) DynamicPartitionsSpec(org.apache.druid.indexer.partitions.DynamicPartitionsSpec) Closeable(java.io.Closeable) ImmutableMap(com.google.common.collect.ImmutableMap) Map(java.util.Map) Test(org.testng.annotations.Test)

Example 34 with DynamicPartitionsSpec

use of org.apache.druid.indexer.partitions.DynamicPartitionsSpec in project druid by druid-io.

the class AbstractAzureInputSourceParallelIndexTest method doTest.

void doTest(Pair<String, List> azureInputSource, Pair<Boolean, Boolean> segmentAvailabilityConfirmationPair) throws Exception {
    final String indexDatasource = "wikipedia_index_test_" + UUID.randomUUID();
    try (final Closeable ignored1 = unloader(indexDatasource + config.getExtraDatasourceNameSuffix())) {
        final Function<String, String> azurePropsTransform = spec -> {
            try {
                String inputSourceValue = jsonMapper.writeValueAsString(azureInputSource.rhs);
                inputSourceValue = StringUtils.replace(inputSourceValue, "%%BUCKET%%", config.getCloudBucket());
                inputSourceValue = StringUtils.replace(inputSourceValue, "%%PATH%%", config.getCloudPath());
                spec = StringUtils.replace(spec, "%%INPUT_FORMAT_TYPE%%", InputFormatDetails.JSON.getInputFormatType());
                spec = StringUtils.replace(spec, "%%PARTITIONS_SPEC%%", jsonMapper.writeValueAsString(new DynamicPartitionsSpec(null, null)));
                spec = StringUtils.replace(spec, "%%INPUT_SOURCE_TYPE%%", "azure");
                spec = StringUtils.replace(spec, "%%INPUT_SOURCE_PROPERTY_KEY%%", azureInputSource.lhs);
                return StringUtils.replace(spec, "%%INPUT_SOURCE_PROPERTY_VALUE%%", inputSourceValue);
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        };
        doIndexTest(indexDatasource, INDEX_TASK, azurePropsTransform, INDEX_QUERIES_RESOURCE, false, true, true, segmentAvailabilityConfirmationPair);
    }
}
Also used : List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) DataProvider(org.testng.annotations.DataProvider) ImmutableMap(com.google.common.collect.ImmutableMap) Closeable(java.io.Closeable) DynamicPartitionsSpec(org.apache.druid.indexer.partitions.DynamicPartitionsSpec) StringUtils(org.apache.druid.java.util.common.StringUtils) UUID(java.util.UUID) Function(java.util.function.Function) Pair(org.apache.druid.java.util.common.Pair) DynamicPartitionsSpec(org.apache.druid.indexer.partitions.DynamicPartitionsSpec) Closeable(java.io.Closeable)

Example 35 with DynamicPartitionsSpec

use of org.apache.druid.indexer.partitions.DynamicPartitionsSpec in project druid by druid-io.

the class AbstractOssInputSourceParallelIndexTest method doTest.

void doTest(Pair<String, List> inputSource, Pair<Boolean, Boolean> segmentAvailabilityConfirmationPair) throws Exception {
    final String indexDatasource = "wikipedia_index_test_" + UUID.randomUUID();
    try (final Closeable ignored1 = unloader(indexDatasource + config.getExtraDatasourceNameSuffix())) {
        final Function<String, String> propsTransform = spec -> {
            try {
                String inputSourceValue = jsonMapper.writeValueAsString(inputSource.rhs);
                inputSourceValue = StringUtils.replace(inputSourceValue, "%%BUCKET%%", config.getCloudBucket());
                inputSourceValue = StringUtils.replace(inputSourceValue, "%%PATH%%", config.getCloudPath());
                spec = StringUtils.replace(spec, "%%INPUT_FORMAT_TYPE%%", InputFormatDetails.JSON.getInputFormatType());
                spec = StringUtils.replace(spec, "%%PARTITIONS_SPEC%%", jsonMapper.writeValueAsString(new DynamicPartitionsSpec(null, null)));
                spec = StringUtils.replace(spec, "%%INPUT_SOURCE_TYPE%%", "oss");
                spec = StringUtils.replace(spec, "%%INPUT_SOURCE_PROPERTY_KEY%%", inputSource.lhs);
                return StringUtils.replace(spec, "%%INPUT_SOURCE_PROPERTY_VALUE%%", inputSourceValue);
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        };
        doIndexTest(indexDatasource, INDEX_TASK, propsTransform, INDEX_QUERIES_RESOURCE, false, true, true, segmentAvailabilityConfirmationPair);
    }
}
Also used : List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) DataProvider(org.testng.annotations.DataProvider) ImmutableMap(com.google.common.collect.ImmutableMap) Closeable(java.io.Closeable) DynamicPartitionsSpec(org.apache.druid.indexer.partitions.DynamicPartitionsSpec) StringUtils(org.apache.druid.java.util.common.StringUtils) UUID(java.util.UUID) Function(java.util.function.Function) Pair(org.apache.druid.java.util.common.Pair) DynamicPartitionsSpec(org.apache.druid.indexer.partitions.DynamicPartitionsSpec) Closeable(java.io.Closeable)

Aggregations

DynamicPartitionsSpec (org.apache.druid.indexer.partitions.DynamicPartitionsSpec)52 Test (org.junit.Test)34 IndexSpec (org.apache.druid.segment.IndexSpec)19 List (java.util.List)15 Map (java.util.Map)15 ImmutableList (com.google.common.collect.ImmutableList)13 StringUtils (org.apache.druid.java.util.common.StringUtils)13 DataSegment (org.apache.druid.timeline.DataSegment)13 ImmutableMap (com.google.common.collect.ImmutableMap)12 HashMap (java.util.HashMap)11 Function (java.util.function.Function)11 Pair (org.apache.druid.java.util.common.Pair)11 Closeable (java.io.Closeable)10 DimensionsSpec (org.apache.druid.data.input.impl.DimensionsSpec)10 RoaringBitmapSerdeFactory (org.apache.druid.segment.data.RoaringBitmapSerdeFactory)10 Duration (org.joda.time.Duration)10 Interval (org.joda.time.Interval)10 ArrayList (java.util.ArrayList)9 UUID (java.util.UUID)9 UniformGranularitySpec (org.apache.druid.segment.indexing.granularity.UniformGranularitySpec)9