Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate index entries #86

Open
roihe opened this issue Mar 13, 2023 · 2 comments
Open

Duplicate index entries #86

roihe opened this issue Mar 13, 2023 · 2 comments

Comments

@roihe
Copy link

roihe commented Mar 13, 2023

I have a question about using Ascend with CreateSortIndex. In the result duplicate entries are not output. Is there a way that these are returned?
In this case only one Alice is returned:

package main
import (
"github.com/kelindar/column"
)
func main() {
// Erstellen einer neuen Tabelle
table := column.NewCollection()
table.CreateColumn("name", column.ForString())
table.CreateColumn("age", column.ForInt())
table.CreateColumn("country", column.ForString())
table.Insert(func(r column.Row) error {
r.SetString("name", "Charlie")
r.SetInt("age", 20)
r.SetString("country", "Großbritannien")
return nil
})
table.Insert(func(r column.Row) error {
r.SetString("name", "Alice")
r.SetInt("age", 25)
r.SetString("country", "USA")
return nil
})
table.Insert(func(r column.Row) error {
r.SetString("name", "Alice")
r.SetInt("age", 34)
r.SetString("country", "Österreich")
return nil
})
table.Insert(func(r column.Row) error {
r.SetString("name", "Bob")
r.SetInt("age", 30)
r.SetString("country", "Kanada")
return nil
})
table.Insert(func(r column.Row) error {
r.SetString("name", "David")
r.SetInt("age", 35)
r.SetString("country", "Australien")
return nil
})
table.CreateSortIndex("index1", "name")
table.Query(func(txn *column.Txn) error {
name := txn.String("name")
age := txn.Int("age")
country := txn.String("country")
return txn.With("name").Ascend("index1", func(idx uint32) {
print("idx: ", idx)
valueName, _ := name.Get()
print(" name: ", valueName)
valueAge, _ := age.Get()
print(" age: ", valueAge)
valueCountry, _ := country.Get()
println(" contry: ", valueCountry)
})
})
}

@Dreeseaw
Copy link
Collaborator

As of right now, no, SortedIndex does not support duplicate entries. If two or more entries share the key value, the most recently updated/created offset will be returned.

@roihe
Copy link
Author

roihe commented Mar 14, 2023

Thank you for the information. I will think about a workaround.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants