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

Index issue #13

Closed
irr123 opened this issue Jul 20, 2021 · 1 comment · Fixed by #14
Closed

Index issue #13

irr123 opened this issue Jul 20, 2021 · 1 comment · Fixed by #14
Labels
bug Something isn't working

Comments

@irr123
Copy link

irr123 commented Jul 20, 2021

Hello, maybe I dont undestand how it works but, I prepare an example, which completely confuses me. Here is the code:

package main

import (
	"fmt"
	
	"github.com/kelindar/column"

)

func main() {
	str()
	fmt.Println()
	int()
}

func str() {
	coll := column.NewCollection()
	coll.CreateColumn("id", column.ForInt64())
	coll.CreateColumn("data", column.ForString())
	coll.CreateIndex("1", "id", func(r column.Reader) bool {
		return r.Int() == 1
	})

	dd := []string{"aaa", "bbb", "ccc", "ddd"}

	for i, d := range dd {
		coll.Insert(map[string]interface{}{"id": i, "data": d})
	}

	coll.Query(func(tx *column.Txn) error {
		tx.With("1").Select(func(v column.Selector) {
			fmt.Printf("%v: %v\n", v.ValueAt("id"), v.ValueAt("data"))
		})

		return nil
	})
}

func int() {
	coll := column.NewCollection()
	coll.CreateColumn("id", column.ForInt64())
	coll.CreateColumn("data", column.ForInt64())
	coll.CreateIndex("1", "id", func(r column.Reader) bool {
		return r.Int() == 1
	})

	dd := []int64{100, 200, 300, 400}

	for i, d := range dd {
		coll.Insert(map[string]interface{}{"id": i, "data": d})
	}

	coll.Query(func(tx *column.Txn) error {
		tx.With("1").Select(func(v column.Selector) {
			fmt.Printf("%v: %v\n", v.ValueAt("id"), v.ValueAt("data"))
		})

		return nil
	})
}

and an output, which is the same on both apple silicon and apple intel macs:

0: ddd
1: ddd
2: ddd
3: ddd

0: 100
1: 200
2: 300
3: 400

So, which behaviour confused me, in str-func, I expect to see output:

1: bbb

similarly, in intI expect something like:

1: 200

But same code works different for different data types and, as I think, not solve problem to get values by index.

@kelindar kelindar added the bug Something isn't working label Jul 25, 2021
@kelindar
Copy link
Owner

@irr123 both are bugs, was able to reproduce them and are going to fix them soon

Florimond added a commit that referenced this issue Jul 25, 2021
Florimond added a commit that referenced this issue Jul 25, 2021
sthagen added a commit to sthagen/kelindar-column that referenced this issue Jul 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants