Class ProximityIndex
- java.lang.Object
-
- org.eclipse.emf.compare.match.eobject.internal.ProximityIndex
-
- All Implemented Interfaces:
EObjectIndex
,MatchAheadOfTime
public class ProximityIndex extends Object implements EObjectIndex, MatchAheadOfTime
This class is responsible for holding several version of EObjects from sides left, right or origins and provides the ability to return the closest instance (from a difference side) of a given EObject. The implementation expects that the queried EObjects have all been indexed before a query is done. The implementation also expects that when you're done with an EObject and if you don't want to get it back in the result of subsequent queries, the EObject is removed.
The scalability of this class will highly depend on the given distance function, especially with calls having a max distance of 0.
It is also based on the assumption that it is very likely that the EObject has another version with e distance of value 0 in the other versions sets.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.eclipse.emf.compare.match.eobject.EObjectIndex
EObjectIndex.Side
-
-
Constructor Summary
Constructors Constructor Description ProximityIndex(ProximityEObjectMatcher.DistanceFunction meter, ScopeQuery matcher)
Create a newProximityIndex
using the given distance function.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Map<EObjectIndex.Side,EObject>
findClosests(Comparison inProgress, EObject eObj, EObjectIndex.Side passedObjectSide)
Return the closest EObjects found in other sides than the one given.Collection<EObject>
getValuesStillThere(EObjectIndex.Side side)
return the list of EObjects of a given side still available in the index.Iterable<EObject>
getValuesToMatchAhead(EObjectIndex.Side left)
Return EObjects to match ahead of time if there are some.void
index(EObject eObject, EObjectIndex.Side side)
Register an Object in the index with the given side.void
remove(EObject obj, EObjectIndex.Side side)
Remove an object from the index.
-
-
-
Constructor Detail
-
ProximityIndex
public ProximityIndex(ProximityEObjectMatcher.DistanceFunction meter, ScopeQuery matcher)
Create a newProximityIndex
using the given distance function.- Parameters:
meter
- the distance function to use to compare the EObjects.matcher
- the object used to know if an instance is in the scope or not.
-
-
Method Detail
-
findClosests
public Map<EObjectIndex.Side,EObject> findClosests(Comparison inProgress, EObject eObj, EObjectIndex.Side passedObjectSide)
Return the closest EObjects found in other sides than the one given.- Specified by:
findClosests
in interfaceEObjectIndex
- Parameters:
inProgress
- the comparison currently being computed. It will not be changed directly but only queried to know if some element has already been matched or not.eObj
- the base EObject used to lookup similar ones.passedObjectSide
- the side of the passed EObject.- Returns:
- a map of Side, EObjects, returning all the found objects (and the passed one) which are the closests.
-
remove
public void remove(EObject obj, EObjectIndex.Side side)
Remove an object from the index.- Specified by:
remove
in interfaceEObjectIndex
- Parameters:
obj
- object to remove.side
- Side in which this object was.
-
index
public void index(EObject eObject, EObjectIndex.Side side)
Register an Object in the index with the given side.- Specified by:
index
in interfaceEObjectIndex
- Parameters:
eObject
- theEObject
to register.side
- the side in which it should be registered.
-
getValuesStillThere
public Collection<EObject> getValuesStillThere(EObjectIndex.Side side)
return the list of EObjects of a given side still available in the index.- Specified by:
getValuesStillThere
in interfaceEObjectIndex
- Parameters:
side
- the side we are looking for.- Returns:
- the list of EObjects of a given side still available in the index.
-
getValuesToMatchAhead
public Iterable<EObject> getValuesToMatchAhead(EObjectIndex.Side left)
Return EObjects to match ahead of time if there are some.- Specified by:
getValuesToMatchAhead
in interfaceMatchAheadOfTime
- Parameters:
left
- the side to look for.- Returns:
- the EObjects to match ahead of time.
-
-