maedhroz commented on code in PR #4222:
URL: https://github.com/apache/cassandra/pull/4222#discussion_r3011360866
##########
test/unit/org/apache/cassandra/utils/ASTGenerators.java:
##########
@@ -982,6 +1023,65 @@ else if (existAllowed)
};
}
+ private static final Gen<Conditional.Where.Inequality>
RANGE_INEQUALITY_GEN =
SourceDSL.arbitrary().pick(Conditional.Where.Inequality.GREATER_THAN_EQ,
+
Conditional.Where.Inequality.GREATER_THAN,
+
Conditional.Where.Inequality.LESS_THAN_EQ,
+
Conditional.Where.Inequality.LESS_THAN);
+
+ private static final Gen<Conditional.Where.Inequality> LOWER_BOUND_GEN
= SourceDSL.arbitrary().pick(Conditional.Where.Inequality.GREATER_THAN,
+
Conditional.Where.Inequality.GREATER_THAN_EQ);
+
+ private static final Gen<Conditional.Where.Inequality> UPPER_BOUND_GEN
= SourceDSL.arbitrary().pick(Conditional.Where.Inequality.LESS_THAN,
+
Conditional.Where.Inequality.LESS_THAN_EQ);
+
+
+ private void valueRange(RandomnessSource rnd,
+ Map<Symbol, ExpressionBuilder>
columnExpressions,
+ Conditional.ConditionalBuilder<?> builder,
+ LinkedHashSet<Symbol> columns,
+ @Nullable Gen <? extends Map<Symbol, Object>>
gen)
+ {
+ if (gen != null)
+ {
+ Map<Symbol, Object> lower = gen.generate(rnd);
+ Map<Symbol, Object> upper = gen.generate(rnd);
+ for (Symbol s : columns)
+ {
+ RangeType type =
SourceDSL.arbitrary().enumValues(RangeType.class).generate(rnd);
+ applyRangeCondition(builder, type, s,
+ type == RangeType.UNBOUD ?
RANGE_INEQUALITY_GEN.generate(rnd) : LOWER_BOUND_GEN.generate(rnd),
+ UPPER_BOUND_GEN.generate(rnd),
+ valueGen(lower.get(s),
s.type()).generate(rnd),
+ valueGen(upper.get(s),
s.type()).generate(rnd));
+ break;
+ }
+ return;
+ }
+
+ List<Symbol> columnList = new ArrayList<>(columns);
+ boolean priorKeysFullyConstrained = true;
+
+ for (int i = 0; i < columnList.size(); i++)
+ {
+ Symbol s = columnList.get(i);
+ Gen<Expression> expressionGen =
columnExpressions.get(s).build();
+
+ if (!priorKeysFullyConstrained)
+ break;
+
+ RangeType type =
SourceDSL.arbitrary().enumValues(RangeType.class).generate(rnd);
+ applyRangeCondition(builder, type, s,
+ type == RangeType.UNBOUD ?
RANGE_INEQUALITY_GEN.generate(rnd) : LOWER_BOUND_GEN.generate(rnd),
+ UPPER_BOUND_GEN.generate(rnd),
+ expressionGen.generate(rnd),
+ expressionGen.generate(rnd));
+
+ priorKeysFullyConstrained = false;
Review Comment:
By setting this unconditionally here, doesn't the `for` loop trivially
always execute only one iteration?
--
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]