Class: OdpsDatahub::CrcCalculator
- Inherits:
-
Object
- Object
- OdpsDatahub::CrcCalculator
- Defined in:
- lib/fluent/plugin/crc/crc.rb
Class Method Summary collapse
-
.calculate(data) ⇒ Object
Crc32c to_i.
- .getOsType ⇒ Object
Class Method Details
.calculate(data) ⇒ Object
Returns crc32c to_i.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/fluent/plugin/crc/crc.rb', line 24 def self.calculate(data) if (!$USE_FAST_CRC) require_relative 'origin/crc32c' crc32c = Digest::CRC32c.new crc32c.update(data.string) return crc32c.checksum.to_i elsif getOsType == "linux" || getOsType == "unix" require_relative 'lib/linux/crc32c.so' return Crc32c.calculate(data.string, data.length, 0).to_i elsif getOsType == "windows" require_relative 'lib/win/crc32c.so' return Crc32c.calculate(data.string, data.length, 0).to_i end end |
.getOsType ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/fluent/plugin/crc/crc.rb', line 39 def self.getOsType host_os = RbConfig::CONFIG['host_os'] case host_os when /mswin|msys|mingw|cygwin|bccwin|wince|emc/ "windows" when /linux/ "linux" when /solaris|bsd/ "unix" else raise Error::WebDriverError, "unspport os" end end |