feiniaofeiafei commented on code in PR #43391:
URL: https://github.com/apache/doris/pull/43391#discussion_r1856425610
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/properties/DataTrait.java:
##########
@@ -450,4 +486,104 @@ public NestedSet toImmutable() {
return new NestedSet(ImmutableSet.copyOf(slots),
ImmutableSet.copyOf(slotSets));
}
}
+
+ static class UniformDescription {
+ // slot and its uniform expression(literal or const expression)
+ // some slot can get uniform values, others can not.
+ Map<Slot, Optional<Expression>> slotUniformValue;
+
+ public UniformDescription() {
+ slotUniformValue = new LinkedHashMap<>();
+ }
+
+ public UniformDescription(UniformDescription ud) {
+ slotUniformValue = new LinkedHashMap<>(ud.slotUniformValue);
+ }
+
+ public UniformDescription(Map<Slot, Optional<Expression>>
slotUniformValue) {
+ this.slotUniformValue = slotUniformValue;
+ }
+
+ public UniformDescription toImmutable() {
+ return new
UniformDescription(ImmutableMap.copyOf(slotUniformValue));
+ }
+
+ public boolean isEmpty() {
+ return slotUniformValue.isEmpty();
+ }
+
+ public boolean contains(Slot slot) {
+ return slotUniformValue.containsKey(slot);
+ }
+
+ public boolean contains(Set<Slot> slots) {
+ return !slots.isEmpty() &&
slotUniformValue.keySet().containsAll(slots);
+ }
+
+ public void add(Slot slot) {
+ slotUniformValue.putIfAbsent(slot, Optional.empty());
+ }
+
+ public void add(Set<Slot> slots) {
+ for (Slot s : slots) {
+ slotUniformValue.putIfAbsent(s, Optional.empty());
+ }
+ }
+
+ public void add(UniformDescription ud) {
+ slotUniformValue.putAll(ud.slotUniformValue);
+ for (Map.Entry<Slot, Optional<Expression>> entry :
ud.slotUniformValue.entrySet()) {
+ add(entry.getKey(), entry.getValue().orElse(null));
+ }
+ }
+
+ public void add(Slot slot, Expression literal) {
+ if (null == literal) {
+ slotUniformValue.putIfAbsent(slot, Optional.empty());
+ } else {
+ slotUniformValue.put(slot, Optional.of(literal));
+ }
+ }
+
+ public void removeNotContain(Set<Slot> slotSet) {
+ if (slotSet.isEmpty()) {
+ return;
+ }
+ Map<Slot, Optional<Expression>> newSlotUniformValue = new
LinkedHashMap<>();
+ for (Map.Entry<Slot, Optional<Expression>> entry :
slotUniformValue.entrySet()) {
+ if (slotSet.contains(entry.getKey())) {
+ newSlotUniformValue.put(entry.getKey(), entry.getValue());
+ }
+ }
+ this.slotUniformValue = newSlotUniformValue;
+ }
+
+ public void replace(Map<Slot, Slot> replaceMap) {
+ Map<Slot, Optional<Expression>> newSlotUniformValue = new
LinkedHashMap<>();
+ for (Map.Entry<Slot, Optional<Expression>> entry :
slotUniformValue.entrySet()) {
+ Slot newKey = replaceMap.getOrDefault(entry.getKey(),
entry.getKey());
+ newSlotUniformValue.put(newKey, entry.getValue());
+ }
+ slotUniformValue = newSlotUniformValue;
+ }
+
+ // The current implementation logic is: if a slot key exists in map
slotUniformValue,
Review Comment:
It will expand slightly. For example, the original isUniformAndNotNull
interface, when given the a=1 column a as input, would not return true. After
modification, it will return true. The uniform range will not be narrowed, and
the meaning of uniform remains unchanged — still indicating a uniform value
(which may include additional nulls).
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]