Class: Pocolog::BlockStream::DataBlockHeader
- Inherits:
-
Object
- Object
- Pocolog::BlockStream::DataBlockHeader
- Defined in:
- lib/pocolog/block_stream.rb
Overview
Information about a data block
Direct Known Subclasses
Instance Attribute Summary collapse
-
#data_size ⇒ Integer
readonly
Size in bytes of the marshalled data sample.
-
#lg_time ⇒ Integer
readonly
Timestamp in logical time for this block, in microseconds.
-
#rt_time ⇒ Integer
readonly
Timestamp in realtime for this block, in microseconds.
Class Method Summary collapse
Instance Method Summary collapse
-
#compressed? ⇒ Boolean
deprecated
Deprecated.
whether the sample is compressed
-
#initialize(rt_time, lg_time, data_size, compressed) ⇒ DataBlockHeader
constructor
A new instance of DataBlockHeader.
-
#lg ⇒ Time
Timestamp in logical time.
-
#rt ⇒ Time
Timestamp in realtime.
Constructor Details
#initialize(rt_time, lg_time, data_size, compressed) ⇒ DataBlockHeader
Returns a new instance of DataBlockHeader.
384 385 386 387 388 389 |
# File 'lib/pocolog/block_stream.rb', line 384 def initialize(rt_time, lg_time, data_size, compressed) @rt_time = rt_time @lg_time = lg_time @data_size = data_size @compressed = compressed end |
Instance Attribute Details
#data_size ⇒ Integer (readonly)
Size in bytes of the marshalled data sample
359 360 361 |
# File 'lib/pocolog/block_stream.rb', line 359 def data_size @data_size end |
#lg_time ⇒ Integer (readonly)
Timestamp in logical time for this block, in microseconds
354 355 356 |
# File 'lib/pocolog/block_stream.rb', line 354 def lg_time @lg_time end |
#rt_time ⇒ Integer (readonly)
Timestamp in realtime for this block, in microseconds
348 349 350 |
# File 'lib/pocolog/block_stream.rb', line 348 def rt_time @rt_time end |
Class Method Details
.parse(raw_data) ⇒ Object
369 370 371 372 373 374 375 376 377 378 379 380 381 382 |
# File 'lib/pocolog/block_stream.rb', line 369 def self.parse(raw_data) if raw_data.size < Format::Current::DATA_BLOCK_HEADER_SIZE raise NotEnoughData, "expected #{Format::Current::DATA_BLOCK_HEADER_SIZE} bytes "\ "for a data block header, but got only #{raw_data.size}" end rt_sec, rt_usec, lg_sec, lg_usec, data_size, compressed = raw_data.unpack("VVVVVC") new(rt_sec * 1_000_000 + rt_usec, lg_sec * 1_000_000 + lg_usec, data_size, compressed != 0) end |
Instance Method Details
#compressed? ⇒ Boolean
Deprecated.
whether the sample is compressed
Per-sample compression should simply not be used. On anything but gigantic samples it introduces a massive overhead for little gain
365 366 367 |
# File 'lib/pocolog/block_stream.rb', line 365 def compressed? @compressed end |
#lg ⇒ Time
Timestamp in logical time
401 402 403 |
# File 'lib/pocolog/block_stream.rb', line 401 def lg StreamIndex.time_from_internal(lg_time, 0) end |
#rt ⇒ Time
Timestamp in realtime
394 395 396 |
# File 'lib/pocolog/block_stream.rb', line 394 def rt StreamIndex.time_from_internal(rt_time, 0) end |