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 Nov 5, 2024
1 parent 6496449 commit 4dfeab2
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 13 deletions.
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 _ Walkable = (*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
16 changes: 8 additions & 8 deletions tests/integration/explain/default/dagscan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ func TestDefaultExplainCommitsDagScanQueryOp(t *testing.T) {
"fieldId": "1",
"spans": []dataMap{
{
"start": "/bae-7aabc9d2-fbbc-5911-b0d0-b49a2a1d0e84/1",
"end": "/bae-7aabc9d2-fbbc-5911-b0d0-b49a2a1d0e84/2",
"start": "/d/bae-7aabc9d2-fbbc-5911-b0d0-b49a2a1d0e84/1",
"end": "/d/bae-7aabc9d2-fbbc-5911-b0d0-b49a2a1d0e84/2",
},
},
},
Expand Down Expand Up @@ -103,8 +103,8 @@ func TestDefaultExplainCommitsDagScanQueryOpWithoutField(t *testing.T) {
"fieldId": nil,
"spans": []dataMap{
{
"start": "/bae-7aabc9d2-fbbc-5911-b0d0-b49a2a1d0e84",
"end": "/bae-7aabc9d2-fbbc-5911-b0d0-b49a2a1d0e85",
"start": "/d/bae-7aabc9d2-fbbc-5911-b0d0-b49a2a1d0e84",
"end": "/d/bae-7aabc9d2-fbbc-5911-b0d0-b49a2a1d0e85",
},
},
},
Expand Down Expand Up @@ -147,8 +147,8 @@ func TestDefaultExplainLatestCommitsDagScanQueryOp(t *testing.T) {
"fieldId": "1",
"spans": []dataMap{
{
"start": "/bae-7aabc9d2-fbbc-5911-b0d0-b49a2a1d0e84/1",
"end": "/bae-7aabc9d2-fbbc-5911-b0d0-b49a2a1d0e84/2",
"start": "/d/bae-7aabc9d2-fbbc-5911-b0d0-b49a2a1d0e84/1",
"end": "/d/bae-7aabc9d2-fbbc-5911-b0d0-b49a2a1d0e84/2",
},
},
},
Expand Down Expand Up @@ -191,8 +191,8 @@ func TestDefaultExplainLatestCommitsDagScanQueryOpWithoutField(t *testing.T) {
"fieldId": "C",
"spans": []dataMap{
{
"start": "/bae-7aabc9d2-fbbc-5911-b0d0-b49a2a1d0e84/C",
"end": "/bae-7aabc9d2-fbbc-5911-b0d0-b49a2a1d0e84/D",
"start": "/d/bae-7aabc9d2-fbbc-5911-b0d0-b49a2a1d0e84/C",
"end": "/d/bae-7aabc9d2-fbbc-5911-b0d0-b49a2a1d0e84/D",
},
},
},
Expand Down

0 comments on commit 4dfeab2

Please sign in to comment.