Skip to content

Commit

Permalink
feat: referenceId
Browse files Browse the repository at this point in the history
  • Loading branch information
friendlymatthew committed Jun 27, 2024
1 parent 75b883e commit 304cae4
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions pkg/pointer/referenced_value.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package pointer
import (
"bytes"
"fmt"
"github.com/kevmo314/appendable/pkg/hnsw"
)

type ReferencedValue struct {
Expand All @@ -18,10 +19,19 @@ type ReferencedValue struct {
Value []byte
}

type ReferencedId struct {
DataPointer MemoryPointer
Value hnsw.Id
}

func (rv ReferencedValue) String() string {
return fmt.Sprintf("ReferencedValue@%s{%s}", rv.DataPointer, rv.Value)
}

func (rv ReferencedId) String() string {
return fmt.Sprintf("ReferencedId@%s{%s}", rv.DataPointer, rv.Value)

Check failure on line 32 in pkg/pointer/referenced_value.go

View workflow job for this annotation

GitHub Actions / go-test (ubuntu-latest)

fmt.Sprintf format %s has arg rv.Value of wrong type uint

Check failure on line 32 in pkg/pointer/referenced_value.go

View workflow job for this annotation

GitHub Actions / go-test (macos-latest)

fmt.Sprintf format %s has arg rv.Value of wrong type uint
}

func CompareReferencedValues(a, b ReferencedValue) int {
if cmp := bytes.Compare(a.Value, b.Value); cmp != 0 {
return cmp
Expand All @@ -36,3 +46,13 @@ func CompareReferencedValues(a, b ReferencedValue) int {
}
return 0
}

func CompareReferencedId(a, b ReferencedId) int {
if a.Value > b.Value {
return 1
} else if a.Value < b.Value {
return -1
}

return 0
}

0 comments on commit 304cae4

Please sign in to comment.