findKeysIterator behavior
Let's say I have following keys in my single DB:
user:10001
user:10002
user:10003
user:10004
post:500
post:501
post:502
post:503
As you can see, the prefixes in the keys indicate stored object type. However when I use findKeysIterator, I find strange result:
String PREFIX = "post";
iterator = snappyDB.findKeysIterator(PREFIX);
for (String[] batch : iterator.byBatch(BATCH_SIZE)) {
for (String key : batch) {
Log.d("KEY", key);
}
}
The logged output is surprisingly shows all keys including "user"-prefixed ones. Is this the correct behavior?
I was thinking to separate my object types into different database, but just realized that it might not work well (issue #26). My current workaround is by adding if(key.startsWith(PREFIX) inside the innermost for-loop.
Is there any cleaner way to achieve my desired result? (i.e. find keys with specified prefix)
I have exactly the same problem. This post is from 11 nov 2014.. so its really really bad that this is still not fixed. It is not really a problem on small collections. But when you look for a few in a few thousand entries this costs a lot of resources on slower phones!
EDIT: The strangest thing is even that this only occurs with one method. Other methods that do exactly the same thing work without a problem.. (the prefix is totally different.. event vs ticket)
Just ran into a same problem recently, and found myself back to this issue I made almost a year ago :sob:
Additional strange behavior: Sometimes it found no keys at all when searching by prefix
Hi @akhyrul I'm investigating this issue, it should be part of 0.6.0 release.
Cheers,
@akhy I know it's late, but did you find any solution for wrong keys during findKeysIterator ?
@indiandragon I've mentioned it in the first post... by doing manual post-filtering 🤦♂️
@akhy I see, thanks for the reply; but it wouldn't cut for my purposes & since SnappyDB wouldn't be updated anymore I've migrated to Realm.
@indiandragon you're welcome, I've not used snappy too anyway 🙈
On Apr 27, 2018, 14:52 +0700, indiandragon [email protected], wrote:
@akhy I see, thanks for the reply; but it wouldn't cut for my purposes & since SnappyDB wouldn't be updated anymore I've migrated to Realm. — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.