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.
  • Constructor Details

  • Method Details

    • 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 interface EObjectIndex
      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 interface EObjectIndex
      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 interface EObjectIndex
      Parameters:
      eObject - the EObject 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 interface EObjectIndex
      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 interface MatchAheadOfTime
      Parameters:
      left - the side to look for.
      Returns:
      the EObjects to match ahead of time.