Class SortedTimeSegment

java.lang.Object
org.yamcs.parameterarchive.BaseSegment
org.yamcs.parameterarchive.SortedTimeSegment

public class SortedTimeSegment extends BaseSegment
TimeSegment stores timestamps relative to a segmentStart. The timestamps are stored in a sorted int array.

The timestamps have to be larger than the segmentStart and have to be part of the same interval (see ParameterArchive.INTERVAL_MASK.

  • Field Details

  • Constructor Details

    • SortedTimeSegment

      public SortedTimeSegment(long segmentStart)
  • Method Details

    • add

      public int add(long instant)
      Insert instant into the array and return the position at which it has been inserted.
      Parameters:
      instant -
    • getTime

      public long getTime(int idx)
      get timestamp at position idx
      Parameters:
      idx -
      Returns:
    • search

      public int search(long instant)
      performs a binary search in the time segment and returns the position of t or where t would fit in.

      Note that this works even if the value would not fit in the same interval, which would cause a subsequent add operation to fail.

      Parameters:
      instant -
      Returns:
      See Also:
    • size

      public int size()
      Specified by:
      size in class BaseSegment
    • getSegmentStart

      public long getSegmentStart()
    • writeTo

      public void writeTo(ByteBuffer bb)
      Specified by:
      writeTo in class BaseSegment
    • writeTo

      public static void writeTo(SortedIntArray tsarray, ByteBuffer bb)
      Encode the time array
    • parseFrom

      public static SortedTimeSegment parseFrom(ByteBuffer bb, long segmentStart) throws DecodingException
      Throws:
      DecodingException
    • getMaxSerializedSize

      public int getMaxSerializedSize()
      Specified by:
      getMaxSerializedSize in class BaseSegment
      Returns:
      a high approximation for the serialized size in order to allocate a ByteBuffer big enough
    • getSegmentEnd

      public long getSegmentEnd()
    • getRange

      public long[] getRange(int posStart, int posStop, boolean ascending)
    • getRangeWithGaps

      public long[] getRangeWithGaps(int posStart, int posStop, boolean ascending, SortedIntArray gaps)
      Get the range between posStart and posStop skipping the positions that are in the gaps array
    • toString

      public String toString()
      Overrides:
      toString in class Object