private ExplicitIndexTransactionStateImpl NewExplicitIndexTxState()
        {
            _indexConfigStore = mock(typeof(IndexConfigStore));
            when(_indexConfigStore.get(eq(typeof(Node)), anyString())).thenReturn(_config);
            when(_indexConfigStore.get(eq(typeof(Relationship)), anyString())).thenReturn(_config);

            ExplicitIndexProvider explicitIndexProvider = mock(typeof(ExplicitIndexProvider));

            when(explicitIndexProvider.GetProviderByName(anyString())).thenReturn(_provider);

            return(new ExplicitIndexTransactionStateImpl(_indexConfigStore, explicitIndexProvider));
        }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public org.neo4j.kernel.api.ExplicitIndex nodeChanges(String indexName) throws org.neo4j.internal.kernel.api.exceptions.explicitindex.ExplicitIndexNotFoundKernelException
        public override ExplicitIndex NodeChanges(string indexName)
        {
            IDictionary <string, string> configuration = _indexConfigStore.get(typeof(Node), indexName);

            if (configuration == null)
            {
                throw new ExplicitIndexNotFoundKernelException("Node index '" + indexName + " not found");
            }
            string providerName          = configuration[Org.Neo4j.Graphdb.index.IndexManager_Fields.PROVIDER];
            IndexImplementation provider = _providerLookup.getProviderByName(providerName);
            ExplicitIndexProviderTransaction transaction = _transactions.computeIfAbsent(providerName, k => provider.NewTransaction(this));

            return(transaction.NodeIndex(indexName, configuration));
        }
Example #3
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);
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReportIndexDoesNotExist()
        public virtual void ShouldReportIndexDoesNotExist()
        {
            // given
            ExplicitIndexTransactionStateImpl state = NewExplicitIndexTxState();

            when(_indexConfigStore.get(any(typeof(Type)), anyString())).thenReturn(null);

            // when
            bool exists = state.CheckIndexExistence(IndexEntityType.Relationship, "name", null);

            // then
            assertFalse(exists);
        }
Example #5
0
 private IDictionary <string, string> Config(Type cls, string indexName, IDictionary <string, string> config)
 {
     // TODO Doesn't look right
     if (config != null)
     {
         config = MapUtil.stringMap(new Dictionary <>(config), Org.Neo4j.Graphdb.index.IndexManager_Fields.PROVIDER, LuceneIndexImplementation.SERVICE_NAME);
         IndexStore.setIfNecessary(cls, indexName, config);
         return(config);
     }
     else
     {
         return(IndexStore.get(cls, indexName));
     }
 }
Example #6
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: IndexType getIndexType(IndexIdentifier identifier, boolean recovery) throws org.neo4j.internal.kernel.api.exceptions.explicitindex.ExplicitIndexNotFoundKernelException
        internal virtual IndexType GetIndexType(IndexIdentifier identifier, bool recovery)
        {
            Pair <int, IndexType>        type   = _cache[identifier];
            IDictionary <string, string> config = _indexStore.get(identifier.EntityType.entityClass(), identifier.IndexName);

            if (config == null)
            {
                if (recovery)
                {
                    return(null);
                }
                throw new ExplicitIndexNotFoundKernelException("Index '%s' doesn't exist.", identifier);
            }
            if (type != null && config.GetHashCode() == type.First())
            {
                return(type.Other());
            }
            type = Pair.of(config.GetHashCode(), IndexType.GetIndexType(config));
            _cache[identifier] = type;
            return(type.Other());
        }