File size: 7,180 Bytes
ae01f49
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
/////////////////////////////////////////////////////////////
//
// pgAdmin 4 - PostgreSQL Tools
//
// Copyright (C) 2013 - 2024, The pgAdmin Development Team
// This software is released under the PostgreSQL Licence
//
//////////////////////////////////////////////////////////////

/*
 * A map which is used to fetch the image to be drawn and
 * text which will appear below it
 */

const ImageMapper = {
  'Aggregate': {
    'image': 'ex_aggregate.svg',
    'image_text': 'Aggregate',
  },
  'Append': {
    'image': 'ex_append.svg',
    'image_text': 'Append',
  },
  'Bitmap Index Scan': function(data) {
    return {
      'image': 'ex_bmp_index.svg',
      'image_text': data['Index Name'],
    };
  },
  'Bitmap Heap Scan': function(data) {
    return {
      'image': 'ex_bmp_heap.svg',
      'image_text': data['Relation Name'],
    };
  },
  'BitmapAnd': {
    'image': 'ex_bmp_and.svg',
    'image_text': 'Bitmap AND',
  },
  'BitmapOr': {
    'image': 'ex_bmp_or.svg',
    'image_text': 'Bitmap OR',
  },
  'CTE Scan': {
    'image': 'ex_cte_scan.svg',
    'image_text': 'CTE Scan',
  },
  'Function Scan': {
    'image': 'ex_result.svg',
    'image_text': 'Function Scan',
  },
  'Foreign Scan': {
    'image': 'ex_foreign_scan.svg',
    'image_text': 'Foreign Scan',
  },
  'Gather': {
    'image': 'ex_gather_motion.svg',
    'image_text': 'Gather',
  },
  'Gather Merge': {
    'image': 'ex_gather_merge.svg',
    'image_text': 'Gather Merge',
  },
  'Group': {
    'image': 'ex_group.svg',
    'image_text': 'Group',
  },
  'GroupAggregate': {
    'image': 'ex_aggregate.svg',
    'image_text': 'Group Aggregate',
  },
  'Hash': {
    'image': 'ex_hash.svg',
    'image_text': 'Hash',
  },
  'Hash Join': function(data) {
    if (!data['Join Type']) return {
      'image': 'ex_join.svg',
      'image_text': 'Join',
    };
    switch (data['Join Type']) {
    case 'Anti':
      return {
        'image': 'ex_hash_anti_join.svg',
        'image_text': 'Hash Anti Join',
      };
    case 'Semi':
      return {
        'image': 'ex_hash_semi_join.svg',
        'image_text': 'Hash Semi Join',
      };
    default:
      return {
        'image': 'ex_hash.svg',
        'image_text': String('Hash ' + data['Join Type'] + ' Join'),
      };
    }
  },
  'HashAggregate': {
    'image': 'ex_aggregate.svg',
    'image_text': 'Hash Aggregate',
  },
  'Index Only Scan': function(data) {
    return {
      'image': 'ex_index_only_scan.svg',
      'image_text': data['Index Name'],
    };
  },
  'Index Scan': function(data) {
    return {
      'image': 'ex_index_scan.svg',
      'image_text': data['Index Name'],
    };
  },
  'Index Scan Backword': {
    'image': 'ex_index_scan.svg',
    'image_text': 'Index Backward Scan',
  },
  'Limit': {
    'image': 'ex_limit.svg',
    'image_text': 'Limit',
  },
  'LockRows': {
    'image': 'ex_lock_rows.svg',
    'image_text': 'Lock Rows',
  },
  'Materialize': {
    'image': 'ex_materialize.svg',
    'image_text': 'Materialize',
  },
  'Merge Append': {
    'image': 'ex_merge_append.svg',
    'image_text': 'Merge Append',
  },
  'Merge Join': function(data) {
    switch (data['Join Type']) {
    case 'Anti':
      return {
        'image': 'ex_merge_anti_join.svg',
        'image_text': 'Merge Anti Join',
      };
    case 'Semi':
      return {
        'image': 'ex_merge_semi_join.svg',
        'image_text': 'Merge Semi Join',
      };
    default:
      return {
        'image': 'ex_merge.svg',
        'image_text': String('Merge ' + data['Join Type'] + ' Join'),
      };
    }
  },
  'ModifyTable': function(data) {
    switch (data['Operation']) {
    case 'Insert':
      return {
        'image': 'ex_insert.svg',
        'image_text': 'Insert',
      };
    case 'Update':
      return {
        'image': 'ex_update.svg',
        'image_text': 'Update',
      };
    case 'Delete':
      return {
        'image': 'ex_delete.svg',
        'image_text': 'Delete',
      };
    case 'Merge':
      return {
        'image': 'ex_merge.svg',
        'image_text': 'Merge',
      };
    }
  },
  'Named Tuplestore Scan': {
    'image': 'ex_named_tuplestore_scan.svg',
    'image_text': 'Named Tuplestore Scan',
  },
  'Nested Loop': function(data) {
    switch (data['Join Type']) {
    case 'Anti':
      return {
        'image': 'ex_nested_loop_anti_join.svg',
        'image_text': 'Nested Loop Anti Join',
      };
    case 'Semi':
      return {
        'image': 'ex_nested_loop_semi_join.svg',
        'image_text': 'Nested Loop Semi Join',
      };
    default:
      return {
        'image': 'ex_nested.svg',
        'image_text': 'Nested Loop ' + data['Join Type'] + ' Join',
      };
    }
  },
  'ProjectSet': {
    'image': 'ex_projectset.svg',
    'image_text': 'ProjectSet',
  },
  'Recursive Union': {
    'image': 'ex_recursive_union.svg',
    'image_text': 'Recursive Union',
  },
  'Result': {
    'image': 'ex_result.svg',
    'image_text': 'Result',
  },
  'Sample Scan': {
    'image': 'ex_scan.svg',
    'image_text': 'Sample Scan',
  },
  'Scan': {
    'image': 'ex_scan.svg',
    'image_text': 'Scan',
  },
  'Seek': {
    'image': 'ex_seek.svg',
    'image_text': 'Seek',
  },
  'SetOp': function(data) {
    let strategy = data['Strategy'],
      command = data['Command'];

    if (strategy == 'Hashed') {
      if (command.startsWith('Intersect')) {
        if (command == 'Intersect All')
          return {
            'image': 'ex_hash_setop_intersect_all.svg',
            'image_text': 'Hashed Intersect All',
          };
        return {
          'image': 'ex_hash_setop_intersect.svg',
          'image_text': 'Hashed Intersect',
        };
      } else if (command.startsWith('Except')) {
        if (command == 'Except All')
          return {
            'image': 'ex_hash_setop_except_all.svg',
            'image_text': 'Hashed Except All',
          };
        return {
          'image': 'ex_hash_setop_except.svg',
          'image_text': 'Hash Except',
        };
      }
      return {
        'image': 'ex_hash_setop_unknown.svg',
        'image_text': 'Hashed SetOp Unknown',
      };
    }
    return {
      'image': 'ex_setop.svg',
      'image_text': 'SetOp',
    };
  },
  'Seq Scan': function(data) {
    return {
      'image': 'ex_scan.svg',
      'image_text': data['Relation Name'],
    };
  },
  'Subquery Scan': {
    'image': 'ex_subplan.svg',
    'image_text': 'SubQuery Scan',
  },
  'Sort': {
    'image': 'ex_sort.svg',
    'image_text': 'Sort',
  },
  'Tid Scan': {
    'image': 'ex_tid_scan.svg',
    'image_text': 'Tid Scan',
  },
  'Table Function Scan': {
    'image': 'ex_table_func_scan.svg',
    'image_text': 'Table Function Scan',
  },
  'Unique': {
    'image': 'ex_unique.svg',
    'image_text': 'Unique',
  },
  'Values Scan': {
    'image': 'ex_values_scan.svg',
    'image_text': 'Values Scan',
  },
  'WindowAgg': {
    'image': 'ex_window_aggregate.svg',
    'image_text': 'Window Aggregate',
  },
  'WorkTable Scan': {
    'image': 'ex_worktable_scan.svg',
    'image_text': 'WorkTable Scan',
  },
  'Undefined': {
    'image': 'ex_unknown.svg',
    'image_text': 'Undefined',
  },
};

export default ImageMapper;