Class: ZSTDS::Dictionary
- Inherits:
-
Object
- Object
- ZSTDS::Dictionary
- Defined in:
- lib/zstds/dictionary.rb
Constant Summary collapse
- TRAIN_DEFAULTS =
{ :gvl => false, :capacity => 0 } .freeze
Instance Attribute Summary collapse
-
#buffer ⇒ Object
readonly
Returns the value of attribute buffer.
Class Method Summary collapse
Instance Method Summary collapse
- #id ⇒ Object
-
#initialize(buffer) ⇒ Dictionary
constructor
A new instance of Dictionary.
Constructor Details
#initialize(buffer) ⇒ Dictionary
Returns a new instance of Dictionary.
19 20 21 22 23 24 |
# File 'lib/zstds/dictionary.rb', line 19 def initialize(buffer) Validation.validate_string buffer raise ValidateError, "dictionary buffer should not be empty" if buffer.empty? @buffer = buffer end |
Instance Attribute Details
#buffer ⇒ Object (readonly)
Returns the value of attribute buffer.
17 18 19 |
# File 'lib/zstds/dictionary.rb', line 17 def buffer @buffer end |
Class Method Details
.train(samples, options = {}) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/zstds/dictionary.rb', line 30 def self.train(samples, = {}) Validation.validate_array samples samples.each do |sample| Validation.validate_string sample raise ValidateError, "dictionary sample should not be empty" if sample.empty? end Validation.validate_hash = TRAIN_DEFAULTS.merge Validation.validate_bool [:gvl] Validation.validate_not_negative_integer [:capacity] buffer = train_buffer samples, new buffer end |
Instance Method Details
#id ⇒ Object
26 27 28 |
# File 'lib/zstds/dictionary.rb', line 26 def id self.class.get_buffer_id @buffer end |