メルカリ カウルの
マスタデータの更新
2017年11月14日(火)
@golang.tokyo #10
The Go gopher was designed by Renée French.
The gopher stickers was made by Takuya Ueda.
Licensed under the Creative Commons 3.0 Attributions license.
2
自己紹介
上田拓也
@tenntenn
所属
コミュニティ活動
&
Go ビギナーズ
Go Conference
上田拓也
@tenntenn
3
ソウゾウ エキスパートチーム
技術をアウトプットするところに技術は集まる
■ エキスパートチームとは?
■ エキスパートチームの役割
■ エキスパートチームの活動
@tenntenn
担当:Go・GCP
@mhidaka
担当:Android
メンバー
アジェンダ
4
メルカリ カウルのマスタデータ
5
Google App Engineを採用
6
メルカリ カウルのマスタデータ
7
マスタデータ更新の例
8
大きなファイルを分割して処理する
9
マスタデータの更新
10
※ すべてのマスタデータがこうなっているわけではない
ID | 製品名 | 発売日 | 発売元 |
001 | ほげ | 2017年11月14日 | 会社A |
002 | ふが | 2017年11月13日 | 会社B |
大きなファイルを扱う問題点
11
大きなファイルを処理する
12
Task Queueによる処理
13
TSVを分割する方法
14
001\tほげ\t2017年11月14日\t会社A\n
002\tふが\t2017年11月13日\t会社B\n
...
バイト列を変換する
15
マスタデータの変換
16
文字コードの変換
17
func main() {
dec := japanese.ShiftJIS.NewDecoder()
r := transform.NewReader(os.Stdin, dec)
io.Copy(os.Stdout, r)
}
$ echo "ごーふぁー" | nkf --sjis | go run sjis.go
ごーふぁー
x/text/transfomを用いる
18
transform.Reader
io.Reader
Transformer
transform.Writer
Transformer
io.Writer
Read
Write
Transformerを実装する
19
type Transformer interface {
Transform(dst, src []byte, atEOF bool) (nDst, nSrc int, err error)
Reset()
}
詳しくはAdvent Calendarで!!
20
バイト列の置換
21
func ExampleReplaceTable() {
t := ReplaceStringTable{
"Hello", "Hi",
"World", "Gophers",
}
r := transform.NewReader(strings.NewReader("Hello, World"), ReplaceAll(t))
io.Copy(os.Stdout, r)
// Output: Hi, Gophers
}
まとめ
22