#5章 データーベースにCookieを保存する
ブラウザからDMPサーバーへリクエストがあった場合、初期アクセスならCookieID発行、2回目以降のアクセスの場合はそのオーディエンスの過去のリクエストログから広告を出すのがCookieを利用したDMPの基本的な処理になります。
ここではリクエストのログをMariaDB(MySQL)に保存する方法について説明します。
以下の記述を追加します
require 'date' | |
(1..12).each do |i| | |
date = Date.new(2014, i, 1) | |
(1..10).each do |x| | |
shop_id = x | |
sales = 100000 * date.month * shop_id | |
puts sprintf("%d,%s,%d", shop_id, date, sales) | |
end | |
end |
SELECT | |
name, | |
title, | |
IF(sum(score) > 10, 10, sum(score)) as score | |
FROM ( | |
SELECT | |
name, | |
title, | |
1 AS score, | |
FROM ( |
SELECT | |
name, | |
title, | |
sum(score) as score | |
FROM ( | |
SELECT | |
name, | |
title, | |
1 AS score, | |
FROM ( |
SELECT | |
name, | |
title, | |
sum(score) as score | |
FROM ( | |
SELECT | |
name, | |
title, | |
1 AS score, | |
FROM ( |
==> Installing kafka | |
==> Downloading http://mirrors.ibiblio.org/apache/kafka/0.8.2.1/kafka-0.8.2.1-src.tgz | |
######################################################################## 100.0% | |
==> gradle | |
==> gradle jar | |
==> Caveats | |
To start Kafka, ensure that ZooKeeper is running and then execute: | |
kafka-server-start.sh /usr/local/etc/kafka/server.properties |
{ | |
"Azure" : { | |
"subscription_key": "" | |
} | |
} |
#ruby trans.rb every60min20150816.log | |
def parser(line) | |
list = line.split(',') | |
list[0..8] | |
end | |
open(ARGV[0]) {|file| | |
counter = 0 |
sc.emptyRDD |
require 'RMagick' | |
class MovieFilmCreater | |
def initialize(image_file1, image_file2, image_file3, image_file4) | |
@image_file1 = image_file1 | |
@image_file2 = image_file2 | |
@image_file3 = image_file3 | |
@image_file4 = image_file4 | |
end |