code: public byte[] toByteArray() {
          int arrSize = 1 + Long.BYTES;  // first byte specifies type of data
          byte type;
          if (data instanceof Long) {
              arrSize += Long.BYTES;
              type = TYPE_LONG;
          } else if (data instanceof Double) {
              arrSize += Double.BYTES;
              type = TYPE_DOUBLE;
          } else {
              arrSize += Integer.BYTES + ((String) data).length();
              type = TYPE_STRING;
          }
  
          ByteBuffer buf = ByteBuffer.allocate(arrSize);
          buf.putLong(time);
          buf.put(type);
          if (type == TYPE_LONG) {
              buf.putLong((Long) data);
          } else if (type == TYPE_DOUBLE) {
              buf.putDouble((Double) data);
          } else {
              String temp = (String) data;
              buf.putInt(temp.length());
              buf.put(temp.getBytes());
          }
          buf.flip();
          return buf.array();
      }
docs: Returns the byte array representation of this data point. Byte array format are as follows:
  
  Starts with 8 bytes for time and 1 byte for type for a total of 9 bytes. Then, based on value
  type, it does the following:
  
  (1) int/long/float/double: 8 bytes for the value, for 17 total bytes.
  
  (2) strings: 4 bytes for string length, then X bytes for string for a total of 13 + X bytes.
  
  @return Byte array representation