本文整理汇总了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();
}
示例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();
}
示例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."));
}
}
示例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."));
}
}