@@ -41,10 +41,86 @@ const ImageMapper = {
4141 'image' : 'ex_bmp_or.svg' ,
4242 'image_text' : 'Bitmap OR' ,
4343 } ,
44+ 'Citus Job' : function ( data ) {
45+ // A 'Citus Job' represents a distributed query operation.
46+ // The details of the distributed operation are in the sub-plans,
47+ // but this node contains task count information, showing how many shards
48+ // the query is being distributed to.
49+
50+ const taskCount = data [ 'Task Count' ] ;
51+ const tasksShown = data [ 'Tasks Shown' ] ;
52+
53+ // "Task Count" is the number of shard operations being run.
54+ // "Tasks Shown" is either "All" or "One of N" depending on whether the returned query plan
55+ // contains one sample task or all of them.
56+
57+ // We show single-shard or multi-shard with different images, and we show the
58+ // literal value of 'Tasks Shown' as the image text.
59+
60+ const image = ( taskCount === 1 )
61+ ? 'ex_citus_distributed_one_of_one.svg'
62+ : 'ex_citus_distributed_one_of_many.svg' ;
63+
64+ return {
65+ 'image' : image ,
66+ 'image_text' : tasksShown
67+ } ;
68+ } ,
69+ 'Citus Task' : function ( data ) {
70+ // A 'Citus Task' represents a Task executed on a particular worker node.
71+ // The details of the Task are in the sub-plans, so for this node we just show
72+ // some details of the worker node.
73+
74+ const node = data [ 'Node' ] ;
75+ // "Node" has a value like "host=citus-worker-7 port=8394 dbname=postgres"
76+ // That's a bit long to display, so we shrink it to 'citus-worker-7:8394 postgres'
77+ const hostMatch = node . match ( / h o s t = ( \S + ) / ) ;
78+ const portMatch = node . match ( / p o r t = ( \S + ) / ) ;
79+ const dbnameMatch = node . match ( / d b n a m e = ( \S + ) / ) ;
80+
81+ const host = hostMatch ? hostMatch [ 1 ] : '' ;
82+ let port = portMatch ? portMatch [ 1 ] : '' ;
83+ if ( port === '5432' ) {
84+ // Default port. Don't bother showing.
85+ port = '' ;
86+ }
87+ const dbname = dbnameMatch ? dbnameMatch [ 1 ] : '' ;
88+
89+ let imageText = `Task ${ host } ` ;
90+ if ( port ) {
91+ imageText += `:${ port } ` ;
92+ }
93+ if ( dbname ) {
94+ imageText += ` ${ dbname } ` ;
95+ }
96+ return {
97+ 'image' : 'ex_citus_worker_task.svg' ,
98+ 'image_text' : imageText
99+ } ;
100+ } ,
44101 'CTE Scan' : {
45102 'image' : 'ex_cte_scan.svg' ,
46103 'image_text' : 'CTE Scan' ,
47104 } ,
105+ 'Custom Scan' : function ( data ) {
106+ const customPlanProvider = data [ 'Custom Plan Provider' ] ;
107+
108+ let image ;
109+
110+ switch ( customPlanProvider ) {
111+ case 'Citus Adaptive' :
112+ image = 'ex_citus.svg' ;
113+ break ;
114+ default :
115+ image = 'ex_unknown.svg' ;
116+ break ;
117+ }
118+
119+ return {
120+ 'image' : image ,
121+ 'image_text' : data [ 'Custom Plan Provider' ]
122+ } ;
123+ } ,
48124 'Function Scan' : {
49125 'image' : 'ex_result.svg' ,
50126 'image_text' : 'Function Scan' ,
0 commit comments