{"action":"created","issue":{"url":"https://api.github.com/repos/Level/leveldown/issues/256","repository_url":"https://api.github.com/repos/Level/leveldown","labels_url":"https://api.github.com/repos/Level/leveldown/issues/256/labels{/name}","comments_url":"https://api.github.com/repos/Level/leveldown/issues/256/comments","events_url":"https://api.github.com/repos/Level/leveldown/issues/256/events","html_url":"https://github.com/Level/leveldown/pull/256","id":133450029,"number":256,"title":"Seek multiple times and support Buffers","user":{"login":"vweevers","id":3055345,"avatar_url":"https://avatars.githubusercontent.com/u/3055345?v=3","gravatar_id":"","url":"https://api.github.com/users/vweevers","html_url":"https://github.com/vweevers","followers_url":"https://api.github.com/users/vweevers/followers","following_url":"https://api.github.com/users/vweevers/following{/other_user}","gists_url":"https://api.github.com/users/vweevers/gists{/gist_id}","starred_url":"https://api.github.com/users/vweevers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vweevers/subscriptions","organizations_url":"https://api.github.com/users/vweevers/orgs","repos_url":"https://api.github.com/users/vweevers/repos","events_url":"https://api.github.com/users/vweevers/events{/privacy}","received_events_url":"https://api.github.com/users/vweevers/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":10,"created_at":"2016-02-13T17:21:12Z","updated_at":"2016-11-17T13:26:05Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/Level/leveldown/pulls/256","html_url":"https://github.com/Level/leveldown/pull/256","diff_url":"https://github.com/Level/leveldown/pull/256.diff","patch_url":"https://github.com/Level/leveldown/pull/256.patch"},"body":"This PR enables multiple calls to `iterator.seek(target)` while iterating, and adds support for Buffer keys. The primary use case is [skip scanning](https://oracle-base.com/articles/9i/index-skip-scanning).\n\n``` js\niter.next(function(err,key,value){\n  if (key.toString() === 'a') {\n    iter.seek('g')\n    iter.next(etc)\n  }\n})\n```\n\nI renamed the variable `key` to `target`, because it better expresses the fact that it's not an exact match.\n\nLike before, `seek()` respects the iterator direction (reverse or not), which differs from the native LevelDB seek behavior. The native seek lands on or _after_ a target, but in leveldown, if reverse is true, it lands on or _before_ the target (at least it should, breaking test cases are welcome).\n\nIt also accounts for keys in the cache. If one of those matches the target, no native seek is performed. Instead, the cache is truncated so that the following `next()` yields the target key.\n\nNote I'm not a C++ guy, and this PR is bigger than I intended. But what I basically did, is move the initial seek in `GetIterator()` to a separate private function (`IteratorSeek`) so that both `GetIterator` (for the regular initial seek) and `Seek` can use it.\n"},"comment":{"url":"https://api.github.com/repos/Level/leveldown/issues/comments/261245641","html_url":"https://github.com/Level/leveldown/pull/256#issuecomment-261245641","issue_url":"https://api.github.com/repos/Level/leveldown/issues/256","id":261245641,"user":{"login":"peakji","id":219051,"avatar_url":"https://avatars.githubusercontent.com/u/219051?v=3","gravatar_id":"","url":"https://api.github.com/users/peakji","html_url":"https://github.com/peakji","followers_url":"https://api.github.com/users/peakji/followers","following_url":"https://api.github.com/users/peakji/following{/other_user}","gists_url":"https://api.github.com/users/peakji/gists{/gist_id}","starred_url":"https://api.github.com/users/peakji/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/peakji/subscriptions","organizations_url":"https://api.github.com/users/peakji/orgs","repos_url":"https://api.github.com/users/peakji/repos","events_url":"https://api.github.com/users/peakji/events{/privacy}","received_events_url":"https://api.github.com/users/peakji/received_events","type":"User","site_admin":false},"created_at":"2016-11-17T13:26:04Z","updated_at":"2016-11-17T13:26:04Z","body":"Any news on this? Skip scanning is really useful."}}
{"actor":{"display_login":"peakji"}}