public static Object[] truncateTailingNull(final Object[] device) {
    if (device == null) {
      throw new IllegalArgumentException("DeviceID's length should be larger than 0.");
    }
    int lastNonNullIndex = -1;
    for (int i = device.length - 1; i >= 0; i--) {
      if (device[i] != null) {
        lastNonNullIndex = i;
        break;
      }
    }
    return lastNonNullIndex == device.length - 1
        ? device
        : Arrays.copyOf(device, lastNonNullIndex + 1);
  }
get device id by full path

@param devicePath device path of the timeseries
@return device id of the timeseries
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/memtable/DeviceIDFactory.java