public static long estimateSize(StructType tableSchema, long totalRecords) {
    if (totalRecords == Long.MAX_VALUE) {
      return totalRecords;
    }

    long result;
    try {
      result = LongMath.checkedMultiply(tableSchema.defaultSize(), totalRecords);
    } catch (ArithmeticException e) {
      result = Long.MAX_VALUE;
    }
    return result;
  }
@Test
  public void testEstimateSizeMaxValue() throws IOException {
    Assert.assertEquals(
        "estimateSize returns Long max value",
        Long.MAX_VALUE,
        SparkSchemaUtil.estimateSize(null, Long.MAX_VALUE));
  }