fenfire-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Fenfire-dev] RDF traversal utility methods


From: Tuukka Hastrup
Subject: Re: [Fenfire-dev] RDF traversal utility methods
Date: Sun, 17 Aug 2003 18:19:31 +0300 (EEST)

This is getting complicated, isn't it? And adding to this, getComponents
should also tell which of the components was with most nodes. Asko would
like the Set sorted by the component size, I would like to return new
Object[2] {components, largest}. I could return an iterator that gives the
largest first.

Should we also consider Java<->Jython interfacing? I didn't find easy ways 
to transfer iterators, sets or sequences between them.


On Sun, 17 Aug 2003, Tuomas Lukka wrote:
> On Sun, Aug 17, 2003 at 04:17:38PM +0300, Tuukka Hastrup wrote:
> > On Sun, 17 Aug 2003, Tuomas Lukka wrote:
> > > Actually, for this purpose, how about 
> > > 
> > >   swamp.util.Iteration.iterateAllNodes(ConstGraph g)
> > > 
> > > for getting all nodes?
> > 
> > Wouldn't it make sense to have it in ConstGraph interface? And it could
> > have iterateAllSubjects and iterateAllObjects as well, and iterateAllNodes
> > would just combine them.
> 
> No, that's not true - there are also predicates.

I didn't think of those, wouldn't that be more like iterateAllURIs? Would
you say they're nodes if they are neither subjects nor objects? Maybe in
some even rarer case would you want to iterate predicates -- eg. if you 
let the user add a statement about "anything existing".

> And we want each node only once.

This I didn't think of neither :-( But you can do filtering while you go 
8-)

> But yes, we could have ConstGraph.findN_Nodes_Iter() if you like.

As I said, I have no current need for such any more. So it would be just 
for completeness. Sorry about the fuss. It wasn't clear to me that "it's 
not complete".

> > Because it's probably generated with findN_X11_Iter, and the method uses
> > it to iterate the nodes.
> 
> Hmm.

It's easy to turn a set or anything into an iterator, but not the other 
way round. Thus it shouldn't matter if a method that needs just an 
iterator takes an iterator, but if a method can simply return a set 
instead of an iterator, it should do that?

> > > So I'm thinking: to do better in that way, we should maybe have
> > > findN_AAX_Set which returns a set of nodes.
> > 
> > Do you mean for all findN methods, or these as a special case?
> 
> All.

At least for HashGraph it would make sense. And implementation looks 
trivial: just remove the iterator() method calls on HashSets.

> > > However, efficiency may be a problem there :(

What do you have in mind, then?

> > In addition to general overhead, at least concatenating two iterators is 
> > simple, but set union I'd imagine is not.
> 
> Both are O(N).

Hmm, at least a new iterator can be created in O(1), and it can be backed 
up by the two iterators. You could look at Traversals to see what I mean.

> > So if you have a non-directed RDF property, your code needs to check both 
> > directions (11X and X11). That is seldom clean in Java (no "for each" 
> > statements). So I made an iterator that simply combines results from 11X 
> > and X11, and use that in my code. Further, we have other code dealing with
> > non-directed properties, and they could be cleaner with the same 
> > technique.
> 
> Problem: you may get the same node twice.

I don't see how that is better if you use 11X and then X11. If it's a 
problem, you can make an iterator that combines, and filters duplicates. 
Or turn the Iterator into a Set and get a new iterator.

In some cases you'll want the node for both 11X and X11, I suppose.

-- 
-- Trying to catch me? Just follow up my Electric Fingerprints
-- To help you: address@hidden
                http://www.iki.fi/Tuukka.Hastrup/
                IRCNet: Stugge/tuukkah @#pii,#fenfire,#ynna
                Jabber ID: address@hidden, ICQ #11321669





reply via email to

[Prev in Thread] Current Thread [Next in Thread]