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


Java CreateSchemaDesc类代码示例

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


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

示例1: startInternal

import com.espertech.esper.epl.spec.CreateSchemaDesc; //导入依赖的package包/类
public EPStatementStartResult startInternal(final EPServicesContext services, final StatementContext statementContext, boolean isNewStatement, boolean isRecoveringStatement, boolean isRecoveringResilient) throws ExprValidationException, ViewProcessingException {
    final CreateSchemaDesc spec = statementSpec.getCreateSchemaDesc();

    EPLValidationUtil.validateTableExists(services.getTableService(), spec.getSchemaName());
    EventType eventType = handleCreateSchema(services, statementContext, spec);

    // enter a reference
    services.getStatementEventTypeRefService().addReferences(statementContext.getStatementName(), new String[]{spec.getSchemaName()});

    final EventType allocatedEventType = eventType;
    EPStatementStopMethod stopMethod = new EPStatementStopMethod() {
        public void stop() {
            services.getStatementEventTypeRefService().removeReferencesStatement(statementContext.getStatementName());
            if (services.getStatementEventTypeRefService().getStatementNamesForType(spec.getSchemaName()).isEmpty()) {
                services.getEventAdapterService().removeType(allocatedEventType.getName());
                services.getFilterService().removeType(allocatedEventType);
            }
        }
    };
    Viewable viewable = new ViewableDefaultImpl(eventType);

    // assign agent instance factory (an empty op)
    statementContext.setStatementAgentInstanceFactory(new StatementAgentInstanceFactoryNoAgentInstance(viewable));

    return new EPStatementStartResult(viewable, stopMethod, null);
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:27,代码来源:EPStatementStartMethodCreateSchema.java

示例2: isMap

import com.espertech.esper.epl.spec.CreateSchemaDesc; //导入依赖的package包/类
public static boolean isMap(Annotation[] annotations, ConfigurationInformation configs, CreateSchemaDesc.AssignedType assignedType) {
    // assigned type has priority
    if (assignedType == CreateSchemaDesc.AssignedType.OBJECTARRAY) {
        return false;
    }
    if (assignedType == CreateSchemaDesc.AssignedType.MAP) {
        return true;
    }
    if (assignedType == CreateSchemaDesc.AssignedType.VARIANT || assignedType != CreateSchemaDesc.AssignedType.NONE) {
        throw new IllegalStateException("Not handled by event representation: " + assignedType);
    }

    // annotation has second priority
    Annotation annotation = AnnotationUtil.findAnnotation(annotations, EventRepresentation.class);
    if (annotation != null) {
        EventRepresentation eventRepresentation = (EventRepresentation) annotation;
        return !eventRepresentation.array();
    }

    // use engine-wide default
    return configs.getEngineDefaults().getEventMeta().getDefaultEventRepresentation() == Configuration.EventRepresentation.MAP;
}
 
开发者ID:mobile-event-processing,项目名称:Asper,代码行数:23,代码来源:EventRepresentationUtil.java

示例3: startInternal

import com.espertech.esper.epl.spec.CreateSchemaDesc; //导入依赖的package包/类
public EPStatementStartResult startInternal(final EPServicesContext services, final StatementContext statementContext, boolean isNewStatement, boolean isRecoveringStatement, boolean isRecoveringResilient) throws ExprValidationException, ViewProcessingException {
    final CreateSchemaDesc spec = statementSpec.getCreateSchemaDesc();

    EventType eventType = handleCreateSchema(services, statementContext, spec);

    // enter a reference
    services.getStatementEventTypeRefService().addReferences(statementContext.getStatementName(), Collections.singleton(spec.getSchemaName()));

    final EventType allocatedEventType = eventType;
    EPStatementStopMethod stopMethod = new EPStatementStopMethod() {
        public void stop()
        {
            services.getStatementEventTypeRefService().removeReferencesStatement(statementContext.getStatementName());
            if (services.getStatementEventTypeRefService().getStatementNamesForType(spec.getSchemaName()).isEmpty()) {
                services.getEventAdapterService().removeType(allocatedEventType.getName());
                services.getFilterService().removeType(allocatedEventType);
            }
        }
    };
    Viewable viewable = new ViewableDefaultImpl(eventType);
    return new EPStatementStartResult(viewable, stopMethod, null);
}
 
开发者ID:mobile-event-processing,项目名称:Asper,代码行数:23,代码来源:EPStatementStartMethodCreateSchema.java

示例4: walkCreateSchema

import com.espertech.esper.epl.spec.CreateSchemaDesc; //导入依赖的package包/类
public static CreateSchemaDesc walkCreateSchema(EsperEPL2GrammarParser.CreateSchemaExprContext ctx) throws EPException {
    CreateSchemaDesc.AssignedType assignedType = CreateSchemaDesc.AssignedType.NONE;
    if (ctx.keyword != null) {
        assignedType = CreateSchemaDesc.AssignedType.parseKeyword(ctx.keyword.getText());
    }
    return getSchemaDesc(ctx.createSchemaDef(), assignedType);
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:8,代码来源:ASTCreateSchemaHelper.java

示例5: getRepresentation

import com.espertech.esper.epl.spec.CreateSchemaDesc; //导入依赖的package包/类
public static EventUnderlyingType getRepresentation(Annotation[] annotations, ConfigurationInformation configs, CreateSchemaDesc.AssignedType assignedType) {
    // assigned type has priority
    if (assignedType == CreateSchemaDesc.AssignedType.OBJECTARRAY) {
        return EventUnderlyingType.OBJECTARRAY;
    } else if (assignedType == CreateSchemaDesc.AssignedType.MAP) {
        return EventUnderlyingType.MAP;
    } else if (assignedType == CreateSchemaDesc.AssignedType.AVRO) {
        return EventUnderlyingType.AVRO;
    }
    if (assignedType == CreateSchemaDesc.AssignedType.VARIANT || assignedType != CreateSchemaDesc.AssignedType.NONE) {
        throw new IllegalStateException("Not handled by event representation: " + assignedType);
    }

    // annotation has second priority
    Annotation annotation = AnnotationUtil.findAnnotation(annotations, EventRepresentation.class);
    if (annotation != null) {
        EventRepresentation eventRepresentation = (EventRepresentation) annotation;
        if (eventRepresentation.value() == EventUnderlyingType.AVRO) {
            return EventUnderlyingType.AVRO;
        } else if (eventRepresentation.value() == EventUnderlyingType.OBJECTARRAY) {
            return EventUnderlyingType.OBJECTARRAY;
        } else if (eventRepresentation.value() == EventUnderlyingType.MAP) {
            return EventUnderlyingType.MAP;
        } else {
            throw new IllegalStateException("Unrecognized enum " + eventRepresentation.value());
        }
    }

    // use engine-wide default
    EventUnderlyingType configured = configs.getEngineDefaults().getEventMeta().getDefaultEventRepresentation();
    if (configured == EventUnderlyingType.OBJECTARRAY) {
        return EventUnderlyingType.OBJECTARRAY;
    } else if (configured == EventUnderlyingType.MAP) {
        return EventUnderlyingType.MAP;
    } else if (configured == EventUnderlyingType.AVRO) {
        return EventUnderlyingType.AVRO;
    }
    return EventUnderlyingType.MAP;
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:40,代码来源:EventRepresentationUtil.java

示例6: handleCreateSchema

import com.espertech.esper.epl.spec.CreateSchemaDesc; //导入依赖的package包/类
private EventType handleCreateSchema(EPServicesContext services, StatementContext statementContext, CreateSchemaDesc spec)
        throws ExprValidationException {

    EventType eventType;

    try {
        if (spec.getAssignedType() != CreateSchemaDesc.AssignedType.VARIANT) {
            eventType = EventTypeUtility.createNonVariantType(false, spec, statementContext.getAnnotations(), services.getConfigSnapshot(), services.getEventAdapterService(), services.getEngineImportService());
        } else {
            if (spec.getCopyFrom() != null && !spec.getCopyFrom().isEmpty()) {
                throw new ExprValidationException("Copy-from types are not allowed with variant types");
            }

            boolean isAny = false;
            ConfigurationVariantStream config = new ConfigurationVariantStream();
            for (String typeName : spec.getTypes()) {
                if (typeName.trim().equals("*")) {
                    isAny = true;
                    break;
                }
                config.addEventTypeName(typeName);
            }
            if (!isAny) {
                config.setTypeVariance(ConfigurationVariantStream.TypeVariance.PREDEFINED);
            } else {
                config.setTypeVariance(ConfigurationVariantStream.TypeVariance.ANY);
            }
            services.getValueAddEventService().addVariantStream(spec.getSchemaName(), config, services.getEventAdapterService(), services.getEventTypeIdGenerator());
            eventType = services.getValueAddEventService().getValueAddProcessor(spec.getSchemaName()).getValueAddEventType();
        }
    } catch (RuntimeException ex) {
        throw new ExprValidationException(ex.getMessage(), ex);
    }

    return eventType;
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:37,代码来源:EPStatementStartMethodCreateSchema.java

示例7: walkCreateSchema

import com.espertech.esper.epl.spec.CreateSchemaDesc; //导入依赖的package包/类
public static CreateSchemaDesc walkCreateSchema(Tree node) throws EPException {
    CreateSchemaDesc.AssignedType assignedType = CreateSchemaDesc.AssignedType.NONE;
    if (node.getChildCount() > 1) {
        String keywordNodeText = node.getChild(1).getText();
        assignedType = CreateSchemaDesc.AssignedType.parseKeyword(keywordNodeText);
    }

    return getSchemaDesc(node.getChild(0), assignedType);
}
 
开发者ID:mobile-event-processing,项目名称:Asper,代码行数:10,代码来源:ASTCreateSchemaHelper.java

示例8: handleCreateSchema

import com.espertech.esper.epl.spec.CreateSchemaDesc; //导入依赖的package包/类
private EventType handleCreateSchema(EPServicesContext services, StatementContext statementContext, CreateSchemaDesc spec)
    throws ExprValidationException {

    EventType eventType;

    try {
        if (spec.getAssignedType() != CreateSchemaDesc.AssignedType.VARIANT) {
            eventType = EventTypeUtility.createNonVariantType(false, spec, statementContext.getAnnotations(), services.getConfigSnapshot(), services.getEventAdapterService(), services.getEngineImportService());
        }
        else {
            if (spec.getCopyFrom() != null && !spec.getCopyFrom().isEmpty()) {
                throw new ExprValidationException("Copy-from types are not allowed with variant types");
            }

            boolean isAny = false;
            ConfigurationVariantStream config = new ConfigurationVariantStream();
            for (String typeName : spec.getTypes()) {
                if (typeName.trim().equals("*")) {
                    isAny = true;
                    break;
                }
                config.addEventTypeName(typeName);
            }
            if (!isAny) {
                config.setTypeVariance(ConfigurationVariantStream.TypeVariance.PREDEFINED);
            }
            else {
                config.setTypeVariance(ConfigurationVariantStream.TypeVariance.ANY);
            }
            services.getValueAddEventService().addVariantStream(spec.getSchemaName(), config, services.getEventAdapterService(), services.getEventTypeIdGenerator());
            eventType = services.getValueAddEventService().getValueAddProcessor(spec.getSchemaName()).getValueAddEventType();
        }
    }
    catch (RuntimeException ex) {
        throw new ExprValidationException(ex.getMessage(), ex);
    }

    return eventType;
}
 
开发者ID:mobile-event-processing,项目名称:Asper,代码行数:40,代码来源:EPStatementStartMethodCreateSchema.java

示例9: getSchemaDesc

import com.espertech.esper.epl.spec.CreateSchemaDesc; //导入依赖的package包/类
private static CreateSchemaDesc getSchemaDesc(EsperEPL2GrammarParser.CreateSchemaDefContext ctx, CreateSchemaDesc.AssignedType assignedType) throws EPException {
    String schemaName = ctx.name.getText();
    List<ColumnDesc> columnTypes = getColTypeList(ctx.createColumnList());

    // get model-after types (could be multiple for variants)
    Set<String> typeNames = new LinkedHashSet<String>();
    if (ctx.variantList() != null) {
        List<EsperEPL2GrammarParser.VariantListElementContext> variantCtxs = ctx.variantList().variantListElement();
        for (EsperEPL2GrammarParser.VariantListElementContext variantCtx : variantCtxs) {
            typeNames.add(variantCtx.getText());
        }
    }

    // get inherited and start timestamp and end timestamps
    String startTimestamp = null;
    String endTimestamp = null;
    Set<String> inherited = new LinkedHashSet<String>();
    Set<String> copyFrom = new LinkedHashSet<String>();
    if (ctx.createSchemaQual() != null) {
        List<EsperEPL2GrammarParser.CreateSchemaQualContext> qualCtxs = ctx.createSchemaQual();
        for (EsperEPL2GrammarParser.CreateSchemaQualContext qualCtx : qualCtxs) {
            String qualName = qualCtx.i.getText().toLowerCase(Locale.ENGLISH);
            List<String> cols = ASTUtil.getIdentList(qualCtx.columnList());
            if (qualName.toLowerCase(Locale.ENGLISH).equals("inherits")) {
                inherited.addAll(cols);
                continue;
            } else if (qualName.toLowerCase(Locale.ENGLISH).equals("starttimestamp")) {
                startTimestamp = cols.get(0);
                continue;
            } else if (qualName.toLowerCase(Locale.ENGLISH).equals("endtimestamp")) {
                endTimestamp = cols.get(0);
                continue;
            } else if (qualName.toLowerCase(Locale.ENGLISH).equals("copyfrom")) {
                copyFrom.addAll(cols);
                continue;
            }
            throw new EPException("Expected 'inherits', 'starttimestamp', 'endtimestamp' or 'copyfrom' keyword after create-schema clause but encountered '" + qualName + "'");
        }
    }

    return new CreateSchemaDesc(schemaName, typeNames, columnTypes, inherited, assignedType, startTimestamp, endTimestamp, copyFrom);
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:43,代码来源:ASTCreateSchemaHelper.java

示例10: getSchemaDesc

import com.espertech.esper.epl.spec.CreateSchemaDesc; //导入依赖的package包/类
private static CreateSchemaDesc getSchemaDesc(Tree node, CreateSchemaDesc.AssignedType assignedType) throws EPException {
    String schemaName = node.getChild(0).getText();

    List<ColumnDesc> columnTypes = getColTypeList(node);

    // get model-after types (could be multiple for variants)
    Set<String> typeNames = new LinkedHashSet<String>();
    for (int i = 0; i < node.getChildCount(); i++) {
        if (node.getChild(i).getType() == EsperEPL2Ast.VARIANT_LIST) {
            for (int j = 0; j < node.getChild(i).getChildCount(); j++) {
                typeNames.add(node.getChild(i).getChild(j).getText());
            }
        }
    }

    // get inherited and start timestamp and end timestamps
    String startTimestamp = null;
    String endTimestamp = null;
    Set<String> inherited = new LinkedHashSet<String>();
    Set<String> copyFrom = new LinkedHashSet<String>();
    for (int i = 0; i < node.getChildCount(); i++) {
        Tree p = node.getChild(i);
        if (p.getType() == EsperEPL2Ast.CREATE_SCHEMA_EXPR_QUAL) {
            String childName = p.getChild(0).getText().toLowerCase();
            if (childName.equals("inherits")) {
                for (int j = 1; j < p.getChildCount(); j++) {
                    if (p.getChild(j).getType() == EsperEPL2Ast.EXPRCOL) {
                        for (int k = 0; k < p.getChild(j).getChildCount(); k++) {
                            inherited.add(p.getChild(j).getChild(k).getText());
                        }
                    }
                }
                continue;
            }
            else if (childName.equals("starttimestamp")) {
                startTimestamp = p.getChild(1).getChild(0).getText();
                continue;
            }
            else if (childName.equals("endtimestamp")) {
                endTimestamp = p.getChild(1).getChild(0).getText();
                continue;
            }
            else if (childName.equals("copyfrom")) {
                Tree parent = p.getChild(1);
                for (int j = 0; j < parent.getChildCount(); j++) {
                    copyFrom.add(parent.getChild(j).getText());
                }
                continue;
            }
            throw new EPException("Expected 'inherits', 'starttimestamp', 'endtimestamp' or 'copyfrom' keyword after create-schema clause but encountered '" + p.getChild(0).getText() + "'");
        }
    }

    return new CreateSchemaDesc(schemaName, typeNames, columnTypes, inherited, assignedType, startTimestamp, endTimestamp, copyFrom);
}
 
开发者ID:mobile-event-processing,项目名称:Asper,代码行数:56,代码来源:ASTCreateSchemaHelper.java


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