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

reverse listing of changes #163

Merged
merged 3 commits into from
Oct 5, 2022
Merged

Conversation

rompetroll
Copy link
Contributor

@rompetroll rompetroll commented Oct 5, 2022

This change introduces the ability to list dataset changes in reverse order.

closes issue #161. only partially (changes only, not entities)

the new feature uses a dataset change iterator. The iterator pattern
moves flow control out of the dataset and storage layer. The plan is to
move more internals over to "service" implementations gradually.
@rompetroll rompetroll merged commit fb6754f into master Oct 5, 2022
@rompetroll rompetroll deleted the feat/issue161/reverse-listing2 branch October 5, 2022 11:31
Copy link
Contributor

@gilgamesjh gilgamesjh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do like the new iterator stuff, it really seems to be able to clean up the internals a lot. Great work.

}
type Iterator interface {
io.Closer
Inverse() Iterator
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure of this should be a property on the Iterator instance instead of it's own method. Or even a ReverseIterator implementation. So by calling a factory method table.GetIterator(reverse:true/false) would then just return the correct Iterator (a Next on a ReverseIterator would then go backwards)

return nil
}

func (b *BadgerDatasetIterator) Inverse() Iterator {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I understand it, you use the call to Inverse() to switch the order. Still not sure that's the best way.

"github.com/mimiro-io/datahub/internal/server"
)

func SeekChanges(datasetID uint32, since uint64) []byte {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do these need to be public methods?Also seem to be more Builders than Seek methods, so not sure about naming.

@@ -250,6 +252,10 @@ func (handler *datasetHandler) getEntitiesHandler(c echo.Context) error {
}

f := c.QueryParam("from")
reverse := c.QueryParam("reverse")
if reverse != "" {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Errorf("reverse parameter only supported for changes"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For Echo, you want to return text, not the err, it has to do with the pathing of the return values in Echo, a return echo.NewHttpError(500, err.Error()) returns the Echo error object, while the echo.NewHttpError(500, err) does not.

})
if err != nil {
return echo.NewHTTPError(http.StatusInternalServerError, err.Error())
if reverse {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not pretty, and should be changed in the future, but I understand why it has to be like this (for now).

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

Successfully merging this pull request may close these issues.

3 participants