当前位置: 首页>>代码示例>>Java>>正文


Java EPStatement.iterator方法代码示例

本文整理汇总了Java中com.espertech.esper.client.EPStatement.iterator方法的典型用法代码示例。如果您正苦于以下问题:Java EPStatement.iterator方法的具体用法?Java EPStatement.iterator怎么用?Java EPStatement.iterator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.espertech.esper.client.EPStatement的用法示例。


在下文中一共展示了EPStatement.iterator方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: runAssertionPatternWithWindow

import com.espertech.esper.client.EPStatement; //导入方法依赖的package包/类
private void runAssertionPatternWithWindow(EPServiceProvider epService) {
    String cepStatementString = "select * from pattern " +
            "[every ( addressInfo = " + SupportBean.class.getName() + "(theString='address') " +
            "-> txnWD = " + SupportBean.class.getName() + "(theString='txn') ) ]#lastevent " +
            "where addressInfo.intBoxed = txnWD.intBoxed";
    EPStatement epStatement = epService.getEPAdministrator().createEPL(cepStatementString);

    SupportBean myEventBean1 = new SupportBean();
    myEventBean1.setTheString("address");
    myEventBean1.setIntBoxed(9001);
    epService.getEPRuntime().sendEvent(myEventBean1);

    SupportBean myEventBean2 = new SupportBean();
    myEventBean2.setTheString("txn");
    myEventBean2.setIntBoxed(9001);
    epService.getEPRuntime().sendEvent(myEventBean2);

    Iterator<EventBean> itr = epStatement.iterator();
    EventBean theEvent = itr.next();
    assertEquals(myEventBean1, theEvent.get("addressInfo"));
    assertEquals(myEventBean2, theEvent.get("txnWD"));

    epStatement.destroy();
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:25,代码来源:ExecQuerytypeIterator.java

示例2: getScores

import com.espertech.esper.client.EPStatement; //导入方法依赖的package包/类
public static Map<String, Integer> getScores(EPServiceProvider engine) {
    EPStatement stmt = engine.getEPAdministrator().getStatement("Score window");
    Map<String, Integer> result = new LinkedHashMap<String, Integer>();
    for (Iterator<EventBean> it = stmt.iterator(); it.hasNext(); ) {
        EventBean next = it.next();
        String playerId = (String) next.get("playerId");
        Integer score = (Integer) next.get("score");
        result.put(playerId, score);
    }
    return result;
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:12,代码来源:TriviaHelper.java

示例3: getScore

import com.espertech.esper.client.EPStatement; //导入方法依赖的package包/类
private int getScore(String playerId) {
    EPStatement stmt = engine.getEPAdministrator().getStatement("Score window");
    for (Iterator<EventBean> it = stmt.iterator(); it.hasNext(); ) {
        EventBean next = it.next();
        if (next.get("playerId").equals(playerId)) {
            return (Integer) next.get("score");
        }
    }
    fail();
    return -1;
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:12,代码来源:TestTriviaCases.java

示例4: assertNotScore

import com.espertech.esper.client.EPStatement; //导入方法依赖的package包/类
private void assertNotScore(String playerId) {
    EPStatement stmt = engine.getEPAdministrator().getStatement("Score window");
    for (Iterator<EventBean> it = stmt.iterator(); it.hasNext(); ) {
        EventBean next = it.next();
        if (next.get("playerId").equals(playerId)) {
            fail();
        }
    }
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:10,代码来源:TestTriviaCases.java

示例5: runAssertionPatternNoWindow

import com.espertech.esper.client.EPStatement; //导入方法依赖的package包/类
private void runAssertionPatternNoWindow(EPServiceProvider epService) {
    // Test for Esper-115
    String cepStatementString = "@IterableUnbound select * from pattern " +
            "[every ( addressInfo = " + SupportBean.class.getName() + "(theString='address') " +
            "-> txnWD = " + SupportBean.class.getName() + "(theString='txn') ) ] " +
            "where addressInfo.intBoxed = txnWD.intBoxed";
    EPStatement epStatement = epService.getEPAdministrator().createEPL(cepStatementString);

    SupportBean myEventBean1 = new SupportBean();
    myEventBean1.setTheString("address");
    myEventBean1.setIntBoxed(9001);
    epService.getEPRuntime().sendEvent(myEventBean1);
    assertFalse(epStatement.iterator().hasNext());

    SupportBean myEventBean2 = new SupportBean();
    myEventBean2.setTheString("txn");
    myEventBean2.setIntBoxed(9001);
    epService.getEPRuntime().sendEvent(myEventBean2);
    assertTrue(epStatement.iterator().hasNext());

    Iterator<EventBean> itr = epStatement.iterator();
    EventBean theEvent = itr.next();
    assertEquals(myEventBean1, theEvent.get("addressInfo"));
    assertEquals(myEventBean2, theEvent.get("txnWD"));

    epStatement.destroy();
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:28,代码来源:ExecQuerytypeIterator.java

示例6: checkValue

import com.espertech.esper.client.EPStatement; //导入方法依赖的package包/类
private void checkValue(EPServiceProvider epService, SupportUpdateListener testListener, EPStatement weightedAvgView, double avgE) {
    Iterator<EventBean> iterator = weightedAvgView.iterator();
    checkValue(iterator.next(), avgE);
    assertTrue(!iterator.hasNext());

    assertTrue(testListener.getLastNewData().length == 1);
    EventBean listenerValues = testListener.getLastNewData()[0];
    checkValue(listenerValues, avgE);

    testListener.reset();
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:12,代码来源:ExecViewTimeWindowWeightedAvg.java

示例7: runAssertionIterator

import com.espertech.esper.client.EPStatement; //导入方法依赖的package包/类
private void runAssertionIterator(EPServiceProvider epService) {
    String epl = "select symbol, price from " + SupportMarketDataBean.class.getName() + "#keepall";
    EPStatement statement = epService.getEPAdministrator().createEPL(epl);
    SupportUpdateListener listener = new SupportUpdateListener();
    statement.addListener(listener);

    sendEvent(epService, "ABC", 20);
    sendEvent(epService, "DEF", 100);

    // check iterator results
    Iterator<EventBean> events = statement.iterator();
    EventBean theEvent = events.next();
    assertEquals("ABC", theEvent.get("symbol"));
    assertEquals(20d, theEvent.get("price"));

    theEvent = events.next();
    assertEquals("DEF", theEvent.get("symbol"));
    assertEquals(100d, theEvent.get("price"));
    assertFalse(events.hasNext());

    sendEvent(epService, "EFG", 50);

    // check iterator results
    events = statement.iterator();
    theEvent = events.next();
    assertEquals("ABC", theEvent.get("symbol"));
    assertEquals(20d, theEvent.get("price"));

    theEvent = events.next();
    assertEquals("DEF", theEvent.get("symbol"));
    assertEquals(100d, theEvent.get("price"));

    theEvent = events.next();
    assertEquals("EFG", theEvent.get("symbol"));
    assertEquals(50d, theEvent.get("price"));

    statement.destroy();
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:39,代码来源:ExecViewKeepAllWindow.java

示例8: runAssertionIterator

import com.espertech.esper.client.EPStatement; //导入方法依赖的package包/类
private void runAssertionIterator(EPServiceProvider epService) {
    String epl = "select symbol, price from " + SupportMarketDataBean.class.getName() + "#length(2)";
    EPStatement statement = epService.getEPAdministrator().createEPL(epl);
    SupportUpdateListener listener = new SupportUpdateListener();
    statement.addListener(listener);

    sendEvent(epService, "ABC", 20);
    sendEvent(epService, "DEF", 100);

    // check iterator results
    Iterator<EventBean> events = statement.iterator();
    EventBean theEvent = events.next();
    assertEquals("ABC", theEvent.get("symbol"));
    assertEquals(20d, theEvent.get("price"));

    theEvent = events.next();
    assertEquals("DEF", theEvent.get("symbol"));
    assertEquals(100d, theEvent.get("price"));
    assertFalse(events.hasNext());

    sendEvent(epService, "EFG", 50);

    // check iterator results
    events = statement.iterator();
    theEvent = events.next();
    assertEquals("DEF", theEvent.get("symbol"));
    assertEquals(100d, theEvent.get("price"));

    theEvent = events.next();
    assertEquals("EFG", theEvent.get("symbol"));
    assertEquals(50d, theEvent.get("price"));
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:33,代码来源:ExecViewLengthWindowStats.java

示例9: checkNew

import com.espertech.esper.client.EPStatement; //导入方法依赖的package包/类
private void checkNew(EPStatement statement, long countE, double sumE, double avgE, double stdevpaE, double stdevE, double varianceE, SupportUpdateListener listener) {
    Iterator<EventBean> iterator = statement.iterator();
    checkValues(iterator.next(), false, false, countE, sumE, avgE, stdevpaE, stdevE, varianceE);
    assertFalse(iterator.hasNext());

    assertTrue(listener.getLastNewData().length == 1);
    EventBean childViewValues = listener.getLastNewData()[0];
    checkValues(childViewValues, false, false, countE, sumE, avgE, stdevpaE, stdevE, varianceE);

    listener.reset();
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:12,代码来源:ExecViewLengthWindowStats.java

示例10: runAssertionIterateTargetedCP

import com.espertech.esper.client.EPStatement; //导入方法依赖的package包/类
private void runAssertionIterateTargetedCP(EPServiceProvider epService) {
    epService.getEPAdministrator().createEPL("create context PartitionedByString partition by theString from SupportBean");
    String[] fields = "c0,c1".split(",");
    EPStatement stmt = epService.getEPAdministrator().createEPL("@Name('StmtOne') context PartitionedByString select context.key1 as c0, sum(intPrimitive) as c1 from SupportBean#length(5)");

    epService.getEPRuntime().sendEvent(new SupportBean("E1", 10));
    epService.getEPRuntime().sendEvent(new SupportBean("E2", 20));
    epService.getEPRuntime().sendEvent(new SupportBean("E2", 21));

    EPAssertionUtil.assertPropsPerRow(stmt.iterator(), stmt.safeIterator(), fields, new Object[][]{{"E1", 10}, {"E2", 41}});

    // test iterator targeted
    SupportSelectorPartitioned selector = new SupportSelectorPartitioned(Collections.singletonList(new Object[]{"E2"}));
    EPAssertionUtil.assertPropsPerRow(stmt.iterator(selector), stmt.safeIterator(selector), fields, new Object[][]{{"E2", 41}});
    assertFalse(stmt.iterator(new SupportSelectorPartitioned((List) null)).hasNext());
    assertFalse(stmt.iterator(new SupportSelectorPartitioned(Collections.singletonList(new Object[]{"EX"}))).hasNext());
    assertFalse(stmt.iterator(new SupportSelectorPartitioned(Collections.emptyList())).hasNext());

    // test iterator filtered
    MySelectorFilteredPartitioned filtered = new MySelectorFilteredPartitioned(new Object[]{"E2"});
    EPAssertionUtil.assertPropsPerRow(stmt.iterator(filtered), stmt.safeIterator(filtered), fields, new Object[][]{{"E2", 41}});

    // test always-false filter - compare context partition info
    MySelectorFilteredPartitioned filteredFalse = new MySelectorFilteredPartitioned(null);
    assertFalse(stmt.iterator(filteredFalse).hasNext());
    EPAssertionUtil.assertEqualsAnyOrder(new Object[]{new Object[]{"E1"}, new Object[]{"E2"}}, filteredFalse.getContexts().toArray());

    try {
        stmt.iterator(new ContextPartitionSelectorCategory() {
            public Set<String> getLabels() {
                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, ContextPartitionSelectorSegmented] interfaces but received com."));
    }

    epService.getEPAdministrator().destroyAllStatements();
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:41,代码来源:ExecContextPartitioned.java

示例11: run

import com.espertech.esper.client.EPStatement; //导入方法依赖的package包/类
public void run(EPServiceProvider epService) throws Exception {
    String eventA = SupportBean.class.getName();
    String eventB = SupportBean.class.getName();

    String joinStatement = "select s0.doubleBoxed, s1.intPrimitive*s1.intBoxed/2.0 as div from " +
            eventA + "(theString='s0')#length(3) as s0," +
            eventB + "(theString='s1')#length(3) as s1" +
            " where s0.doubleBoxed = s1.doubleBoxed";

    EPStatement joinView = epService.getEPAdministrator().createEPL(joinStatement);
    SupportUpdateListener updateListener = new SupportUpdateListener();
    joinView.addListener(updateListener);

    EventType result = joinView.getEventType();
    assertEquals(Double.class, result.getPropertyType("s0.doubleBoxed"));
    assertEquals(Double.class, result.getPropertyType("div"));
    assertEquals(2, joinView.getEventType().getPropertyNames().length);

    assertNull(updateListener.getLastNewData());

    sendEvent(epService, "s0", 1, 4, 5);
    sendEvent(epService, "s1", 1, 3, 2);

    EventBean[] newEvents = updateListener.getLastNewData();
    assertEquals(1d, newEvents[0].get("s0.doubleBoxed"));
    assertEquals(3d, newEvents[0].get("div"));

    Iterator<EventBean> iterator = joinView.iterator();
    EventBean theEvent = iterator.next();
    assertEquals(1d, theEvent.get("s0.doubleBoxed"));
    assertEquals(3d, theEvent.get("div"));
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:33,代码来源:ExecJoinSelectClause.java

示例12: tryUnsupportedIterator

import com.espertech.esper.client.EPStatement; //导入方法依赖的package包/类
private void tryUnsupportedIterator(EPStatement stmt) {
    try {
        stmt.iterator();
        fail();
    } catch (UnsupportedOperationException ex) {
        assertEquals("Iteration over a unidirectional join is not supported", ex.getMessage());
    }
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:9,代码来源:ExecJoinUnidirectionalStream.java

示例13: checkMeanIterator

import com.espertech.esper.client.EPStatement; //导入方法依赖的package包/类
private void checkMeanIterator(EPStatement timeBatchMean, double meanExpected) {
    Iterator<EventBean> iterator = timeBatchMean.iterator();
    checkValue(iterator.next(), meanExpected);
    assertTrue(!iterator.hasNext());
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:6,代码来源:ExecViewTimeBatchMean.java

示例14: runAssertionContextPartitionSelection

import com.espertech.esper.client.EPStatement; //导入方法依赖的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

示例15: runAssertionSegmentedNWConsumeSameContext

import com.espertech.esper.client.EPStatement; //导入方法依赖的package包/类
private void runAssertionSegmentedNWConsumeSameContext(EPServiceProvider epService) {
    epService.getEPAdministrator().createEPL("@Name('context') create context SegmentedByString partition by theString from SupportBean");

    EPStatement stmtNamedWindow = epService.getEPAdministrator().createEPL("@Name('named window') context SegmentedByString create window MyWindow#keepall as SupportBean");
    SupportUpdateListener listenerNamedWindow = new SupportUpdateListener();
    stmtNamedWindow.addListener(listenerNamedWindow);
    epService.getEPAdministrator().createEPL("@Name('insert') insert into MyWindow select * from SupportBean");

    String[] fieldsNW = new String[]{"theString", "intPrimitive"};
    String[] fieldsCnt = new String[]{"theString", "cnt"};
    EPStatement stmtSelect = epService.getEPAdministrator().createEPL("@Name('select') context SegmentedByString select theString, count(*) as cnt from MyWindow group by theString");
    SupportUpdateListener listenerSelect = new SupportUpdateListener();
    stmtSelect.addListener(listenerSelect);

    epService.getEPRuntime().sendEvent(new SupportBean("G1", 10));
    EPAssertionUtil.assertProps(listenerNamedWindow.assertOneGetNewAndReset(), fieldsNW, new Object[]{"G1", 10});
    EPAssertionUtil.assertProps(listenerSelect.assertOneGetNewAndReset(), fieldsCnt, new Object[]{"G1", 1L});

    epService.getEPRuntime().sendEvent(new SupportBean("G2", 20));
    EPAssertionUtil.assertProps(listenerNamedWindow.assertOneGetNewAndReset(), fieldsNW, new Object[]{"G2", 20});
    EPAssertionUtil.assertProps(listenerSelect.assertOneGetNewAndReset(), fieldsCnt, new Object[]{"G2", 1L});

    epService.getEPRuntime().sendEvent(new SupportBean("G1", 11));
    EPAssertionUtil.assertProps(listenerNamedWindow.assertOneGetNewAndReset(), fieldsNW, new Object[]{"G1", 11});
    EPAssertionUtil.assertProps(listenerSelect.assertOneGetNewAndReset(), fieldsCnt, new Object[]{"G1", 2L});

    epService.getEPRuntime().sendEvent(new SupportBean("G2", 21));
    EPAssertionUtil.assertProps(listenerNamedWindow.assertOneGetNewAndReset(), fieldsNW, new Object[]{"G2", 21});
    EPAssertionUtil.assertProps(listenerSelect.assertOneGetNewAndReset(), fieldsCnt, new Object[]{"G2", 2L});

    stmtSelect.destroy();

    // In-context consumer not initialized
    EPStatement stmtSelectCount = epService.getEPAdministrator().createEPL("@Name('select') context SegmentedByString select count(*) as cnt from MyWindow");
    stmtSelectCount.addListener(listenerSelect);
    try {
        // EPAssertionUtil.assertProps(stmtSelectCount.iterator().next(), "cnt".split(","), new Object[] {0L});
        stmtSelectCount.iterator();
    } catch (UnsupportedOperationException ex) {
        assertEquals("Iterator not supported on statements that have a context attached", ex.getMessage());
    }
    epService.getEPAdministrator().destroyAllStatements();
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:44,代码来源:ExecContextPartitionedInfra.java


注:本文中的com.espertech.esper.client.EPStatement.iterator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。