Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
taylanisikdemir committed Jun 24, 2024
1 parent 2aaa4a0 commit 9733ab0
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 16 deletions.
2 changes: 1 addition & 1 deletion common/mapq/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ func (p *InMemoryPersister) Persist(ctx context.Context, items []types.ItemToPer
for _, item := range items {
partitionsKV := map[string]any{}
actualKV := map[string]any{}
for _, k := range item.GetPartitions() {
for _, k := range item.GetPartitionKeys() {
partitionsKV[k] = item.GetPartitionValue(k)
actualKV[k] = item.GetAttribute(k)
}
Expand Down
24 changes: 12 additions & 12 deletions common/mapq/types/item.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ func NewItemToPersist(item Item, itemPartitions ItemPartitions) ItemToPersist {
}

type ItemPartitions interface {
// GetPartitions returns the partition keys ordered by their level in the tree
GetPartitions() []string
// GetPartitionKeys returns the partition keys ordered by their level in the tree
GetPartitionKeys() []string

// GetPartitionValue returns the partition value to determine the target queue
// e.g.
Expand All @@ -68,28 +68,28 @@ type ItemPartitions interface {
String() string
}

func NewItemPartitions(partitions []string, partitionMap map[string]any) ItemPartitions {
func NewItemPartitions(partitionKeys []string, partitionMap map[string]any) ItemPartitions {
return &defaultItemPartitions{
partitions: partitions,
partitionMap: partitionMap,
partitionKeys: partitionKeys,
partitionMap: partitionMap,
}
}

type defaultItemPartitions struct {
partitions []string
partitionMap map[string]any
partitionKeys []string
partitionMap map[string]any
}

func (i *defaultItemPartitions) GetPartitions() []string {
return i.partitions
func (i *defaultItemPartitions) GetPartitionKeys() []string {
return i.partitionKeys
}

func (i *defaultItemPartitions) GetPartitionValue(key string) any {
return i.partitionMap[key]
}

func (i *defaultItemPartitions) String() string {
return fmt.Sprintf("ItemPartitions{partitions:%v, partitionMap:%v}", i.partitions, i.partitionMap)
return fmt.Sprintf("ItemPartitions{partitionKeys:%v, partitionMap:%v}", i.partitionKeys, i.partitionMap)
}

type defaultItemToPersist struct {
Expand All @@ -109,8 +109,8 @@ func (i *defaultItemToPersist) GetAttribute(key string) any {
return i.item.GetAttribute(key)
}

func (i *defaultItemToPersist) GetPartitions() []string {
return i.itemPartitions.GetPartitions()
func (i *defaultItemToPersist) GetPartitionKeys() []string {
return i.itemPartitions.GetPartitionKeys()
}

func (i *defaultItemToPersist) GetPartitionValue(key string) any {
Expand Down
4 changes: 2 additions & 2 deletions common/mapq/types/item_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ func TestNewItemToPersist(t *testing.T) {
t.Errorf("itemToPersist.GetAttribute(attr2) = %v, want %v", got, "value2")
}

gotPartitions := itemToPersist.GetPartitions()
gotPartitions := itemToPersist.GetPartitionKeys()
if diff := cmp.Diff(partitions, gotPartitions); diff != "" {
t.Fatalf("Partitions mismatch (-want +got):\n%s", diff)
t.Fatalf("Partition keys mismatch (-want +got):\n%s", diff)
}
if got := itemToPersist.GetPartitionValue("attr1"); got != "*" {
t.Errorf("itemToPersist.GetPartitionValue(attr1) = %v, want %v", got, "*")
Expand Down
3 changes: 2 additions & 1 deletion common/mapq/types/offsets.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

package types

// Offsets encapsulates the whole queue tree state including the offsets of each leaf node
type Offsets struct {
// TODO: define offsets
// TODO: complete
}

0 comments on commit 9733ab0

Please sign in to comment.