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

Spira#count counts subjects - should it count instances? #37

Open
Robsteranium opened this issue May 1, 2014 · 1 comment
Open

Spira#count counts subjects - should it count instances? #37

Robsteranium opened this issue May 1, 2014 · 1 comment
Labels
help wanted Extra attention is needed

Comments

@Robsteranium
Copy link

I'm just getting to grips with Spira and I've found something that strikes me as odd (the mailing list looks a bit quiet so I'm posting here instead). I wonder if this is an expectation set by the OOP/ ActiveRecord world that simply doesn't apply in the graph/ RDF world...

I expect Spira::Base#count to return the count of objects of the relevant type - i.e. the distinct count of "?s a <model_type>", the number of instances. Instead #count returns the count of occurrences of those subjects - i.e. the number of triples where a "?s a <model_type>" is the subject. In OOP terms this is basically like counting the number of attributes which is certainly not what I would expect.

I realise that what might need 'fixing' is in fact my expectations about how objects work in a graph world. If so, I'd be very grateful if someone could elaborate on this.

Nevertheless the apparent congruence between the AR and Spira public APIs leads me to believe that I won't be the only one making this mistake! It might be clearer, for example, if Spira distinguished between a #count and a #count_of_subjects method.

@cordawyn
Copy link
Member

cordawyn commented May 5, 2014

I agree with you here. However, it should be noted that there are two count methods defined for Spira::Base: a class method and an instance method. I believe, Spira::Base.count (class method) should return the number of "model types" (and it actually says so). Spira::Base#count returns "the number of RDF::Statements this projection has" (looks to be implemented properly).

So, if Spira::Base.count does not work as expected, there's definitely a bug there. Please make sure you're using the correct "count" ;-) Does Spira::Base.count work for you?

Speaking of the congruence between AR and Spira, you'd also call ActiveRecord::Base.count to count the records in the DB, not (non-existant) ActiveRecord::Base#count.

@gkellogg gkellogg added the help wanted Extra attention is needed label Nov 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants