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

NotFoundException #52

Closed
kurzum opened this issue Sep 20, 2017 · 3 comments
Closed

NotFoundException #52

kurzum opened this issue Sep 20, 2017 · 3 comments

Comments

@kurzum
Copy link

kurzum commented Sep 20, 2017

Hi all,

 try {
                IteratorTripleString it = hdt.search(identifier, property, "");
                while (it.hasNext()) {
                    TripleString ts = it.next();
                    ValAgg.put(identifier, ts.getObject().toString(), lang);
                }
            } catch (NotFoundException nfe) {
                //intentionally left blank.
                //hdt.search returns NF exception instead of null or it.hasNext() == false
            }

this is how my code looks like. I find it weird, that I have to leave the catch block empty. But the code works.

@webdata
Copy link
Contributor

webdata commented Sep 20, 2017

Hi Sebastian,

The exception means that one of the terms in the search does not exist in the dictionary.

org.rdfhdt.hdt.exceptions.NotFoundException: String not found in dictionary

In fact, if all terms exist, the result of the query is empty as you mentioned.

But we can change it to return a null iterator if one of the terms doesn't exist (as in hdt-cpp). Please vote with 👍 if you agree to return a null iterator.

@kurzum
Copy link
Author

kurzum commented Sep 20, 2017

Ok, I see that HDT is special in this respect compared to a database. However, I am not aware of any data structure that throws an exception if something is not found in the database. I can't judge whether this is valuable information that something that is not in the dictionary is queried. I would expect it to just return an empty iterator, if no result is found.

@webdata
Copy link
Contributor

webdata commented Sep 20, 2017

You are right, and essentially it makes no sense to have two different approaches in C++ and Java.

I have added an empty iterator in d26a0af

Now you have the expected empty iterator if a term is not found.

@webdata webdata closed this as completed Sep 21, 2017
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

No branches or pull requests

2 participants