Skip to content

Commit 038b1de

Browse files
author
tengu-alt
committed
some deprecated features were removed
1 parent 34fdeeb commit 038b1de

File tree

6 files changed

+17
-211
lines changed

6 files changed

+17
-211
lines changed

cassandra_test.go

Lines changed: 1 addition & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020
"time"
2121
"unicode"
2222

23-
inf "gopkg.in/inf.v0"
23+
"gopkg.in/inf.v0"
2424
)
2525

2626
func TestEmptyHosts(t *testing.T) {
@@ -2199,45 +2199,6 @@ func TestGetColumnMetadata(t *testing.T) {
21992199
}
22002200
}
22012201

2202-
func TestViewMetadata(t *testing.T) {
2203-
session := createSession(t)
2204-
defer session.Close()
2205-
createViews(t, session)
2206-
2207-
views, err := getViewsMetadata(session, "gocql_test")
2208-
if err != nil {
2209-
t.Fatalf("failed to query view metadata with err: %v", err)
2210-
}
2211-
if views == nil {
2212-
t.Fatal("failed to query view metadata, nil returned")
2213-
}
2214-
2215-
if len(views) != 1 {
2216-
t.Fatal("expected one view")
2217-
}
2218-
2219-
textType := TypeText
2220-
if flagCassVersion.Before(3, 0, 0) {
2221-
textType = TypeVarchar
2222-
}
2223-
2224-
expectedView := ViewMetadata{
2225-
Keyspace: "gocql_test",
2226-
Name: "basicview",
2227-
FieldNames: []string{"birthday", "nationality", "weight", "height"},
2228-
FieldTypes: []TypeInfo{
2229-
NativeType{typ: TypeTimestamp},
2230-
NativeType{typ: textType},
2231-
NativeType{typ: textType},
2232-
NativeType{typ: textType},
2233-
},
2234-
}
2235-
2236-
if !reflect.DeepEqual(views[0], expectedView) {
2237-
t.Fatalf("view is %+v, but expected %+v", views[0], expectedView)
2238-
}
2239-
}
2240-
22412202
func TestMaterializedViewMetadata(t *testing.T) {
22422203
if flagCassVersion.Before(3, 0, 0) {
22432204
return
@@ -2443,7 +2404,6 @@ func TestKeyspaceMetadata(t *testing.T) {
24432404
t.Fatalf("failed to create table with error '%v'", err)
24442405
}
24452406
createAggregate(t, session)
2446-
createViews(t, session)
24472407
createMaterializedViews(t, session)
24482408

24492409
if err := session.Query("CREATE INDEX index_metadata ON test_metadata ( third_id )").Exec(); err != nil {
@@ -2521,32 +2481,6 @@ func TestKeyspaceMetadata(t *testing.T) {
25212481
t.Fatalf("expected state function %s, but got %s", "avgstate", aggregate.StateFunc.Name)
25222482
}
25232483

2524-
_, found = keyspaceMetadata.Views["basicview"]
2525-
if !found {
2526-
t.Fatal("failed to find the view in metadata")
2527-
}
2528-
_, found = keyspaceMetadata.UserTypes["basicview"]
2529-
if !found {
2530-
t.Fatal("failed to find the types in metadata")
2531-
}
2532-
textType := TypeText
2533-
if flagCassVersion.Before(3, 0, 0) {
2534-
textType = TypeVarchar
2535-
}
2536-
expectedType := UserTypeMetadata{
2537-
Keyspace: "gocql_test",
2538-
Name: "basicview",
2539-
FieldNames: []string{"birthday", "nationality", "weight", "height"},
2540-
FieldTypes: []TypeInfo{
2541-
NativeType{typ: TypeTimestamp},
2542-
NativeType{typ: textType},
2543-
NativeType{typ: textType},
2544-
NativeType{typ: textType},
2545-
},
2546-
}
2547-
if !reflect.DeepEqual(*keyspaceMetadata.UserTypes["basicview"], expectedType) {
2548-
t.Fatalf("type is %+v, but expected %+v", keyspaceMetadata.UserTypes["basicview"], expectedType)
2549-
}
25502484
if flagCassVersion.Major >= 3 {
25512485
materializedView, found := keyspaceMetadata.MaterializedViews["view_view"]
25522486
if !found {

conn.go

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -154,14 +154,6 @@ func (fn connErrorHandlerFn) HandleError(conn *Conn, err error, closed bool) {
154154
fn(conn, err, closed)
155155
}
156156

157-
// If not zero, how many timeouts we will allow to occur before the connection is closed
158-
// and restarted. This is to prevent a single query timeout from killing a connection
159-
// which may be serving more queries just fine.
160-
// Default is 0, should not be changed concurrently with queries.
161-
//
162-
// Deprecated.
163-
var TimeoutLimit int64 = 0
164-
165157
// Conn is a single connection to a Cassandra node. It can be used to execute
166158
// queries, but users are usually advised to use a more reliable, higher
167159
// level API.
@@ -752,7 +744,7 @@ func (c *Conn) releaseStream(call *callReq) {
752744
}
753745

754746
func (c *Conn) handleTimeout() {
755-
if TimeoutLimit > 0 && atomic.AddInt64(&c.timeouts, 1) > TimeoutLimit {
747+
if atomic.AddInt64(&c.timeouts, 1) > 0 {
756748
c.closeWithError(ErrTooManyTimeouts)
757749
}
758750
}

frame.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -255,17 +255,6 @@ func ParseConsistencyWrapper(s string) (consistency Consistency, err error) {
255255
return
256256
}
257257

258-
// MustParseConsistency is the same as ParseConsistency except it returns
259-
// an error (never). It is kept here since breaking changes are not good.
260-
// DEPRECATED: use ParseConsistency if you want a panic on parse error.
261-
func MustParseConsistency(s string) (Consistency, error) {
262-
c, err := ParseConsistencyWrapper(s)
263-
if err != nil {
264-
panic(err)
265-
}
266-
return c, nil
267-
}
268-
269258
type SerialConsistency uint16
270259

271260
const (

marshal.go

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2435,14 +2435,6 @@ type TypeInfo interface {
24352435
Version() byte
24362436
Custom() string
24372437

2438-
// New creates a pointer to an empty version of whatever type
2439-
// is referenced by the TypeInfo receiver.
2440-
//
2441-
// If there is no corresponding Go type for the CQL type, New panics.
2442-
//
2443-
// Deprecated: Use NewWithError instead.
2444-
New() interface{}
2445-
24462438
// NewWithError creates a pointer to an empty version of whatever type
24472439
// is referenced by the TypeInfo receiver.
24482440
//
@@ -2468,14 +2460,6 @@ func (t NativeType) NewWithError() (interface{}, error) {
24682460
return reflect.New(typ).Interface(), nil
24692461
}
24702462

2471-
func (t NativeType) New() interface{} {
2472-
val, err := t.NewWithError()
2473-
if err != nil {
2474-
panic(err.Error())
2475-
}
2476-
return val
2477-
}
2478-
24792463
func (s NativeType) Type() Type {
24802464
return s.typ
24812465
}
@@ -2511,14 +2495,6 @@ func (t CollectionType) NewWithError() (interface{}, error) {
25112495
return reflect.New(typ).Interface(), nil
25122496
}
25132497

2514-
func (t CollectionType) New() interface{} {
2515-
val, err := t.NewWithError()
2516-
if err != nil {
2517-
panic(err.Error())
2518-
}
2519-
return val
2520-
}
2521-
25222498
func (c CollectionType) String() string {
25232499
switch c.typ {
25242500
case TypeMap:
@@ -2556,14 +2532,6 @@ func (t TupleTypeInfo) NewWithError() (interface{}, error) {
25562532
return reflect.New(typ).Interface(), nil
25572533
}
25582534

2559-
func (t TupleTypeInfo) New() interface{} {
2560-
val, err := t.NewWithError()
2561-
if err != nil {
2562-
panic(err.Error())
2563-
}
2564-
return val
2565-
}
2566-
25672535
type UDTField struct {
25682536
Name string
25692537
Type TypeInfo
@@ -2584,14 +2552,6 @@ func (u UDTTypeInfo) NewWithError() (interface{}, error) {
25842552
return reflect.New(typ).Interface(), nil
25852553
}
25862554

2587-
func (u UDTTypeInfo) New() interface{} {
2588-
val, err := u.NewWithError()
2589-
if err != nil {
2590-
panic(err.Error())
2591-
}
2592-
return val
2593-
}
2594-
25952555
func (u UDTTypeInfo) String() string {
25962556
buf := &bytes.Buffer{}
25972557

metadata.go

Lines changed: 13 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,13 @@ import (
1515

1616
// schema metadata for a keyspace
1717
type KeyspaceMetadata struct {
18-
Name string
19-
DurableWrites bool
20-
StrategyClass string
21-
StrategyOptions map[string]interface{}
22-
Tables map[string]*TableMetadata
23-
Functions map[string]*FunctionMetadata
24-
Aggregates map[string]*AggregateMetadata
25-
// Deprecated: use the MaterializedViews field for views and UserTypes field for udts instead.
26-
Views map[string]*ViewMetadata
18+
Name string
19+
DurableWrites bool
20+
StrategyClass string
21+
StrategyOptions map[string]interface{}
22+
Tables map[string]*TableMetadata
23+
Functions map[string]*FunctionMetadata
24+
Aggregates map[string]*AggregateMetadata
2725
MaterializedViews map[string]*MaterializedViewMetadata
2826
UserTypes map[string]*UserTypeMetadata
2927
}
@@ -85,15 +83,6 @@ type AggregateMetadata struct {
8583
finalFunc string
8684
}
8785

88-
// ViewMetadata holds the metadata for views.
89-
// Deprecated: this is kept for backwards compatibility issues. Use MaterializedViewMetadata.
90-
type ViewMetadata struct {
91-
Keyspace string
92-
Name string
93-
FieldNames []string
94-
FieldTypes []TypeInfo
95-
}
96-
9786
// MaterializedViewMetadata holds the metadata for materialized views.
9887
type MaterializedViewMetadata struct {
9988
Keyspace string
@@ -280,17 +269,13 @@ func (s *schemaDescriber) refreshSchema(keyspaceName string) error {
280269
if err != nil {
281270
return err
282271
}
283-
views, err := getViewsMetadata(s.session, keyspaceName)
284-
if err != nil {
285-
return err
286-
}
287272
materializedViews, err := getMaterializedViewsMetadata(s.session, keyspaceName)
288273
if err != nil {
289274
return err
290275
}
291276

292277
// organize the schema data
293-
compileMetadata(s.session.cfg.ProtoVersion, keyspace, tables, columns, functions, aggregates, views,
278+
compileMetadata(s.session.cfg.ProtoVersion, keyspace, tables, columns, functions, aggregates,
294279
materializedViews, s.session.logger)
295280

296281
// update the cache
@@ -311,7 +296,6 @@ func compileMetadata(
311296
columns []ColumnMetadata,
312297
functions []FunctionMetadata,
313298
aggregates []AggregateMetadata,
314-
views []ViewMetadata,
315299
materializedViews []MaterializedViewMetadata,
316300
logger StdLogger,
317301
) {
@@ -331,20 +315,12 @@ func compileMetadata(
331315
aggregates[i].StateFunc = *keyspace.Functions[aggregates[i].stateFunc]
332316
keyspace.Aggregates[aggregates[i].Name] = &aggregates[i]
333317
}
334-
keyspace.Views = make(map[string]*ViewMetadata, len(views))
335-
for i := range views {
336-
keyspace.Views[views[i].Name] = &views[i]
318+
types := make([]UserTypeMetadata, len(materializedViews))
319+
for i, mView := range materializedViews {
320+
types[i].Keyspace = mView.Keyspace
321+
types[i].Name = mView.Name
337322
}
338-
// Views currently holds the types and hasn't been deleted for backward compatibility issues.
339-
// That's why it's ok to copy Views into Types in this case. For the real Views use MaterializedViews.
340-
types := make([]UserTypeMetadata, len(views))
341-
for i := range views {
342-
types[i].Keyspace = views[i].Keyspace
343-
types[i].Name = views[i].Name
344-
types[i].FieldNames = views[i].FieldNames
345-
types[i].FieldTypes = views[i].FieldTypes
346-
}
347-
keyspace.UserTypes = make(map[string]*UserTypeMetadata, len(views))
323+
keyspace.UserTypes = make(map[string]*UserTypeMetadata, len(materializedViews))
348324
for i := range types {
349325
keyspace.UserTypes[types[i].Name] = &types[i]
350326
}
@@ -930,51 +906,6 @@ func getTypeInfo(t string, logger StdLogger) TypeInfo {
930906
return getCassandraType(t, logger)
931907
}
932908

933-
func getViewsMetadata(session *Session, keyspaceName string) ([]ViewMetadata, error) {
934-
if session.cfg.ProtoVersion == protoVersion1 {
935-
return nil, nil
936-
}
937-
var tableName string
938-
if session.useSystemSchema {
939-
tableName = "system_schema.types"
940-
} else {
941-
tableName = "system.schema_usertypes"
942-
}
943-
stmt := fmt.Sprintf(`
944-
SELECT
945-
type_name,
946-
field_names,
947-
field_types
948-
FROM %s
949-
WHERE keyspace_name = ?`, tableName)
950-
951-
var views []ViewMetadata
952-
953-
rows := session.control.query(stmt, keyspaceName).Scanner()
954-
for rows.Next() {
955-
view := ViewMetadata{Keyspace: keyspaceName}
956-
var argumentTypes []string
957-
err := rows.Scan(&view.Name,
958-
&view.FieldNames,
959-
&argumentTypes,
960-
)
961-
if err != nil {
962-
return nil, err
963-
}
964-
view.FieldTypes = make([]TypeInfo, len(argumentTypes))
965-
for i, argumentType := range argumentTypes {
966-
view.FieldTypes[i] = getTypeInfo(argumentType, session.logger)
967-
}
968-
views = append(views, view)
969-
}
970-
971-
if err := rows.Err(); err != nil {
972-
return nil, err
973-
}
974-
975-
return views, nil
976-
}
977-
978909
func getMaterializedViewsMetadata(session *Session, keyspaceName string) ([]MaterializedViewMetadata, error) {
979910
if !session.useSystemSchema {
980911
return nil, nil

metadata_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ func TestCompileMetadata(t *testing.T) {
9595
{Keyspace: "V1Keyspace", Table: "peers", Kind: ColumnRegular, Name: "schema_version", ComponentIndex: 0, Validator: "org.apache.cassandra.db.marshal.UUIDType"},
9696
{Keyspace: "V1Keyspace", Table: "peers", Kind: ColumnRegular, Name: "tokens", ComponentIndex: 0, Validator: "org.apache.cassandra.db.marshal.SetType(org.apache.cassandra.db.marshal.UTF8Type)"},
9797
}
98-
compileMetadata(1, keyspace, tables, columns, nil, nil, nil, nil, log)
98+
compileMetadata(1, keyspace, tables, columns, nil, nil, nil, log)
9999
assertKeyspaceMetadata(
100100
t,
101101
keyspace,
@@ -376,7 +376,7 @@ func TestCompileMetadata(t *testing.T) {
376376
Validator: "org.apache.cassandra.db.marshal.UTF8Type",
377377
},
378378
}
379-
compileMetadata(2, keyspace, tables, columns, nil, nil, nil, nil, log)
379+
compileMetadata(2, keyspace, tables, columns, nil, nil, nil, log)
380380
assertKeyspaceMetadata(
381381
t,
382382
keyspace,

0 commit comments

Comments
 (0)