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

Allow to access collection of IDs from find result #165

Closed
tkainrad opened this issue May 10, 2019 · 11 comments
Closed

Allow to access collection of IDs from find result #165

tkainrad opened this issue May 10, 2019 · 11 comments
Assignees
Milestone

Comments

@tkainrad
Copy link

I have recently started to use Nitrite as backend storage for large element collections displayed in a Java desktop application. I am very impressed with its performance.

However, I have an idea that could improve the speed further. Often, I require to get a list of IDs of all elements that fit a specific filter. At the moment I do the following:

Cursor find = nitriteDatabase.getCollection(ELEMENT_COLLECTION)
    .find(Filters.eq(attributeName,
       value));

for (Document document : find)
{
    set.add(document.getId().getIdValue());
}

For indexed attributes, iterating through the Cursor object actually takes more time than the find operation itself. This is a little frustrating since the Cursor already has internally exactly what I need, the Collection<NitriteId> resultSet.

I would suggest to allow access to the resultSet or add a way of retrieving the IDs without having to create the actual documents with all their key-value pairs.

Thank you for considering my request. If you point me to a solution you would be fine with, I could also think about contributing a PR myself.

@gibis07
Copy link

gibis07 commented May 14, 2019

Did you already find a solution for this? We would need that, too!

@TareqK
Copy link

TareqK commented May 14, 2019 via email

@anidotnet
Copy link
Contributor

Sorry guys, I am currently crammed up with my office work. Once I get some free time I'll work on it and hopefully introduce in 3.3.0.

@anidotnet
Copy link
Contributor

and this(in addition to the ability to throw an exception if
update/deletes don't change anything)

You should not do this, as this scenario is not exceptional. It's a very valid scenario. On the other hand WriteResult returns the number of effected elements. You should check it after modification and execute your logic based on the number.

@anidotnet anidotnet self-assigned this May 14, 2019
@anidotnet anidotnet added this to the 3.3.0 milestone May 14, 2019
anidotnet added a commit that referenced this issue May 14, 2019
@anidotnet
Copy link
Contributor

This feature should be available in 3.3.0-SNAPSHOT now.

@tkainrad
Copy link
Author

Wow, that was fast, thanks a lot!

@tkainrad
Copy link
Author

Maybe a naive question, but is 3.3.0-SNAPSHOT published somewhere? It does not seem to be available through maven. We can wait for the full release, no problem, just wondering. Thanks again!

@anidotnet
Copy link
Contributor

You can get it from maven snapshot repository. https://oss.sonatype.org/content/repositories/snapshots/org/dizitart/nitrite

@tkainrad
Copy link
Author

Thanks, was not aware of this. Works like a charm!

@anidotnet
Copy link
Contributor

Great. Glad to be of help.. 😀

@gibis07
Copy link

gibis07 commented May 15, 2019

Thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

No branches or pull requests

4 participants