*
* @param node the node to be split
* @param distanceFunction the distance function
*/
private void promote(N node, DistanceQuery<O, D> distanceFunction) {
DBID firstPromoted = null;
DBID secondPromoted = null;
// choose first and second routing object
D currentMaxDist = distanceFunction.nullDistance();
for(int i = 0; i < node.getNumEntries(); i++) {
DBID id1 = node.getEntry(i).getRoutingObjectID();
for(int j = i + 1; j < node.getNumEntries(); j++) {
DBID id2 = node.getEntry(j).getRoutingObjectID();
D distance = distanceFunction.distance(id1, id2);
if(distance.compareTo(currentMaxDist) >= 0) {
firstPromoted = id1;
secondPromoted = id2;
currentMaxDist = distance;
}
}
}
// partition the entries
List<DistanceEntry<D, E>> list1 = new ArrayList<DistanceEntry<D, E>>();
List<DistanceEntry<D, E>> list2 = new ArrayList<DistanceEntry<D, E>>();
for(int i = 0; i < node.getNumEntries(); i++) {
DBID id = node.getEntry(i).getRoutingObjectID();
D d1 = distanceFunction.distance(firstPromoted, id);
D d2 = distanceFunction.distance(secondPromoted, id);
list1.add(new DistanceEntry<D, E>(node.getEntry(i), d1, i));
list2.add(new DistanceEntry<D, E>(node.getEntry(i), d2, i));