public GroupExpression init(OptExpression originExpression) {
        Preconditions.checkState(groups.size() == 0);
        Preconditions.checkState(groupExpressions.size() == 0);
        GroupExpression rootGroupExpression = copyIn(null, originExpression).second;
        rootGroup = rootGroupExpression.getGroup();
        return rootGroupExpression;
    }
@Test
    public void testInit(@Mocked OlapTable olapTable1,
                         @Mocked OlapTable olapTable2) {
        new Expectations() {
            {
                olapTable1.getId();
                result = 0;
                minTimes = 0;

                olapTable2.getId();
                result = 1;
                minTimes = 0;
            }
        };

        OptExpression expr = OptExpression.create(new LogicalProjectOperator(Maps.newHashMap()),
                OptExpression.create(new LogicalJoinOperator(),
                        OptExpression.create(new LogicalOlapScanOperator(olapTable1)),
                        OptExpression.create(new LogicalOlapScanOperator(olapTable2))));

        Memo memo = new Memo();
        GroupExpression groupExpression = memo.init(expr);

        assertEquals(OperatorType.LOGICAL_PROJECT, groupExpression.getOp().getOpType());
        assertEquals(OperatorType.LOGICAL_JOIN,
                groupExpression.inputAt(0).getFirstLogicalExpression().getOp().getOpType());

        assertEquals(OperatorType.LOGICAL_OLAP_SCAN,
                groupExpression.inputAt(0).getFirstLogicalExpression().inputAt(0)
                        .getFirstLogicalExpression().getOp()
                        .getOpType());
        assertEquals(OperatorType.LOGICAL_OLAP_SCAN,
                groupExpression.inputAt(0).getFirstLogicalExpression().inputAt(1)
                        .getFirstLogicalExpression().getOp()
                        .getOpType());

        assertEquals(memo.getGroups().size(), 4);
        assertEquals(memo.getGroupExpressions().size(), 4);

        assertEquals(memo.getGroups().get(0).getId(), 0);
        assertEquals(memo.getGroups().get(1).getId(), 1);
        assertEquals(memo.getGroups().get(2).getId(), 2);
        assertEquals(memo.getGroups().get(3).getId(), 3);
    }