-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
679 lines (545 loc) · 48.8 KB
/
index.html
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
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
<!DOCTYPE html>
<html lang="en" prefix="og: http://ogp.me/ns# fb: https://www.facebook.com/2008/fbml">
<head>
<title>Stackdiver as a Service</title>
<!-- Using the latest rendering mode for IE -->
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="canonical" href="https://www.lyh.me">
<meta name="author" content="Neville Li" />
<!-- Open Graph tags -->
<meta property="og:site_name" content="Stackdiver as a Service" />
<meta property="og:type" content="website"/>
<meta property="og:title" content="Stackdiver as a Service"/>
<meta property="og:url" content="https://www.lyh.me"/>
<meta property="og:description" content="Stackdiver as a Service"/>
<!-- Bootstrap -->
<link rel="stylesheet" href="https://www.lyh.me/theme/css/bootstrap.min.css" type="text/css"/>
<link href="https://www.lyh.me/theme/css/font-awesome.min.css" rel="stylesheet">
<link href="https://www.lyh.me/theme/css/pygments/monokai.css" rel="stylesheet">
<link href="https://www.lyh.me/theme/css/typogrify.css" rel="stylesheet">
<link rel="stylesheet" href="https://www.lyh.me/theme/css/style.css" type="text/css"/>
<link href="https://www.lyh.me/feeds/all.atom.xml" type="application/atom+xml" rel="alternate"
title="Stackdiver as a Service ATOM Feed"/>
</head>
<body>
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a href="https://www.lyh.me/" class="navbar-brand">
Stackdiver as a Service </a>
</div>
<div class="collapse navbar-collapse navbar-ex1-collapse">
<ul class="nav navbar-nav">
<li><a href="https://www.lyh.me/pages/about-me.html">
About Me
</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
</div> <!-- /.navbar -->
<!-- Banner -->
<!-- End Banner -->
<!-- Content Container -->
<div class="container">
<div class="row">
<div class="col-sm-9">
<article>
<h2><a href="https://www.lyh.me/magnolify.html">Magnolify</a></h2>
<div class="well well-sm">
<footer class="post-info">
<span class="label label-default">Date</span>
<span class="published">
<i class="fa fa-calendar"></i><time datetime="2020-03-14T10:33:00-04:00"> Sat 14 March 2020</time>
</span>
<span class="label label-default">Category</span>
<a href="https://www.lyh.me/category/code.html">code</a>
<span class="label label-default">Tags</span>
<a href="https://www.lyh.me/tag/scala.html">scala</a>
/
<a href="https://www.lyh.me/tag/fp.html">fp</a>
/
<a href="https://www.lyh.me/tag/data.html">data</a>
</footer><!-- /.post-info --> </div>
<div class="summary"><p>It’s been a while since I last posted or given talks on new content. I atteneded <a href="https://nescala.io/">Northeast Scala Symposium 2020</a> virtually last week and talked about some interested learnings from type class derivation with <a href="https://github.com/propensive/magnolia">Magnolia</a> with my coworker Claire M. Most of the code are open sourced in <a href="https://github.com/spotify/magnolify">Magnolify</a>. Here are the <a href="/slides/magnolify.html">slides</a>.</p>
<iframe src="/slides/magnolify.html" width="800" height="450"></iframe>
<a class="btn btn-default btn-xs" href="https://www.lyh.me/magnolify.html">more ...</a>
</div>
</article>
<hr/>
<article>
<h2><a href="https://www.lyh.me/featran.html">Featran</a></h2>
<div class="well well-sm">
<footer class="post-info">
<span class="label label-default">Date</span>
<span class="published">
<i class="fa fa-calendar"></i><time datetime="2017-12-11T13:58:00-05:00"> Mon 11 December 2017</time>
</span>
<span class="label label-default">Category</span>
<a href="https://www.lyh.me/category/code.html">code</a>
<span class="label label-default">Tags</span>
<a href="https://www.lyh.me/tag/scala.html">scala</a>
/
<a href="https://www.lyh.me/tag/fp.html">fp</a>
/
<a href="https://www.lyh.me/tag/data.html">data</a>
/
<a href="https://www.lyh.me/tag/ml.html">ml</a>
</footer><!-- /.post-info --> </div>
<div class="summary"><p>Featran is a Scala feature transformation library for data science and machine learning. We recently open sourced it and I gave talks at <a href="http://scale.bythebay.io/">Scale By the Bay</a> and <a href="http://www.criteo.com/events/nabdconf-palo-alto/">NABDConf</a>. Here are the <a href="/slides/featran.html">slides</a>.</p>
<iframe src="/slides/featran.html" width="800" height="450"></iframe>
<a class="btn btn-default btn-xs" href="https://www.lyh.me/featran.html">more ...</a>
</div>
</article>
<hr/>
<article>
<h2><a href="https://www.lyh.me/automatic-type-class-derivation-with-shapeless.html">Automatic type-class derivation with Shapeless</a></h2>
<div class="well well-sm">
<footer class="post-info">
<span class="label label-default">Date</span>
<span class="published">
<i class="fa fa-calendar"></i><time datetime="2017-08-21T09:30:00-04:00"> Mon 21 August 2017</time>
</span>
<span class="label label-default">Category</span>
<a href="https://www.lyh.me/category/code.html">code</a>
<span class="label label-default">Tags</span>
<a href="https://www.lyh.me/tag/scala.html">scala</a>
/
<a href="https://www.lyh.me/tag/fp.html">fp</a>
</footer><!-- /.post-info --> </div>
<div class="summary"><p>We had a knowledge sharing session at work recently on <a href="https://github.com/milessabin/shapeless/">Shapeless</a> for automatic type class derivation. Here is a little write-up for the topic.</p>
<h2>Scala List</h2>
<p>First let’s review how <code>List</code> works in Scala. A <code>List</code> is a linked list with <code>head</code> and <code>tail</code>, plus <code>Nil</code> for empty list. It can be represented with the following abstract data type:</p>
<div class="highlight"><pre><span></span><code><span class="k">sealed</span> <span class="k">trait</span> <span class="nc">List</span><span class="o">[</span><span class="kt">+A</span><span class="o">]</span> <span class="o">{</span>
<span class="k">def</span> <span class="o">::[</span><span class="kt">B</span> <span class="k">>:</span> <span class="kt">A</span><span class="o">](</span><span class="n">head</span><span class="k">:</span> <span class="kt">B</span><span class="o">)</span><span class="k">:</span> <span class="kt">List</span><span class="o">[</span><span class="kt">B</span><span class="o">]</span> <span class="k">=</span> <span class="nc">Cons</span><span class="o">(</span><span class="n">head</span><span class="o">,</span> <span class="k">this</span><span class="o">)</span>
<span class="o">}</span>
<span class="k">case</span> <span class="k">object</span> <span class="nc">Nil</span> <span class="k">extends</span> <span class="nc">List</span><span class="o">[</span><span class="kt">Nothing</span><span class="o">]</span> <span class="c1">// Nothing is a sub-type of every other type</span>
<span class="k">case</span> <span class="k">class</span> <span class="nc">Cons</span><span class="o">[</span><span class="kt">+A</span><span class="o">](</span><span class="n">head</span><span class="k">:</span> <span class="kt">A</span><span class="o">,</span> <span class="n">tail</span><span class="k">:</span> <span class="kt">List</span><span class="o">[</span><span class="kt">A</span><span class="o">])</span> <span class="k">extends</span> <span class="nc">List</span><span class="o">[</span><span class="kt">A</span><span class="o">]</span>
</code></pre></div>
<p>Notice that <code>::</code>, the list concatenation operation, is just a method on trait <code>List[+A]</code>. Since Scala operators that end with <code>:</code> are right-associative, we can conveniently create lists by chaining multiple <code>::</code>s. Therefore the following expressions are equivalent:</p>
<div class="highlight"><pre><span></span><code><span class="mi">1</span> <span class="o">::</span> <span class="mi">2</span> <span class="o">::</span> <span class="nc">Nil</span>
<span class="mi">1</span> <span class="o">::</span> <span class="o">(</span><span class="mi">2</span> <span class="o">::</span> <span class="nc">Nil</span><span class="o">)</span>
<span class="nc">Nil</span><span class="o">.::(</span><span class="mi">2</span><span class="o">).::(</span><span class="mi">1</span><span class="o">)</span>
<span class="nc">Cons</span><span class="o">(</span><span class="mi">1</span><span class="o">,</span> <span class="nc">Cons</span><span class="o">(</span><span class="mi">2</span><span class="o">,</span> <span class="nc">Nil</span><span class="o">))</span>
</code></pre></div>
<p>It’s important to point out here that Scala <code>List</code> is homogeneous, i.e. it has a single type parameter <code>A</code> and thus can only store elements of <code>A</code> and its sub-types. On the other hand, it can have varying numbers of elements at runtime.</p>
<h2>Shapeless HList</h2>
<p>Since <code>List …</code></p>
<a class="btn btn-default btn-xs" href="https://www.lyh.me/automatic-type-class-derivation-with-shapeless.html">more ...</a>
</div>
</article>
<hr/>
<article>
<h2><a href="https://www.lyh.me/lambda-serialization.html">Lambda serialization</a></h2>
<div class="well well-sm">
<footer class="post-info">
<span class="label label-default">Date</span>
<span class="published">
<i class="fa fa-calendar"></i><time datetime="2017-08-01T13:51:00-04:00"> Tue 01 August 2017</time>
</span>
<span class="label label-default">Category</span>
<a href="https://www.lyh.me/category/code.html">code</a>
<span class="label label-default">Tags</span>
<a href="https://www.lyh.me/tag/scala.html">scala</a>
/
<a href="https://www.lyh.me/tag/scio.html">scio</a>
/
<a href="https://www.lyh.me/tag/data.html">data</a>
</footer><!-- /.post-info --> </div>
<div class="summary"><p>Lambda serialization is one of the more confusion issues in distributed data processing in Scala. No matter which framework you choose, whether it’s Scalding, Spark, Flink or Scio, sooner or later you’ll be hit by the dreaded <code>NotSerializableException</code>. In this post we’ll take a closer look at the common causes and solutions to this problem.</p>
<h2>Setup</h2>
<p>To demonstrate the problem, first we need a minimal setup that minics the behavior of a distributed data processing system. We start with a utility method that roundtrips an object throguh Java serialization. Anonymous functions, or lambdas, in such systems are serialized so that they can be distributed to workers for parallel processing.</p>
<div class="highlight"><pre><span></span><code><span class="k">import</span> <span class="nn">java.io.</span><span class="o">{</span><span class="nc">ByteArrayInputStream</span><span class="o">,</span> <span class="nc">ByteArrayOutputStream</span><span class="o">,</span> <span class="nc">ObjectInputStream</span><span class="o">,</span> <span class="nc">ObjectOutputStream</span><span class="o">}</span>
<span class="k">object</span> <span class="nc">SerDeUtil</span> <span class="o">{</span>
<span class="k">def</span> <span class="n">serDe</span><span class="o">[</span><span class="kt">T</span><span class="o">](</span><span class="n">obj</span><span class="k">:</span> <span class="kt">T</span><span class="o">)</span><span class="k">:</span> <span class="kt">T</span> <span class="o">=</span> <span class="o">{</span>
<span class="k">val</span> <span class="n">buffer</span> <span class="k">=</span> <span class="k">new</span> <span class="nc">ByteArrayOutputStream</span><span class="o">()</span>
<span class="k">val</span> <span class="n">out</span> <span class="k">=</span> <span class="k">new</span> <span class="nc">ObjectOutputStream</span><span class="o">(</span><span class="n">buffer</span><span class="o">)</span>
<span class="n">out</span><span class="o">.</span><span class="n">writeObject</span><span class="o">(</span><span class="n">obj</span><span class="o">)</span>
<span class="n">out</span><span class="o">.</span><span class="n">close</span><span class="o">()</span>
<span class="k">val</span> <span class="n">in</span> <span class="k">=</span> <span class="k">new</span> <span class="nc">ObjectInputStream</span><span class="o">(</span><span class="k">new</span> <span class="nc">ByteArrayInputStream</span><span class="o">(</span><span class="n">buffer</span><span class="o">.</span><span class="n">toByteArray</span><span class="o">))</span>
<span class="n">in</span><span class="o">.</span><span class="n">readObject</span><span class="o">().</span><span class="n">asInstanceOf</span><span class="o">[</span><span class="kt">T</span><span class="o">]</span>
<span class="o">}</span>
<span class="o">}</span>
</code></pre></div>
<p>Next we create a bare minimal <code>Collection[T]</code> type that mimics an abstract distributed data set, akin to <code>TypedPipe</code>, <code>RDD</code>, or <code>SCollection</code> in Scalding, Spark or Scio respectively. Our implementation is backed by a local in-memory <code>Seq[T]</code> but does pass the function <code>f</code> through serialization like …</p>
<a class="btn btn-default btn-xs" href="https://www.lyh.me/lambda-serialization.html">more ...</a>
</div>
</article>
<hr/>
<article>
<h2><a href="https://www.lyh.me/lawfulness-of-aggregatebykey.html">Lawfulness of aggregateByKey</a></h2>
<div class="well well-sm">
<footer class="post-info">
<span class="label label-default">Date</span>
<span class="published">
<i class="fa fa-calendar"></i><time datetime="2017-07-19T11:23:00-04:00"> Wed 19 July 2017</time>
</span>
<span class="label label-default">Category</span>
<a href="https://www.lyh.me/category/code.html">code</a>
<span class="label label-default">Tags</span>
<a href="https://www.lyh.me/tag/scala.html">scala</a>
/
<a href="https://www.lyh.me/tag/scio.html">scio</a>
/
<a href="https://www.lyh.me/tag/data.html">data</a>
/
<a href="https://www.lyh.me/tag/fp.html">fp</a>
</footer><!-- /.post-info --> </div>
<div class="summary"><p>I spent a couple hours yesterday debugging what I thought was a Protobuf serialization issue, which turns out to be an unlawful Monoid-like use of <code>aggregateByKey</code> in <a href="https://github.com/spotify/scio">Scio</a>.</p>
<h2>The Problem</h2>
<p>Both Scio and Spark have <code>aggregate</code> and <code>aggregateByKey</code> transformations that look like this:</p>
<div class="highlight"><pre><span></span><code><span class="c1">// on SCollection[V]</span>
<span class="k">def</span> <span class="n">aggregate</span><span class="o">[</span><span class="kt">U</span><span class="o">](</span><span class="n">zeroValue</span><span class="k">:</span> <span class="kt">U</span><span class="o">)(</span><span class="n">seqOp</span><span class="k">:</span> <span class="o">(</span><span class="kt">U</span><span class="o">,</span> <span class="kt">V</span><span class="o">)</span> <span class="k">=></span> <span class="n">U</span><span class="o">,</span> <span class="n">combOp</span><span class="k">:</span> <span class="o">(</span><span class="kt">U</span><span class="o">,</span> <span class="kt">U</span><span class="o">)</span> <span class="k">=></span> <span class="n">U</span><span class="o">)</span><span class="k">:</span> <span class="kt">SCollection</span><span class="o">[</span><span class="kt">U</span><span class="o">]</span>
<span class="c1">// on SCollection[(K, V)]</span>
<span class="k">def</span> <span class="n">aggregateByKey</span><span class="o">[</span><span class="kt">U</span><span class="o">](</span><span class="n">zeroValue</span><span class="k">:</span> <span class="kt">U</span><span class="o">)(</span><span class="n">seqOp</span><span class="k">:</span> <span class="o">(</span><span class="kt">U</span><span class="o">,</span> <span class="kt">V</span><span class="o">)</span> <span class="k">=></span> <span class="n">U</span><span class="o">,</span> <span class="n">combOp</span><span class="k">:</span> <span class="o">(</span><span class="kt">U</span><span class="o">,</span> <span class="kt">U</span><span class="o">)</span> <span class="k">=></span> <span class="n">U</span><span class="o">)</span><span class="k">:</span> <span class="kt">SCollection</span><span class="o">[(</span><span class="kt">K</span><span class="p">,</span> <span class="kt">U</span><span class="o">)]</span>
</code></pre></div>
<p>And we have some business logic that looks like this:</p>
<div class="highlight"><pre><span></span><code><span class="k">case</span> <span class="k">class</span> <span class="nc">Count</span><span class="o">(</span><span class="n">id</span><span class="k">:</span> <span class="kt">String</span><span class="o">,</span> <span class="n">count</span><span class="k">:</span> <span class="kt">Int</span><span class="o">)</span>
<span class="k">val</span> <span class="n">z</span> <span class="k">=</span> <span class="nc">Count</span><span class="o">(</span><span class="s">""</span><span class="o">,</span> <span class="mi">0</span><span class="o">)</span> <span class="c1">// zeroValue</span>
<span class="k">def</span> <span class="n">seqOp</span><span class="o">(</span><span class="n">acc</span><span class="k">:</span> <span class="kt">Count</span><span class="o">,</span> <span class="n">v</span><span class="k">:</span> <span class="kt">Count</span><span class="o">)</span> <span class="k">=</span> <span class="nc">Count</span><span class="o">(</span><span class="n">v</span><span class="o">.</span><span class="n">id</span><span class="o">,</span> <span class="n">acc</span><span class="o">.</span><span class="n">count</span> <span class="o">+</span> <span class="n">v</span><span class="o">.</span><span class="n">count</span><span class="o">)</span>
<span class="k">def</span> <span class="n">combOp</span><span class="o">(</span><span class="n">x</span><span class="k">:</span> <span class="kt">Count</span><span class="o">,</span> <span class="n">y</span><span class="k">:</span> <span class="kt">Count</span><span class="o">)</span> <span class="k">=</span> <span class="nc">Count</span><span class="o">(</span><span class="n">x</span><span class="o">.</span><span class="n">id</span><span class="o">,</span> <span class="n">x</span><span class="o">.</span><span class="n">count</span> <span class="o">+</span> <span class="n">y</span><span class="o">.</span><span class="n">count</span><span class="o">)</span>
<span class="n">sc</span><span class="o">.</span><span class="n">parallelize</span><span class="o">(</span><span class="nc">Seq</span><span class="o">(</span><span class="nc">Count</span><span class="o">(</span><span class="s">"a"</span><span class="o">,</span> <span class="mi">10</span><span class="o">),</span> <span class="nc">Count</span><span class="o">(</span><span class="s">"a"</span><span class="o">,</span> <span class="mi">100</span><span class="o">),</span> <span class="nc">Count</span><span class="o">(</span><span class="s">"b"</span><span class="o">,</span> <span class="mi">5</span><span class="o">),</span> <span class="nc">Count</span><span class="o">(</span><span class="s">"b"</span><span class="o">,</span> <span class="mi">50</span><span class="o">)))</span>
<span class="o">.</span><span class="n">groupBy</span><span class="o">(</span><span class="k">_</span><span class="o">.</span><span class="n">id</span><span class="o">)</span>
<span class="o">.</span><span class="n">aggregateByKey</span><span class="o">(</span><span class="n">z</span><span class="o">)(</span><span class="n">seqOp</span><span class="o">,</span> <span class="n">combOp</span><span class="o">)</span>
</code></pre></div>
<p>This code however, only works correctly locally with <code>DirectRunner</code> and always produces results with <code>id == ""</code> when running on Dataflow service with the <code>DataflowRunner</code>. Can you spot the bug?</p>
<h2>Monoid laws</h2>
<p>You might notice that <code>zeroValue</code> and <code>combOp</code> together resemble a <a href="https://en.wikipedia.org/wiki/Monoid">Monoid</a>, which should satisfy the identity law:</p>
<div class="highlight"><pre><span></span><code><span class="n">combOp</span><span class="o">(</span><span class="n">zeroValue …</span></code></pre></div>
<a class="btn btn-default btn-xs" href="https://www.lyh.me/lawfulness-of-aggregatebykey.html">more ...</a>
</div>
</article>
<hr/>
<article>
<h2><a href="https://www.lyh.me/canbuildfrom.html">CanBuildFrom</a></h2>
<div class="well well-sm">
<footer class="post-info">
<span class="label label-default">Date</span>
<span class="published">
<i class="fa fa-calendar"></i><time datetime="2017-05-18T09:46:00-04:00"> Thu 18 May 2017</time>
</span>
<span class="label label-default">Category</span>
<a href="https://www.lyh.me/category/code.html">code</a>
<span class="label label-default">Tags</span>
<a href="https://www.lyh.me/tag/scala.html">scala</a>
/
<a href="https://www.lyh.me/tag/fp.html">fp</a>
</footer><!-- /.post-info --> </div>
<div class="summary"><p>We recently had an internal knowledge sharing on higher-kinded types and <code>CanBuildFrom</code> type classes in Scala. Here’s a short summary.</p>
<h2>Basics</h2>
<p>Let’s start by implementing <code>map</code>.</p>
<div class="highlight"><pre><span></span><code><span class="k">def</span> <span class="n">map</span><span class="o">(</span><span class="n">xs</span><span class="k">:</span> <span class="kt">Seq</span><span class="o">[</span><span class="kt">Int</span><span class="o">],</span> <span class="n">f</span><span class="k">:</span> <span class="kt">Int</span> <span class="o">=></span> <span class="nc">Double</span><span class="o">)</span><span class="k">:</span> <span class="kt">Seq</span><span class="o">[</span><span class="kt">Double</span><span class="o">]</span> <span class="k">=</span> <span class="n">xs</span><span class="o">.</span><span class="n">map</span><span class="o">(</span><span class="n">f</span><span class="o">)</span>
<span class="n">map</span><span class="o">(</span><span class="nc">Seq</span><span class="o">(</span><span class="mi">1</span><span class="o">,</span> <span class="mi">2</span><span class="o">,</span> <span class="mi">3</span><span class="o">),</span> <span class="k">_</span> <span class="o">+</span> <span class="mf">0.1</span><span class="o">)</span>
</code></pre></div>
<p>This implementation is not very good since it only works with <code>Seq[Int]</code> and <code>Int => Double</code>. It’s easy to parameterize <code>Int</code> and <code>Double</code>.</p>
<div class="highlight"><pre><span></span><code><span class="k">def</span> <span class="n">map</span><span class="o">[</span><span class="kt">A</span><span class="p">,</span> <span class="kt">B</span><span class="o">](</span><span class="n">xs</span><span class="k">:</span> <span class="kt">Seq</span><span class="o">[</span><span class="kt">A</span><span class="o">],</span> <span class="n">f</span><span class="k">:</span> <span class="kt">A</span> <span class="o">=></span> <span class="n">B</span><span class="o">)</span><span class="k">:</span> <span class="kt">Seq</span><span class="o">[</span><span class="kt">B</span><span class="o">]</span> <span class="k">=</span> <span class="n">xs</span><span class="o">.</span><span class="n">map</span><span class="o">(</span><span class="n">f</span><span class="o">)</span>
</code></pre></div>
<p>However <code>map(Seq(1, 2, 3), _ + 0.1)</code> now fails to compile with a message <code>missing parameter type for expanded function ((x$1) => x$1.$plus(10))</code></p>
<p>This is because inference of <code>A</code> in <code>f: A => B</code> depends on the type of <code>xs: Seq[A]</code>, and limitation of Scala type inference. A common workaround is to curry arguments.</p>
<div class="highlight"><pre><span></span><code><span class="k">def</span> <span class="n">map</span><span class="o">[</span><span class="kt">A</span><span class="p">,</span> <span class="kt">B</span><span class="o">](</span><span class="n">xs</span><span class="k">:</span> <span class="kt">Seq</span><span class="o">[</span><span class="kt">A</span><span class="o">])(</span><span class="n">f</span><span class="k">:</span> <span class="kt">A</span> <span class="o">=></span> <span class="n">B</span><span class="o">)</span><span class="k">:</span> <span class="kt">Seq</span><span class="o">[</span><span class="kt">B</span><span class="o">]</span> <span class="k">=</span> <span class="n">xs</span><span class="o">.</span><span class="n">map</span><span class="o">(</span><span class="n">f</span><span class="o">)</span>
<span class="n">map</span><span class="o">(</span><span class="nc">Seq</span><span class="o">(</span><span class="mi">1</span><span class="o">,</span> <span class="mi">2</span><span class="o">,</span> <span class="mi">3</span><span class="o">))(</span><span class="k">_</span> <span class="o">+</span> <span class="mf">0.1</span><span class="o">)</span>
</code></pre></div>
<p>Similar pattern is commonly seen in Scala, like <code>foldLeft(z: B)(op: (B, A) => B)</code>. Another benefit is we can now write <code>f</code> in a multi-line <code>{}</code> block more elegantly.</p>
<div class="highlight"><pre><span></span><code><span class="n">map …</span></code></pre></div>
<a class="btn btn-default btn-xs" href="https://www.lyh.me/canbuildfrom.html">more ...</a>
</div>
</article>
<hr/>
<article>
<h2><a href="https://www.lyh.me/decompiling-scala-code.html">Decompiling Scala code</a></h2>
<div class="well well-sm">
<footer class="post-info">
<span class="label label-default">Date</span>
<span class="published">
<i class="fa fa-calendar"></i><time datetime="2017-05-06T17:14:00-04:00"> Sat 06 May 2017</time>
</span>
<span class="label label-default">Category</span>
<a href="https://www.lyh.me/category/code.html">code</a>
<span class="label label-default">Tags</span>
<a href="https://www.lyh.me/tag/scala.html">scala</a>
/
<a href="https://www.lyh.me/tag/fp.html">fp</a>
</footer><!-- /.post-info --> </div>
<div class="summary"><p>I was bored today and decided to decompile some Scala code for fun and profit. I’m using Scala 2.12.2 and Java 1.8.0_121.</p>
<h2>Scala object</h2>
<div class="highlight"><pre><span></span><code><span class="k">package</span> <span class="nn">javap</span>
<span class="k">object</span> <span class="nc">Test01</span> <span class="o">{</span>
<span class="k">def</span> <span class="n">main</span><span class="o">(</span><span class="n">args</span><span class="k">:</span> <span class="kt">Array</span><span class="o">[</span><span class="kt">String</span><span class="o">])</span><span class="k">:</span> <span class="kt">Unit</span> <span class="o">=</span> <span class="nc">Unit</span>
<span class="o">}</span>
</code></pre></div>
<div class="highlight"><pre><span></span><code><span class="kd">public</span> <span class="kd">final</span> <span class="kd">class</span> <span class="nc">javap</span><span class="p">.</span><span class="na">Test01$</span> <span class="p">{</span>
<span class="kd">public</span> <span class="kd">static</span> <span class="n">javap</span><span class="p">.</span><span class="na">Test01$</span> <span class="n">MODULE$</span><span class="p">;</span>
<span class="kd">public</span> <span class="kd">static</span> <span class="p">{};</span>
<span class="kd">public</span> <span class="kt">void</span> <span class="nf">main</span><span class="p">(</span><span class="n">java</span><span class="p">.</span><span class="na">lang</span><span class="p">.</span><span class="na">String</span><span class="o">[]</span><span class="p">);</span>
<span class="kd">private</span> <span class="n">javap</span><span class="p">.</span><span class="na">Test01$</span><span class="p">();</span>
<span class="p">}</span>
<span class="kd">public</span> <span class="kd">final</span> <span class="kd">class</span> <span class="nc">javap</span><span class="p">.</span><span class="na">Test01</span> <span class="p">{</span>
<span class="kd">public</span> <span class="kd">static</span> <span class="kt">void</span> <span class="nf">main</span><span class="p">(</span><span class="n">java</span><span class="p">.</span><span class="na">lang</span><span class="p">.</span><span class="na">String</span><span class="o">[]</span><span class="p">);</span>
<span class="p">}</span>
</code></pre></div>
<p>As we can see a Scala object is compiled to 2 Java classes, <code>Test01</code> with static methods for Java compatibility and a <code>Test01$</code> with a static instance of itself as <code>MODULE$</code>, so that <code>Test01</code> can be used as an instance value in Scala.</p>
<h2>Class constructors</h2>
<div class="highlight"><pre><span></span><code><span class="k">package</span> <span class="nn">javap</span>
<span class="k">class</span> <span class="nc">Test02</span><span class="o">(</span><span class="k">val</span> <span class="n">x</span><span class="k">:</span> <span class="kt">Int</span><span class="o">,</span> <span class="k">val</span> <span class="n">y</span><span class="k">:</span> <span class="kt">Int</span><span class="o">,</span> <span class="n">z</span><span class="k">:</span> <span class="kt">Int</span><span class="o">)</span> <span class="o">{</span>
<span class="k">def</span> <span class="k">this</span><span class="o">(</span><span class="n">x</span><span class="k">:</span> <span class="kt">Int</span><span class="o">,</span> <span class="n">y</span><span class="k">:</span> <span class="kt">Int</span><span class="o">)</span> <span class="k">=</span> <span class="k">this</span><span class="o">(</span><span class="n">x</span><span class="o">,</span> <span class="n">y</span><span class="o">,</span> <span class="mi">0</span><span class="o">)</span>
<span class="o">}</span>
</code></pre></div>
<div class="highlight"><pre><span></span><code><span class="kd">public</span> <span class="kd">class</span> <span class="nc">javap</span><span class="p">.</span><span class="na">Test02</span> <span class="p">{</span>
<span class="kd">private</span> <span class="kd">final</span> <span class="kt">int</span> <span class="n">x</span><span class="p">;</span>
<span class="kd">private</span> <span class="kd">final</span> <span class="kt">int</span> <span class="n">y</span><span class="p">;</span>
<span class="kd">public</span> <span class="kt">int</span> <span class="nf">x</span><span class="p">();</span>
<span class="kd">public</span> <span class="kt">int</span> <span class="nf">y</span><span class="p">();</span>
<span class="kd">public</span> <span class="n">javap</span><span class="p">.</span><span class="na">Test02</span><span class="p">(</span><span class="kt">int</span><span class="p">,</span> <span class="kt">int</span><span class="p">,</span> <span class="kt">int</span><span class="p">);</span>
<span class="kd">public</span> <span class="n">javap</span><span class="p">.</span><span class="na">Test02</span><span class="p">(</span><span class="kt">int</span><span class="p">,</span> <span class="kt">int</span><span class="p">);</span>
<span class="p">}</span>
</code></pre></div>
<p>Looks like the default constructor <code>(val x: Int, val y: Int, z: Int)</code> and the overloaded one <code>(x: Int, y: Int)</code> each generated a Java constructor. However only <code>x</code> and <code>y …</code></p>
<a class="btn btn-default btn-xs" href="https://www.lyh.me/decompiling-scala-code.html">more ...</a>
</div>
</article>
<hr/>
<article>
<h2><a href="https://www.lyh.me/implicits.html">Implicits</a></h2>
<div class="well well-sm">
<footer class="post-info">
<span class="label label-default">Date</span>
<span class="published">
<i class="fa fa-calendar"></i><time datetime="2017-04-21T08:48:00-04:00"> Fri 21 April 2017</time>
</span>
<span class="label label-default">Category</span>
<a href="https://www.lyh.me/category/code.html">code</a>
<span class="label label-default">Tags</span>
<a href="https://www.lyh.me/tag/scala.html">scala</a>
/
<a href="https://www.lyh.me/tag/fp.html">fp</a>
</footer><!-- /.post-info --> </div>
<div class="summary"><p>In this post we’re going to take a closer look at Scala implicits and various use cases.</p>
<h2>Basics</h2>
<p>Let’s first look at the basics. There’re 3 main basic uses of implicits, as an argument, as a conversion method, and enhancing an existing class, a.k.a. the “Pimp My Library” pattern.</p>
<h3>Implicit arguments</h3>
<p>Suppose we have a basic function like this.</p>
<div class="highlight"><pre><span></span><code><span class="k">def</span> <span class="n">plus</span><span class="o">(</span><span class="n">x</span><span class="k">:</span> <span class="kt">Int</span><span class="o">)</span> <span class="k">=</span> <span class="n">x</span> <span class="o">+</span> <span class="mi">1</span>
<span class="n">plus</span><span class="o">(</span><span class="mi">10</span><span class="o">)</span> <span class="c1">// => 11</span>
</code></pre></div>
<p>We can add a second argument and make it a curried function.</p>
<div class="highlight"><pre><span></span><code><span class="k">def</span> <span class="n">plus</span><span class="o">(</span><span class="n">x</span><span class="k">:</span> <span class="kt">Int</span><span class="o">)(</span><span class="n">y</span><span class="k">:</span> <span class="kt">Int</span><span class="o">)</span> <span class="k">=</span> <span class="n">x</span> <span class="o">+</span> <span class="n">y</span>
<span class="n">plus</span><span class="o">(</span><span class="mi">10</span><span class="o">)(</span><span class="mi">1</span><span class="o">)</span> <span class="c1">// => 11</span>
</code></pre></div>
<p>We can then make the second argument implicit and supply it via an <code>implicit val</code>.</p>
<div class="highlight"><pre><span></span><code><span class="k">def</span> <span class="n">plus</span><span class="o">(</span><span class="n">x</span><span class="k">:</span> <span class="kt">Int</span><span class="o">)(</span><span class="k">implicit</span> <span class="n">y</span><span class="k">:</span> <span class="kt">Int</span><span class="o">)</span> <span class="k">=</span> <span class="n">x</span> <span class="o">+</span> <span class="n">y</span>
<span class="k">implicit</span> <span class="k">val</span> <span class="n">one</span> <span class="k">=</span> <span class="mi">1</span>
<span class="n">plus</span><span class="o">(</span><span class="mi">10</span><span class="o">)</span> <span class="c1">// => 11</span>
</code></pre></div>
<p>Since <code>plus</code> needs an implicit argument of type <code>Int</code> and there happens to be one in the scope, <code>one</code> is applied automatically. However it won’t work if there are multiple <code>implicit val</code>s.</p>
<div class="highlight"><pre><span></span><code><span class="k">implicit</span> <span class="k">val</span> <span class="n">one</span> <span class="k">=</span> <span class="mi">1</span>
<span class="k">implicit</span> <span class="k">val</span> <span class="n">two</span> <span class="k">=</span> <span class="mi">2</span>
<span class="n">plus</span><span class="o">(</span><span class="mi">10</span><span class="o">)</span> <span class="c1">// => ambiguous implicit values</span>
</code></pre></div>
<p>This example isn’t very interesting and one can usually use argument with a default value instead. However implicit arguments are handy for decoupling behavior …</p>
<a class="btn btn-default btn-xs" href="https://www.lyh.me/implicits.html">more ...</a>
</div>
</article>
<hr/>
<article>
<h2><a href="https://www.lyh.me/scio-at-philly-ete.html">Scio at Philly <span class="caps">ETE</span></a></h2>
<div class="well well-sm">
<footer class="post-info">
<span class="label label-default">Date</span>
<span class="published">
<i class="fa fa-calendar"></i><time datetime="2017-04-20T11:12:00-04:00"> Thu 20 April 2017</time>
</span>
<span class="label label-default">Category</span>
<a href="https://www.lyh.me/category/code.html">code</a>
<span class="label label-default">Tags</span>
<a href="https://www.lyh.me/tag/data.html">data</a>
/
<a href="https://www.lyh.me/tag/scala.html">scala</a>
/
<a href="https://www.lyh.me/tag/scio.html">scio</a>
</footer><!-- /.post-info --> </div>
<div class="summary"><p>It’s been another 6 months since my talk about <a href="https://github.com/spotify/scio">Scio</a> at <a href="http://scala.bythebay.io">Scala by the Bay</a>. We’ve seen huge adoption and improvements since then. The number of production Scio pipelines has grown from ~70 to 400+ within <a href="https://www.spotify.com/">Spotify</a>. A lot of other companies are using and contributing to it as well. In the most recent edition of the Spotify data university, an internal week long big data training camp for non-data engineers, we revamped the curriculum to cover Scio, BigQuery and other <a href="https://cloud.google.com/solutions/big-data/">Google Cloud Big Data</a> products instead of Hadoop, Scalding and Hive.</p>
<blockquote class="twitter-tweet" data-lang="en"><p lang="en" dir="ltr">Spotify data university round 3 <span class="amp">&</span> 1st time covering Scio, <a href="https://twitter.com/ApacheBeam">@ApacheBeam</a> <span class="amp">&</span> <a href="https://twitter.com/GCPBigData">@GCPBigData</a> 👋 Hadoop, <span class="caps">HDFS</span>, M/R, <span class="caps">YARN</span> 🍾 batch + streaming <a href="https://t.co/1gWIEbN0mW">pic.twitter.com/1gWIEbN0mW</a></p>— Neville Li (@sinisa_lyh) <a href="https://twitter.com/sinisa_lyh/status/846549633367265281">March 28, 2017</a></blockquote>
<script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>
<p>And here’s a list of some notable improvements in Scio.</p>
<ul>
<li>Master branch is now based on <a href="https://beam.apache.org/">Apache Beam</a></li>
<li>Graduate type safe BigQuery <span class="caps">API</span> form experimental to stable</li>
<li><a href="https://github.com/spotify/sparkey-java">Sparkey</a> side input support</li>
<li><a href="https://www.tensorflow.org/">TensorFlow</a> TFRecord file <span class="caps">IO</span></li>
<li><a href="https://cloud.google.com/pubsub/">Cloud Pub/Sub</a> attributes support</li>
<li>Named transformations for streaming update</li>
<li>Safe-guard against malformed tests and better error messages</li>
<li>Flexible custom <span class="caps">IO</span> wiring</li>
<li>KryoRegistrar for custom Kryo serialization</li>
<li>Table description for type-safe BigQuery</li>
<li>Lots of performance improvements and bug fixes</li>
</ul>
<p>I talked about …</p>
<a class="btn btn-default btn-xs" href="https://www.lyh.me/scio-at-philly-ete.html">more ...</a>
</div>
</article>
<hr/>
<article>
<h2><a href="https://www.lyh.me/joins.html">Joins</a></h2>
<div class="well well-sm">
<footer class="post-info">
<span class="label label-default">Date</span>
<span class="published">
<i class="fa fa-calendar"></i><time datetime="2017-03-28T14:38:00-04:00"> Tue 28 March 2017</time>
</span>
<span class="label label-default">Category</span>
<a href="https://www.lyh.me/category/code.html">code</a>
<span class="label label-default">Tags</span>
<a href="https://www.lyh.me/tag/scala.html">scala</a>
/
<a href="https://www.lyh.me/tag/fp.html">fp</a>
/
<a href="https://www.lyh.me/tag/data.html">data</a>
</footer><!-- /.post-info --> </div>
<div class="summary"><p>We recently started teaching <a href="https://github.com/spotify/scio">Scio</a> at Spotify’s internal data university and I made these <a href="/slides/joins.html">slides</a> to explain how joins work and some lower level details.</p>
<iframe src="/slides/joins.html" width="800" height="450"></iframe>
<a class="btn btn-default btn-xs" href="https://www.lyh.me/joins.html">more ...</a>
</div>
</article>
<hr/>
<ul class="pagination">
<li class="prev disabled"><a href="#">«</a></li>
<li class="active"><a
href="https://www.lyh.me/index.html">1</a></li>
<li class=""><a
href="https://www.lyh.me/index2.html">2</a></li>
<li class=""><a
href="https://www.lyh.me/index3.html">3</a></li>
<li class="next"><a
href="https://www.lyh.me/index2.html">»</a></li>
</ul>
</div>
<div class="col-sm-3" id="sidebar">
<aside>
<div id="aboutme">
<p>
<img width="100%" class="img-thumbnail" src="https://www.lyh.me//avatar.jpg"/>
</p>
<p>
<strong>About Neville Li</strong><br/>
Data infrastructure @<a href="https://twitter.com/Spotify">Spotify</a>, ex-@<a href="https://twitter.com/Yahoo">Yahoo</a> search, creator of <a href="https://github.com/spotify/scio">Scio</a>, technical cave & wreck diver, lefty guitar player
</p>
</div><!-- Sidebar -->
<section class="well well-sm">
<ul class="list-group list-group-flush">
<!-- Sidebar/Social -->
<li class="list-group-item">
<h4><i class="fa fa-home fa-lg"></i><span class="icon-label">Social</span></h4>
<ul class="list-group" id="social">
<li class="list-group-item"><a href="https://open.spotify.com/user/sinisa_lyh"><i class="fa fa-spotify fa-lg"></i> Spotify</a></li>
<li class="list-group-item"><a href="https://github.com/nevillelyh"><i class="fa fa-github-square fa-lg"></i> GitHub</a></li>
<li class="list-group-item"><a href="https://twitter.com/sinisa_lyh"><i class="fa fa-twitter-square fa-lg"></i> Twitter</a></li>
<li class="list-group-item"><a href="https://www.slideshare.net/sinisalyh"><i class="fa fa-slideshare fa-lg"></i> SlideShare</a></li>
<li class="list-group-item"><a href="https://www.youtube.com/user/sinisalyh/videos"><i class="fa fa-youtube-square fa-lg"></i> YouTube</a></li>
<li class="list-group-item"><a href="https://www.instagram.com/sinisa/"><i class="fa fa-instagram fa-lg"></i> Instagram</a></li>
<li class="list-group-item"><a href="https://www.flickr.com/photos/sinisa_lyh"><i class="fa fa-flickr fa-lg"></i> Flickr</a></li>
</ul>
</li>
<!-- End Sidebar/Social -->
<!-- Sidebar/Recent Posts -->
<li class="list-group-item">
<h4><i class="fa fa-home fa-lg"></i><span class="icon-label">Recent Posts</span></h4>
<ul class="list-group" id="recentposts">
<li class="list-group-item"><a href="https://www.lyh.me/magnolify.html">Magnolify</a></li>
<li class="list-group-item"><a href="https://www.lyh.me/featran.html">Featran</a></li>
<li class="list-group-item"><a href="https://www.lyh.me/automatic-type-class-derivation-with-shapeless.html">Automatic type-class derivation with Shapeless</a></li>
<li class="list-group-item"><a href="https://www.lyh.me/lambda-serialization.html">Lambda serialization</a></li>
<li class="list-group-item"><a href="https://www.lyh.me/lawfulness-of-aggregatebykey.html">Lawfulness of aggregateByKey</a></li>
</ul>
</li>
<!-- End Sidebar/Recent Posts -->
<!-- Sidebar/Categories -->
<li class="list-group-item">
<h4><i class="fa fa-home fa-lg"></i><span class="icon-label">Categories</span></h4>
<ul class="list-group" id="categories">
<li class="list-group-item">
<a href="https://www.lyh.me/category/code.html"><i class="fa fa-folder-open fa-lg"></i>code</a>
</li>
<li class="list-group-item">
<a href="https://www.lyh.me/category/misc.html"><i class="fa fa-folder-open fa-lg"></i>misc</a>
</li>
</ul>
</li>
<!-- End Sidebar/Categories -->
<!-- Sidebar/Twitter Timeline -->
<li class="list-group-item">
<h4><i class="fa fa-twitter fa-lg"></i><span class="icon-label">Latest Tweets</span></h4>
<div id="twitter_timeline">
<a class="twitter-timeline" data-width="250" data-height="300" data-dnt="true" data-theme="light" href="https://twitter.com/sinisa_lyh">Tweets by sinisa_lyh</a> <script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>
</div>
</li>
<!-- End Sidebar/Twitter Timeline -->
</ul>
</section>
<!-- End Sidebar --> </aside>
</div>
</div>
</div>
<!-- End Content Container -->
<footer>
<div class="container">
<hr>
<div class="row">
<div class="col-xs-10">© 2020 Neville Li
· Powered by <a href="https://github.com/getpelican/pelican-themes/tree/master/pelican-bootstrap3" target="_blank">pelican-bootstrap3</a>,
<a href="http://docs.getpelican.com/" target="_blank">Pelican</a>,
<a href="http://getbootstrap.com" target="_blank">Bootstrap</a> <p><small> <a rel="license" href="https://creativecommons.org/licenses/by-nc/4.0/deed.en"><img alt="Creative Commons License" style="border-width:0" src="//i.creativecommons.org/l/by-nc/4.0/80x15.png" /></a>
Content
licensed under a <a rel="license" href="https://creativecommons.org/licenses/by-nc/4.0/deed.en">Creative Commons Attribution-NonCommercial 4.0 International License</a>, except where indicated otherwise.
</small></p>
</div>
<div class="col-xs-2"><p class="pull-right"><i class="fa fa-arrow-up"></i> <a href="#">Back to top</a></p></div>
</div>
</div>
</footer>
<script src="https://www.lyh.me/theme/js/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="https://www.lyh.me/theme/js/bootstrap.min.js"></script>
<!-- Enable responsive features in IE8 with Respond.js (https://github.com/scottjehl/Respond) -->
<script src="https://www.lyh.me/theme/js/respond.min.js"></script>
<!-- Disqus -->
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'lyh'; // required: replace example with your forum shortname
/* * * DON'T EDIT BELOW THIS LINE * * */
(function () {
var s = document.createElement('script');
s.async = true;
s.type = 'text/javascript';
s.src = '//' + disqus_shortname + '.disqus.com/count.js';
(document.getElementsByTagName('HEAD')[0] || document.getElementsByTagName('BODY')[0]).appendChild(s);
}());
</script>
<!-- End Disqus Code -->
<!-- Google Analytics -->
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-6988688-5']);
_gaq.push(['_trackPageview']);
(function () {
var ga = document.createElement('script');
ga.type = 'text/javascript';
ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(ga, s);
})();
</script>
<!-- End Google Analytics Code -->
</body>
</html>