Skip to content
Merged
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 @@ -149,6 +149,8 @@ private KeyValueClusteringFileWriter createKvSeparatedFileWriter(

private KeyValueDataFileWriter createDataFileWriter(
Path path, WriteFormatKey key, FileSource fileSource, boolean isExternalPath) {
// Changelog is sequentially consumed, file index is unnecessary.
FileIndexOptions indexOptions = key.isChangelog ? new FileIndexOptions() : fileIndexOptions;
return formatContext.thinModeEnabled
? new KeyValueThinDataFileWriterImpl(
fileIO,
Expand All @@ -161,7 +163,7 @@ private KeyValueDataFileWriter createDataFileWriter(
key.level,
options,
fileSource,
fileIndexOptions,
indexOptions,
isExternalPath)
: new KeyValueDataFileWriterImpl(
fileIO,
Expand All @@ -174,7 +176,7 @@ private KeyValueDataFileWriter createDataFileWriter(
key.level,
options,
fileSource,
fileIndexOptions,
indexOptions,
isExternalPath);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,11 +308,16 @@ public void testFileSuffix(@TempDir java.nio.file.Path tempDir) throws Exception
}

protected KeyValueFileWriterFactory createWriterFactory(String pathStr, String format) {
Options options = new Options();
options.set(CoreOptions.METADATA_STATS_MODE, "FULL");
return createWriterFactory(pathStr, format, options);
}

protected KeyValueFileWriterFactory createWriterFactory(
String pathStr, String format, Options options) {
Path path = new Path(pathStr);
int suggestedFileSize = ThreadLocalRandom.current().nextInt(8192) + 1024;
FileIO fileIO = FileIOFinder.find(path);
Options options = new Options();
options.set(CoreOptions.METADATA_STATS_MODE, "FULL");

Function<String, FileStorePathFactory> pathFactoryMap =
format1 ->
Expand Down Expand Up @@ -455,6 +460,49 @@ private void checkRollingFiles(
}
}

@Test
void testChangelogFile() throws Exception {
Options options = new Options();
options.set(CoreOptions.METADATA_STATS_MODE, "FULL");
options.setString("file-index.bloom-filter.columns", "comment");
options.setString("file-index.in-manifest-threshold", "1B");

KeyValueFileWriterFactory writerFactory =
createWriterFactory(tempDir.toString(), "avro", options);

DataFileTestDataGenerator.Data data = gen.next();
RollingFileWriter<KeyValue, DataFileMeta> dataWriter =
writerFactory.createRollingMergeTreeFileWriter(0, FileSource.APPEND);
dataWriter.write(CloseableIterator.fromList(data.content, kv -> {}));
dataWriter.close();
List<DataFileMeta> dataFileMetas = dataWriter.result();

assertThat(dataFileMetas).isNotEmpty();
assertThat(
dataFileMetas.stream()
.anyMatch(
meta ->
meta.extraFiles().stream()
.anyMatch(
f ->
f.endsWith(
DataFilePathFactory
.INDEX_PATH_SUFFIX))))
.isTrue();

RollingFileWriter<KeyValue, DataFileMeta> changelogWriter =
writerFactory.createRollingChangelogFileWriter(0);
changelogWriter.write(CloseableIterator.fromList(data.content, kv -> {}));
changelogWriter.close();
List<DataFileMeta> changelogMetas = changelogWriter.result();

assertThat(changelogMetas).isNotEmpty();
for (DataFileMeta meta : changelogMetas) {
assertThat(meta.extraFiles())
.noneMatch(f -> f.endsWith(DataFilePathFactory.INDEX_PATH_SUFFIX));
}
}

@ParameterizedTest
@ValueSource(strings = {"parquet", "orc", "avro"})
public void testReaderUseFileSizeFromMetadata(String format) throws Exception {
Expand Down