Class Tablet


  • public class Tablet
    extends Object
    A tablet data of one device, the tablet contains multiple measurements of this device that share the same time column.

    for example: device root.sg1.d1

    time, m1, m2, m3 1, 1, 2, 3 2, 1, 2, 3 3, 1, 2, 3

    Notice: The tablet should not have empty cell, please use BitMap to denote null value

    • Field Detail

      • deviceId

        public String deviceId
        deviceId of this tablet
      • timestamps

        public long[] timestamps
        timestamps in this tablet
      • values

        public Object[] values
        each object is a primitive type array, which represents values of one measurement
      • bitMaps

        public BitMap[] bitMaps
        each bitmap represents the existence of each value in the current column.
      • rowSize

        public int rowSize
        the number of rows to include in this tablet
    • Constructor Detail

      • Tablet

        public Tablet​(String deviceId,
                      List<MeasurementSchema> schemas)
        Return a tablet with default specified row number. This is the standard constructor (all Tablet should be the same size).
        Parameters:
        deviceId - the name of the device specified to be written in
        schemas - the list of measurement schemas for creating the tablet, only measurementId and type take effects
      • Tablet

        public Tablet​(String deviceId,
                      List<MeasurementSchema> schemas,
                      int maxRowNumber)
        Return a tablet with the specified number of rows (maxBatchSize). Only call this constructor directly for testing purposes. Tablet should normally always be default size.
        Parameters:
        deviceId - the name of the device specified to be written in
        schemas - the list of measurement schemas for creating the row batch, only measurementId and type take effects
        maxRowNumber - the maximum number of rows for this tablet
      • Tablet

        public Tablet​(String deviceId,
                      List<MeasurementSchema> schemas,
                      long[] timestamps,
                      Object[] values,
                      BitMap[] bitMaps,
                      int maxRowNumber)
        Return a tablet with specified timestamps and values. Only call this constructor directly for Trigger.
        Parameters:
        deviceId - the name of the device specified to be written in
        schemas - the list of measurement schemas for creating the row batch, only measurementId and type take effects
        timestamps - given timestamps
        values - given values
        bitMaps - given bitmaps
        maxRowNumber - the maximum number of rows for this tablet
    • Method Detail

      • setDeviceId

        public void setDeviceId​(String deviceId)
      • initBitMaps

        public void initBitMaps()
      • addTimestamp

        public void addTimestamp​(int rowIndex,
                                 long timestamp)
      • addValue

        public void addValue​(String measurementId,
                             int rowIndex,
                             Object value)
      • getMaxRowNumber

        public int getMaxRowNumber()
        Return the maximum number of rows for this tablet
      • reset

        public void reset()
        Reset Tablet to the default state - set the rowSize to 0 and reset bitMaps
      • getTimeBytesSize

        public int getTimeBytesSize()
      • getTotalValueOccupation

        public int getTotalValueOccupation()
        Returns:
        total bytes of values
      • deserialize

        public static Tablet deserialize​(ByteBuffer byteBuffer)
        Deserialize Tablet
      • readBitMapsFromBuffer

        public static BitMap[] readBitMapsFromBuffer​(ByteBuffer byteBuffer,
                                                     int columns)
        deserialize bitmaps
      • readTabletValuesFromBuffer

        public static Object[] readTabletValuesFromBuffer​(ByteBuffer byteBuffer,
                                                          TSDataType[] types,
                                                          int columns,
                                                          int rowSize)
        Parameters:
        byteBuffer - data values
        columns - column number