本文整理汇总了Java中com.espertech.esper.epl.spec.CreateIndexItem类的典型用法代码示例。如果您正苦于以下问题:Java CreateIndexItem类的具体用法?Java CreateIndexItem怎么用?Java CreateIndexItem使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CreateIndexItem类属于com.espertech.esper.epl.spec包,在下文中一共展示了CreateIndexItem类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: walk
import com.espertech.esper.epl.spec.CreateIndexItem; //导入依赖的package包/类
public static CreateIndexDesc walk(EsperEPL2GrammarParser.CreateIndexExprContext ctx, Map<Tree, ExprNode> astExprNodeMap) {
String indexName = ctx.n.getText();
String windowName = ctx.w.getText();
boolean unique = false;
if (ctx.u != null) {
String ident = ctx.u.getText();
if (ident.toLowerCase(Locale.ENGLISH).trim().equals("unique")) {
unique = true;
} else {
throw ASTWalkException.from("Invalid keyword '" + ident + "' in create-index encountered, expected 'unique'");
}
}
List<CreateIndexItem> columns = new ArrayList<>();
List<EsperEPL2GrammarParser.CreateIndexColumnContext> cols = ctx.createIndexColumnList().createIndexColumn();
for (EsperEPL2GrammarParser.CreateIndexColumnContext col : cols) {
CreateIndexItem item = walk(col, astExprNodeMap);
columns.add(item);
}
return new CreateIndexDesc(unique, indexName, windowName, columns);
}
示例2: handleStartIndex
import com.espertech.esper.epl.spec.CreateIndexItem; //导入依赖的package包/类
public void handleStartIndex(CreateIndexDesc spec) {
try {
List<VirtualDataWindowEventStartIndex.VDWCreateIndexField> fields = new ArrayList<VirtualDataWindowEventStartIndex.VDWCreateIndexField>();
for (CreateIndexItem col : spec.getColumns()) {
fields.add(new VirtualDataWindowEventStartIndex.VDWCreateIndexField(col.getExpressions(), col.getType(), col.getParameters()));
}
VirtualDataWindowEventStartIndex create = new VirtualDataWindowEventStartIndex(spec.getWindowName(), spec.getIndexName(), fields, spec.isUnique());
dataExternal.handleEvent(create);
} catch (Exception ex) {
String message = "Exception encountered invoking virtual data window handle start-index event for window '" + namedWindowName + "': " + ex.getMessage();
log.warn(message, ex);
throw new EPException(message, ex);
}
}
示例3: validateCompileExplicitIndex
import com.espertech.esper.epl.spec.CreateIndexItem; //导入依赖的package包/类
public static QueryPlanIndexItem validateCompileExplicitIndex(String indexName, boolean unique, List<CreateIndexItem> columns, EventType eventType, StatementContext statementContext)
throws ExprValidationException {
List<IndexedPropDesc> hashProps = new ArrayList<IndexedPropDesc>();
List<IndexedPropDesc> btreeProps = new ArrayList<IndexedPropDesc>();
Set<String> indexedColumns = new HashSet<String>();
EventAdvancedIndexProvisionDesc advancedIndexProvisionDesc = null;
for (CreateIndexItem columnDesc : columns) {
String indexType = columnDesc.getType().toLowerCase(Locale.ENGLISH).trim();
if (indexType.equals(CreateIndexType.HASH.getNameLower()) || indexType.equals(CreateIndexType.BTREE.getNameLower())) {
validateBuiltin(columnDesc, eventType, hashProps, btreeProps, indexedColumns);
} else {
if (advancedIndexProvisionDesc != null) {
throw new ExprValidationException("Nested advanced-type indexes are not supported");
}
advancedIndexProvisionDesc = validateAdvanced(indexName, indexType, columnDesc, eventType, statementContext);
}
}
if (unique && !btreeProps.isEmpty()) {
throw new ExprValidationException("Combination of unique index with btree (range) is not supported");
}
if ((!btreeProps.isEmpty() || !hashProps.isEmpty()) && advancedIndexProvisionDesc != null) {
throw new ExprValidationException("Combination of hash/btree columns an advanced-type indexes is not supported");
}
return new QueryPlanIndexItem(hashProps, btreeProps, unique, advancedIndexProvisionDesc);
}
示例4: validateAdvanced
import com.espertech.esper.epl.spec.CreateIndexItem; //导入依赖的package包/类
private static EventAdvancedIndexProvisionDesc validateAdvanced(String indexName, String indexType, CreateIndexItem columnDesc, EventType eventType, StatementContext statementContext) throws ExprValidationException {
// validate index expressions: valid and plain expressions
ExprValidationContext validationContextColumns = getValidationContext(eventType, statementContext);
ExprNode[] columns = columnDesc.getExpressions().toArray(new ExprNode[columnDesc.getExpressions().size()]);
ExprNodeUtilityRich.getValidatedSubtree(ExprNodeOrigin.CREATEINDEXCOLUMN, columns, validationContextColumns);
ExprNodeUtilityRich.validatePlainExpression(ExprNodeOrigin.CREATEINDEXCOLUMN, columns);
// validate parameters, may not depend on props
ExprNode[] parameters = null;
if (columnDesc.getParameters() != null && !columnDesc.getParameters().isEmpty()) {
parameters = columnDesc.getParameters().toArray(new ExprNode[columnDesc.getParameters().size()]);
ExprNodeUtilityRich.getValidatedSubtree(ExprNodeOrigin.CREATEINDEXPARAMETER, parameters, validationContextColumns);
ExprNodeUtilityRich.validatePlainExpression(ExprNodeOrigin.CREATEINDEXPARAMETER, parameters);
// validate no stream dependency of parameters
ExprNodeIdentifierAndStreamRefVisitor visitor = new ExprNodeIdentifierAndStreamRefVisitor(false);
for (ExprNode param : columnDesc.getParameters()) {
param.accept(visitor);
if (!visitor.getRefs().isEmpty()) {
throw new ExprValidationException("Index parameters may not refer to event properties");
}
}
}
// obtain provider
AdvancedIndexFactoryProvider provider;
try {
provider = statementContext.getEngineImportService().resolveAdvancedIndexProvider(indexType);
} catch (EngineImportException ex) {
throw new ExprValidationException(ex.getMessage(), ex);
}
return provider.validateEventIndex(indexName, indexType, columns, parameters);
}
示例5: validateBuiltin
import com.espertech.esper.epl.spec.CreateIndexItem; //导入依赖的package包/类
private static void validateBuiltin(CreateIndexItem columnDesc, EventType eventType, List<IndexedPropDesc> hashProps, List<IndexedPropDesc> btreeProps, Set<String> indexedColumns)
throws ExprValidationException {
if (columnDesc.getExpressions().isEmpty()) {
throw new ExprValidationException("Invalid empty list of index expressions");
}
if (columnDesc.getExpressions().size() > 1) {
throw new ExprValidationException("Invalid multiple index expressions for index type '" + columnDesc.getType() + "'");
}
ExprNode expression = columnDesc.getExpressions().get(0);
if (!(expression instanceof ExprIdentNode)) {
throw new ExprValidationException("Invalid index expression '" + ExprNodeUtilityCore.toExpressionStringMinPrecedenceSafe(expression) + "'");
}
ExprIdentNode identNode = (ExprIdentNode) expression;
if (identNode.getFullUnresolvedName().contains(".")) {
throw new ExprValidationException("Invalid index expression '" + ExprNodeUtilityCore.toExpressionStringMinPrecedenceSafe(expression) + "'");
}
String columnName = identNode.getFullUnresolvedName();
Class type = JavaClassHelper.getBoxedType(eventType.getPropertyType(columnName));
if (type == null) {
throw new ExprValidationException("Property named '" + columnName + "' not found");
}
if (!indexedColumns.add(columnName)) {
throw new ExprValidationException("Property named '" + columnName + "' has been declared more then once");
}
IndexedPropDesc desc = new IndexedPropDesc(columnName, type);
String indexType = columnDesc.getType().toLowerCase(Locale.ENGLISH);
if (indexType.equals(CreateIndexType.HASH.getNameLower())) {
hashProps.add(desc);
} else {
btreeProps.add(desc);
}
}
示例6: addExplicitIndex
import com.espertech.esper.epl.spec.CreateIndexItem; //导入依赖的package包/类
/**
* Add an explicit index.
* @param unique indicator whether unique
* @param namedWindowName window name
* @param indexName indexname
* @param columns properties indexed
* @throws com.espertech.esper.epl.expression.ExprValidationException if the index fails to be valid
*/
public synchronized void addExplicitIndex(boolean unique, String namedWindowName, String indexName, List<CreateIndexItem> columns) throws ExprValidationException {
if (explicitIndexes.containsKey(indexName)) {
throw new ExprValidationException("Index by name '" + indexName + "' already exists");
}
List<IndexedPropDesc> hashProps = new ArrayList<IndexedPropDesc>();
List<IndexedPropDesc> btreeProps = new ArrayList<IndexedPropDesc>();
Set<String> indexed = new HashSet<String>();
for (CreateIndexItem columnDesc : columns) {
String columnName = columnDesc.getName();
Class type = JavaClassHelper.getBoxedType(rootView.getEventType().getPropertyType(columnName));
if (type == null) {
throw new ExprValidationException("Property named '" + columnName + "' not found on named window '" + namedWindowName + "'");
}
if (!indexed.add(columnName)) {
throw new ExprValidationException("Property named '" + columnName + "' has been declared more then once");
}
IndexedPropDesc desc = new IndexedPropDesc(columnName, type);
if (columnDesc.getType() == CreateIndexType.HASH) {
hashProps.add(desc);
} else {
btreeProps.add(desc);
}
}
if (unique && !btreeProps.isEmpty()) {
throw new ExprValidationException("Combination of unique index with btree (range) is not supported");
}
Pair<IndexMultiKey, EventTableAndNamePair> pair = indexRepository.addExplicitIndexOrReuse(unique, hashProps, btreeProps, dataWindowContents, rootView.getEventType(), indexName);
explicitIndexes.put(indexName, pair.getSecond().getEventTable());
}
示例7: handleStartIndex
import com.espertech.esper.epl.spec.CreateIndexItem; //导入依赖的package包/类
public void handleStartIndex(CreateIndexDesc spec) {
try {
List<VirtualDataWindowEventStartIndex.VDWCreateIndexField> fields = new ArrayList<VirtualDataWindowEventStartIndex.VDWCreateIndexField>();
for (CreateIndexItem col : spec.getColumns()) {
fields.add(new VirtualDataWindowEventStartIndex.VDWCreateIndexField(col.getName(), col.getType() == CreateIndexType.HASH));
}
VirtualDataWindowEventStartIndex create = new VirtualDataWindowEventStartIndex(spec.getWindowName(), spec.getIndexName(), fields, spec.isUnique());
dataExternal.handleEvent(create);
}
catch (Exception ex) {
String message = "Exception encountered invoking virtual data window handle start-index event for window '" + namedWindowName + "': " + ex.getMessage();
log.warn(message, ex);
throw new EPException(message, ex);
}
}