class ZSTDS::Dictionary
ZSTDS::Dictionary class.
Constants
- FINALIZE_DEFAULTS
Current finalize defaults.
- FINALIZE_DICTIONARY_DEFAULTS
Current finalize dictionary defaults.
- TRAIN_DEFAULTS
Current train defaults.
Attributes
Reads current buffer binary data.
Public Class Methods
Finalizes dictionary. Uses content binary data. Uses samples list of binary datas. Uses options options hash. Option gvl is global interpreter lock enabled. Option max_size max size of dictionary buffer. Option dictionary_options standard dictionary options hash. Returns dictionary based on new buffer.
# File lib/zstds/dictionary.rb, line 75 def self.finalize(content, samples, options = {}) Validation.validate_string content raise ValidateError, "content should not be empty" if content.empty? validate_samples samples Validation.validate_hash options options = FINALIZE_DEFAULTS.merge options Validation.validate_bool options[:gvl] Validation.validate_not_negative_integer options[:max_size] Validation.validate_hash options[:dictionary_options] dictionary_options = FINALIZE_DICTIONARY_DEFAULTS.merge options[:dictionary_options] compression_level = dictionary_options[:compression_level] Validation.validate_integer compression_level raise ValidateError, "invalid compression level" if compression_level < Option::MIN_COMPRESSION_LEVEL || compression_level > Option::MAX_COMPRESSION_LEVEL Validation.validate_not_negative_integer dictionary_options[:notification_level] Validation.validate_not_negative_integer dictionary_options[:dictionary_id] buffer = finalize_buffer content, samples, options new buffer end
Initializes compressor. Uses buffer binary data.
# File lib/zstds/dictionary.rb, line 40 def initialize(buffer) Validation.validate_string buffer raise ValidateError, "dictionary buffer should not be empty" if buffer.empty? @buffer = buffer end
Trains dictionary. Uses samples list of binary datas. Uses options options hash. Option gvl is global interpreter lock enabled. Option capacity capacity of dictionary buffer. Returns dictionary based on new buffer.
# File lib/zstds/dictionary.rb, line 53 def self.train(samples, options = {}) validate_samples samples Validation.validate_hash options options = TRAIN_DEFAULTS.merge options Validation.validate_bool options[:gvl] Validation.validate_not_negative_integer options[:capacity] buffer = train_buffer samples, options new buffer end
Raises error when samples are not list of not empty strings.
# File lib/zstds/dictionary.rb, line 104 def self.validate_samples(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 end
Public Instance Methods
Returns current dictionary header size.
# File lib/zstds/dictionary.rb, line 119 def header_size self.class.get_header_size @buffer end
Returns current dictionary id.
# File lib/zstds/dictionary.rb, line 114 def id self.class.get_buffer_id @buffer end