Search in sources :

Example 11 with IndexInvalidException

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);
    }
}
Also used : CompiledIteratorDef(org.apache.geode.cache.query.internal.CompiledIteratorDef) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) List(java.util.List) IndexInvalidException(org.apache.geode.cache.query.IndexInvalidException) IndexInvalidException(org.apache.geode.cache.query.IndexInvalidException) RuntimeIterator(org.apache.geode.cache.query.internal.RuntimeIterator)

Aggregations

IndexInvalidException (org.apache.geode.cache.query.IndexInvalidException)11 IndexExistsException (org.apache.geode.cache.query.IndexExistsException)5 IndexNameConflictException (org.apache.geode.cache.query.IndexNameConflictException)5 NameResolutionException (org.apache.geode.cache.query.NameResolutionException)5 TypeMismatchException (org.apache.geode.cache.query.TypeMismatchException)5 List (java.util.List)4 AmbiguousNameException (org.apache.geode.cache.query.AmbiguousNameException)4 ExecutionException (java.util.concurrent.ExecutionException)3 FutureTask (java.util.concurrent.FutureTask)3 Index (org.apache.geode.cache.query.Index)3 CompiledBindArgument (org.apache.geode.cache.query.internal.CompiledBindArgument)3 CompiledIteratorDef (org.apache.geode.cache.query.internal.CompiledIteratorDef)3 CompiledValue (org.apache.geode.cache.query.internal.CompiledValue)3 ArrayList (java.util.ArrayList)2 MultiIndexCreationException (org.apache.geode.cache.query.MultiIndexCreationException)2 QueryException (org.apache.geode.cache.query.QueryException)2 QueryService (org.apache.geode.cache.query.QueryService)2 RegionNotFoundException (org.apache.geode.cache.query.RegionNotFoundException)2 CompiledIndexOperation (org.apache.geode.cache.query.internal.CompiledIndexOperation)2 CompiledOperation (org.apache.geode.cache.query.internal.CompiledOperation)2