Class: Pocolog::BlockStream::DataBlockHeader

Inherits:
Object
  • Object
show all
Defined in:
lib/pocolog/block_stream.rb

Overview

Information about a data block

Direct Known Subclasses

Logfiles::DataHeader

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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_sizeInteger (readonly)

Size in bytes of the marshalled data sample

Returns:

  • (Integer)


359
360
361
# File 'lib/pocolog/block_stream.rb', line 359

def data_size
  @data_size
end

#lg_timeInteger (readonly)

Timestamp in logical time for this block, in microseconds

Returns:

  • (Integer)

See Also:



354
355
356
# File 'lib/pocolog/block_stream.rb', line 354

def lg_time
  @lg_time
end

#rt_timeInteger (readonly)

Timestamp in realtime for this block, in microseconds

Returns:

  • (Integer)

See Also:



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

Returns:

  • (Boolean)


365
366
367
# File 'lib/pocolog/block_stream.rb', line 365

def compressed?
    @compressed
end

#lgTime

Timestamp in logical time

Returns:

  • (Time)


401
402
403
# File 'lib/pocolog/block_stream.rb', line 401

def lg
    StreamIndex.time_from_internal(lg_time, 0)
end

#rtTime

Timestamp in realtime

Returns:

  • (Time)


394
395
396
# File 'lib/pocolog/block_stream.rb', line 394

def rt
    StreamIndex.time_from_internal(rt_time, 0)
end