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

Preliminary version of DMap.Query function #18

Closed
buraksezer opened this issue Feb 22, 2020 · 4 comments
Closed

Preliminary version of DMap.Query function #18

buraksezer opened this issue Feb 22, 2020 · 4 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@buraksezer
Copy link
Owner

We need to implement a preliminary version of Query function. It would be like the following:

dm, err := db.NewDMap("mydmap")
if err != nil {
	// handle error
}

q, err := dm.Query(olric.Q{"$onKey": {"$regexMatch": "/foo.?"}})
if err != nil {
	// handle error
}

q.Range(func(key string, value []byte) bool {
	err = dm.Delete(key)
	if err != nil {
		// handle error
	}
})

Currently there is no secondary index to query keys($onKeys) or fields in values($onValues). In this preliminary version, it will do full DMap scan in a distributed manner. Later on we can implement a secondary index to query keys and values. The first version will work only for keys.

See this thread for more info: #9 (comment)

@buraksezer buraksezer self-assigned this Feb 22, 2020
@buraksezer buraksezer added the enhancement New feature or request label Feb 22, 2020
@buraksezer buraksezer added this to the v0.2.0 milestone Feb 22, 2020
@justinfx
Copy link
Contributor

I've tested this a bit and wanted to give some feedback. I'm using the following to find keys with a certain prefix:

	q, err := c.dmap.Query(
		query.M{"$onKey": query.M{
			"$regexMatch": fmt.Sprintf("^%s", keyPrefix),
			"$options": query.M{
				"$onValue": query.M{"$ignore": true},
			},
		}})

On one hand its nice that you came up with a flexible query dsl. On the other hand, I initially had a bug because I misspelled the case of "$onkey". So its easy to make a typo on the query. Also its a little verbose to get a key-only query iterator, but this works.
Thanks!

@buraksezer
Copy link
Owner Author

On one hand its nice that you came up with a flexible query dsl. On the other hand, I initially had a bug because I misspelled the case of "$onkey". So its easy to make a typo on the query. Also its a little verbose to get a key-only query iterator, but this works.

I really like this distributed query feature. It will be very useful when we build a secondary index on keys and fields of values. I'm going to focus on distributed queries in one of the next milestones.

I use MongoDB at my day job. I'm heavily inspired by its query language. It's fine, I think. I'm totally open to new ideas and improvements on the query language for the next releases.

The development work of this issue is about to be completed. I'll probably merge this branch into the master branch at Monday.

@buraksezer
Copy link
Owner Author

I merged feature/issue-18 into the master branch. If you have any further questions or find bugs, please open an issue.

Thank you!

@justinfx
Copy link
Contributor

justinfx commented Mar 2, 2020

Thanks! I was just looking at this again today and hoped it would be merged so that I could use all of the new features together. Will definitely provide feedback if anything presents a problem.

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

No branches or pull requests

2 participants