Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Gunosy.go#2 package/compress
Search
shunsukeaihara
June 19, 2014
Technology
150
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Gunosy.go#2 package/compress
shunsukeaihara
June 19, 2014
More Decks by shunsukeaihara
See All by shunsukeaihara
BONXを支える技術:発話区間検出(VAD)の話/Akerun & BONX Tech Talk
shunsukeaihara
4
7.8k
Goのnet.TCPConnの話/shibuya.go01
shunsukeaihara
3
890
Norikra in Gunosy Network Ads@Norikra meetup #2
shunsukeaihara
1
6.1k
LevelDB on S3 As A KVS
shunsukeaihara
1
3k
色恒常性仮説に基づく色補正ライブラリcolorcorrect / 2015-01-31-kantocv27
shunsukeaihara
3
2.6k
Sparkによる分散処理 / 2015-01-16 PyData.Tokyo#3
shunsukeaihara
11
3.6k
ゼロから始めた Gunosyアドサーバ開発運用記 / 2014-12-16-dots
shunsukeaihara
6
1.2k
Gunosy.Go#5 index/io/log
shunsukeaihara
0
200
Other Decks in Technology
See All in Technology
HacobuにおけるFDEとは/登壇資料(戸井田 裕貴)
hacobu
PRO
1
560
AWS FinOps Agent 結局何が得意なの?
siromi
0
220
音声コミュニティを守るAI監視基盤_ 90%以上の入力削減を支えたServerless設計と運用判断
shuheioka123
0
120
AI Native Platform Engineering 〜PlatformとAgileで“作る速さ”を“価値”へ〜
uya116
0
470
Amazon Bedrock Agents ClassicからAmazon Bedrock AgentCoreへ移行した際、ガードレール設定が2箇所に割れた話
matsunobu
0
160
20260930_Gemma4_Hands-on
tsho
0
150
いちAWSエンジニアのAI活用を振り返る #devio2026 / devio osaka 2026 kawahara
masahirokawahara
1
280
なぜ「決定性」が 決定的に重要なのか? Durable Execution 基盤の数理的理解 #serverlessjp / ServerlessDays Tokyo 2026
ytaka23
4
1.4k
【データ横丁主催】AI Agentがコンテキストを使って仕事をした後、何が残るのか― 組織の経験を次の判断に引き継ぐ「Agent Memory」
shisyu_gaku
2
250
Snowflake Horizon Catalog と Apache Iceberg で作る オープンなデータ基盤
kitagawaz
0
320
セルフサービスのオブザーバビリティ基盤をOpenTelemetryで作る / Building a Self-Service Observability Platform with OpenTelemetry
ymotongpoo
3
480
The kernel report
ennael
PRO
1
130
Featured
See All Featured
Technical Leadership for Architectural Decision Making
baasie
3
580
My Coaching Mixtape
mlcsv
0
330
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
2.2k
Believing is Seeing
oripsolob
1
230
Highjacked: Video Game Concept Design
rkendrick25
PRO
1
470
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
3k
Designing Powerful Visuals for Engaging Learning
tmiket
1
580
Art, The Web, and Tiny UX
lynnandtonic
304
22k
Navigating Algorithm Shifts & AI Overviews - #SMXNext
aleyda
1
1.6k
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
350
世界の人気アプリ100個を分析して見えたペイウォール設計の心得
akihiro_kokubo
PRO
74
42k
The #1 spot is gone: here's how to win anyway
tamaranovitovic
4
1.2k
Transcript
Gunosy.go#2 package/compress Shunsuke Aihara
compress is ... • http://golang.org/pkg/compress/ • いわゆる圧縮ファイルを扱うもの – なんか⾒見見てみたらGoで全部書いてある –
libzlibとかに依存せずgoで完結してる • 複数の圧縮ファイルフォーマットに対応 – bzip2 – zlib – gzip – lzw
実装されている圧縮アルゴリズム • bzip2 – Bw変換を⽤用いた圧縮アルゴリズム。 – 遅いが圧縮率率率が⾼高い • flate(bzip, zlib)
– zipで⽤用いられている圧縮アルゴリズム(Deflate) – LZ77 + ハフマン符号 • lzw – deflateと⽐比べると⾼高速だが圧縮効率率率が若若⼲干悪い – LZ78の改良良アルゴリズム。gifで使われていて昔 特許で騒がれたアレ
• bzip2 – Bw変換を⽤用いた圧縮アルゴリズム。 – 遅いが圧縮率率率が⾼高い • flate(bzip, zlib) –
zipで⽤用いられている圧縮アルゴリズム(Deflate) – LZ77 + ハフマン符号 • lzw – deflateと⽐比べると⾼高速だが圧縮効率率率が若若⼲干悪い – LZ78の改良良アルゴリズム。gifで使われていて昔 特許で騒がれたアレ 実装されている圧縮アルゴリズム 圧縮アルゴリズムは共通で、ファイル形式のみ異異なる
アルゴリズムについて詳しくは… • ⾼高速⽂文字列列解析の世界を読みましょう! • h9p://www.amazon.co.jp/dp/4000069748
compress/*の使い⽅方 • 基本的な使い⽅方はどれも同じ – 圧縮ファイルを扱う際は… • NewReaderで圧縮ファイル読み込み⽤用Reader作成 –
物によっては辞書や圧縮オプションを指定可能(ただし圧 縮時に利利⽤用した物を指定しないとerror) • NewWriterで圧縮ファイル作成⽤用Writer作成 – ものによって辞書(LZ77⽅方式で利利⽤用する初期⽂文脈?)と圧縮 オプションを指定可能 – Bzip2は伸張のみサポート – 微妙にIFが異異なる • Exampleがあるzlibから紹介 • h9p://play.golang.org/p/GH6_Mtoaek
compress/zlib • func NewReader(r io.Reader) (io.ReadCloser, error) • func
NewReaderDict(r io.Reader, dict []byte) (io.ReadCloser, error) • type Writer – func NewWriter(w io.Writer) *Writer – func NewWriterLevel(w io.Writer, level int) (*Writer, error) – func NewWriterLevelDict(w io.Writer, level int, dict []byte) (*Writer, error) – func (z *Writer) Close() error – func (z *Writer) Flush() error – func (z *Writer) Reset(w io.Writer) – func (z *Writer) Write(p []byte) (n int, err error) • その他、圧縮オプションに関する定数値、エラー型を定義 • 中でflateを呼んでいる
解凍時の処理理 • h9p://golang.org/pkg/compress/zlib/#example_NewReader
圧縮時の処理理 • h9p://golang.org/pkg/compress/zlib/#example_NewWriter
compress/flate • func NewReader(r io.Reader) io.ReadCloser • func NewReaderDict(r
io.Reader, dict []byte) io.ReadCloser • type CorruptInputError – func (e CorruptInputError) Error() string • type InternalError – func (e InternalError) Error() string • type ReadError – func (e *ReadError) Error() string • type Reader • type WriteError – func (e *WriteError) Error() string • type Writer – func NewWriter(w io.Writer, level int) (*Writer, error) – func NewWriterDict(w io.Writer, level int, dict []byte) (*Writer, error) – func (w *Writer) Close() error – func (w *Writer) Flush() error – func (w *Writer) Reset(dst io.Writer) – func (w *Writer) Write(data []byte) (n int, err error) • その他、圧縮オプションに関する定数値、エラー型を定義
compress/gzip • type Header • type Reader –
func NewReader(r io.Reader) (*Reader, error) – func (z *Reader) Close() error – func (z *Reader) Read(p []byte) (n int, err error) • type Writer – func NewWriter(w io.Writer) *Writer – func NewWriterLevel(w io.Writer, level int) (*Writer, error) – func (z *Writer) Close() error – func (z *Writer) Flush() error – func (z *Writer) Reset(w io.Writer) – func (z *Writer) Write(p []byte) (int, error) • その他、圧縮オプションに関する定数値、エラー型を定義 • gzipは独⾃自のヘッダ型がある • 中でflateを呼んでいる
compress/bzip2 • func NewReader(r io.Reader) io.Reader • type StructuralError
– func (s StructuralError) Error() string • Block sort(BW変換)のgo実装読んでみた かったけど圧縮は未対応だった
compress/lzw • func NewReader(r io.Reader, order Order, litWidth int)
io.ReadCloser • func NewWriter(w io.Writer, order Order, litWidth int) io.WriteCloser • type Order