lukasz-antoniak commented on code in PR #1828:
URL:
https://github.com/apache/cassandra-gocql-driver/pull/1828#discussion_r1820705139
##########
metadata.go:
##########
@@ -1332,15 +1360,60 @@ func (class *typeParserClassNode) asTypeInfo() TypeInfo
{
elem := class.params[1].class.asTypeInfo()
return CollectionType{
NativeType: NativeType{
- typ: TypeMap,
+ typ: TypeMap,
+ proto: class.proto,
},
Key: key,
Elem: elem,
}
}
+ if strings.HasPrefix(class.name, UDT_TYPE) {
+ udtName, _ := hex.DecodeString(class.params[1].class.name)
+ fields := make([]UDTField, len(class.params)-2)
+ for i := 2; i < len(class.params); i++ {
+ fieldName, _ := hex.DecodeString(*class.params[i].name)
+ fields[i-2] = UDTField{
+ Name: string(fieldName),
+ Type: class.params[i].class.asTypeInfo(),
+ }
+ }
+ return UDTTypeInfo{
+ NativeType: NativeType{
+ typ: TypeUDT,
+ proto: class.proto,
+ },
+ KeySpace: class.params[0].class.name,
+ Name: string(udtName),
+ Elements: fields,
+ }
+ }
+ if strings.HasPrefix(class.name, TUPLE_TYPE) {
+ fields := make([]TypeInfo, len(class.params))
+ for i := 0; i < len(class.params); i++ {
+ fields[i] = class.params[i].class.asTypeInfo()
+ }
+ return TupleTypeInfo{
+ NativeType: NativeType{
+ typ: TypeTuple,
+ proto: class.proto,
+ },
+ Elems: fields,
+ }
+ }
+ if strings.HasPrefix(class.name, VECTOR_TYPE) {
+ dim, _ := strconv.Atoi(class.params[1].class.name)
+ return VectorType{
+ NativeType: NativeType{
+ typ: TypeCustom,
+ proto: class.proto,
+ },
+ SubType: class.params[0].class.asTypeInfo(),
+ Dimensions: dim,
+ }
+ }
Review Comment:
If you remove vector block the following metadata_test.go will fail:
```
// vector
assertParseCompositeType(
t,
"org.apache.cassandra.db.marshal.VectorType(org.apache.cassandra.db.marshal.FloatType,
3)",
[]assertTypeInfo{
{Type: TypeFloat},
{Type: TypeCustom, Custom: "3"},
},
nil,
)
```
Shall we leave only vector changes here?
--
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]