!1382 hetu-core clean code modify

Merge pull request !1382 from chenpingzeng/clean_code_modify
This commit is contained in:
i-robot 2022-02-18 07:27:14 +00:00 committed by Gitee
commit 68d84d95b4
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
4 changed files with 24 additions and 27 deletions

View File

@ -243,7 +243,7 @@ public class TestEffectivePredicateExtractor
// Rewrite in terms of group by symbols
assertEquals(normalizeConjuncts(effectivePredicate),
normalizeConjuncts(
normalizeConjunctsSet(
lessThan(AE, bigintLiteral(10)),
lessThan(BE, AE),
greaterThan(AE, bigintLiteral(2)),
@ -302,7 +302,7 @@ public class TestEffectivePredicateExtractor
// Rewrite in terms of project output symbols
assertEquals(normalizeConjuncts(effectivePredicate),
normalizeConjuncts(
normalizeConjunctsSet(
lessThan(DE, bigintLiteral(10)),
equals(DE, EE)));
}
@ -322,7 +322,7 @@ public class TestEffectivePredicateExtractor
// Pass through
assertEquals(normalizeConjuncts(effectivePredicate),
normalizeConjuncts(
normalizeConjunctsSet(
equals(AE, BE),
equals(BE, CE),
lessThan(CE, bigintLiteral(10))));
@ -344,7 +344,7 @@ public class TestEffectivePredicateExtractor
// Pass through
assertEquals(normalizeConjuncts(effectivePredicate),
normalizeConjuncts(
normalizeConjunctsSet(
equals(AE, BE),
equals(BE, CE),
lessThan(CE, bigintLiteral(10))));
@ -366,7 +366,7 @@ public class TestEffectivePredicateExtractor
// Pass through
assertEquals(normalizeConjuncts(effectivePredicate),
normalizeConjuncts(
normalizeConjunctsSet(
equals(AE, BE),
equals(BE, CE),
lessThan(CE, bigintLiteral(10))));
@ -395,7 +395,7 @@ public class TestEffectivePredicateExtractor
// Pass through
assertEquals(normalizeConjuncts(effectivePredicate),
normalizeConjuncts(
normalizeConjunctsSet(
equals(AE, BE),
equals(BE, CE),
lessThan(CE, bigintLiteral(10))));
@ -440,7 +440,7 @@ public class TestEffectivePredicateExtractor
assignments,
predicate, Optional.empty(), ReuseExchangeOperator.STRATEGY.REUSE_STRATEGY_DEFAULT, new UUID(0, 0), 0, false);
effectivePredicate = effectivePredicateExtractorWithoutTableProperties.extract(SESSION, node, TypeProvider.empty(), typeAnalyzer);
assertEquals(normalizeConjuncts(effectivePredicate), normalizeConjuncts(equals(bigintLiteral(2L), BE), equals(bigintLiteral(1L), AE)));
assertEquals(normalizeConjuncts(effectivePredicate), normalizeConjunctsSet(equals(bigintLiteral(2L), BE), equals(bigintLiteral(1L), AE)));
node = new TableScanNode(
newId(),
@ -464,7 +464,7 @@ public class TestEffectivePredicateExtractor
Optional.empty(), ReuseExchangeOperator.STRATEGY.REUSE_STRATEGY_DEFAULT,
new UUID(0, 0), 0, false);
effectivePredicate = effectivePredicateExtractor.extract(SESSION, node, TypeProvider.empty(), typeAnalyzer);
assertEquals(normalizeConjuncts(effectivePredicate), normalizeConjuncts(equals(bigintLiteral(2L), BE), equals(bigintLiteral(1L), AE)));
assertEquals(normalizeConjuncts(effectivePredicate), normalizeConjunctsSet(equals(bigintLiteral(2L), BE), equals(bigintLiteral(1L), AE)));
node = new TableScanNode(
newId(),
@ -659,7 +659,7 @@ public class TestEffectivePredicateExtractor
// All predicates having output symbol should be carried through
assertEquals(normalizeConjuncts(effectivePredicate),
normalizeConjuncts(lessThan(BE, AE),
normalizeConjunctsSet(lessThan(BE, AE),
lessThan(CE, bigintLiteral(10)),
equals(DE, EE),
lessThan(FE, bigintLiteral(100)),
@ -775,7 +775,7 @@ public class TestEffectivePredicateExtractor
// All right side symbols having output symbols should be checked against NULL
assertEquals(normalizeConjuncts(effectivePredicate),
normalizeConjuncts(lessThan(BE, AE),
normalizeConjunctsSet(lessThan(BE, AE),
lessThan(CE, bigintLiteral(10)),
or(equals(DE, EE), and(isNull(DE), isNull(EE))),
or(lessThan(FE, bigintLiteral(100)), isNull(FE)),
@ -820,7 +820,7 @@ public class TestEffectivePredicateExtractor
// False literal on the right side should be ignored
assertEquals(normalizeConjuncts(effectivePredicate),
normalizeConjuncts(lessThan(BE, AE),
normalizeConjunctsSet(lessThan(BE, AE),
lessThan(CE, bigintLiteral(10)),
or(equals(AE, DE), isNull(DE))));
}
@ -868,7 +868,7 @@ public class TestEffectivePredicateExtractor
// All left side symbols should be checked against NULL
assertEquals(normalizeConjuncts(effectivePredicate),
normalizeConjuncts(or(lessThan(BE, AE), and(isNull(BE), isNull(AE))),
normalizeConjunctsSet(or(lessThan(BE, AE), and(isNull(BE), isNull(AE))),
or(lessThan(CE, bigintLiteral(10)), isNull(CE)),
equals(DE, EE),
lessThan(FE, bigintLiteral(100)),
@ -912,7 +912,7 @@ public class TestEffectivePredicateExtractor
// False literal on the left side should be ignored
assertEquals(normalizeConjuncts(effectivePredicate),
normalizeConjuncts(equals(DE, EE),
normalizeConjunctsSet(equals(DE, EE),
lessThan(FE, bigintLiteral(100)),
or(equals(AE, DE), isNull(AE))));
}
@ -1002,12 +1002,12 @@ public class TestEffectivePredicateExtractor
return new IsNullPredicate(expression);
}
private Set<Expression> normalizeConjuncts(Expression... conjuncts)
private Set<Expression> normalizeConjunctsSet(Expression... conjuncts)
{
return normalizeOneConjuncts(Arrays.asList(conjuncts));
return normalizeConjunctsCollection(Arrays.asList(conjuncts));
}
private Set<Expression> normalizeOneConjuncts(Collection<Expression> conjuncts)
private Set<Expression> normalizeConjunctsCollection(Collection<Expression> conjuncts)
{
return normalizeConjuncts(combineConjuncts(conjuncts));
}

View File

@ -68,10 +68,7 @@ public class MockSplit
@JsonProperty("endIndex") long endIndex,
@JsonProperty("lastModifiedTime") long lastModifiedTime)
{
this.filepath = filepath;
this.startIndex = startIndex;
this.endIndex = endIndex;
this.lastModifiedTime = lastModifiedTime;
this(filepath, startIndex, endIndex, lastModifiedTime);
this.schema = TEST_SCHEMA;
this.table = TEST_TABLE;
}

View File

@ -127,11 +127,11 @@ public class RcFileWriteValidation
{
this.types = ImmutableList.copyOf(requireNonNull(types, "types is null"));
ImmutableList.Builder<XxHash64> columnHashes = ImmutableList.builder();
ImmutableList.Builder<XxHash64> localColumnHashes = ImmutableList.builder();
for (Type ignored : types) {
columnHashes.add(new XxHash64());
localColumnHashes.add(new XxHash64());
}
this.columnHashes = columnHashes.build();
this.columnHashes = localColumnHashes.build();
}
public static WriteChecksumBuilder createWriteChecksumBuilder(Map<Integer, Type> readColumns)
@ -143,13 +143,13 @@ public class RcFileWriteValidation
.max().getAsInt() + 1;
checkArgument(readColumns.size() == columnCount, "checksum requires all columns to be read");
ImmutableList.Builder<Type> types = ImmutableList.builder();
ImmutableList.Builder<Type> localTypes = ImmutableList.builder();
for (int column = 0; column < columnCount; column++) {
Type type = readColumns.get(column);
checkArgument(type != null, "checksum requires all columns to be read");
types.add(type);
localTypes.add(type);
}
return new WriteChecksumBuilder(types.build());
return new WriteChecksumBuilder(localTypes.build());
}
public void addRowGroup(int rowCount)

View File

@ -54,7 +54,7 @@ public class StringEncoding
throw new IllegalArgumentException("escape not implemented");
}
String escapedValue = unescapeText(new String(slice.getBytes(), StandardCharsets.UTF_8));
if (escapedValue.getBytes().length < slice.getBytes().length) {
if (escapedValue.getBytes(StandardCharsets.UTF_8).length < slice.getBytes().length) {
sliceOutput.writeBytes(escapedValue.getBytes(StandardCharsets.UTF_8));
}
else {