Skip to content

Commit

Permalink
Adjust names
Browse files Browse the repository at this point in the history
  • Loading branch information
islamaliev committed Mar 27, 2023
1 parent 12d6287 commit f8956c1
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 deletions.
18 changes: 9 additions & 9 deletions core/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ type Key interface {

// DataStoreKey is a type that represents a key in the database.
type DataStoreKey struct {
CollectionId string
CollectionID string
InstanceType InstanceType
DocKey string
FieldId string
Expand Down Expand Up @@ -144,7 +144,7 @@ func NewDataStoreKey(key string) (DataStoreKey, error) {
return dataStoreKey, ErrInvalidKey
}

dataStoreKey.CollectionId = elements[0]
dataStoreKey.CollectionID = elements[0]
dataStoreKey.InstanceType = InstanceType(elements[1])
dataStoreKey.DocKey = elements[2]
if numberOfElements == 4 {
Expand Down Expand Up @@ -272,8 +272,8 @@ func (k HeadStoreKey) WithFieldId(fieldId string) HeadStoreKey {
func (k DataStoreKey) ToString() string {
var result string

if k.CollectionId != "" {
result = result + "/" + k.CollectionId
if k.CollectionID != "" {
result = result + "/" + k.CollectionID
}
if k.InstanceType != "" {
result = result + "/" + string(k.InstanceType)
Expand All @@ -297,22 +297,22 @@ func (k DataStoreKey) ToDS() ds.Key {
}

func (k DataStoreKey) Equal(other DataStoreKey) bool {
return k.CollectionId == other.CollectionId &&
return k.CollectionID == other.CollectionID &&
k.DocKey == other.DocKey &&
k.FieldId == other.FieldId &&
k.InstanceType == other.InstanceType
}

func (k DataStoreKey) ToPrimaryDataStoreKey() PrimaryDataStoreKey {
return PrimaryDataStoreKey{
CollectionId: k.CollectionId,
CollectionId: k.CollectionID,
DocKey: k.DocKey,
}
}

func (k PrimaryDataStoreKey) ToDataStoreKey() DataStoreKey {
return DataStoreKey{
CollectionId: k.CollectionId,
CollectionID: k.CollectionId,
DocKey: k.DocKey,
}
}
Expand Down Expand Up @@ -506,8 +506,8 @@ func (k DataStoreKey) PrefixEnd() DataStoreKey {
newKey.InstanceType = InstanceType(bytesPrefixEnd([]byte(k.InstanceType)))
return newKey
}
if k.CollectionId != "" {
newKey.CollectionId = string(bytesPrefixEnd([]byte(k.CollectionId)))
if k.CollectionID != "" {
newKey.CollectionID = string(bytesPrefixEnd([]byte(k.CollectionID)))
return newKey
}
return newKey
Expand Down
4 changes: 2 additions & 2 deletions core/key_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func TestNewDataStoreKey_ReturnsCollectionIdAndIndexIdAndDocKeyAndFieldIdAndInst
assert.Equal(
t,
DataStoreKey{
CollectionId: collectionId,
CollectionID: collectionId,
DocKey: docKey,
FieldId: fieldId,
InstanceType: InstanceType(instanceType)},
Expand Down Expand Up @@ -77,7 +77,7 @@ func TestNewDataStoreKey_GivenAShortObjectMarker(t *testing.T) {
assert.Equal(
t,
DataStoreKey{
CollectionId: collectionId,
CollectionID: collectionId,
DocKey: docKey,
InstanceType: InstanceType(instanceType)},
result)
Expand Down
4 changes: 2 additions & 2 deletions db/base/collection_keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ import (
// MakeIndexPrefix generates a key prefix for the given collection/index descriptions
func MakeCollectionKey(col client.CollectionDescription) core.DataStoreKey {
return core.DataStoreKey{
CollectionId: col.IDString(),
CollectionID: col.IDString(),
}
}

// MakeIndexKey generates a key for the target dockey, using the collection/index description
func MakeDocKey(col client.CollectionDescription, docKey string) core.DataStoreKey {
return core.DataStoreKey{
CollectionId: col.IDString(),
CollectionID: col.IDString(),
DocKey: docKey,
}
}
Expand Down
4 changes: 2 additions & 2 deletions db/collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -1076,7 +1076,7 @@ func (c *collection) getPrimaryKeyFromDocKey(docKey client.DocKey) core.PrimaryD

func (c *collection) getDSKeyFromDockey(docKey client.DocKey) core.DataStoreKey {
return core.DataStoreKey{
CollectionId: fmt.Sprint(c.colID),
CollectionID: fmt.Sprint(c.colID),
DocKey: docKey.String(),
InstanceType: core.ValueKey,
}
Expand All @@ -1089,7 +1089,7 @@ func (c *collection) tryGetFieldKey(key core.PrimaryDataStoreKey, fieldName stri
}

return core.DataStoreKey{
CollectionId: key.CollectionId,
CollectionID: key.CollectionId,
DocKey: key.DocKey,
FieldId: strconv.FormatUint(uint64(fieldId), 10),
}, true
Expand Down
4 changes: 2 additions & 2 deletions planner/commit.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,12 +308,12 @@ func (n *dagScanNode) dagBlockToNodeDoc(block blocks.Block) (core.Doc, []*ipld.L
n.commitSelect.DocumentMapping.SetFirstOfName(&commit,
request.DockeyFieldName, dockeyObj.DocKey)

collectionId, err := strconv.Atoi(dockeyObj.CollectionId)
collectionID, err := strconv.Atoi(dockeyObj.CollectionID)
if err != nil {
return core.Doc{}, nil, err
}
n.commitSelect.DocumentMapping.SetFirstOfName(&commit,
request.CollectionIDFieldName, int64(collectionId))
request.CollectionIDFieldName, int64(collectionID))

heads := make([]*ipld.Link, 0)

Expand Down

0 comments on commit f8956c1

Please sign in to comment.