{"action":"created","issue":{"url":"https://api.github.com/repos/facebook/rocksdb/issues/675","labels_url":"https://api.github.com/repos/facebook/rocksdb/issues/675/labels{/name}","comments_url":"https://api.github.com/repos/facebook/rocksdb/issues/675/comments","events_url":"https://api.github.com/repos/facebook/rocksdb/issues/675/events","html_url":"https://github.com/facebook/rocksdb/issues/675","id":97435444,"number":675,"title":"Ideas for changing the Java RocksIterator","user":{"login":"adamretter","id":1264057,"avatar_url":"https://avatars.githubusercontent.com/u/1264057?v=3","gravatar_id":"","url":"https://api.github.com/users/adamretter","html_url":"https://github.com/adamretter","followers_url":"https://api.github.com/users/adamretter/followers","following_url":"https://api.github.com/users/adamretter/following{/other_user}","gists_url":"https://api.github.com/users/adamretter/gists{/gist_id}","starred_url":"https://api.github.com/users/adamretter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adamretter/subscriptions","organizations_url":"https://api.github.com/users/adamretter/orgs","repos_url":"https://api.github.com/users/adamretter/repos","events_url":"https://api.github.com/users/adamretter/events{/privacy}","received_events_url":"https://api.github.com/users/adamretter/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/facebook/rocksdb/labels/question","name":"question","color":"cc317c"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-07-27T10:45:04Z","updated_at":"2015-08-05T22:28:59Z","closed_at":null,"body":"At present the design of the Java RocksIterator is not very Java'esk. That is to say that as a Java developer you will typically hold the assumption that calling `getKey()` or `getValue()` on the iterator will be stable until you call `next()`, `prev()`, `seek...`. This is not the case; see: https://github.com/facebook/rocksdb/issues/616#issuecomment-124246253\r\n\r\nI would suggest that the Java RocksIterator should be replaced by two different types of iterator:\r\n\r\n1. A direct iterator which uses `ByteBuffer` to access the underlying C++ memory. This would avoid the JNI copy that is done with the current RocksIterator on every call to `getKey()` or `getValue()`. It would also be unstable like the current RocksIterator, however because of the use of ByteBuffer this would be expected by the Java developer.\r\n\r\n2. A non-direct iterator which uses `byte[]` just as the current RocksIterator does, however the behaviour of `getKey()` and `getValue()` would be stable until `next()` or `prev()` is called; It would also be stable for example when remove is called on a non-direct iterator of a WriteBatch. This could for example be achieved by the first call to `getKey` internally caching the value, the value would be disposed on the call to `next` or `close`, the same principle would apply to `getValue`.\r\n\r\nComments?"},"comment":{"url":"https://api.github.com/repos/facebook/rocksdb/issues/comments/128170453","html_url":"https://github.com/facebook/rocksdb/issues/675#issuecomment-128170453","issue_url":"https://api.github.com/repos/facebook/rocksdb/issues/675","id":128170453,"user":{"login":"adamretter","id":1264057,"avatar_url":"https://avatars.githubusercontent.com/u/1264057?v=3","gravatar_id":"","url":"https://api.github.com/users/adamretter","html_url":"https://github.com/adamretter","followers_url":"https://api.github.com/users/adamretter/followers","following_url":"https://api.github.com/users/adamretter/following{/other_user}","gists_url":"https://api.github.com/users/adamretter/gists{/gist_id}","starred_url":"https://api.github.com/users/adamretter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adamretter/subscriptions","organizations_url":"https://api.github.com/users/adamretter/orgs","repos_url":"https://api.github.com/users/adamretter/repos","events_url":"https://api.github.com/users/adamretter/events{/privacy}","received_events_url":"https://api.github.com/users/adamretter/received_events","type":"User","site_admin":false},"created_at":"2015-08-05T22:28:59Z","updated_at":"2015-08-05T22:28:59Z","body":"@yhchiang Thanks I have re-opened this, so that I don't forget and will attempt to close with a pull-request in the near future."}}