dcapwell commented on code in PR #2310:
URL: https://github.com/apache/cassandra/pull/2310#discussion_r1224545005
##########
test/unit/org/apache/cassandra/utils/AbstractTypeGenerators.java:
##########
@@ -215,24 +628,48 @@ public static Gen<UserType>
userTypeGen(Gen<AbstractType<?>> elementGen)
}
public static Gen<UserType> userTypeGen(Gen<AbstractType<?>> elementGen,
Gen<Integer> sizeGen)
+ {
+ return userTypeGen(elementGen, sizeGen, IDENTIFIER_GEN);
+ }
+
+ public static Gen<UserType> userTypeGen(Gen<AbstractType<?>> elementGen,
Gen<Integer> sizeGen, Gen<String> ksGen)
+ {
+ return userTypeGen(elementGen, sizeGen, ksGen, IDENTIFIER_GEN);
+ }
+
+ public static Gen<UserType> userTypeGen(Gen<AbstractType<?>> elementGen,
Gen<Integer> sizeGen, Gen<String> ksGen, Gen<String> nameGen)
+ {
+ return userTypeGen(elementGen, sizeGen, ksGen, nameGen, BOOLEAN_GEN);
+ }
+
+ public static Gen<UserType> userTypeGen(Gen<AbstractType<?>> elementGen,
Gen<Integer> sizeGen, Gen<String> ksGen, Gen<String> nameGen, Gen<Boolean>
multiCellGen)
{
Gen<FieldIdentifier> fieldNameGen =
IDENTIFIER_GEN.map(FieldIdentifier::forQuoted);
return rnd -> {
- boolean multiCell = BOOLEAN_GEN.generate(rnd);
+ boolean multiCell = multiCellGen.generate(rnd);
int numElements = sizeGen.generate(rnd);
List<AbstractType<?>> fieldTypes = new ArrayList<>(numElements);
LinkedHashSet<FieldIdentifier> fieldNames = new
LinkedHashSet<>(numElements);
- String ks = IDENTIFIER_GEN.generate(rnd);
- ByteBuffer name =
AsciiType.instance.decompose(IDENTIFIER_GEN.generate(rnd));
+ String ks = ksGen.generate(rnd);
+ String name = nameGen.generate(rnd);
+ ByteBuffer nameBB = AsciiType.instance.decompose(name);
Gen<FieldIdentifier> distinctNameGen =
Generators.filter(fieldNameGen, 30, e -> !fieldNames.contains(e));
// UDTs don't allow duplicate names, so make sure all names are
unique
for (int i = 0; i < numElements; i++)
{
- fieldTypes.add(elementGen.generate(rnd));
- fieldNames.add(distinctNameGen.generate(rnd));
+ FieldIdentifier fieldName = distinctNameGen.generate(rnd);
+ fieldNames.add(fieldName);
+
+ AbstractType<?> element = elementGen.generate(rnd);
+ if (!multiCell)
+ element = element.freeze();
+ // a UDT cannot contain a non-frozen UDT; as defined by
CreateType
+ if (element.isUDT())
Review Comment:
Changing `if (!multiCell)` to `if (multiCell)`. CreateType allows
non-frozen collections, but when we use the UDT it has to be frozen for that to
happen...
The issue I keep facing is that `TypeParser` works, but `CQLTypeParser`
fails... so UDTs keep causing an inconsistent behavior between the 2... and
fixing breaks other things 😢
--
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]