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


Java ContextPartitionSelectorCategory类代码示例

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


ContextPartitionSelectorCategory类属于com.espertech.esper.client.context包,在下文中一共展示了ContextPartitionSelectorCategory类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: runAssertionContextNamedWindowQuery

import com.espertech.esper.client.context.ContextPartitionSelectorCategory; //导入依赖的package包/类
private void runAssertionContextNamedWindowQuery(EPServiceProvider epService) {

        epService.getEPAdministrator().createEPL("create context PartitionedByString partition by theString from SupportBean");
        epService.getEPAdministrator().createEPL("context PartitionedByString create window MyWindow#keepall as SupportBean");
        epService.getEPAdministrator().createEPL("insert into MyWindow select * from SupportBean");

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

        // test no context
        runQueryAll(epService, "select sum(intPrimitive) as c1 from MyWindow", "c1", new Object[][]{{51}}, 1);
        runQueryAll(epService, "select sum(intPrimitive) as c1 from MyWindow where intPrimitive > 15", "c1", new Object[][]{{41}}, 1);
        runQuery(epService, "select sum(intPrimitive) as c1 from MyWindow", "c1", new Object[][]{{41}}, new ContextPartitionSelector[]{new SupportSelectorPartitioned(Collections.singletonList(new Object[]{"E2"}))});
        runQuery(epService, "select sum(intPrimitive) as c1 from MyWindow", "c1", new Object[][]{{41}}, new ContextPartitionSelector[]{new SupportSelectorById(Collections.<Integer>singleton(1))});

        // test with context props
        runQueryAll(epService, "context PartitionedByString select context.key1 as c0, intPrimitive as c1 from MyWindow",
                "c0,c1", new Object[][]{{"E1", 10}, {"E2", 20}, {"E2", 21}}, 1);
        runQueryAll(epService, "context PartitionedByString select context.key1 as c0, intPrimitive as c1 from MyWindow where intPrimitive > 15",
                "c0,c1", new Object[][]{{"E2", 20}, {"E2", 21}}, 1);

        // test targeted context partition
        runQuery(epService, "context PartitionedByString select context.key1 as c0, intPrimitive as c1 from MyWindow where intPrimitive > 15",
                "c0,c1", new Object[][]{{"E2", 20}, {"E2", 21}}, new SupportSelectorPartitioned[]{new SupportSelectorPartitioned(Collections.singletonList(new Object[]{"E2"}))});

        try {
            epService.getEPRuntime().executeQuery("context PartitionedByString select * from MyWindow", new ContextPartitionSelector[] {new ContextPartitionSelectorCategory() {
                public Set<String> getLabels() {
                    return null;
                }
            } });
            fail();
        } catch (EPStatementException ex) {
            assertTrue("message: " + ex.getMessage(), ex.getMessage().startsWith("Error executing statement: 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,代码行数:40,代码来源:ExecContextSelectionAndFireAndForget.java

示例2: getSelectedContextPartitionPathIds

import com.espertech.esper.client.context.ContextPartitionSelectorCategory; //导入依赖的package包/类
public Collection<Integer> getSelectedContextPartitionPathIds(ContextPartitionSelector contextPartitionSelector) {
    if (contextPartitionSelector instanceof ContextPartitionSelectorFiltered) {
        ContextPartitionSelectorFiltered filter = (ContextPartitionSelectorFiltered) contextPartitionSelector;
        ContextPartitionIdentifierCategory identifier = new ContextPartitionIdentifierCategory();
        List<Integer> accepted = new ArrayList<Integer>();
        for (Map.Entry<Integer, ContextControllerInstanceHandle> entry : handleCategories.entrySet()) {
            identifier.setContextPartitionId(entry.getValue().getContextPartitionOrPathId());
            identifier.setLabel(factory.getCategorySpec().getItems().get(entry.getKey()).getName());
            if (filter.filter(identifier)) {
                accepted.add(entry.getValue().getContextPartitionOrPathId());
            }
        }
        return accepted;
    }
    if (contextPartitionSelector instanceof ContextPartitionSelectorCategory) {
        ContextPartitionSelectorCategory category = (ContextPartitionSelectorCategory) contextPartitionSelector;
        if (category.getLabels() == null || category.getLabels().isEmpty()) {
            return Collections.emptyList();
        }
        List<Integer> items = new ArrayList<Integer>();
        int count = 0;
        for (ContextDetailCategoryItem item : factory.getCategorySpec().getItems()) {
            if (category.getLabels().contains(item.getName())) {
                ContextControllerInstanceHandle handle = handleCategories.get(count);
                if (handle != null) {
                    items.add(handle.getContextPartitionOrPathId());
                }
            }
            count++;
        }
        return items;
    }
    throw ContextControllerSelectorUtil.getInvalidSelector(new Class[] {ContextPartitionSelectorCategory.class}, contextPartitionSelector);
}
 
开发者ID:mobile-event-processing,项目名称:Asper,代码行数:35,代码来源:ContextControllerCategory.java

示例3: testContextNamedWindowQuery

import com.espertech.esper.client.context.ContextPartitionSelectorCategory; //导入依赖的package包/类
public void testContextNamedWindowQuery() {

        epService.getEPAdministrator().createEPL("create context PartitionedByString partition by theString from SupportBean");
        epService.getEPAdministrator().createEPL("context PartitionedByString create window MyWindow.win:keepall() as SupportBean");
        epService.getEPAdministrator().createEPL("insert into MyWindow select * from SupportBean");

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

        // test no context
        runQueryAll("select sum(intPrimitive) as c1 from MyWindow", "c1", new Object[][]{{51}}, 1);
        runQueryAll("select sum(intPrimitive) as c1 from MyWindow where intPrimitive > 15", "c1", new Object[][]{{41}}, 1);
        runQuery("select sum(intPrimitive) as c1 from MyWindow", "c1", new Object[][]{{41}}, new ContextPartitionSelector[] {new SupportSelectorPartitioned(Collections.singletonList(new Object[]{"E2"}))});
        runQuery("select sum(intPrimitive) as c1 from MyWindow", "c1", new Object[][]{{41}}, new ContextPartitionSelector[] {new SupportSelectorById(Collections.<Integer>singleton(1))});

        // test with context props
        runQueryAll("context PartitionedByString select context.key1 as c0, intPrimitive as c1 from MyWindow",
                "c0,c1", new Object[][]{{"E1", 10}, {"E2", 20}, {"E2", 21}}, 1);
        runQueryAll("context PartitionedByString select context.key1 as c0, intPrimitive as c1 from MyWindow where intPrimitive > 15",
                "c0,c1", new Object[][]{{"E2", 20}, {"E2", 21}}, 1);

        // test targeted context partition
        runQuery("context PartitionedByString select context.key1 as c0, intPrimitive as c1 from MyWindow where intPrimitive > 15",
                "c0,c1", new Object[][]{{"E2", 20}, {"E2", 21}}, new SupportSelectorPartitioned[]{new SupportSelectorPartitioned(Collections.singletonList(new Object[]{"E2"}))});
        
        try {
            epService.getEPRuntime().executeQuery("context PartitionedByString select * from MyWindow", new ContextPartitionSelector[] {new ContextPartitionSelectorCategory() {
                public Set<String> getLabels() {
                    return null;
                }
            }});
            fail();
        }
        catch (EPStatementException ex) {
            assertTrue("message: " + ex.getMessage(), ex.getMessage().startsWith("Error executing statement: Invalid context partition selector, expected an implementation class of any of [ContextPartitionSelectorAll, ContextPartitionSelectorFiltered, ContextPartitionSelectorById, ContextPartitionSelectorSegmented] interfaces but received com"));
        }
    }
 
开发者ID:mobile-event-processing,项目名称:Asper,代码行数:39,代码来源:TestContextSelectionAndFireAndForget.java


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