Skip to content

refactor CompactionState since 'core' and 'processing' modules have been merged#17741

Merged
kfaraz merged 6 commits intoapache:masterfrom
clintropolis:refactor-compaction-state
Feb 21, 2025
Merged

refactor CompactionState since 'core' and 'processing' modules have been merged#17741
kfaraz merged 6 commits intoapache:masterfrom
clintropolis:refactor-compaction-state

Conversation

@clintropolis
Copy link
Member

Description

Trying #14932 again since the conflicts got a bit much.

changes:

  • CompactionState now uses real types instead of Map
  • Rename ClientCompactionTaskTransformSpec to CompactionTransformSpec and move to processing, deleted UserCompactionTaskTransformConfig since it was the same as CompactionTransformSpec
  • Moved GranularitySpec and implementations to processing module

…een merged

changes:
* CompactionState now uses real types instead of Map
* Rename ClientCompactionTaskTransformSpec to CompactionTransformSpec and move to processing, deleted UserCompactionTaskTransformConfig since it was the same as CompactionTransformSpec
* Moved GranularitySpec and implementations to processing module
Copy link
Contributor

@kfaraz kfaraz left a comment

Choose a reason for hiding this comment

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

Thanks a lot for the cleanup, @clintropolis !

Left some minor comments.

Only blocking suggestion is to revert the formatting done in ControllerImpl.java since that is an involved class and it would be best to keep the diff there to a minimum.

IndexSpec.class
),
ImmutableMap.of()
jsonMapper.convertValue(ImmutableMap.of(), GranularitySpec.class)
Copy link
Contributor

Choose a reason for hiding this comment

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

Might be nice to add a GranularitySpec.DEFAULT in a later PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

yea, I was just leaving these as is to preserve the way stuff was being tested exactly instead of what they were effectively doing, not sure how useful that is though

Comment on lines +555 to +574
totalProcessedBytes =
msqTaskReportPayload.getCounters()
.copyMap()
.entrySet()
.stream()
.filter(entry -> stagesReport == null || stagesToInclude.contains(entry.getKey()))
.flatMap(counterSnapshotsMap -> counterSnapshotsMap.getValue()
.values()
.stream())
.flatMap(counterSnapshots -> counterSnapshots.getMap()
.entrySet()
.stream())
.filter(entry -> entry.getKey().startsWith("input"))
.mapToLong(entry -> {
ChannelCounters.Snapshot snapshot = (ChannelCounters.Snapshot) entry.getValue();
return snapshot.getBytes() == null
? 0L
: Arrays.stream(snapshot.getBytes()).sum();
})
.sum();
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the reformat really needed here and in other places in this file?
Maybe we can limit the diff in this PR to only the modified code.

Copy link
Member Author

Choose a reason for hiding this comment

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

so like I don't normally do the whole file, but when looking through this one I kept noticing things that were obviously incorrectly formatted and decided to just run the whole file through because it was so ugly. I can revert but I'm going to immediately turn around and open another PR to do the same thing, if you would prefer that I can go to the trouble...

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure, we can leave it as it is then.

Copy link
Member Author

Choose a reason for hiding this comment

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

went ahead and reverted, will fix in follow-up

ImmutableMap.of()
ImmutableList.of(new CountAggregatorFactory("count")),
new CompactionTransformSpec(new SelectorDimFilter("dim1", "foo", null)),
MAPPER.convertValue(ImmutableMap.of(), IndexSpec.class),
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe use IndexSpec.DEFAULT instead?

Collections.singletonMap("test2", "map2")
ImmutableList.of(new CountAggregatorFactory("count")),
new CompactionTransformSpec(new SelectorDimFilter("dim1", "foo", null)),
MAPPER.convertValue(Collections.singletonMap("test", "map"), IndexSpec.class),
Copy link
Contributor

Choose a reason for hiding this comment

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

Since we are touching these lines anyway, Map.of and List.of could be used for less verbosity.

Suggested change
MAPPER.convertValue(Collections.singletonMap("test", "map"), IndexSpec.class),
MAPPER.convertValue(Map.of("test", "map"), IndexSpec.class),

Copy link
Member Author

Choose a reason for hiding this comment

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

oh yea, I guess we aren't stuck on java 8 anymore... i forgot these methods exist now.

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah, happens to me too 😄

Copy link
Contributor

@kfaraz kfaraz left a comment

Choose a reason for hiding this comment

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

Latest patch looks good

@kfaraz kfaraz merged commit 9b48f41 into apache:master Feb 21, 2025
75 checks passed
@clintropolis clintropolis deleted the refactor-compaction-state branch February 21, 2025 07:20
kfaraz pushed a commit that referenced this pull request Feb 21, 2025
Follow-up to #17741 to fix some formatting in ControllerImpl, no functional changes
@kgyrtkirk kgyrtkirk added this to the 33.0.0 milestone Apr 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants