Skip to content

Conversation

@tsreaper
Copy link
Contributor

Currently DataFileWriter exposes write method for data files and extra files.

However, as the number of patterns to write files is increasing (for example, we'd like to write some records into a data file, then write some other records into an extra files when producing changelogs from full compaction) we'll have to keep adding methods to DataFileWriter if we keep the current implementation.

We'd like to refactor DataFileWriter into a factory to create writers, so that the users of writers can write however they like.

// adding one record then remove one record, but after merging this record will not
// appear in lsm file. This is OK because we can also skip this changelog.
DataFileMeta fileMeta = writer.result();
if (fileMeta != null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (fileMeta == null), extraFiles is not be deleted?

RowType valueType,
BulkWriter.Factory<RowData> writerFactory,
@Nullable FileStatsExtractor fileStatsExtractor,
FileStatsExtractor fileStatsExtractor,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why remove nullable?


public void delete(DataFileMeta file) {
delete(file.fileName());
public SingleFileWriter<KeyValue, Void> createExtraFileWriter() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

createChangelogFileWriter? we may have more extra files in future.

DataFileMeta fileMeta = writer.result();
if (fileMeta != null) {
if (fileMeta == null) {
for (String extraFile : extraFiles) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a test for this? Maybe in ChangelogWithKeyFileStoreTableTest.testStreamingChangelog

Copy link
Contributor

@JingsongLi JingsongLi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@JingsongLi JingsongLi merged commit a881f41 into apache:master Oct 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants