Exemplo n.º 1
0
  private void runAssertionGroupedMixedMethodAndAccess(boolean soda) throws Exception {
    String eplDeclare =
        "create table varMyAgg ("
            + "key string primary key, "
            + "c0 count(*), "
            + "c1 count(distinct object), "
            + "c2 window(*) @type('SupportBean'), "
            + "c3 sum(long)"
            + ")";
    SupportModelHelper.createByCompileOrParse(epService, soda, eplDeclare);

    String eplBind =
        "into table varMyAgg select "
            + "count(*) as c0, "
            + "count(distinct intPrimitive) as c1, "
            + "window(*) as c2, "
            + "sum(longPrimitive) as c3 "
            + "from SupportBean.win:length(3) group by theString";
    SupportModelHelper.createByCompileOrParse(epService, soda, eplBind);

    String eplSelect =
        "select "
            + "varMyAgg[p00].c0 as c0, "
            + "varMyAgg[p00].c1 as c1, "
            + "varMyAgg[p00].c2 as c2, "
            + "varMyAgg[p00].c3 as c3"
            + " from SupportBean_S0";
    EPStatement stmtSelect = SupportModelHelper.createByCompileOrParse(epService, soda, eplSelect);
    stmtSelect.addListener(listener);
    String[] fields = "c0,c1,c2,c3".split(",");

    assertEquals(Long.class, stmtSelect.getEventType().getPropertyType("c0"));
    assertEquals(Long.class, stmtSelect.getEventType().getPropertyType("c1"));
    assertEquals(SupportBean[].class, stmtSelect.getEventType().getPropertyType("c2"));
    assertEquals(Long.class, stmtSelect.getEventType().getPropertyType("c3"));

    SupportBean b1 = makeSendBean("E1", 10, 100);
    SupportBean b2 = makeSendBean("E1", 11, 101);
    SupportBean b3 = makeSendBean("E1", 10, 102);

    epService.getEPRuntime().sendEvent(new SupportBean_S0(0, "E1"));
    EPAssertionUtil.assertProps(
        listener.assertOneGetNewAndReset(),
        fields,
        new Object[] {3L, 2L, new SupportBean[] {b1, b2, b3}, 303L});

    epService.getEPRuntime().sendEvent(new SupportBean_S0(0, "E2"));
    EPAssertionUtil.assertProps(
        listener.assertOneGetNewAndReset(), fields, new Object[] {null, null, null, null});

    SupportBean b4 = makeSendBean("E2", 20, 200);
    epService.getEPRuntime().sendEvent(new SupportBean_S0(0, "E2"));
    EPAssertionUtil.assertProps(
        listener.assertOneGetNewAndReset(),
        fields,
        new Object[] {1L, 1L, new SupportBean[] {b4}, 200L});

    epService.getEPAdministrator().destroyAllStatements();
  }
Exemplo n.º 2
0
  private void runAssertionGroupedSingleKeyNoContext(boolean soda) throws Exception {
    String eplDeclare = "create table varTotal (key string primary key, total sum(int))";
    SupportModelHelper.createByCompileOrParse(epService, soda, eplDeclare);

    String eplBind =
        "into table varTotal "
            + "select theString, sum(intPrimitive) as total from SupportBean group by theString";
    SupportModelHelper.createByCompileOrParse(epService, soda, eplBind);

    String eplUse = "select p00 as c0, varTotal[p00].total as c1 from SupportBean_S0";
    SupportModelHelper.createByCompileOrParse(epService, soda, eplUse).addListener(listener);

    runAssertionTopLevelSingle();

    epService.getEPAdministrator().destroyAllStatements();
  }
Exemplo n.º 3
0
  private void runAssertionIntegerIndexedPropertyLookAlike(boolean soda) {
    String eplDeclare =
        "create table varagg (key int primary key, myevents window(*) @type('SupportBean'))";
    SupportModelHelper.createByCompileOrParse(epService, soda, eplDeclare);

    String eplInto =
        "into table varagg select window(*) as myevents from SupportBean.win:length(3) group by intPrimitive";
    SupportModelHelper.createByCompileOrParse(epService, soda, eplInto);

    String eplSelect =
        "select varagg[1] as c0, varagg[1].myevents as c1, varagg[1].myevents.last(*) as c2 from SupportBean_S0";
    EPStatement stmt = SupportModelHelper.createByCompileOrParse(epService, soda, eplSelect);
    stmt.addListener(listener);

    SupportBean e1 = makeSendBean("E1", 1, 10L);
    SupportBean e2 = makeSendBean("E2", 1, 20L);

    epService.getEPRuntime().sendEvent(new SupportBean_S0(0));
    assertIntegerIndexed(listener.assertOneGetNewAndReset(), new SupportBean[] {e1, e2});

    epService.getEPAdministrator().destroyAllStatements();
  }
Exemplo n.º 4
0
  private void runAssertionTopLevelReadGrouped2Keys(boolean soda) {
    SupportModelHelper.createByCompileOrParse(
        epService, soda, "create objectarray schema MyEvent as (c0 int, c1 string, c2 int)");
    SupportModelHelper.createByCompileOrParse(
        epService,
        soda,
        "create table windowAndTotal ("
            + "keyi int primary key, keys string primary key, thewindow window(*) @type('MyEvent'), thetotal sum(int))");
    SupportModelHelper.createByCompileOrParse(
        epService,
        soda,
        "into table windowAndTotal "
            + "select window(*) as thewindow, sum(c2) as thetotal from MyEvent.win:length(2) group by c0, c1");

    EPStatement stmtSelect =
        SupportModelHelper.createByCompileOrParse(
            epService, soda, "select windowAndTotal[id,p00] as val0 from SupportBean_S0");
    stmtSelect.addListener(listener);
    assertTopLevelTypeInfo(stmtSelect);

    Object[] e1 = new Object[] {10, "G1", 100};
    epService.getEPRuntime().sendEvent(e1, "MyEvent");

    String[] fieldsInner = "thewindow,thetotal".split(",");
    epService.getEPRuntime().sendEvent(new SupportBean_S0(10, "G1"));
    EPAssertionUtil.assertPropsMap(
        (Map) listener.assertOneGetNewAndReset().get("val0"),
        fieldsInner,
        new Object[][] {e1},
        100);

    Object[] e2 = new Object[] {20, "G2", 200};
    epService.getEPRuntime().sendEvent(e2, "MyEvent");

    epService.getEPRuntime().sendEvent(new SupportBean_S0(20, "G2"));
    EPAssertionUtil.assertPropsMap(
        (Map) listener.assertOneGetNewAndReset().get("val0"),
        fieldsInner,
        new Object[][] {e2},
        200);

    Object[] e3 = new Object[] {20, "G2", 300};
    epService.getEPRuntime().sendEvent(e3, "MyEvent");

    epService.getEPRuntime().sendEvent(new SupportBean_S0(10, "G1"));
    EPAssertionUtil.assertPropsMap(
        (Map) listener.assertOneGetNewAndReset().get("val0"), fieldsInner, null, null);
    epService.getEPRuntime().sendEvent(new SupportBean_S0(20, "G2"));
    EPAssertionUtil.assertPropsMap(
        (Map) listener.assertOneGetNewAndReset().get("val0"),
        fieldsInner,
        new Object[][] {e2, e3},
        500);

    // test typable output
    stmtSelect.destroy();
    EPStatement stmtConvert =
        epService
            .getEPAdministrator()
            .createEPL(
                "insert into AggBean select windowAndTotal[20, 'G2'] as val0 from SupportBean_S0");
    stmtConvert.addListener(listener);

    epService.getEPRuntime().sendEvent(new SupportBean_S0(0));
    EPAssertionUtil.assertProps(
        listener.assertOneGetNewAndReset(),
        "val0.thewindow,val0.thetotal".split(","),
        new Object[] {new Object[][] {e2, e3}, 500});

    epService.getEPAdministrator().destroyAllStatements();
  }