use of org.apache.geode.cache.query.IndexInvalidException in project geode by apache.
the class PrimaryKeyIndexCreationHelper method prepareFromClause.
private void prepareFromClause(IndexManager imgr) throws IndexInvalidException {
List list = this.compiler.compileFromClause(fromClause);
if (list.size() > 1) {
throw new IndexInvalidException(LocalizedStrings.PrimaryKeyIndexCreationHelper_THE_FROMCLAUSE_FOR_A_PRIMARY_KEY_INDEX_SHOULD_ONLY_HAVE_ONE_ITERATOR_AND_THE_COLLECTION_MUST_BE_A_REGION_PATH_ONLY.toLocalizedString());
}
try {
CompiledIteratorDef iterDef = (CompiledIteratorDef) list.get(0);
if (iterDef.getCollectionExpr().getType() != OQLLexerTokenTypes.RegionPath) {
throw new IndexInvalidException(LocalizedStrings.PrimaryKeyIndexCreationHelper_THE_FROMCLAUSE_FOR_A_PRIMARY_KEY_INDEX_SHOULD_BE_A_REGION_PATH_ONLY.toLocalizedString());
}
iterDef.computeDependencies(this.context);
RuntimeIterator rIter = (iterDef.getRuntimeIterator(this.context));
String definition = rIter.getDefinition();
this.canonicalizedIteratorDefinitions = new String[1];
this.canonicalizedIteratorDefinitions[0] = definition;
// Bind the Index_Internal_ID to the RuntimeIterator
PartitionedRegion pr = this.context.getPartitionedRegion();
this.canonicalizedIteratorNames = new String[1];
String name = null;
if (pr != null) {
name = pr.getIndexManager().putCanonicalizedIteratorNameIfAbsent(definition);
} else {
name = imgr.putCanonicalizedIteratorNameIfAbsent(definition);
}
rIter.setIndexInternalID(name);
this.canonicalizedIteratorNames = new String[1];
this.canonicalizedIteratorNames[0] = name;
this.fromClause = new StringBuilder(definition).append(' ').append(name).toString();
context.bindIterator(rIter);
} catch (IndexInvalidException e) {
// propagate
throw e;
} catch (Exception e) {
// wrap any other exceptions
throw new IndexInvalidException(e);
}
}
Aggregations