Class DeviceTimeIndex

  • All Implemented Interfaces:
    ITimeIndex

    public class DeviceTimeIndex
    extends java.lang.Object
    implements ITimeIndex
    • Constructor Summary

      Constructors 
      Constructor Description
      DeviceTimeIndex()  
      DeviceTimeIndex​(java.util.Map<java.lang.String,​java.lang.Integer> deviceToIndex, long[] startTimes, long[] endTimes)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      long calculateRamSize()  
      boolean checkDeviceIdExist​(java.lang.String deviceId)
      check whether deviceId exists in TsFile
      void close()
      do something when TsFileResource is closing (may be empty method)
      int compareDegradePriority​(ITimeIndex timeIndex)
      compare the priority of two ITimeIndex
      DeviceTimeIndex deserialize​(java.io.InputStream inputStream)
      deserialize from inputStream
      DeviceTimeIndex deserialize​(java.nio.ByteBuffer buffer)
      deserialize from byte buffer
      boolean endTimeEmpty()  
      java.util.Set<java.lang.String> getDevices​(java.lang.String tsFilePath, TsFileResource tsFileResource)
      get devices in TimeIndex
      long getEndTime​(java.lang.String deviceId)
      get end time of device
      long getMaxEndTime()
      get max end time of device
      long getMinStartTime()
      get min start time of device
      long getStartTime​(java.lang.String deviceId)
      get start time of device
      long getTimePartition​(java.lang.String tsFilePath)
      get time partition
      long getTimePartitionWithCheck​(java.lang.String tsFilePath)
      get time partition with check.
      boolean isSpanMultiTimePartitions()
      Check whether the tsFile spans multiple time partitions.
      boolean mayContainsDevice​(java.lang.String device)
      Whether this TsFile contains this device, if false, it must not contain this device, if true, it may or may not contain this device
      void putEndTime​(java.lang.String deviceId, long time)
      put end time
      void putStartTime​(java.lang.String deviceId, long time)
      put start time
      void serialize​(java.io.OutputStream outputStream)
      serialize to outputStream
      boolean stillLives​(long ttlLowerBound)  
      void updateEndTime​(java.lang.String deviceId, long time)
      update end time
      void updateStartTime​(java.lang.String deviceId, long time)
      update start time
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • startTimes

        protected long[] startTimes
        start times array.
      • endTimes

        protected long[] endTimes
        end times array. The values in this array are Long.MIN_VALUE if it's an unsealed sequence tsfile
      • deviceToIndex

        protected java.util.Map<java.lang.String,​java.lang.Integer> deviceToIndex
        device -> index of start times array and end times array
    • Constructor Detail

      • DeviceTimeIndex

        public DeviceTimeIndex()
      • DeviceTimeIndex

        public DeviceTimeIndex​(java.util.Map<java.lang.String,​java.lang.Integer> deviceToIndex,
                               long[] startTimes,
                               long[] endTimes)
    • Method Detail

      • serialize

        public void serialize​(java.io.OutputStream outputStream)
                       throws java.io.IOException
        Description copied from interface: ITimeIndex
        serialize to outputStream
        Specified by:
        serialize in interface ITimeIndex
        Parameters:
        outputStream - outputStream
        Throws:
        java.io.IOException
      • deserialize

        public DeviceTimeIndex deserialize​(java.io.InputStream inputStream)
                                    throws java.io.IOException
        Description copied from interface: ITimeIndex
        deserialize from inputStream
        Specified by:
        deserialize in interface ITimeIndex
        Parameters:
        inputStream - inputStream
        Returns:
        TimeIndex
        Throws:
        java.io.IOException
      • deserialize

        public DeviceTimeIndex deserialize​(java.nio.ByteBuffer buffer)
        Description copied from interface: ITimeIndex
        deserialize from byte buffer
        Specified by:
        deserialize in interface ITimeIndex
        Parameters:
        buffer - byte buffer
        Returns:
        TimeIndex
      • close

        public void close()
        Description copied from interface: ITimeIndex
        do something when TsFileResource is closing (may be empty method)
        Specified by:
        close in interface ITimeIndex
      • getDevices

        public java.util.Set<java.lang.String> getDevices​(java.lang.String tsFilePath,
                                                          TsFileResource tsFileResource)
        Description copied from interface: ITimeIndex
        get devices in TimeIndex
        Specified by:
        getDevices in interface ITimeIndex
        Returns:
        device names
      • endTimeEmpty

        public boolean endTimeEmpty()
        Specified by:
        endTimeEmpty in interface ITimeIndex
        Returns:
        whether end time is empty (Long.MIN_VALUE)
      • stillLives

        public boolean stillLives​(long ttlLowerBound)
        Specified by:
        stillLives in interface ITimeIndex
        Parameters:
        ttlLowerBound - time lower bound
        Returns:
        whether any of the device lives over the given time bound
      • calculateRamSize

        public long calculateRamSize()
        Specified by:
        calculateRamSize in interface ITimeIndex
        Returns:
        Calculate file index ram size
      • getTimePartition

        public long getTimePartition​(java.lang.String tsFilePath)
        Description copied from interface: ITimeIndex
        get time partition
        Specified by:
        getTimePartition in interface ITimeIndex
        Parameters:
        tsFilePath - tsFile absolute path
        Returns:
        partition
      • isSpanMultiTimePartitions

        public boolean isSpanMultiTimePartitions()
        Description copied from interface: ITimeIndex
        Check whether the tsFile spans multiple time partitions.
        Specified by:
        isSpanMultiTimePartitions in interface ITimeIndex
        Returns:
        true if the tsFile spans multiple time partitions, otherwise false.
      • updateStartTime

        public void updateStartTime​(java.lang.String deviceId,
                                    long time)
        Description copied from interface: ITimeIndex
        update start time
        Specified by:
        updateStartTime in interface ITimeIndex
        Parameters:
        deviceId - device name
        time - start time
      • updateEndTime

        public void updateEndTime​(java.lang.String deviceId,
                                  long time)
        Description copied from interface: ITimeIndex
        update end time
        Specified by:
        updateEndTime in interface ITimeIndex
        Parameters:
        deviceId - device name
        time - end time
      • putStartTime

        public void putStartTime​(java.lang.String deviceId,
                                 long time)
        Description copied from interface: ITimeIndex
        put start time
        Specified by:
        putStartTime in interface ITimeIndex
        Parameters:
        deviceId - device name
        time - start time
      • putEndTime

        public void putEndTime​(java.lang.String deviceId,
                               long time)
        Description copied from interface: ITimeIndex
        put end time
        Specified by:
        putEndTime in interface ITimeIndex
        Parameters:
        deviceId - device name
        time - end time
      • getStartTime

        public long getStartTime​(java.lang.String deviceId)
        Description copied from interface: ITimeIndex
        get start time of device
        Specified by:
        getStartTime in interface ITimeIndex
        Parameters:
        deviceId - device name
        Returns:
        start time
      • getEndTime

        public long getEndTime​(java.lang.String deviceId)
        Description copied from interface: ITimeIndex
        get end time of device
        Specified by:
        getEndTime in interface ITimeIndex
        Parameters:
        deviceId - device name
        Returns:
        end time
      • checkDeviceIdExist

        public boolean checkDeviceIdExist​(java.lang.String deviceId)
        Description copied from interface: ITimeIndex
        check whether deviceId exists in TsFile
        Specified by:
        checkDeviceIdExist in interface ITimeIndex
        Parameters:
        deviceId - device name
        Returns:
        true if the deviceId may exist in TsFile, otherwise false.
      • getMinStartTime

        public long getMinStartTime()
        Description copied from interface: ITimeIndex
        get min start time of device
        Specified by:
        getMinStartTime in interface ITimeIndex
        Returns:
        min start time
      • getMaxEndTime

        public long getMaxEndTime()
        Description copied from interface: ITimeIndex
        get max end time of device
        Specified by:
        getMaxEndTime in interface ITimeIndex
        Returns:
        max end time
      • compareDegradePriority

        public int compareDegradePriority​(ITimeIndex timeIndex)
        Description copied from interface: ITimeIndex
        compare the priority of two ITimeIndex
        Specified by:
        compareDegradePriority in interface ITimeIndex
        Parameters:
        timeIndex - another timeIndex
        Returns:
        value is less than 0 if the priority of this timeIndex is higher than the argument, value is equal to 0 if the priority of this timeIndex is equal to the argument, value is larger than 0 if the priority of this timeIndex is less than the argument
      • mayContainsDevice

        public boolean mayContainsDevice​(java.lang.String device)
        Description copied from interface: ITimeIndex
        Whether this TsFile contains this device, if false, it must not contain this device, if true, it may or may not contain this device
        Specified by:
        mayContainsDevice in interface ITimeIndex