Skip to content
Draft
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 @@ -158,6 +158,16 @@ public static void preprocess(File indexDir, IndexLoadingConfig indexLoadingConf
Preconditions.checkArgument(indexDir.isDirectory(), "Index directory: %s does not exist or is not a directory",
indexDir);

// Respect skipSegmentPreprocess uniformly across every caller — including cold-download load paths
// (BaseTableDataManager#downloadAndLoadSegment and #replaceSegmentIfCrcMismatch) that hard-code
// needPreprocess=true. Without this early exit, those paths run every index handler even when the
// (possibly tier-scoped) flag says to skip, defeating the point of the setting.
if (indexLoadingConfig.isSkipSegmentPreprocess()) {
LOGGER.info("Skipping preprocess for segment: {} because skipSegmentPreprocess is set",
indexDir.getName());
return;
}

SegmentMetadataImpl segmentMetadata = new SegmentMetadataImpl(indexDir);
if (segmentMetadata.getTotalDocs() > 0) {
if (segmentOperationsThrottlerSet != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,31 @@ public void testIfNeedConvertSegmentFormat()
}
}

@Test
public void testSkipSegmentPreprocessShortCircuitsPreprocess()
throws Exception {
constructV1Segment();
// Baseline: freshly built V1 segment, no V3 directory yet.
assertEquals(new SegmentMetadataImpl(_indexDir).getVersion(), SegmentVersion.v1);
assertFalse(SegmentDirectoryPaths.segmentDirectoryFor(_indexDir, SegmentVersion.v3).exists());

// Build a v3 ILC with skipSegmentPreprocess=true. Preprocess (including the V1→V3 format
// conversion) must be a no-op even though the caller invoked preprocess directly — mirroring the
// cold-download path in BaseTableDataManager#downloadAndLoadSegment / #replaceSegmentIfCrcMismatch
// which hard-codes needPreprocess=true.
TableConfig skipTableConfig = new TableConfigBuilder(TableType.OFFLINE).setTableName(RAW_TABLE_NAME)
.setSegmentVersion("v3")
.setSkipSegmentPreprocess(true)
.build();
IndexLoadingConfig skipIlc = new IndexLoadingConfig(skipTableConfig, createSchema());

ImmutableSegmentLoader.preprocess(_indexDir, skipIlc, SEGMENT_OPERATIONS_THROTTLER, null);

// Skip flag honored: segment stays V1, no V3 directory materialized.
assertEquals(new SegmentMetadataImpl(_indexDir).getVersion(), SegmentVersion.v1);
assertFalse(SegmentDirectoryPaths.segmentDirectoryFor(_indexDir, SegmentVersion.v3).exists());
}

private void testConversion()
throws Exception {
// Do not set segment version, should not convert the segment
Expand Down
Loading