Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
annick
Contributor III
Contributor III

Optimize ApplyMap

Hello,

 

I am using the following load script with the ApplyMap function :

Map_a_to_b:
Mapping LOAD
*
Inline
[
map_a, map_b
0, 0
1, 1
2, 2
3, 3
4, 4
5, 5
6, 6
7, 7
8, 8
9, 9
10, 10
11, 11
12, 12
13, 13
14, 14,
15, 15
16, 16
17, 17,
18, 18
19, 19
20, 20
21, 21
22, 22
23, 23
24, 24
25, 25
26, 27
28, 28
29, 29
30, 30
31, 30
32, 30
33, 30
34, 30
35, 30
36, 30
37, 37
38, 37
39, 37
40, 37
41, 37
42, 37
43, 37
44, 44
45, 44
46, 44
47, 44
48, 44
49, 44
50, 44
51, 51
52, 51
53, 51
54, 51
55, 51
56, 51
57, 51
57, 51
58 ,58
59 ,58
60 ,58
61 ,58
62 ,58
63 ,58
64 ,58
65 ,65
66 ,65
67 ,65
68 ,65
69 ,65
70 ,65
71 ,65
72 ,72
73 ,72
74 ,72
75 ,72
76 ,72
77 ,72
78 ,72
79 ,79
80 ,79
81 ,79
82 ,79
83 ,79
84 ,79
85 ,79
86 ,86
87 ,86
88 ,86
89 ,86
90 ,86
91 ,86
92 ,86
93 ,86
94 ,86
95 ,86
96 ,86
97 ,86
98 ,86
99 ,86
100 ,100
101 ,100
102 ,100
103 ,100
104 ,100
105 ,100
106 ,100
107 ,100
108 ,100
109 ,100
110 ,100
111 ,100
112 ,100
113 ,100
114, 114
115, 114
116, 114
117, 114
118, 114
119, 114
120, 114
121, 114
122, 114
123, 114
124, 114
125, 114
126, 114
127, 114
128, 128
129, 128
130, 128
131, 128
132, 128
133, 128
134, 128
135, 128
136, 128
137, 128
138, 128
139, 128
140, 128
141, 128
142, 142
143, 142
144, 142
145, 142
146, 142
147, 142
148, 142
149, 142
150, 142
151, 142
152, 142
153, 142
154, 142
155, 142
156, 156
157, 156
158, 156
159, 156
160, 156
161, 156
162, 156
163, 156
164, 156
165, 156
166, 156
167, 156
168, 156
169, 156
170, 170
171, 170
172, 170
173, 170
174, 170
175, 170
176, 170
177, 170
178, 170
179, 170
180, 170
181, 170
182, 170
183, 170
184, 170
185, 170
186, 170
187, 170
188, 170
189, 170
190, 170
191, 170
192, 170
193, 170
194, 170
195, 170
196, 170
197, 170
198, 170
199, 170
200,200
201,200
202,200
203,200
204,200
205,200
206,200
207,200
208,200
209,200
210,200
211,200
212,200
213,200
214,200
215,200
216,200
217,200
218,200
219,200
220,200
221,200
222,200
223,200
224,200
225,200
226,200
227,200
228 ,200
229 ,200
230 ,230
231 ,230
232 ,230
233 ,230
234 ,230
235 ,230
236 ,230
237 ,230
238 ,230
239 ,230
240 ,230
241 ,230
242 ,230
243 ,230
244 ,230
245 ,230
246 ,230
247 ,230
248 ,230
249 ,230
250 ,230
251 ,230
252 ,230
253 ,230
254 ,230
255 ,230
256 ,230
257 ,230
258 ,230
259 ,230
260 ,260
261 ,260
262 ,260
263 ,260
264 ,260
265 ,260
266 ,260
267 ,260
268 ,260
269 ,260
270 ,260
271 ,260
272 ,260
273 ,260
274 ,260
275 ,260
276 ,260
277 ,260
278 ,260
279 ,260
280 ,260
281 , 260
282 , 260
283 , 260
284 , 260
285 , 260
286 , 260
287 , 260
288 , 260
289 , 260
290, 290
291, 290
292, 290
293, 290
294, 290
295, 290
296, 290
297, 290
298, 290
299, 290
300,290
301,290
302,290
303,290
304,290
305,290
306,290
307,290
308,290
309,290
310,290
311,290
312,290
313,290
314,290
315,290
316,290
317,290
318,290
319 ,290
320 ,320
321 ,320
322 ,320
323 ,320
324 ,320
325 ,320
326 ,320
327 ,320
328 ,320
329 ,320
330 ,320
331 ,320
332 ,320
333 ,320
334 ,320
335 ,320
336 ,320
337 ,320
338 ,320
339 ,320
340 ,320
341 ,320
342 ,320
343 ,320
344 ,320
345 ,320
346 ,320
347 ,320
348 ,320
349 ,320
350, 350
351, 350
352, 350
353, 350
354, 350
355, 350
356, 350
357, 350
358, 350
359, 350
360, 350
361, 350
362, 350
363, 350
364, 350
365, 350
];

 

sales:
Load*,
ApplyMap('Map_a_to_b', a) as b;
LOAD
* Inline [
Id, product, NbSales, Amount, a
0, Dress, 1, 100, 0
1, Pants, 1, 50, 1
2, Dress, 1, 100, 2
3, Pants, 1, 50, 3
4, Pants, 1, 50, 200
5, Dress, 1, 100, 201
6, Pants, 1, 50, 203
7, Dress, 1, 100, 361
8, Pants, 1, 50, 362
9, Pants, 1, 50, 363
];

 

Is there a way to optimize the above code for the ApplyMap function?

 

Thanks a lot

Annick

 

Labels (1)
1 Reply
Or
MVP
MVP

What about that code isn't already optimized? It's just a long list, not suboptimal, near as I can tell. You could get rid of all the identical pairings and use the third parameter for ApplyMap to fetch the original value, I suppose, and make it shorter, but it wouldn't impact performance.

ApplyMap('Map_a_to_b', a,a) as b;