fluentd-plugin-aliyun-odps 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/CHANGELOG.md +0 -0
- data/Gemfile +3 -0
- data/License +13 -0
- data/README.md +120 -0
- data/Rakefile +14 -0
- data/VERSION +1 -0
- data/fluentd-plugin-aliyun-odps.gemspec +27 -0
- data/lib/fluent/plugin/conf/config.rb +32 -0
- data/lib/fluent/plugin/digest/crc.rb +120 -0
- data/lib/fluent/plugin/digest/crc32.rb +125 -0
- data/lib/fluent/plugin/digest/crc32c.rb +105 -0
- data/lib/fluent/plugin/exceptions.rb +49 -0
- data/lib/fluent/plugin/http/http_connection.rb +130 -0
- data/lib/fluent/plugin/http/http_flag.rb +73 -0
- data/lib/fluent/plugin/odps/odps_table.rb +253 -0
- data/lib/fluent/plugin/odps/odps_table_schema.rb +64 -0
- data/lib/fluent/plugin/odps/xml_template.rb +57 -0
- data/lib/fluent/plugin/odps/xstream_pack.pb.rb +21 -0
- data/lib/fluent/plugin/odps/xstream_pack.proto +8 -0
- data/lib/fluent/plugin/out_odps.rb +373 -0
- data/lib/fluent/plugin/serialize/deserializer.rb +32 -0
- data/lib/fluent/plugin/serialize/serializer.rb +141 -0
- data/lib/fluent/plugin/stream_client.rb +111 -0
- data/lib/fluent/plugin/stream_reader.rb +53 -0
- data/lib/fluent/plugin/stream_writer.rb +152 -0
- data/odps_example.conf +30 -0
- metadata +174 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5ed8c1161239bfcf51441928d9cbc340337fd56d
|
4
|
+
data.tar.gz: 4dd26fa30a0b600707d34141fa9f780494ffe2a5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c8374bf03b54e76a1cf6c576635f548e4ea17fef29982ea8c22dde77621a673e2be6e9780e2ad40023bfef63b9f56bd5ad14c7323a3d638b502a3d49d5d0c680
|
7
|
+
data.tar.gz: 3bde7264c57c046e2da13ba3f25635c61b7082ba6515048610036451967b9dc63965c664cc0d88430b44c73daba964d891b1070b0f94d6d396cdacfdf7f800b1
|
data/.gitignore
ADDED
data/CHANGELOG.md
ADDED
File without changes
|
data/Gemfile
ADDED
data/License
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
Copyright 1999-2015 Alibaba Group Holding Ltd.
|
2
|
+
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
6
|
+
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
|
+
limitations under the License.
|
data/README.md
ADDED
@@ -0,0 +1,120 @@
|
|
1
|
+
# Aliyun ODPS Plugin for Fluentd
|
2
|
+
|
3
|
+
## Getting Started
|
4
|
+
---
|
5
|
+
|
6
|
+
### Introduction
|
7
|
+
|
8
|
+
- ODPS-Open Data Processing Service is a massive data processing platform designed by alibaba.
|
9
|
+
- DHS-ODPS DataHub Service is a service in Odps, which provides real-time upload and download functions for user.
|
10
|
+
|
11
|
+
|
12
|
+
### Requirements
|
13
|
+
|
14
|
+
To get started using this plugin, you will need three things:
|
15
|
+
|
16
|
+
1. Ruby 2.1.0 or later
|
17
|
+
2. Gem 2.4.5 or later
|
18
|
+
3. Fluentd-0.10.49 or later (*[Home Page](http://www.fluentd.org/)*)
|
19
|
+
4. Protobuf-3.5.1 or later(Ruby protobuf)
|
20
|
+
|
21
|
+
### Install the Plugin
|
22
|
+
|
23
|
+
install the project from gem or github:
|
24
|
+
|
25
|
+
```
|
26
|
+
$ gem install fluentd-plugin-aliyun-odps
|
27
|
+
$ git clone https://github.com/aliyun/aliyun-odps-fluentd-plugin.git
|
28
|
+
```
|
29
|
+
|
30
|
+
Use gem to install dependency:
|
31
|
+
|
32
|
+
```
|
33
|
+
$ gem install protobuf
|
34
|
+
$ gem install fluentd --no-ri --no-rdoc
|
35
|
+
```
|
36
|
+
|
37
|
+
Your plugin is in aliyun-odps-fluentd-plugin/lib/fluent/plugin, entry file is out_odps.rb.
|
38
|
+
|
39
|
+
### Use the Plugin
|
40
|
+
|
41
|
+
- If you installed this plugin from gem, please ignore this step.
|
42
|
+
- Move the plugin dir into the plugin directory of Fluentd.
|
43
|
+
- (i.e., copy the folder aliyun-odps-fluentd-plugin/lib/fluent/plugin into {YOUR_FLUENTD_DIRECTORY}/lib/fluent/plugin).
|
44
|
+
|
45
|
+
```
|
46
|
+
$ cp aliyun-odps-fluentd-plugin/lib/fluent/plugin/* {YOUR_FLUENTD_DIRECTORY}/lib/fluent/plugin/ -r
|
47
|
+
```
|
48
|
+
|
49
|
+
### ODPS Fluentd plugin now is available. Following is a simple example of how to write ODPS output configuration.
|
50
|
+
|
51
|
+
```
|
52
|
+
<source>
|
53
|
+
type tail
|
54
|
+
path /opt/log/in/in.log
|
55
|
+
pos_file /opt/log/in/in.log.pos
|
56
|
+
refresh_interval 5s
|
57
|
+
tag in.log
|
58
|
+
format /^(?<remote>[^ ]*) - - \[(?<datetime>[^\]]*)\] "(?<method>\S+)(?: +(?<path>[^\"]*?)(?: +\S*)?)?" (?<code>[^ ]*) (?<size>[^ ]*) "-" "(?<agent>[^\"]*)"$/
|
59
|
+
time_format %Y%b%d %H:%M:%S %z
|
60
|
+
</source>
|
61
|
+
```
|
62
|
+
```
|
63
|
+
<match in.**>
|
64
|
+
type aliyun_odps
|
65
|
+
aliyun_access_id ************
|
66
|
+
aliyun_access_key *********
|
67
|
+
aliyun_odps_endpoint http://service.odps.aliyun.com/api
|
68
|
+
aliyun_odps_hub_endpoint http://dh.odps.aliyun.com
|
69
|
+
buffer_chunk_limit 2m
|
70
|
+
buffer_queue_limit 128
|
71
|
+
flush_interval 5s
|
72
|
+
project your_projectName
|
73
|
+
<table in.log>
|
74
|
+
table your_tableName
|
75
|
+
fields remote,method,path,code,size,agent
|
76
|
+
partition ctime=${datetime.strftime('%Y%m%d')}
|
77
|
+
time_format %d/%b/%Y:%H:%M:%S %z
|
78
|
+
shard_number 1
|
79
|
+
</table>
|
80
|
+
</match>
|
81
|
+
```
|
82
|
+
### Parameters
|
83
|
+
- type(Fixed): always be aliyun_odps.
|
84
|
+
- aliyun_access_id(Required):your aliyun access id.
|
85
|
+
- aliyun_access_key(Required):your aliyun access key.
|
86
|
+
- aliyun_odps_hub_endpoint(Required):if you are using ECS, set it as http://dh-ext.odps.aliyun-inc.com, otherwise using http://dh.odps.aliyun.com.
|
87
|
+
- aliyunodps_endpoint(Required):if you are using ECS, set it as http://odps-ext.aiyun-inc.com/api, otherwise using http://service.odps.aliyun.com/api .
|
88
|
+
- buffer_chunk_limit(Optional):chunk size,��k�� (KB), ��m�� (MB), and ��g�� (GB) ��default 8MB��recommended number is 2MB.
|
89
|
+
- buffer_queue_limit(Optional):buffer chunk size��example: buffer_chunk_limit2m��buffer_queue_limit 128��then the total buffer size is 2*128MB.
|
90
|
+
- flush_interval(Optional):interval to flush data buffer, default 60s.
|
91
|
+
- project(Required):your project name.
|
92
|
+
- table(Required):your table name.
|
93
|
+
- fields(Required): must match the keys in source.
|
94
|
+
- partition(Optional)��set this if your table is partitioned.
|
95
|
+
- partition format:
|
96
|
+
- fix string: partition ctime=20150804
|
97
|
+
- key words: partition ctime=${remote}
|
98
|
+
- key words int time format: partition ctime=${datetime.strftime('%Y%m%d')}
|
99
|
+
- time_format(Optional):
|
100
|
+
- if the odps table is partitioned, you need to set the param <partition>
|
101
|
+
- if you are using the key words to set your <partition> and the key word is in time format, please set the param <time_format>. example: source[datetime] = "29/Aug/2015:11:10:16 +0800", and the param <time_format> is "%d/%b/%Y:%H:%M:%S %z"
|
102
|
+
- shard_number(Optional):less than the number you set when create the hubtable.
|
103
|
+
|
104
|
+
## Useful Links
|
105
|
+
---
|
106
|
+
|
107
|
+
- [Fluentd User Guide](http://docs.fluentd.org/)
|
108
|
+
|
109
|
+
## Authors && Contributors
|
110
|
+
---
|
111
|
+
|
112
|
+
- [Sun Zongtao]()
|
113
|
+
- [Cai Ying]()
|
114
|
+
- [Dong Xiao](https://github.com/dongxiao1198)
|
115
|
+
- [Yang Hongbo](https://github.com/hongbosoftware)
|
116
|
+
|
117
|
+
## License
|
118
|
+
---
|
119
|
+
|
120
|
+
licensed under the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0.html)
|
data/Rakefile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
|
2
|
+
require 'bundler'
|
3
|
+
Bundler::GemHelper.install_tasks
|
4
|
+
|
5
|
+
require 'rake/testtask'
|
6
|
+
|
7
|
+
Rake::TestTask.new(:test) do |test|
|
8
|
+
test.libs << 'lib' << 'test'
|
9
|
+
test.test_files = FileList['test/test_*.rb']
|
10
|
+
test.verbose = true
|
11
|
+
end
|
12
|
+
|
13
|
+
task :default => [:build]
|
14
|
+
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.1
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
$:.push File.expand_path('../lib', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.name = "fluentd-plugin-aliyun-odps"
|
6
|
+
gem.description = "Aliyun ODPS output plugin for Fluentd event collector"
|
7
|
+
gem.license = "Apache-2.0"
|
8
|
+
gem.homepage = "https://github.com/aliyun/aliyun-odps-fluentd-plugin"
|
9
|
+
gem.summary = gem.description
|
10
|
+
gem.version = File.read("VERSION").strip
|
11
|
+
gem.authors = [""]
|
12
|
+
gem.email = ""
|
13
|
+
gem.has_rdoc = false
|
14
|
+
#gem.platform = Gem::Platform::RUBY
|
15
|
+
gem.files = `git ls-files`.split("\n")
|
16
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
17
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
18
|
+
gem.require_paths = ['lib']
|
19
|
+
|
20
|
+
gem.add_dependency "fluentd", [">= 0.10.49", "< 2"]
|
21
|
+
gem.add_dependency "protobuf", "~> 3.5.1"
|
22
|
+
gem.add_dependency "yajl-ruby", "~> 1.0"
|
23
|
+
gem.add_dependency "fluent-mixin-config-placeholders"
|
24
|
+
gem.add_development_dependency "rake", ">= 0.9.2"
|
25
|
+
gem.add_development_dependency "flexmock", ">= 1.2.0"
|
26
|
+
gem.add_development_dependency "test-unit", ">= 3.0.8"
|
27
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
#
|
2
|
+
#Licensed to the Apache Software Foundation (ASF) under one
|
3
|
+
#or more contributor license agreements. See the NOTICE file
|
4
|
+
#distributed with this work for additional information
|
5
|
+
#regarding copyright ownership. The ASF licenses this file
|
6
|
+
#to you under the Apache License, Version 2.0 (the
|
7
|
+
#"License"); you may not use this file except in compliance
|
8
|
+
#with the License. You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
#Unless required by applicable law or agreed to in writing,
|
13
|
+
#software distributed under the License is distributed on an
|
14
|
+
#"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
15
|
+
#KIND, either express or implied. See the License for the
|
16
|
+
#specific language governing permissions and limitations
|
17
|
+
#under the License.
|
18
|
+
#
|
19
|
+
module OdpsDatahub
|
20
|
+
class OdpsConfig
|
21
|
+
attr_accessor :accessId, :accessKey, :odpsEndpoint, :datahubEndpoint, :defaultProjectName, :userAgent
|
22
|
+
|
23
|
+
def initialize(accessId, accessKey, odpsEndpoint, datahubEndpoint, defaultProjectName = "")
|
24
|
+
@accessId = accessId
|
25
|
+
@accessKey = accessKey
|
26
|
+
@odpsEndpoint = odpsEndpoint
|
27
|
+
@datahubEndpoint = datahubEndpoint
|
28
|
+
@defaultProject = defaultProjectName
|
29
|
+
@userAgent = ""
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,120 @@
|
|
1
|
+
#
|
2
|
+
#Licensed to the Apache Software Foundation (ASF) under one
|
3
|
+
#or more contributor license agreements. See the NOTICE file
|
4
|
+
#distributed with this work for additional information
|
5
|
+
#regarding copyright ownership. The ASF licenses this file
|
6
|
+
#to you under the Apache License, Version 2.0 (the
|
7
|
+
#"License"); you may not use this file except in compliance
|
8
|
+
#with the License. You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
#Unless required by applicable law or agreed to in writing,
|
13
|
+
#software distributed under the License is distributed on an
|
14
|
+
#"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
15
|
+
#KIND, either express or implied. See the License for the
|
16
|
+
#specific language governing permissions and limitations
|
17
|
+
#under the License.
|
18
|
+
#
|
19
|
+
require 'digest'
|
20
|
+
module Digest
|
21
|
+
#
|
22
|
+
# Base class for all CRC algorithms.
|
23
|
+
#
|
24
|
+
class CRC < Digest::Class
|
25
|
+
include Digest::Instance
|
26
|
+
# The initial value of the CRC checksum
|
27
|
+
INIT_CRC = 0x00
|
28
|
+
# The XOR mask to apply to the resulting CRC checksum
|
29
|
+
XOR_MASK = 0x00
|
30
|
+
# The bit width of the CRC checksum
|
31
|
+
WIDTH = 0
|
32
|
+
#
|
33
|
+
# Calculates the CRC checksum.
|
34
|
+
#
|
35
|
+
# @param [String] data
|
36
|
+
# The given data.
|
37
|
+
#
|
38
|
+
# @return [Integer]
|
39
|
+
# The CRC checksum.
|
40
|
+
#
|
41
|
+
def self.checksum(data)
|
42
|
+
crc = self.new
|
43
|
+
crc << data
|
44
|
+
return crc.checksum
|
45
|
+
end
|
46
|
+
#
|
47
|
+
# Packs the given CRC checksum.
|
48
|
+
#
|
49
|
+
# @return [String]
|
50
|
+
# The packed CRC checksum.
|
51
|
+
#
|
52
|
+
def self.pack(crc)
|
53
|
+
''
|
54
|
+
end
|
55
|
+
#
|
56
|
+
# Initializes the CRC checksum.
|
57
|
+
#
|
58
|
+
def initialize
|
59
|
+
@crc = self.class.const_get(:INIT_CRC)
|
60
|
+
end
|
61
|
+
#
|
62
|
+
# The input block length.
|
63
|
+
#
|
64
|
+
# @return [1]
|
65
|
+
#
|
66
|
+
def block_length
|
67
|
+
1
|
68
|
+
end
|
69
|
+
#
|
70
|
+
# The length of the digest.
|
71
|
+
#
|
72
|
+
# @return [Integer]
|
73
|
+
# The length in bytes.
|
74
|
+
#
|
75
|
+
def digest_length
|
76
|
+
(self.class.const_get(:WIDTH) / 8.0).ceil
|
77
|
+
end
|
78
|
+
#
|
79
|
+
# Updates the CRC checksum with the given data.
|
80
|
+
#
|
81
|
+
# @param [String] data
|
82
|
+
# The data to update the CRC checksum with.
|
83
|
+
#
|
84
|
+
def update(data)
|
85
|
+
end
|
86
|
+
#
|
87
|
+
# @see {#update}
|
88
|
+
#
|
89
|
+
def <<(data)
|
90
|
+
update(data)
|
91
|
+
return self
|
92
|
+
end
|
93
|
+
#
|
94
|
+
# Resets the CRC checksum.
|
95
|
+
#
|
96
|
+
# @return [Integer]
|
97
|
+
# The default value of the CRC checksum.
|
98
|
+
#
|
99
|
+
def reset
|
100
|
+
@crc = self.class.const_get(:INIT_CRC)
|
101
|
+
end
|
102
|
+
#
|
103
|
+
# The resulting CRC checksum.
|
104
|
+
#
|
105
|
+
# @return [Integer]
|
106
|
+
# The resulting CRC checksum.
|
107
|
+
#
|
108
|
+
def checksum
|
109
|
+
@crc ^ self.class.const_get(:XOR_MASK)
|
110
|
+
end
|
111
|
+
#
|
112
|
+
# Finishes the CRC checksum calculation.
|
113
|
+
#
|
114
|
+
# @see {pack}
|
115
|
+
#
|
116
|
+
def finish
|
117
|
+
self.class.pack(checksum)
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
@@ -0,0 +1,125 @@
|
|
1
|
+
#
|
2
|
+
#Licensed to the Apache Software Foundation (ASF) under one
|
3
|
+
#or more contributor license agreements. See the NOTICE file
|
4
|
+
#distributed with this work for additional information
|
5
|
+
#regarding copyright ownership. The ASF licenses this file
|
6
|
+
#to you under the Apache License, Version 2.0 (the
|
7
|
+
#"License"); you may not use this file except in compliance
|
8
|
+
#with the License. You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
#Unless required by applicable law or agreed to in writing,
|
13
|
+
#software distributed under the License is distributed on an
|
14
|
+
#"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
15
|
+
#KIND, either express or implied. See the License for the
|
16
|
+
#specific language governing permissions and limitations
|
17
|
+
#under the License.
|
18
|
+
#
|
19
|
+
require_relative 'crc'
|
20
|
+
module Digest
|
21
|
+
#
|
22
|
+
# Implements the CRC32 algorithm.
|
23
|
+
#
|
24
|
+
class CRC32 < CRC
|
25
|
+
WIDTH = 4
|
26
|
+
INIT_CRC = 0xffffffff
|
27
|
+
XOR_MASK = 0xffffffff
|
28
|
+
# Generated by `./pycrc.py --algorithm=table-driven --model=crc-32 --generate=c`
|
29
|
+
TABLE = [
|
30
|
+
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba,
|
31
|
+
0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3,
|
32
|
+
0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
|
33
|
+
0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91,
|
34
|
+
0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de,
|
35
|
+
0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
|
36
|
+
0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec,
|
37
|
+
0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5,
|
38
|
+
0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172,
|
39
|
+
0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b,
|
40
|
+
0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940,
|
41
|
+
0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
|
42
|
+
0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116,
|
43
|
+
0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f,
|
44
|
+
0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
|
45
|
+
0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d,
|
46
|
+
0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a,
|
47
|
+
0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
|
48
|
+
0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818,
|
49
|
+
0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01,
|
50
|
+
0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e,
|
51
|
+
0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457,
|
52
|
+
0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c,
|
53
|
+
0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
|
54
|
+
0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2,
|
55
|
+
0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb,
|
56
|
+
0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0,
|
57
|
+
0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9,
|
58
|
+
0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086,
|
59
|
+
0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
|
60
|
+
0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4,
|
61
|
+
0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad,
|
62
|
+
0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a,
|
63
|
+
0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683,
|
64
|
+
0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8,
|
65
|
+
0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
|
66
|
+
0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe,
|
67
|
+
0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7,
|
68
|
+
0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc,
|
69
|
+
0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5,
|
70
|
+
0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252,
|
71
|
+
0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
|
72
|
+
0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60,
|
73
|
+
0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79,
|
74
|
+
0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
|
75
|
+
0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f,
|
76
|
+
0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04,
|
77
|
+
0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
|
78
|
+
0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a,
|
79
|
+
0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713,
|
80
|
+
0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38,
|
81
|
+
0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21,
|
82
|
+
0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e,
|
83
|
+
0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
|
84
|
+
0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c,
|
85
|
+
0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45,
|
86
|
+
0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2,
|
87
|
+
0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db,
|
88
|
+
0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0,
|
89
|
+
0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
|
90
|
+
0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6,
|
91
|
+
0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf,
|
92
|
+
0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94,
|
93
|
+
0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d
|
94
|
+
]
|
95
|
+
#
|
96
|
+
# Packs the CRC32 checksum.
|
97
|
+
#
|
98
|
+
# @param [Integer] crc
|
99
|
+
# The checksum to pack.
|
100
|
+
#
|
101
|
+
# @return [String]
|
102
|
+
# The packed checksum.
|
103
|
+
#
|
104
|
+
def self.pack(crc)
|
105
|
+
buffer = ''
|
106
|
+
buffer << ((crc & 0xff000000) >> 24).chr
|
107
|
+
buffer << ((crc & 0xff0000) >> 16).chr
|
108
|
+
buffer << ((crc & 0xff00) >> 8).chr
|
109
|
+
buffer << (crc & 0xff).chr
|
110
|
+
buffer
|
111
|
+
end
|
112
|
+
#
|
113
|
+
# Updates the CRC32 checksum.
|
114
|
+
#
|
115
|
+
# @param [String] data
|
116
|
+
# The data to update the checksum with.
|
117
|
+
#
|
118
|
+
def update(data)
|
119
|
+
data.each_byte do |b|
|
120
|
+
@crc = (((@crc >> 8) & 0x00ffffff) ^ TABLE[(@crc ^ b) & 0xff])
|
121
|
+
end
|
122
|
+
return self
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|