Exemple #1
0
        /// <summary>
        /// Get an applier suitable for the specified IndexCommand.
        /// </summary>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private TransactionApplier applier(org.neo4j.kernel.impl.index.IndexCommand command) throws java.io.IOException
        private TransactionApplier Applier(IndexCommand command)
        {
            // Have we got an applier for this index?
            string indexName = _defineCommand.getIndexName(command.IndexNameId);
            IDictionary <string, TransactionApplier> applierByIndex = ApplierByIndexMap(command);
            TransactionApplier applier = applierByIndex[indexName];

            if (applier == null)
            {
                // We don't. Have we got an applier for the provider of this index?
                IndexEntityType entityType          = IndexEntityType.byId(command.EntityType);
                IDictionary <string, string> config = _indexConfigStore.get(entityType.entityClass(), indexName);
                if (config == null)
                {
                    // This provider doesn't even exist, return an EMPTY handler, i.e. ignore these changes.
                    // Could be that the index provider is temporarily unavailable?
                    return(TransactionApplier_Fields.Empty);
                }
                string providerName = config[PROVIDER];
                applier = ApplierByProvider[providerName];
                if (applier == null)
                {
                    // We don't, so create the applier
                    applier = _applierLookup.newApplier(providerName, _mode.needsIdempotencyChecks());
                    applier.VisitIndexDefineCommand(_defineCommand);
                    ApplierByProvider[providerName] = applier;
                }

                // Also cache this applier for this index
                applierByIndex[indexName] = applier;
            }
            return(applier);
        }
Exemple #2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private CommitContext commitContext(org.neo4j.kernel.impl.index.IndexCommand command) throws org.neo4j.internal.kernel.api.exceptions.explicitindex.ExplicitIndexNotFoundKernelException
        private CommitContext CommitContext(IndexCommand command)
        {
            IDictionary <string, CommitContext> contextMap = CommitContextMap(command.EntityType);
            string        indexName = _definitions.getIndexName(command.IndexNameId);
            CommitContext context   = contextMap[indexName];

            if (context == null)
            {
                IndexIdentifier identifier = new IndexIdentifier(IndexEntityType.byId(command.EntityType), indexName);

                // TODO the fact that we look up index type from config here using the index store
                // directly should be avoided. But how can we do it in, say recovery?
                // The `dataSource.getType()` call can throw an exception if the index is concurrently deleted.
                // To avoid bubbling an exception during commit, we instead ignore the commands related to that index,
                // and proceed as if the index never existed, and thus cannot accept any modifications.
                IndexType type = _dataSource.getType(identifier, _recovery);
                context = new CommitContext(_dataSource, identifier, type, _recovery);
                contextMap[indexName] = context;
            }
            return(context);
        }