Skip to content

Commit

Permalink
WIP - Namespace headstore docs
Browse files Browse the repository at this point in the history
Will soon be adding collections to the headstore, and we dont want the keys to intermingle
  • Loading branch information
AndrewSisley committed Oct 30, 2024
1 parent 7c7c030 commit c3fad6e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
2 changes: 1 addition & 1 deletion internal/db/fetcher/dag.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (hf *HeadFetcher) Start(
hf.fieldId = fieldId

q := dsq.Query{
Prefix: hf.spans.Value[0].Start().ToString(),
Prefix: keys.HEADSTORE_DOC + "/" + hf.spans.Value[0].Start().ToString(),
Orders: []dsq.Order{dsq.OrderByKey{}},
}

Expand Down
15 changes: 15 additions & 0 deletions internal/keys/headstore.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright 2024 Democratized Data Foundation
//
// Use of this software is governed by the Business Source License
// included in the file licenses/BSL.txt.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, Version 2.0, included in the file
// licenses/APL.txt.

package keys

const (
HEADSTORE_DOC = "/d"
)
10 changes: 5 additions & 5 deletions internal/keys/headstore_doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,19 @@ var _ Key = (*HeadStoreKey)(nil)
// Any properties before the above are ignored
func NewHeadStoreKey(key string) (HeadStoreKey, error) {
elements := strings.Split(key, "/")
if len(elements) != 4 {
if len(elements) != 5 {
return HeadStoreKey{}, ErrInvalidKey
}

cid, err := cid.Decode(elements[3])
cid, err := cid.Decode(elements[4])
if err != nil {
return HeadStoreKey{}, err
}

return HeadStoreKey{
// elements[0] is empty (key has leading '/')
DocID: elements[1],
FieldID: elements[2],
DocID: elements[2],
FieldID: elements[3],
Cid: cid,
}, nil
}
Expand All @@ -70,7 +70,7 @@ func (k HeadStoreKey) WithFieldID(fieldID string) HeadStoreKey {
}

func (k HeadStoreKey) ToString() string {
var result string
result := HEADSTORE_DOC

if k.DocID != "" {
result = result + "/" + k.DocID
Expand Down

0 comments on commit c3fad6e

Please sign in to comment.