Hi,
On Sun, Jan 26, 2020 at 3:25 PM C. Anim <
codea...@gmail.com> wrote:
>
> Hello,
>
> In the
http://www.hypergraphdb.org/?project=hypergraphdb&page=IntroQuerying Intro to Querying help this example:
>
> HyperGraph graph = new HyperGraph(tutorialHyperGraphLocation); List<Book> books = hg.getAll(hg.and(hg.type(Book.class), hg.eq("author", "Bob Smith")));
>
> ... doesn't seem to compile, but this getAll overload including the graph instance as the 1st parameter works:
>
> List<Product> products = hg.getAll(graph, hg.and(hg.type(Product.class), hg.eq("id", "banana")));
Ah, that's a typo: we used to frequently used 'hg' as a variable name
for a HyperGraph instance. Then the HGQuery.hg class came to be, so
now in general 'graph' is used as a variable name. And the HyperGraph
class has those methods getAll, findAll, getOne, findOne, so it should
be:
graph.getAll(hg.and(hg.type(Product.class), hg.eq("id", "banana")))
>
> Also, I couldn't find a good "count" example, but these seem to work:
>
> HGQueryCondition cond = hg.and(hg.type(Product.class));
>
> long c1 = hg.count(graph, cond);
>
>
> long c2 = hg.count(graph, hg.and(hg.type(Product.class), hg.eq("id", "orange")));
>
>
> In the c2 example, the filtered query seems to take an inordinately long time
>
> for large data. Is there a way I can structure my query to get a quicker answer?
In the first query, the count is already available (a bit like getting
the number of rows in a relational table). In the second, the result
has to be computed in order to get the count. If you have an index of
that "id" attribute, which you probably should if it's an ID with
frequent lookups, then it should be almost instantaneous as well. If
it's take a very long time, it's probably doing a scan on a lot of
data. That scan would be avoided with an index.
Cheers,
Boris
> Thanks
>
> --
> You received this message because you are subscribed to the Google Groups "HyperGraphDB" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
hypergraphdb...@googlegroups.com.
> To view this discussion on the web visit
https://groups.google.com/d/msgid/hypergraphdb/251676b1-fc18-4b7d-852e-48aebd327ab3%40googlegroups.com.
--
"Damn! The world is big!"
-- Heleni Daly