Indexing model changes [message #1828304] |
Sat, 06 June 2020 15:00  |
Eclipse User |
|
|
|
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 #1828349 is a reply to message #1828327] |
Mon, 08 June 2020 05:19   |
Eclipse User |
|
|
|
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 #1829082 is a reply to message #1828612] |
Wed, 24 June 2020 17:36   |
Eclipse User |
|
|
|
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);
}
}
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04982 seconds