in frame.go [850:928]
func (f *framer) readTypeInfo() TypeInfo {
// TODO: factor this out so the same code paths can be used to parse custom
// types and other types, as much of the logic will be duplicated.
id := f.readShort()
simple := NativeType{
proto: f.proto,
typ: Type(id),
}
if simple.typ == TypeCustom {
simple.custom = f.readString()
if cassType := getApacheCassandraType(simple.custom); cassType != TypeCustom {
simple.typ = cassType
}
}
switch simple.typ {
case TypeTuple:
n := f.readShort()
tuple := TupleTypeInfo{
NativeType: simple,
Elems: make([]TypeInfo, n),
}
for i := 0; i < int(n); i++ {
tuple.Elems[i] = f.readTypeInfo()
}
return tuple
case TypeUDT:
udt := UDTTypeInfo{
NativeType: simple,
}
udt.KeySpace = f.readString()
udt.Name = f.readString()
n := f.readShort()
udt.Elements = make([]UDTField, n)
for i := 0; i < int(n); i++ {
field := &udt.Elements[i]
field.Name = f.readString()
field.Type = f.readTypeInfo()
}
return udt
case TypeMap, TypeList, TypeSet:
collection := CollectionType{
NativeType: simple,
}
if simple.typ == TypeMap {
collection.Key = f.readTypeInfo()
}
collection.Elem = f.readTypeInfo()
return collection
case TypeCustom:
if strings.HasPrefix(simple.custom, VECTOR_TYPE) {
spec := strings.TrimPrefix(simple.custom, VECTOR_TYPE)
spec = spec[1 : len(spec)-1] // remove parenthesis
idx := strings.LastIndex(spec, ",")
typeStr := spec[:idx]
dimStr := spec[idx+1:]
subType := getCassandraLongType(strings.TrimSpace(typeStr), f.proto, nopLogger{})
dim, _ := strconv.Atoi(strings.TrimSpace(dimStr))
vector := VectorType{
NativeType: simple,
SubType: subType,
Dimensions: dim,
}
return vector
}
}
return simple
}