當前位置: 首頁>>代碼示例>>Java>>正文


Java InvalidContextPartitionSelector類代碼示例

本文整理匯總了Java中com.espertech.esper.client.context.InvalidContextPartitionSelector的典型用法代碼示例。如果您正苦於以下問題:Java InvalidContextPartitionSelector類的具體用法?Java InvalidContextPartitionSelector怎麽用?Java InvalidContextPartitionSelector使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


InvalidContextPartitionSelector類屬於com.espertech.esper.client.context包,在下文中一共展示了InvalidContextPartitionSelector類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: runAssertionContextPartitionSelection

import com.espertech.esper.client.context.InvalidContextPartitionSelector; //導入依賴的package包/類
private void runAssertionContextPartitionSelection(EPServiceProvider epService) {
    String[] fields = "c0,c1,c2,c3".split(",");
    epService.getEPRuntime().sendEvent(new CurrentTimeEvent(0));
    epService.getEPAdministrator().createEPL("create context MyCtx as initiated by SupportBean_S0 s0 terminated by SupportBean_S1(id=s0.id)");
    EPStatement stmt = epService.getEPAdministrator().createEPL("context MyCtx select context.id as c0, context.s0.p00 as c1, theString as c2, sum(intPrimitive) as c3 from SupportBean#keepall group by theString");

    epService.getEPRuntime().sendEvent(new CurrentTimeEvent(1000));
    SupportBean_S0 initOne = new SupportBean_S0(1, "S0_1");
    epService.getEPRuntime().sendEvent(initOne);
    epService.getEPRuntime().sendEvent(new SupportBean("E1", 1));
    epService.getEPRuntime().sendEvent(new SupportBean("E2", 10));
    epService.getEPRuntime().sendEvent(new SupportBean("E1", 2));

    epService.getEPRuntime().sendEvent(new CurrentTimeEvent(2000));
    SupportBean_S0 initTwo = new SupportBean_S0(2, "S0_2");
    epService.getEPRuntime().sendEvent(initTwo);
    epService.getEPRuntime().sendEvent(new SupportBean("E3", 100));
    epService.getEPRuntime().sendEvent(new SupportBean("E3", 101));
    epService.getEPRuntime().sendEvent(new SupportBean("E1", 3));
    EPAssertionUtil.assertPropsPerRowAnyOrder(stmt.iterator(), stmt.safeIterator(), fields, new Object[][]{{0, "S0_1", "E1", 6}, {0, "S0_1", "E2", 10}, {0, "S0_1", "E3", 201}, {1, "S0_2", "E1", 3}, {1, "S0_2", "E3", 201}});
    SupportContextPropUtil.assertContextProps(epService, "MyCtx", new int[] {0, 1}, "startTime,endTime,s0", new Object[][] {{1000L, null, initOne}, {2000L, null, initTwo}});

    // test iterator targeted by context partition id
    SupportSelectorById selectorById = new SupportSelectorById(Collections.singleton(1));
    EPAssertionUtil.assertPropsPerRowAnyOrder(stmt.iterator(selectorById), stmt.safeIterator(selectorById), fields, new Object[][]{{1, "S0_2", "E1", 3}, {1, "S0_2", "E3", 201}});

    // test iterator targeted by property on triggering event
    SupportSelectorFilteredInitTerm filtered = new SupportSelectorFilteredInitTerm("S0_2");
    EPAssertionUtil.assertPropsPerRowAnyOrder(stmt.iterator(filtered), stmt.safeIterator(filtered), fields, new Object[][]{{1, "S0_2", "E1", 3}, {1, "S0_2", "E3", 201}});

    // test always-false filter - compare context partition info
    filtered = new SupportSelectorFilteredInitTerm(null);
    assertFalse(stmt.iterator(filtered).hasNext());
    EPAssertionUtil.assertEqualsAnyOrder(new Object[]{1000L, 2000L}, filtered.getContextsStartTimes());
    EPAssertionUtil.assertEqualsAnyOrder(new Object[]{"S0_1", "S0_2"}, filtered.getP00PropertyValues());

    try {
        stmt.iterator(new ContextPartitionSelectorSegmented() {
            public List<Object[]> getPartitionKeys() {
                return null;
            }
        });
        fail();
    } catch (InvalidContextPartitionSelector ex) {
        assertTrue("message: " + ex.getMessage(), ex.getMessage().startsWith("Invalid context partition selector, expected an implementation class of any of [ContextPartitionSelectorAll, ContextPartitionSelectorFiltered, ContextPartitionSelectorById] interfaces but received com."));
    }

    epService.getEPAdministrator().destroyAllStatements();
}
 
開發者ID:espertechinc,項目名稱:esper,代碼行數:50,代碼來源:ExecContextInitTerm.java

示例2: runAssertionContextPartitionSelection

import com.espertech.esper.client.context.InvalidContextPartitionSelector; //導入依賴的package包/類
private void runAssertionContextPartitionSelection(EPServiceProvider epService) {
    String[] fields = "c0,c1,c2,c3".split(",");
    epService.getEPRuntime().sendEvent(new CurrentTimeEvent(0));
    epService.getEPAdministrator().createEPL("create context MyCtx as start SupportBean_S0 s0 end SupportBean_S1(id=s0.id)");
    EPStatement stmt = epService.getEPAdministrator().createEPL("context MyCtx select context.id as c0, context.s0.p00 as c1, theString as c2, sum(intPrimitive) as c3 from SupportBean#keepall group by theString");

    epService.getEPRuntime().sendEvent(new CurrentTimeEvent(1000));
    epService.getEPRuntime().sendEvent(new SupportBean_S0(1, "S0_1"));
    epService.getEPRuntime().sendEvent(new SupportBean("E1", 1));
    epService.getEPRuntime().sendEvent(new SupportBean("E2", 10));
    epService.getEPRuntime().sendEvent(new SupportBean("E1", 2));
    epService.getEPRuntime().sendEvent(new SupportBean("E3", 100));
    epService.getEPRuntime().sendEvent(new SupportBean("E3", 101));
    epService.getEPRuntime().sendEvent(new SupportBean("E1", 3));
    Object[][] expected = new Object[][]{{0, "S0_1", "E1", 6}, {0, "S0_1", "E2", 10}, {0, "S0_1", "E3", 201}};
    EPAssertionUtil.assertPropsPerRowAnyOrder(stmt.iterator(), stmt.safeIterator(), fields, expected);

    // test iterator targeted by context partition id
    SupportSelectorById selectorById = new SupportSelectorById(Collections.singleton(0));
    EPAssertionUtil.assertPropsPerRowAnyOrder(stmt.iterator(selectorById), stmt.safeIterator(selectorById), fields, expected);

    // test iterator targeted by property on triggering event
    SupportSelectorFilteredInitTerm filtered = new SupportSelectorFilteredInitTerm("S0_1");
    EPAssertionUtil.assertPropsPerRowAnyOrder(stmt.iterator(filtered), stmt.safeIterator(filtered), fields, expected);
    filtered = new SupportSelectorFilteredInitTerm("S0_2");
    assertFalse(stmt.iterator(filtered).hasNext());

    // test always-false filter - compare context partition info
    filtered = new SupportSelectorFilteredInitTerm(null);
    assertFalse(stmt.iterator(filtered).hasNext());
    EPAssertionUtil.assertEqualsAnyOrder(new Object[]{1000L}, filtered.getContextsStartTimes());
    EPAssertionUtil.assertEqualsAnyOrder(new Object[]{"S0_1"}, filtered.getP00PropertyValues());

    try {
        stmt.iterator(new ContextPartitionSelectorSegmented() {
            public List<Object[]> getPartitionKeys() {
                return null;
            }
        });
        fail();
    } catch (InvalidContextPartitionSelector ex) {
        assertTrue("message: " + ex.getMessage(), ex.getMessage().startsWith("Invalid context partition selector, expected an implementation class of any of [ContextPartitionSelectorAll, ContextPartitionSelectorFiltered, ContextPartitionSelectorById] interfaces but received com."));
    }

    epService.getEPAdministrator().destroyAllStatements();
}
 
開發者ID:espertechinc,項目名稱:esper,代碼行數:47,代碼來源:ExecContextInitTermTemporalFixed.java

示例3: testContextPartitionSelection

import com.espertech.esper.client.context.InvalidContextPartitionSelector; //導入依賴的package包/類
public void testContextPartitionSelection() {
    String[] fields = "c0,c1,c2,c3".split(",");
    epService.getEPRuntime().sendEvent(new CurrentTimeEvent(0));
    epService.getEPAdministrator().createEPL("create context MyCtx as start SupportBean_S0 s0 end SupportBean_S1(id=s0.id)");
    EPStatement stmt = epService.getEPAdministrator().createEPL("context MyCtx select context.id as c0, context.s0.p00 as c1, theString as c2, sum(intPrimitive) as c3 from SupportBean.win:keepall() group by theString");

    epService.getEPRuntime().sendEvent(new CurrentTimeEvent(1000));
    epService.getEPRuntime().sendEvent(new SupportBean_S0(1, "S0_1"));
    epService.getEPRuntime().sendEvent(new SupportBean("E1", 1));
    epService.getEPRuntime().sendEvent(new SupportBean("E2", 10));
    epService.getEPRuntime().sendEvent(new SupportBean("E1", 2));
    epService.getEPRuntime().sendEvent(new SupportBean("E3", 100));
    epService.getEPRuntime().sendEvent(new SupportBean("E3", 101));
    epService.getEPRuntime().sendEvent(new SupportBean("E1", 3));
    Object[][] expected = new Object[][] {{0, "S0_1", "E1", 6}, {0, "S0_1", "E2", 10}, {0, "S0_1", "E3", 201}};
    EPAssertionUtil.assertPropsPerRowAnyOrder(stmt.iterator(), stmt.safeIterator(), fields, expected);

    // test iterator targeted by context partition id
    SupportSelectorById selectorById = new SupportSelectorById(Collections.singleton(0));
    EPAssertionUtil.assertPropsPerRowAnyOrder(stmt.iterator(selectorById), stmt.safeIterator(selectorById), fields, expected);

    // test iterator targeted by property on triggering event
    SupportSelectorFilteredInitTerm filtered = new SupportSelectorFilteredInitTerm("S0_1");
    EPAssertionUtil.assertPropsPerRowAnyOrder(stmt.iterator(filtered), stmt.safeIterator(filtered), fields, expected);
    filtered = new SupportSelectorFilteredInitTerm("S0_2");
    assertFalse(stmt.iterator(filtered).hasNext());

    // test always-false filter - compare context partition info
    filtered = new SupportSelectorFilteredInitTerm(null);
    assertFalse(stmt.iterator(filtered).hasNext());
    EPAssertionUtil.assertEqualsAnyOrder(new Object[]{1000L}, filtered.getContextsStartTimes());
    EPAssertionUtil.assertEqualsAnyOrder(new Object[]{"S0_1"}, filtered.getP00PropertyValues());

    try {
        stmt.iterator(new ContextPartitionSelectorSegmented() {
            public List<Object[]> getPartitionKeys() {
                return null;
            }
        });
        fail();
    }
    catch (InvalidContextPartitionSelector ex) {
        assertTrue("message: " + ex.getMessage(), ex.getMessage().startsWith("Invalid context partition selector, expected an implementation class of any of [ContextPartitionSelectorAll, ContextPartitionSelectorFiltered, ContextPartitionSelectorById] interfaces but received com."));
    }
}
 
開發者ID:mobile-event-processing,項目名稱:Asper,代碼行數:46,代碼來源:TestContextTemporalFixed.java

示例4: testContextPartitionSelection

import com.espertech.esper.client.context.InvalidContextPartitionSelector; //導入依賴的package包/類
public void testContextPartitionSelection() {
    String[] fields = "c0,c1,c2,c3".split(",");
    epService.getEPRuntime().sendEvent(new CurrentTimeEvent(0));
    epService.getEPAdministrator().createEPL("create context MyCtx as initiated by SupportBean_S0 s0 terminated by SupportBean_S1(id=s0.id)");
    EPStatement stmt = epService.getEPAdministrator().createEPL("context MyCtx select context.id as c0, context.s0.p00 as c1, theString as c2, sum(intPrimitive) as c3 from SupportBean.win:keepall() group by theString");

    epService.getEPRuntime().sendEvent(new CurrentTimeEvent(1000));
    epService.getEPRuntime().sendEvent(new SupportBean_S0(1, "S0_1"));
    epService.getEPRuntime().sendEvent(new SupportBean("E1", 1));
    epService.getEPRuntime().sendEvent(new SupportBean("E2", 10));
    epService.getEPRuntime().sendEvent(new SupportBean("E1", 2));

    epService.getEPRuntime().sendEvent(new CurrentTimeEvent(2000));
    epService.getEPRuntime().sendEvent(new SupportBean_S0(2, "S0_2"));
    epService.getEPRuntime().sendEvent(new SupportBean("E3", 100));
    epService.getEPRuntime().sendEvent(new SupportBean("E3", 101));
    epService.getEPRuntime().sendEvent(new SupportBean("E1", 3));
    EPAssertionUtil.assertPropsPerRowAnyOrder(stmt.iterator(), stmt.safeIterator(), fields, new Object[][]{{0, "S0_1", "E1", 6}, {0, "S0_1", "E2", 10}, {0, "S0_1", "E3", 201}, {1, "S0_2", "E1", 3}, {1, "S0_2", "E3", 201}});

    // test iterator targeted by context partition id
    SupportSelectorById selectorById = new SupportSelectorById(Collections.singleton(1));
    EPAssertionUtil.assertPropsPerRowAnyOrder(stmt.iterator(selectorById), stmt.safeIterator(selectorById), fields, new Object[][]{{1, "S0_2", "E1", 3}, {1, "S0_2", "E3", 201}});

    // test iterator targeted by property on triggering event
    SupportSelectorFilteredInitTerm filtered = new SupportSelectorFilteredInitTerm("S0_2");
    EPAssertionUtil.assertPropsPerRowAnyOrder(stmt.iterator(filtered), stmt.safeIterator(filtered), fields, new Object[][]{{1, "S0_2", "E1", 3}, {1, "S0_2", "E3", 201}});

    // test always-false filter - compare context partition info
    filtered = new SupportSelectorFilteredInitTerm(null);
    assertFalse(stmt.iterator(filtered).hasNext());
    EPAssertionUtil.assertEqualsAnyOrder(new Object[]{1000L, 2000L}, filtered.getContextsStartTimes());
    EPAssertionUtil.assertEqualsAnyOrder(new Object[]{"S0_1", "S0_2"}, filtered.getP00PropertyValues());

    try {
        stmt.iterator(new ContextPartitionSelectorSegmented() {
            public List<Object[]> getPartitionKeys() {
                return null;
            }
        });
        fail();
    }
    catch (InvalidContextPartitionSelector ex) {
        assertTrue("message: " + ex.getMessage(), ex.getMessage().startsWith("Invalid context partition selector, expected an implementation class of any of [ContextPartitionSelectorAll, ContextPartitionSelectorFiltered, ContextPartitionSelectorById] interfaces but received com."));
    }
}
 
開發者ID:mobile-event-processing,項目名稱:Asper,代碼行數:46,代碼來源:TestContextInitatedTerminated.java


注:本文中的com.espertech.esper.client.context.InvalidContextPartitionSelector類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。