Skip to content

Commit

Permalink
Remove unhelpful col.colID property
Browse files Browse the repository at this point in the history
Just get it from col.Schema instead of having to maintain the same prop in multiple places.
  • Loading branch information
AndrewSisley committed Oct 2, 2023
1 parent 6cd8f2b commit 63edb26
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
13 changes: 4 additions & 9 deletions db/collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ type collection struct {
// of the operation in question.
txn immutable.Option[datastore.Txn]

colID uint32

desc client.CollectionDescription
schema client.SchemaDescription

Expand Down Expand Up @@ -87,7 +85,6 @@ func (db *db) newCollection(desc client.CollectionDescription) (*collection, err
Schema: desc.Schema,
},
schema: desc.Schema,
colID: desc.ID,
}, nil
}

Expand Down Expand Up @@ -640,7 +637,6 @@ func (db *db) getCollectionByVersionID(
db: db,
desc: desc,
schema: desc.Schema,
colID: desc.ID,
}

err = col.loadIndexes(ctx, txn)
Expand Down Expand Up @@ -738,7 +734,7 @@ func (c *collection) getAllDocKeysChan(
txn datastore.Txn,
) (<-chan client.DocKeysResult, error) {
prefix := core.PrimaryDataStoreKey{ // empty path for all keys prefix
CollectionId: fmt.Sprint(c.colID),
CollectionId: fmt.Sprint(c.ID()),
}
q, err := txn.Datastore().Query(ctx, query.Query{
Prefix: prefix.ToString(),
Expand Down Expand Up @@ -808,7 +804,7 @@ func (c *collection) Schema() client.SchemaDescription {

// ID returns the ID of the collection.
func (c *collection) ID() uint32 {
return c.colID
return c.desc.ID
}

func (c *collection) SchemaID() string {
Expand All @@ -823,7 +819,6 @@ func (c *collection) WithTxn(txn datastore.Txn) client.Collection {
txn: immutable.Some(txn),
desc: c.desc,
schema: c.schema,
colID: c.colID,
indexes: c.indexes,
fetcherFactory: c.fetcherFactory,
}
Expand Down Expand Up @@ -1410,14 +1405,14 @@ func (c *collection) commitImplicitTxn(ctx context.Context, txn datastore.Txn) e

func (c *collection) getPrimaryKeyFromDocKey(docKey client.DocKey) core.PrimaryDataStoreKey {
return core.PrimaryDataStoreKey{
CollectionId: fmt.Sprint(c.colID),
CollectionId: fmt.Sprint(c.ID()),
DocKey: docKey.String(),
}
}

func (c *collection) getDSKeyFromDockey(docKey client.DocKey) core.DataStoreKey {
return core.DataStoreKey{
CollectionID: fmt.Sprint(c.colID),
CollectionID: fmt.Sprint(c.ID()),
DocKey: docKey.String(),
InstanceType: core.ValueKey,
}
Expand Down
2 changes: 1 addition & 1 deletion db/collection_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ func (c *collection) deleteWithFilter(

// Convert from string to client.DocKey.
key := core.PrimaryDataStoreKey{
CollectionId: fmt.Sprint(c.colID),
CollectionId: fmt.Sprint(c.ID()),
DocKey: docKey,
}

Expand Down

0 comments on commit 63edb26

Please sign in to comment.