Skip to content

Commit 24daa93

Browse files
Revert unnecessary changes
1 parent e21b496 commit 24daa93

File tree

2 files changed

+4
-31
lines changed

2 files changed

+4
-31
lines changed

helpers.go

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -337,31 +337,14 @@ func splitCompositeTypes(name string, typeOpen int32, typeClose int32) []string
337337

338338
// Convert long Java style type definition into the short CQL type names.
339339
func apacheToCassandraType(t string) string {
340+
t = strings.Replace(t, apacheCassandraTypePrefix, "", -1)
340341
t = strings.Replace(t, "(", "<", -1)
341342
t = strings.Replace(t, ")", ">", -1)
342343
types := strings.FieldsFunc(t, func(r rune) bool {
343344
return r == '<' || r == '>' || r == ','
344345
})
345-
for i := 0; i < len(types); i++ {
346-
class := strings.TrimSpace(types[i])
347-
// UDT fields are represented in format {field id}:{class}, example 66697273745f6e616d65:org.apache.cassandra.db.marshal.UTF8Type
348-
// Do not override hex encoded field names
349-
idx := strings.Index(class, ":")
350-
class = class[idx+1:]
351-
val := ""
352-
if strings.HasPrefix(class, apacheCassandraTypePrefix) {
353-
act := getApacheCassandraType(class)
354-
val = act.String()
355-
switch act {
356-
case TypeUDT:
357-
i += 2 // skip next two parameters (keyspace and type ID), do not attempt to resolve their type
358-
case TypeCustom:
359-
val = getApacheCassandraCustomSubType(class)
360-
}
361-
} else {
362-
val = class
363-
}
364-
t = strings.Replace(t, class, val, -1)
346+
for _, typ := range types {
347+
t = strings.Replace(t, typ, getApacheCassandraType(typ).String(), -1)
365348
}
366349
// This is done so it exactly matches what Cassandra returns
367350
return strings.Replace(t, ",", ", ", -1)
@@ -424,16 +407,6 @@ func getApacheCassandraType(class string) Type {
424407
}
425408
}
426409

427-
// Dedicated function parsing known special subtypes of CQL custom type.
428-
// Currently, only vectors are implemented as special custom subtype.
429-
func getApacheCassandraCustomSubType(class string) string {
430-
switch strings.TrimPrefix(class, apacheCassandraTypePrefix) {
431-
case "VectorType":
432-
return "vector"
433-
}
434-
return "custom"
435-
}
436-
437410
func (r *RowData) rowMap(m map[string]interface{}) {
438411
for i, column := range r.Columns {
439412
val := dereference(r.Values[i])

helpers_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import (
3030
)
3131

3232
func TestGetCassandraType_Set(t *testing.T) {
33-
typ := getCassandraType("set<text>", 4, &defaultLogger{})
33+
typ := getCassandraType("set<text>", protoVersion4, &defaultLogger{})
3434
set, ok := typ.(CollectionType)
3535
if !ok {
3636
t.Fatalf("expected CollectionType got %T", typ)

0 commit comments

Comments
 (0)