PolynomialExpansionMapper extends SISOMapper { @VisibleForTesting static int getPolySize(int num, int degree) { if (num == 0) { return 1; } if (num == 1 || degree == 1) { return num + degree; } if (degree > num) { return getPolySize(degree, num); } long res = 1; int i = num + 1; int j; if (num + degree < CONSTANT) { for (j = 1; j <= degree; ++j) { res = res * i / j; ++i; } } else { int depth; for (j = 1; j <= degree; ++j) { depth = ArithmeticUtils.gcd(i, j); res = ArithmeticUtils.mulAndCheck(res / (j / depth), i / depth); ++i; } } if (res > Integer.MAX_VALUE) { throw new IllegalArgumentException("The expended polynomial size is too large."); } return (int) res; } PolynomialExpansionMapper(TableSchema dataSchema, Params params);   }
@Test public void testGetPolySize() { int res1 = PolynomialExpansionMapper.getPolySize(4, 4); int res2 = PolynomialExpansionMapper.getPolySize(65, 2); assertEquals(res1, 70); assertEquals(res2, 2211); }