関数AllPairsShortestPathの関数マッピング定義usr_AllPairsShortestPathは、入力テーブルとパラメータの変数を指定します(TargetKeyの連結変数式など)。
CREATE FUNCTION MAPPING usr_AllPairsShortestPath
FOR AllPairsShortestPath SERVER TD_SERVER_DB.coprocessor
USING
vertices(vertex) IN TABLE ,
edges(edge) IN TABLE ,
sources(source) IN TABLE ,
targets(trgt) IN TABLE ,
TargetKey(GroupColumn||'_'||Distance) ,
EdgeWeight('calls') ,
MaxDistance(Distance) ,
Directed ,GroupSize ,SequenceInputBy;
SELECT文は、変数Distanceの値を指定します。
SELECT * FROM usr_AllPairsShortestPath (
ON callers AS vertices PARTITION BY callerid
ON calls AS edges PARTITION BY callerfrom
USING
Distance ('1')
) as dt ORDER BY source, target;
実行時、このクエリーは次のように書き換えられます。マッピング定義に従って、MaxDistanceはDistanceに置き換えられます。また、EdgeWeightも含まれます(マッピング定義でこのパラメータのデフォルトが指定されるため)。TargetKeyは含まれません(連結変数式のGroupColumn変数が解決されないため)。
SELECT * FROM AllPairsShortestPath (
ON callers AS vertices PARTITION BY callerid
ON calls AS edges PARTITION BY callerfrom
EdgeWeight ('calls')
MaxDistance ('1')
) ORDER BY source, target;