Class Tablet


  • public class Tablet
    extends java.lang.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 Summary

      Fields 
      Modifier and Type Field Description
      BitMap[] bitMaps
      each bitmap represents the existence of each value in the current column.
      java.lang.String deviceId
      deviceId of this tablet
      int rowSize
      the number of rows to include in this tablet
      long[] timestamps
      timestamps in this tablet
      java.lang.Object[] values
      each object is a primitive type array, which represents values of one measurement
    • Constructor Summary

      Constructors 
      Constructor Description
      Tablet​(java.lang.String deviceId, java.util.List<MeasurementSchema> schemas)
      Return a tablet with default specified row number.
      Tablet​(java.lang.String deviceId, java.util.List<MeasurementSchema> schemas, int maxRowNumber)
      Return a tablet with the specified number of rows (maxBatchSize).
      Tablet​(java.lang.String deviceId, java.util.List<MeasurementSchema> schemas, long[] timestamps, java.lang.Object[] values, BitMap[] bitMaps, int maxRowNumber)
      Return a tablet with specified timestamps and values.
    • Field Detail

      • deviceId

        public java.lang.String deviceId
        deviceId of this tablet
      • timestamps

        public long[] timestamps
        timestamps in this tablet
      • values

        public java.lang.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​(java.lang.String deviceId,
                      java.util.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​(java.lang.String deviceId,
                      java.util.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​(java.lang.String deviceId,
                      java.util.List<MeasurementSchema> schemas,
                      long[] timestamps,
                      java.lang.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​(java.lang.String deviceId)
      • initBitMaps

        public void initBitMaps()
      • addTimestamp

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

        public void addValue​(java.lang.String measurementId,
                             int rowIndex,
                             java.lang.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
      • serialize

        public java.nio.ByteBuffer serialize()
                                      throws java.io.IOException
        serialize Tablet
        Throws:
        java.io.IOException
      • serialize

        public void serialize​(java.io.DataOutputStream stream)
                       throws java.io.IOException
        Throws:
        java.io.IOException
      • deserialize

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

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

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

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object