Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Hawk » Indexing model changes(Track the number of elements added or deleted for each version)
Indexing model changes [message #1828304] Sat, 06 June 2020 19:00 Go to next message
Saheed Popoola is currently offline Saheed PopoolaFriend
Messages: 21
Registered: June 2019
Junior Member
Hi, What is the best way to index changes (such as number of elements added or deleted) in Time-Aware Hawk. For example, when the indexer updates a model, I also want to track other properties like (number of elements added or deleted). Suppose I can generate this properties somewhere but I want the graph to keep track of it, the same way we also keep track of the commit messages or other properties. Would I need a new indexer or model updater?
Re: Indexing model changes [message #1828316 is a reply to message #1828304] Sun, 07 June 2020 11:13 Go to previous messageGo to next message
Antonio Garcia-Dominguez is currently offline Antonio Garcia-DominguezFriend
Messages: 597
Registered: January 2010
Location: Birmingham, UK
Senior Member

Hi Saheed,

Hawk computes some of this information, but its default updater does not store it. You could create a custom updater (based on the current time-aware updater) that stores this additional information in the repository.

In order to use that new updater, you will need to create your own IHawkFactory itself. Let me know if you need help with that!

Kind regards,
Antonio
Re: Indexing model changes [message #1828327 is a reply to message #1828316] Sun, 07 June 2020 17:22 Go to previous messageGo to next message
Saheed Popoola is currently offline Saheed PopoolaFriend
Messages: 21
Registered: June 2019
Junior Member
I can create a new IHawkFactory (I already did that before). Can you state the method/class/ package that computes some of the information . That should be a good hint on how to go about mine.
Thanks.
Re: Indexing model changes [message #1828349 is a reply to message #1828327] Mon, 08 June 2020 09:19 Go to previous messageGo to next message
Antonio Garcia-Dominguez is currently offline Antonio Garcia-DominguezFriend
Messages: 597
Registered: January 2010
Location: Birmingham, UK
Senior Member

GraphModelInserter.calculateModelDeltaRatio computes the ratio of change of a file, measured as the proportion of objects that were added, updated, retyped or deleted in it. To do so, it classifies the various objects in the current file into those categories. Rather than EMF Compare, it uses a signature-based comparison (the signature is computed by the IHawkObject: in EMF it is based on applying SHA1 to its location / type / attributes / references) to detect updated objects.

The TimeAwareModelUpdater has a custom GraphModelInserter which still does this classification, but always returns 0 as the ratio to ensure that updates are always transactional: this way we force Hawk to apply changes incrementally (needed for the temporal graph), rather than do a "batch" update when it deletes the entire file and reindexes it (which is more performant in the non-timeaware case when we just want the latest version).

BTW, you can already see how we store information for the repository node in the TimeAwareIndexer class, using the setIndexedRevision method.
Re: Indexing model changes [message #1828439 is a reply to message #1828349] Tue, 09 June 2020 15:47 Go to previous messageGo to next message
Saheed Popoola is currently offline Saheed PopoolaFriend
Messages: 21
Registered: June 2019
Junior Member
Thanks. This is really helpful.
Re: Indexing model changes [message #1828606 is a reply to message #1828439] Mon, 15 June 2020 04:27 Go to previous messageGo to next message
Saheed Popoola is currently offline Saheed PopoolaFriend
Messages: 21
Registered: June 2019
Junior Member
is there a way to get the previous version of a model (maybe as an emfresource) in the modelupdater. I can see that the filenode in GraphModelInserter.calculateModelDeltaRatio stores this information. How can I extract this infomation as an emfresource or emfmodel in order to compare it with the new resource.
Re: Indexing model changes [message #1828612 is a reply to message #1828606] Mon, 15 June 2020 07:58 Go to previous messageGo to next message
Antonio Garcia-Dominguez is currently offline Antonio Garcia-DominguezFriend
Messages: 597
Registered: January 2010
Location: Birmingham, UK
Senior Member

calculateModelDeltaRatio does not use EMF or EMF Compare at all - as I said above, it uses a signature-based approach to detect changes. If you only want to count the number of changes, that would be enough: you don't need to do any additional comparisons.

However, if you really need to use EMF Compare, the .emfresource plugin has a LocalHawkResourceImpl class that provides a read-only EMF resource view over a Hawk graph (it's the same one as for .localhawkmodel files). Before the updater changes the graph, the graph should reflect the previous version of the model (if present). You could cast down the IHawkResource that Hawk is currently processing to an EmfResource, and then get the underlying EMF resource for the new version of the model, then run the comparison. LocalHawkResourceImpl accepts a number of repoPatterns and filePatterns that can limit the scope of the resource.
Re: Indexing model changes [message #1829082 is a reply to message #1828612] Wed, 24 June 2020 21:36 Go to previous messageGo to next message
Saheed Popoola is currently offline Saheed PopoolaFriend
Messages: 21
Registered: June 2019
Junior Member
I'm having issues with the query. When I called the function "ChangeNode repNode = new ChangeManager((ITimeAwareGraphDatabase) graph).getOrCreateChangeNode();" from the query language, it returns a different node (with different id and null info), but when I called it within the setIndexedChanges in my custom indexer, it returns the real node. What could be wrong? Note, the repositoryNode for commit messages works fine in the Query language. Here is my code snippets.
public void setIndexedChanges(Collection<DiffChange> change) throws Exception {
try (IGraphTransaction tx = graph.beginTransaction()) {
ChangeManager manager = new ChangeManager((ITimeAwareGraphDatabase) graph);
ChangeNode repoNode = manager.getOrCreateChangeNode();
repo.setAdd(my variable);
tx.success();
}
ChangeNode repNode = new ChangeManager((ITimeAwareGraphDatabase) graph).getOrCreateChangeNode();
}
//constructor for ChangeManager
public ChangeManager(ITimeAwareGraphDatabase db) {
this.db = db;
this.idx = db.getOrCreateNodeIndex("_hawkChangeIndex");
}

//getorCreateChangeNode method
public ChangeNode getOrCreateChangeNode() {
String repoURI ="_hawkChangerrr";
String URI_PROPERTY = "uri";
IGraphIterable<? extends IGraphNode> iNode = idx.get(URI_PROPERTY, repoURI);
if (iNode.size() > 0) {
return new ChangeNode((ITimeAwareGraphNode) iNode.getSingle());
} else {
final ITimeAwareGraphNode node = db.createNode(
Collections.singletonMap(URI_PROPERTY, repoURI), "_hawkChanger");
idx.add(node, URI_PROPERTY, repoURI);
return new ChangeNode(node);
}
}
Re: Indexing model changes [message #1829148 is a reply to message #1829082] Thu, 25 June 2020 21:51 Go to previous messageGo to next message
Saheed Popoola is currently offline Saheed PopoolaFriend
Messages: 21
Registered: June 2019
Junior Member
for every query I run in the UI (after the indexing); it firsts create a new node (instead of retrieving an existing node) which indicates that the original node may not be in the database. So it only has the URI_PROPERTY which is stated in the function getOrCreateChangeNode().

[Updated on: Fri, 26 June 2020 04:00]

Report message to a moderator

Re: Indexing model changes [message #1829163 is a reply to message #1829148] Fri, 26 June 2020 07:59 Go to previous messageGo to next message
Antonio Garcia-Dominguez is currently offline Antonio Garcia-DominguezFriend
Messages: 597
Registered: January 2010
Location: Birmingham, UK
Senior Member

You have to be careful with the timepoint that the ITimeAwareGraphDatabase is at when you create the node. If the timepoint of the graph is X when you create the node, then it will only be available from X onwards.

Could you double check the result of ((ITimeAwareGraphDatabase)graph).getTime() in both places?
Re: Indexing model changes [message #1829206 is a reply to message #1829163] Sat, 27 June 2020 19:16 Go to previous messageGo to next message
Saheed Popoola is currently offline Saheed PopoolaFriend
Messages: 21
Registered: June 2019
Junior Member
I don't think its about the timepoint. I feel like maybe I need to register something. When I used the exact values as these 3 variables in VCSManagerIndex.getOrCreateRepositoryNode(), it works perfectly fine, although it also means it is the same node that will be used for both my ChangeNode and the TimeAware RepositoryNode. The three variables are the String RepoURL, URI_PROPERTY (i.e "uri") and the "_hawkVCSIndex" for the node index. I'm using this approach for now, until I can figure out what is going on.

Thanks
Re: Indexing model changes [message #1829236 is a reply to message #1829206] Mon, 29 June 2020 12:26 Go to previous message
Antonio Garcia-Dominguez is currently offline Antonio Garcia-DominguezFriend
Messages: 597
Registered: January 2010
Location: Birmingham, UK
Senior Member

No problem! If you'd like to revisit it later, let me know :-).
Previous Topic:Reporting failures via Thrift Client
Next Topic:Tracking deleted model elements
Goto Forum:
  


Current Time: Fri May 24 19:32:14 GMT 2024

Powered by FUDForum. Page generated in 0.04831 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top