suneet-s commented on a change in pull request #10651:
URL: https://github.com/apache/druid/pull/10651#discussion_r562940613



##########
File path: 
indexing-service/src/main/java/org/apache/druid/indexing/overlord/sampler/InputSourceSampler.java
##########
@@ -103,90 +103,102 @@ public SamplerResponse sample(
     final File tempDir = FileUtils.createTempDir();
     closer.register(() -> FileUtils.deleteDirectory(tempDir));
 
-    final InputSourceReader reader = buildReader(
-        nonNullSamplerConfig,
-        nonNullDataSchema,
-        inputSource,
-        inputFormat,
-        tempDir
-    );
-    try (final CloseableIterator<InputRowListPlusRawValues> iterator = 
reader.sample();
-         final IncrementalIndex<Aggregator> index = 
buildIncrementalIndex(nonNullSamplerConfig, nonNullDataSchema);
-         final Closer closer1 = closer) {
-      List<SamplerResponseRow> responseRows = new 
ArrayList<>(nonNullSamplerConfig.getNumRows());
-      int numRowsIndexed = 0;
-
-      while (responseRows.size() < nonNullSamplerConfig.getNumRows() && 
iterator.hasNext()) {
-        final InputRowListPlusRawValues inputRowListPlusRawValues = 
iterator.next();
-
-        final List<Map<String, Object>> rawColumnsList = 
inputRowListPlusRawValues.getRawValuesList();
-
-        final ParseException parseException = 
inputRowListPlusRawValues.getParseException();
-        if (parseException != null) {
-          if (rawColumnsList != null) {
-            // add all rows to response
-            responseRows.addAll(rawColumnsList.stream()
-                                              .map(rawColumns -> new 
SamplerResponseRow(rawColumns, null, true, parseException.getMessage()))
-                                              .collect(Collectors.toList()));
-          } else {
-            // no data parsed, add one response row
-            responseRows.add(new SamplerResponseRow(null, null, true, 
parseException.getMessage()));
+    try {
+      final InputSourceReader reader = buildReader(
+          nonNullSamplerConfig,
+          nonNullDataSchema,
+          inputSource,
+          inputFormat,
+          tempDir
+      );

Review comment:
       @egor-ryashin Why not write a unit test for this `sample` method that 
expects a `SamplerException` to be thrown when `buildReader` to throw any 
exception




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to