Skip to content

Commit

Permalink
[hotfix] Remove customPredicate in CastRulePredicate
Browse files Browse the repository at this point in the history
  • Loading branch information
JingsongLi committed Aug 26, 2024
1 parent cec757e commit 97d343f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ private BinaryToStringCastRule() {

@Override
public CastExecutor<byte[], BinaryString> create(DataType inputType, DataType targetType) {
return value -> BinaryString.fromBytes(value);
return BinaryString::fromBytes;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@

import java.util.Collections;
import java.util.HashSet;
import java.util.Optional;
import java.util.Set;
import java.util.function.BiPredicate;

/**
* In order to apply a {@link CastRule}, the runtime checks if a particular rule matches the tuple
Expand All @@ -46,13 +44,7 @@
* <li>{@link #getInputTypeFamilies()} includes one of the {@link DataTypeFamily} of input
* type
* </ol>
* <li>Or, if {@link #getCustomPredicate()} is not null, the input {@link DataType} and target
* {@link DataType} matches the predicate.
* </ol>
*
* <p>The {@code customPredicate} should be used in cases where {@link DataTypeRoot} and {@link
* DataTypeFamily} are not enough to identify whether a rule is applicable or not, for example when
* the matching depends on a field of the provided input {@link DataType} instance.
*/
public class CastRulePredicate {

Expand All @@ -64,21 +56,17 @@ public class CastRulePredicate {
private final Set<DataTypeFamily> inputTypeFamilies;
private final Set<DataTypeFamily> targetTypeFamilies;

private final BiPredicate<DataType, DataType> customPredicate;

private CastRulePredicate(
Set<DataType> targetTypes,
Set<DataTypeRoot> inputTypeRoots,
Set<DataTypeRoot> targetTypeRoots,
Set<DataTypeFamily> inputTypeFamilies,
Set<DataTypeFamily> targetTypeFamilies,
BiPredicate<DataType, DataType> customPredicate) {
Set<DataTypeFamily> targetTypeFamilies) {
this.targetTypes = targetTypes;
this.inputTypeRoots = inputTypeRoots;
this.targetTypeRoots = targetTypeRoots;
this.inputTypeFamilies = inputTypeFamilies;
this.targetTypeFamilies = targetTypeFamilies;
this.customPredicate = customPredicate;
}

public Set<DataType> getTargetTypes() {
Expand All @@ -101,10 +89,6 @@ public Set<DataTypeFamily> getTargetTypeFamilies() {
return targetTypeFamilies;
}

public Optional<BiPredicate<DataType, DataType>> getCustomPredicate() {
return Optional.ofNullable(customPredicate);
}

public static Builder builder() {
return new Builder();
}
Expand All @@ -118,8 +102,6 @@ public static class Builder {
private final Set<DataTypeFamily> inputTypeFamilies = new HashSet<>();
private final Set<DataTypeFamily> targetTypeFamilies = new HashSet<>();

private BiPredicate<DataType, DataType> customPredicate;

public Builder input(DataTypeRoot inputTypeRoot) {
inputTypeRoots.add(inputTypeRoot);
return this;
Expand All @@ -145,19 +127,13 @@ public Builder target(DataTypeFamily outputTypeFamily) {
return this;
}

public Builder predicate(BiPredicate<DataType, DataType> customPredicate) {
this.customPredicate = customPredicate;
return this;
}

public CastRulePredicate build() {
return new CastRulePredicate(
Collections.unmodifiableSet(targetTypes),
Collections.unmodifiableSet(inputTypeRoots),
Collections.unmodifiableSet(targetTypeRoots),
Collections.unmodifiableSet(inputTypeFamilies),
Collections.unmodifiableSet(targetTypeFamilies),
customPredicate);
Collections.unmodifiableSet(targetTypeFamilies));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@

import static org.assertj.core.api.Assertions.assertThat;

/** Test for {@link UnawareAppendTableCompactionCoordinator}. */
public class AppendOnlyTableCompactionITTest {
/** Test for append table compaction. */
public class AppendOnlyTableCompactionTest {

@TempDir private Path tempDir;
private FileStoreTable appendOnlyFileStoreTable;
Expand Down

0 comments on commit 97d343f

Please sign in to comment.