static long sizeOf(Mutation m) {
    if (m.getOperation() == Mutation.Op.DELETE) {
      return sizeOf(m.getKeySet());
    }
    long result = 0;
    for (Value v : m.getValues()) {
      switch (v.getType().getCode()) {
        case ARRAY:
          result += estimateArrayValue(v);
          break;
        case STRUCT:
          throw new IllegalArgumentException("Structs are not supported in mutation.");
        default:
          result += estimatePrimitiveValue(v);
      }
    }
    return result;
  }
@Test
  public void nullPrimitiveArrays() throws Exception {
    Mutation int64 =
        Mutation.newInsertOrUpdateBuilder("test").set("one").toInt64Array((long[]) null).build();
    Mutation protoEnum =
        Mutation.newInsertOrUpdateBuilder("test")
            .set("one")
            .toProtoEnumArray(null, "customer.app.TestEnum")
            .build();
    Mutation float32 =
        Mutation.newInsertOrUpdateBuilder("test").set("one").toFloat32Array((float[]) null).build();
    Mutation float64 =
        Mutation.newInsertOrUpdateBuilder("test")
            .set("one")
            .toFloat64Array((double[]) null)
            .build();
    Mutation bool =
        Mutation.newInsertOrUpdateBuilder("test").set("one").toBoolArray((boolean[]) null).build();
    Mutation numeric =
        Mutation.newInsertOrUpdateBuilder("test")
            .set("one")
            .toNumericArray((Iterable<BigDecimal>) null)
            .build();
    Mutation pgNumeric =
        Mutation.newInsertOrUpdateBuilder("test")
            .set("one")
            .toPgNumericArray((Iterable<String>) null)
            .build();
    Mutation json = Mutation.newInsertOrUpdateBuilder("test").set("one").toJsonArray(null).build();
    Mutation jsonb =
        Mutation.newInsertOrUpdateBuilder("test").set("one").toPgJsonbArray(null).build();

    assertThat(MutationSizeEstimator.sizeOf(int64), is(0L));
    assertThat(MutationSizeEstimator.sizeOf(float32), is(0L));
    assertThat(MutationSizeEstimator.sizeOf(float64), is(0L));
    assertThat(MutationSizeEstimator.sizeOf(bool), is(0L));
    assertThat(MutationSizeEstimator.sizeOf(numeric), is(0L));
    assertThat(MutationSizeEstimator.sizeOf(pgNumeric), is(0L));
    assertThat(MutationSizeEstimator.sizeOf(json), is(0L));
    assertThat(MutationSizeEstimator.sizeOf(jsonb), is(0L));
    assertThat(MutationSizeEstimator.sizeOf(protoEnum), is(0L));
  }