Class: HKeyPerfDataReader::BinaryParser

Inherits:
Object
  • Object
show all
Includes:
RawType
Defined in:
lib/fluent/plugin/hkey_perf_data_raw_type.rb

Instance Method Summary collapse

Constructor Details

#initialize(is_little_endian: true) ⇒ BinaryParser

Returns a new instance of BinaryParser.



95
96
97
98
99
100
101
102
103
104
105
# File 'lib/fluent/plugin/hkey_perf_data_raw_type.rb', line 95

def initialize(is_little_endian: true)
  @is_little_endian = is_little_endian

  # In order to speed up the parsing, initialize each bindata first.

  # https://github.com/dmendel/bindata/wiki/FAQ#how-do-i-speed-up-initialization

  @data_block = PerfDataBlock.new(:endian => endian)
  @object_type = PerfObjectType.new(:endian => endian)
  @counter_definition = PerfCounterDefinition.new(:endian => endian)
  @counter_block = PerfCounterBlock.new(:endian => endian)
  @instance_definition = PerfInstanceDefinition.new(:endian => endian)
end

Instance Method Details

#parse_counter_block(data) ⇒ Object



125
126
127
128
129
# File 'lib/fluent/plugin/hkey_perf_data_raw_type.rb', line 125

def parse_counter_block(data)
  result = @counter_block.read(data).snapshot
  @counter_block.clear
  result
end

#parse_counter_definition(data) ⇒ Object



119
120
121
122
123
# File 'lib/fluent/plugin/hkey_perf_data_raw_type.rb', line 119

def parse_counter_definition(data)
  result = @counter_definition.read(data).snapshot
  @counter_definition.clear
  result
end

#parse_data_block(data) ⇒ Object



107
108
109
110
111
# File 'lib/fluent/plugin/hkey_perf_data_raw_type.rb', line 107

def parse_data_block(data)
  result = @data_block.read(data).snapshot
  @data_block.clear
  result
end

#parse_instance_definition(data) ⇒ Object



131
132
133
134
135
# File 'lib/fluent/plugin/hkey_perf_data_raw_type.rb', line 131

def parse_instance_definition(data)
  result = @instance_definition.read(data).snapshot
  @instance_definition.clear
  result
end

#parse_object_type(data) ⇒ Object



113
114
115
116
117
# File 'lib/fluent/plugin/hkey_perf_data_raw_type.rb', line 113

def parse_object_type(data)
  result = @object_type.read(data).snapshot
  @object_type.clear
  result
end