views:

187

answers:

1

I want to rank how strongly connected instances of Entity A are to other instances or Entity A are in my graph.I only need to do this for the n most recently viewed entities. I describe relations between two instances of Entity A by means of another Entity B. This is because I need to describe each relationship.

I was considering using a fetched property like so:

ANY isSourceOfRelation.destinationThing == "$SOURCE_THING"
OR ANY isDestinationOfRelation.sourceThing == "$SOURCE_THING"

But I am wary of doing so because I doubt it will evaluate this via relations but via an exhaustive search. This would not be such a problem on the desktop but on iPhone it would not be practical with my dataset.

As Fetched Properties are lazily evaluated and subsequently cached I could perhaps access the fetched property on every single object on the desktop but would this cache be maintained in the sqlite store?

My alternative to this would be to dynamically evaluate this by accessing every Entity B to retrieve the destination Entity A and subsequently add these to a dictionary.

The graph has 10,000 Entity A and about 30,000 relations between them (entity B).

My priority is performance.

What do you think?

A: 

Sounds like a good candidate for pre-calculating and loading separately on-demand, perhaps even in a separate store. If the actual data is small, that's not too taxing and most iPhones can spare a meg or two of 'disk' storage for this sort of thing.

If the values are mutable, you could run a background thread after modifications to make sure the pre-calc tables are kept up-to-date. A 'dirty' flag will let you know if the user interrupts the operation before it's done so you can do it again the next time the app is run.

Ramin