Skip to content

Commit 900f01f

Browse files
authored
Make getConfigMapWithPrefix auto append tailing dot if missing (#8522)
1 parent 4f30ab2 commit 900f01f

File tree

4 files changed

+17
-6
lines changed

4 files changed

+17
-6
lines changed

pinot-controller/src/main/java/org/apache/pinot/controller/util/FileIngestionHelper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ public static void copyURIToLocal(Map<String, String> batchConfigMap, URI source
176176
if (!PinotFSFactory.isSchemeSupported(sourceFileURIScheme)) {
177177
PinotFSFactory.register(sourceFileURIScheme, batchConfigMap.get(BatchConfigProperties.INPUT_FS_CLASS),
178178
IngestionConfigUtils.getInputFsProps(IngestionConfigUtils.getConfigMapWithPrefix(
179-
batchConfigMap, BatchConfigProperties.INPUT_FS_PROP_PREFIX + IngestionConfigUtils.DOT_SEPARATOR)));
179+
batchConfigMap, BatchConfigProperties.INPUT_FS_PROP_PREFIX)));
180180
}
181181
PinotFSFactory.create(sourceFileURIScheme).copyToLocalFile(sourceFileURI, destFile);
182182
}

pinot-plugins/pinot-minion-tasks/pinot-minion-builtin-tasks/src/main/java/org/apache/pinot/plugin/minion/tasks/segmentgenerationandpush/SegmentGenerationAndPushTaskExecutor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ protected SegmentGenerationTaskSpec generateTaskSpec(Map<String, String> taskCon
306306
SegmentNameGeneratorSpec segmentNameGeneratorSpec = new SegmentNameGeneratorSpec();
307307
segmentNameGeneratorSpec.setType(taskConfigs.get(BatchConfigProperties.SEGMENT_NAME_GENERATOR_TYPE));
308308
segmentNameGeneratorSpec.setConfigs(IngestionConfigUtils.getConfigMapWithPrefix(taskConfigs,
309-
BatchConfigProperties.SEGMENT_NAME_GENERATOR_PROP_PREFIX + IngestionConfigUtils.DOT_SEPARATOR));
309+
BatchConfigProperties.SEGMENT_NAME_GENERATOR_PROP_PREFIX));
310310
taskSpec.setSegmentNameGeneratorSpec(segmentNameGeneratorSpec);
311311
taskSpec.setCustomProperty(BatchConfigProperties.INPUT_DATA_FILE_URI_KEY, inputFileURI.toString());
312312
return taskSpec;

pinot-spi/src/main/java/org/apache/pinot/spi/utils/IngestionConfigUtils.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,25 +117,25 @@ public static String getBatchSegmentIngestionFrequency(TableConfig tableConfig)
117117
* Fetch the properties which belong to record reader, by removing the identifier prefix
118118
*/
119119
public static Map<String, String> getRecordReaderProps(Map<String, String> batchConfigMap) {
120-
return getConfigMapWithPrefix(batchConfigMap, BatchConfigProperties.RECORD_READER_PROP_PREFIX + DOT_SEPARATOR);
120+
return getConfigMapWithPrefix(batchConfigMap, BatchConfigProperties.RECORD_READER_PROP_PREFIX);
121121
}
122122

123123
/**
124124
* Fetch the properties which belong to segment name generator, by removing the identifier prefix
125125
*/
126126
public static Map<String, String> getSegmentNameGeneratorProps(Map<String, String> batchConfigMap) {
127127
return getConfigMapWithPrefix(batchConfigMap,
128-
BatchConfigProperties.SEGMENT_NAME_GENERATOR_PROP_PREFIX + DOT_SEPARATOR);
128+
BatchConfigProperties.SEGMENT_NAME_GENERATOR_PROP_PREFIX);
129129
}
130130

131131
public static PinotConfiguration getInputFsProps(Map<String, String> batchConfigMap) {
132132
return new PinotConfiguration(
133-
getPropsWithPrefix(batchConfigMap, BatchConfigProperties.INPUT_FS_PROP_PREFIX + DOT_SEPARATOR));
133+
getPropsWithPrefix(batchConfigMap, BatchConfigProperties.INPUT_FS_PROP_PREFIX));
134134
}
135135

136136
public static PinotConfiguration getOutputFsProps(Map<String, String> batchConfigMap) {
137137
return new PinotConfiguration(
138-
getPropsWithPrefix(batchConfigMap, BatchConfigProperties.OUTPUT_FS_PROP_PREFIX + DOT_SEPARATOR));
138+
getPropsWithPrefix(batchConfigMap, BatchConfigProperties.OUTPUT_FS_PROP_PREFIX));
139139
}
140140

141141
/**
@@ -160,6 +160,9 @@ public static Map<String, Object> getPropsWithPrefix(Map<String, String> batchCo
160160

161161
public static Map<String, String> getConfigMapWithPrefix(Map<String, String> batchConfigMap, String prefix) {
162162
Map<String, String> props = new HashMap<>();
163+
if (!prefix.endsWith(DOT_SEPARATOR)) {
164+
prefix = prefix + DOT_SEPARATOR;
165+
}
163166
for (String configKey : batchConfigMap.keySet()) {
164167
if (configKey.startsWith(prefix)) {
165168
String[] splits = configKey.split(prefix, 2);

pinot-spi/src/test/java/org/apache/pinot/spi/utils/IngestionConfigUtilsTest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
*/
1919
package org.apache.pinot.spi.utils;
2020

21+
import com.google.common.collect.ImmutableMap;
2122
import com.google.common.collect.Lists;
2223
import java.util.HashMap;
2324
import java.util.Map;
@@ -146,4 +147,11 @@ public void testGetPushType() {
146147
segmentsValidationAndRetentionConfig.setSegmentPushType(null);
147148
Assert.assertNull(IngestionConfigUtils.getBatchSegmentIngestionType(tableConfig));
148149
}
150+
151+
@Test
152+
public void testGetConfigMapWithPrefix() {
153+
Map<String, String> testMap = ImmutableMap.of("k1", "v1", "k1.k2", "v2", "k1.k3", "v3", "k4", "v4");
154+
Assert.assertEquals(2, IngestionConfigUtils.getConfigMapWithPrefix(testMap, "k1").size());
155+
Assert.assertEquals(2, IngestionConfigUtils.getConfigMapWithPrefix(testMap, "k1.").size());
156+
}
149157
}

0 commit comments

Comments
 (0)