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