• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java DatabasePollingViewableFactory类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: testDBStatementViewFactory

import com.espertech.esper.epl.db.DatabasePollingViewableFactory; //导入依赖的package包/类
public void testDBStatementViewFactory() throws Exception
{
    DBStatementStreamSpec spec = new DBStatementStreamSpec("s0", new LinkedList<ViewSpec>(),
            "mydb_part", "select * from mytesttable where mybigint=${idnum}", null);

    EventCollection eventCollection = DatabasePollingViewableFactory.createDBStatementView("id", 1, spec,
            SupportDatabaseService.makeService(),
            SupportEventAdapterService.getService(), null, null, null, true);
    
    assertEquals(Long.class, eventCollection.getEventType().getPropertyType("mybigint"));
    assertEquals(String.class, eventCollection.getEventType().getPropertyType("myvarchar"));
    assertEquals(Boolean.class, eventCollection.getEventType().getPropertyType("mybool"));
    assertEquals(BigDecimal.class, eventCollection.getEventType().getPropertyType("mynumeric"));
    assertEquals(BigDecimal.class, eventCollection.getEventType().getPropertyType("mydecimal"));
}
 
开发者ID:mobile-event-processing,项目名称:Asper,代码行数:16,代码来源:TestPollingViewableFactory.java


示例2: testLexSampleSQL

import com.espertech.esper.epl.db.DatabasePollingViewableFactory; //导入依赖的package包/类
public void testLexSampleSQL() throws ExprValidationException
{
    String[][] testcases = new String[][] {
            {"select * from A where a=b and c=d", "select * from A where 1=0 and a=b and c=d"},
            {"select * from A where 1=0", "select * from A where 1=0 and 1=0"},
            {"select * from A", "select * from A where 1=0"},
            {"select * from A group by x", "select * from A where 1=0 group by x"},
            {"select * from A having a>b", "select * from A where 1=0 having a>b"},
            {"select * from A order by d", "select * from A where 1=0 order by d"},
            {"select * from A group by a having b>c order by d", "select * from A where 1=0 group by a having b>c order by d"},
            {"select * from A where (7<4) group by a having b>c order by d", "select * from A where 1=0 and (7<4) group by a having b>c order by d"},
            {"select * from A union select * from B", "select * from A  where 1=0 union  select * from B where 1=0"},
            {"select * from A where a=2 union select * from B where 2=3", "select * from A where 1=0 and a=2 union  select * from B where 1=0 and 2=3"},
            {"select * from A union select * from B union select * from C", "select * from A  where 1=0 union  select * from B  where 1=0 union  select * from C where 1=0"},
    };

    for (int i = 0; i < testcases.length; i++)
    {
        String result = null;
        try
        {
            result = DatabasePollingViewableFactory.lexSampleSQL(testcases[i][0]).trim();
        }
        catch (Exception ex)
        {
            fail("failed case with exception:" + testcases[i][0]);
        }
        String expected = testcases[i][1].trim();
        assertEquals("failed case " + i + " :" + testcases[i][0], expected, result);
    }
}
 
开发者ID:mobile-event-processing,项目名称:Asper,代码行数:32,代码来源:TestPollingViewableFactory.java


示例3: mapSQLParameters

import com.espertech.esper.epl.db.DatabasePollingViewableFactory; //导入依赖的package包/类
private static void mapSQLParameters(FromClause fromClause, StatementSpecRaw raw, StatementSpecMapContext mapContext) {
    if ((fromClause == null) || (fromClause.getStreams() == null)) {
        return;
    }
    int streamNum = -1;
    for (Stream stream : fromClause.getStreams()) {
        streamNum++;
        if (!(stream instanceof SQLStream)) {
            continue;
        }
        SQLStream sqlStream = (SQLStream) stream;

        List<PlaceholderParser.Fragment> sqlFragments = null;
        try {
            sqlFragments = PlaceholderParser.parsePlaceholder(sqlStream.getSqlWithSubsParams());
        } catch (PlaceholderParseException e) {
            throw new RuntimeException("Error parsing SQL placeholder expression '" + sqlStream.getSqlWithSubsParams() + "': ");
        }

        for (PlaceholderParser.Fragment fragment : sqlFragments) {
            if (!(fragment instanceof PlaceholderParser.ParameterFragment)) {
                continue;
            }

            // Parse expression, store for substitution parameters
            String expression = fragment.getValue();
            if (expression.toUpperCase(Locale.ENGLISH).equals(DatabasePollingViewableFactory.SAMPLE_WHERECLAUSE_PLACEHOLDER)) {
                continue;
            }

            if (expression.trim().length() == 0) {
                throw ASTWalkException.from("Missing expression within ${...} in SQL statement");
            }
            String toCompile = "select * from java.lang.Object where " + expression;
            StatementSpecRaw rawSqlExpr = EPAdministratorHelper.compileEPL(toCompile, expression, false, null, SelectClauseStreamSelectorEnum.ISTREAM_ONLY,
                    mapContext.getEngineImportService(), mapContext.getVariableService(), mapContext.getEngineURI(), mapContext.getConfiguration(), mapContext.getPatternNodeFactory(), mapContext.getContextManagementService(), mapContext.getExprDeclaredService(), mapContext.getTableService());

            if ((rawSqlExpr.getSubstitutionParameters() != null) && (rawSqlExpr.getSubstitutionParameters().size() > 0)) {
                throw ASTWalkException.from("EPL substitution parameters are not allowed in SQL ${...} expressions, consider using a variable instead");
            }

            if (rawSqlExpr.isHasVariables()) {
                mapContext.setHasVariables(true);
            }

            // add expression
            if (raw.getSqlParameters() == null) {
                raw.setSqlParameters(new HashMap<Integer, List<ExprNode>>());
            }
            List<ExprNode> listExp = raw.getSqlParameters().get(streamNum);
            if (listExp == null) {
                listExp = new ArrayList<ExprNode>();
                raw.getSqlParameters().put(streamNum, listExp);
            }
            listExp.add(rawSqlExpr.getFilterRootNode());
        }
    }
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:59,代码来源:StatementSpecMapper.java


示例4: mapSQLParameters

import com.espertech.esper.epl.db.DatabasePollingViewableFactory; //导入依赖的package包/类
private static void mapSQLParameters(FromClause fromClause, StatementSpecRaw raw, StatementSpecMapContext mapContext)
{
    if ((fromClause == null) || (fromClause.getStreams() == null)) {
        return;
    }
    int streamNum = -1;
    for (Stream stream : fromClause.getStreams()) {
        streamNum++;
        if (!(stream instanceof SQLStream)) {
            continue;
        }
        SQLStream sqlStream = (SQLStream) stream;

        List<PlaceholderParser.Fragment> sqlFragments = null;
        try
        {
            sqlFragments = PlaceholderParser.parsePlaceholder(sqlStream.getSqlWithSubsParams());
        }
        catch (PlaceholderParseException e)
        {
            throw new RuntimeException("Error parsing SQL placeholder expression '" + sqlStream.getSqlWithSubsParams() + "': ");
        }

        for (PlaceholderParser.Fragment fragment : sqlFragments)
        {
            if (!(fragment instanceof PlaceholderParser.ParameterFragment)) {
                continue;
            }

            // Parse expression, store for substitution parameters
            String expression = fragment.getValue();
            if (expression.toUpperCase().equals(DatabasePollingViewableFactory.SAMPLE_WHERECLAUSE_PLACEHOLDER)) {
                continue;
            }

            if (expression.trim().length() == 0) {
                throw new ASTWalkException("Missing expression within ${...} in SQL statement");
            }
            String toCompile = "select * from java.lang.Object where " + expression;
            StatementSpecRaw rawSqlExpr = EPAdministratorHelper.compileEPL(toCompile, expression, false, null, SelectClauseStreamSelectorEnum.ISTREAM_ONLY,
                    mapContext.getEngineImportService(), mapContext.getVariableService(), mapContext.getSchedulingService(), mapContext.getEngineURI(), mapContext.getConfiguration(), mapContext.getPatternNodeFactory(), mapContext.getContextManagementService(), mapContext.getExprDeclaredService());

            if ((rawSqlExpr.getSubstitutionParameters() != null) && (rawSqlExpr.getSubstitutionParameters().size() > 0)) {
                throw new ASTWalkException("EPL substitution parameters are not allowed in SQL ${...} expressions, consider using a variable instead");
            }

            if (rawSqlExpr.isHasVariables()) {
                mapContext.setHasVariables(true);
            }

            // add expression
            if (raw.getSqlParameters() == null) {
                raw.setSqlParameters(new HashMap<Integer, List<ExprNode>>());
            }
            List<ExprNode> listExp = raw.getSqlParameters().get(streamNum);
            if (listExp == null) {
                listExp = new ArrayList<ExprNode>();
                raw.getSqlParameters().put(streamNum, listExp);
            }
            listExp.add(rawSqlExpr.getFilterRootNode());
        }
    }
}
 
开发者ID:mobile-event-processing,项目名称:Asper,代码行数:64,代码来源:StatementSpecMapper.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java CollectionSpace类代码示例发布时间:2022-05-16
下一篇:
Java ReferenceCollection类代码示例发布时间:2022-05-16
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap